[savara-commits] savara SVN: r496 - trunk and 549 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Nov 20 19:30:15 EST 2010
Author: objectiser
Date: 2010-11-20 19:29:50 -0500 (Sat, 20 Nov 2010)
New Revision: 496
Added:
trunk/
trunk/.project
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/org.scribble.expression.xpath/
trunk/bundles/org.scribble.expression.xpath/.classpath
trunk/bundles/org.scribble.expression.xpath/.project
trunk/bundles/org.scribble.expression.xpath/LICENSE.txt
trunk/bundles/org.scribble.expression.xpath/META-INF/
trunk/bundles/org.scribble.expression.xpath/META-INF/MANIFEST.MF
trunk/bundles/org.scribble.expression.xpath/build.properties
trunk/bundles/org.scribble.expression.xpath/pom.xml
trunk/bundles/org.scribble.expression.xpath/src/
trunk/bundles/org.scribble.expression.xpath/src/main/
trunk/bundles/org.scribble.expression.xpath/src/main/java/
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/export/
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/export/text/
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/export/text/XPathExpressionTextExportRule.java
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/model/
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/model/XPathExpression.java
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/model/types/
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/model/types/XPathExpressionTypeResolverRule.java
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/osgi/
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/osgi/Activator.java
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/validation/
trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/validation/XPathExpressionValidationRule.java
trunk/bundles/org.scribble.lang.model/
trunk/bundles/org.scribble.lang.model/.classpath
trunk/bundles/org.scribble.lang.model/.project
trunk/bundles/org.scribble.lang.model/LICENSE.txt
trunk/bundles/org.scribble.lang.model/META-INF/
trunk/bundles/org.scribble.lang.model/META-INF/MANIFEST.MF
trunk/bundles/org.scribble.lang.model/build.properties
trunk/bundles/org.scribble.lang.model/pom.xml
trunk/bundles/org.scribble.lang.model/src/
trunk/bundles/org.scribble.lang.model/src/main/
trunk/bundles/org.scribble.lang.model/src/main/java/
trunk/bundles/org.scribble.lang.model/src/main/java/org/
trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/
trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/
trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/
trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/JavaLanguageModel.java
trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/LanguageModel.java
trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/osgi/
trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/osgi/Activator.java
trunk/bundles/pom.xml
trunk/distribution/
trunk/distribution/pom.xml
trunk/distribution/src/
trunk/distribution/src/files/
trunk/distribution/src/files/jbossesb/
trunk/distribution/src/files/jbossesb/jbossesb-properties-original.xml
trunk/distribution/src/files/jbossesb/jbossesb-properties-validator.xml
trunk/distribution/src/files/jbossws-native/
trunk/distribution/src/files/jbossws-native/standard-jaxws-client-config-original.xml
trunk/distribution/src/files/jbossws-native/standard-jaxws-client-config-validator.xml
trunk/distribution/src/files/jbossws-native/standard-jaxws-endpoint-config-original.xml
trunk/distribution/src/files/jbossws-native/standard-jaxws-endpoint-config-validator.xml
trunk/distribution/src/main/
trunk/distribution/src/main/assembly/
trunk/distribution/src/main/assembly/bin.xml
trunk/distribution/src/main/assembly/src.xml
trunk/distribution/src/main/release/
trunk/distribution/src/main/release/JBossORG-EULA.txt
trunk/distribution/src/main/release/README.txt
trunk/distribution/src/main/release/ReleaseNotes.txt
trunk/distribution/src/main/release/install/
trunk/distribution/src/main/release/install/README.txt
trunk/distribution/src/main/release/install/build.xml
trunk/distribution/src/main/release/install/deployment.properties
trunk/distribution/src/main/release/samples/
trunk/distribution/src/main/release/samples/jbossesb/
trunk/distribution/src/main/release/samples/jbossesb/trailblazer/
trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/
trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.classpath
trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.project
trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.settings/
trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.settings/org.eclipse.core.resources.prefs
trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/src/
trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/src/pi4soa.xml
trunk/docs/
trunk/docs/gettingstartedguide/
trunk/docs/gettingstartedguide/pom.xml
trunk/docs/gettingstartedguide/src/
trunk/docs/gettingstartedguide/src/main/
trunk/docs/gettingstartedguide/src/main/en-US/
trunk/docs/gettingstartedguide/src/main/en-US/images/
trunk/docs/gettingstartedguide/src/main/en-US/images/ChoreoMonReady.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/ConformanceCheckError.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/ConformanceCheckErrorMessage.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/ConformanceCheckErrorMessageMenu.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/ExpectedToFail.png
trunk/docs/gettingstartedguide/src/main/en-US/images/ExportBPMNMenu.png
trunk/docs/gettingstartedguide/src/main/en-US/images/ExportHTMLDialog.png
trunk/docs/gettingstartedguide/src/main/en-US/images/ExportHTMLMenu.png
trunk/docs/gettingstartedguide/src/main/en-US/images/ExportedBPMN.png
trunk/docs/gettingstartedguide/src/main/en-US/images/ExportedHTML.png
trunk/docs/gettingstartedguide/src/main/en-US/images/GenerateESBServicesDialog.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/GenerateESBServicesMenu.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/GenerateESBServicesNav.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/ImportDialog.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/ImportFileDialog.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/ImportMenu.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/ImportProjectsDialog.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/ImportedProject.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/InvalidPurchasePostTest.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/JavaCompiler1-5Compliant.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/MonitorMenu.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/ParticipantAndOtherTypes.png
trunk/docs/gettingstartedguide/src/main/en-US/images/PurchaseGoods.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/QuickFixDialog.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/RolesAndRelationships.png
trunk/docs/gettingstartedguide/src/main/en-US/images/SAVARAMonitorPurchasing1.png
trunk/docs/gettingstartedguide/src/main/en-US/images/SAVARAMonitorPurchasing2.png
trunk/docs/gettingstartedguide/src/main/en-US/images/ShowReferencedDescription.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/SuccessfulPurchasePostTest.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/SuccessfulPurchasePreTest.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/TrailBlazerMonitorError.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/TrailblazerWebPage.jpg
trunk/docs/gettingstartedguide/src/main/en-US/images/editvalidatorann.png
trunk/docs/gettingstartedguide/src/main/en-US/images/validatorannotation.png
trunk/docs/gettingstartedguide/src/main/en-US/images/validatortooltip.png
trunk/docs/gettingstartedguide/src/main/en-US/master.xml
trunk/docs/gettingstartedguide/src/main/en-US/module/
trunk/docs/gettingstartedguide/src/main/en-US/module/architecture.xml
trunk/docs/gettingstartedguide/src/main/en-US/module/author_group.xml
trunk/docs/gettingstartedguide/src/main/en-US/module/businessanalysis.xml
trunk/docs/gettingstartedguide/src/main/en-US/module/installation.xml
trunk/docs/gettingstartedguide/src/main/en-US/module/overview.xml
trunk/docs/gettingstartedguide/src/main/en-US/module/runtimevalidation.xml
trunk/docs/gettingstartedguide/src/main/en-US/module/serviceanalysisdesign.xml
trunk/docs/gettingstartedguide/src/main/en-US/module/servicedev.xml
trunk/docs/gettingstartedguide/src/main/en-US/module/tap.xml
trunk/docs/gettingstartedguide/src/main/en-US/xslt/
trunk/docs/gettingstartedguide/src/main/en-US/xslt/pdf.xsl
trunk/docs/pom.xml
trunk/docs/samplesguide/
trunk/docs/samplesguide/pom.xml
trunk/docs/samplesguide/src/
trunk/docs/samplesguide/src/main/
trunk/docs/samplesguide/src/main/en-US/
trunk/docs/samplesguide/src/main/en-US/images/
trunk/docs/samplesguide/src/main/en-US/images/ChoreoMonReady.jpg
trunk/docs/samplesguide/src/main/en-US/images/MonitorMenu.jpg
trunk/docs/samplesguide/src/main/en-US/images/TrailblazerWebPage.jpg
trunk/docs/samplesguide/src/main/en-US/master.xml
trunk/docs/samplesguide/src/main/en-US/module/
trunk/docs/samplesguide/src/main/en-US/module/author_group.xml
trunk/docs/samplesguide/src/main/en-US/module/overview.xml
trunk/docs/samplesguide/src/main/en-US/module/servicevalidator.xml
trunk/docs/samplesguide/src/main/en-US/xslt/
trunk/docs/samplesguide/src/main/en-US/xslt/pdf.xsl
trunk/docs/trailblazer/
trunk/docs/trailblazer/TBGuide.odt
trunk/docs/trailblazer/TBGuide.pdf
trunk/docs/userguide/
trunk/docs/userguide/pom.xml
trunk/docs/userguide/src/
trunk/docs/userguide/src/main/
trunk/docs/userguide/src/main/en-US/
trunk/docs/userguide/src/main/en-US/images/
trunk/docs/userguide/src/main/en-US/images/editvalidatorann.png
trunk/docs/userguide/src/main/en-US/images/editvalidatoranndiag.png
trunk/docs/userguide/src/main/en-US/images/editvalidatorannselect.png
trunk/docs/userguide/src/main/en-US/images/genbpel1.png
trunk/docs/userguide/src/main/en-US/images/genbpel2.png
trunk/docs/userguide/src/main/en-US/images/genbpel3.png
trunk/docs/userguide/src/main/en-US/images/genesbconfig1.png
trunk/docs/userguide/src/main/en-US/images/genesbconfig2.png
trunk/docs/userguide/src/main/en-US/images/genesbconfig3.png
trunk/docs/userguide/src/main/en-US/images/genvalidatordialog.png
trunk/docs/userguide/src/main/en-US/images/genvalidatormenu.png
trunk/docs/userguide/src/main/en-US/images/monitorprefs.png
trunk/docs/userguide/src/main/en-US/images/monitorui.png
trunk/docs/userguide/src/main/en-US/images/setconversationtype.png
trunk/docs/userguide/src/main/en-US/images/validatorannotation.png
trunk/docs/userguide/src/main/en-US/master.xml
trunk/docs/userguide/src/main/en-US/module/
trunk/docs/userguide/src/main/en-US/module/author_group.xml
trunk/docs/userguide/src/main/en-US/module/bpel.xml
trunk/docs/userguide/src/main/en-US/module/conversation-validation.xml
trunk/docs/userguide/src/main/en-US/module/overview.xml
trunk/docs/userguide/src/main/en-US/xslt/
trunk/docs/userguide/src/main/en-US/xslt/pdf.xsl
trunk/pom.xml
trunk/samples/
trunk/samples/jbossesb/
trunk/samples/jbossesb/trailblazer/
trunk/samples/jbossesb/trailblazer/banks/
trunk/samples/jbossesb/trailblazer/banks/JBoss ESB Loan Broker Banks Guide.html
trunk/samples/jbossesb/trailblazer/banks/JBoss ESB Loan Broker Banks Guide.odt
trunk/samples/jbossesb/trailblazer/banks/build.xml
trunk/samples/jbossesb/trailblazer/banks/lib/
trunk/samples/jbossesb/trailblazer/banks/lib/ext/
trunk/samples/jbossesb/trailblazer/banks/lib/ext/Licenses.txt
trunk/samples/jbossesb/trailblazer/banks/lib/ext/jbossall-client.jar
trunk/samples/jbossesb/trailblazer/banks/lib/ext/junit-4.1.jar
trunk/samples/jbossesb/trailblazer/banks/lib/ext/log4j.jar
trunk/samples/jbossesb/trailblazer/banks/lib/ext/org.sadun.util.jar
trunk/samples/jbossesb/trailblazer/banks/lib/ext/pollmgt.jar
trunk/samples/jbossesb/trailblazer/banks/lib/ext/trove.jar
trunk/samples/jbossesb/trailblazer/banks/lib/ext/xstream-1.2.2.jar
trunk/samples/jbossesb/trailblazer/banks/log4j.xml
trunk/samples/jbossesb/trailblazer/banks/monitored_folders/
trunk/samples/jbossesb/trailblazer/banks/src/
trunk/samples/jbossesb/trailblazer/banks/src/org/
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/Bank.java
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReply.java
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FileUtil.java
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java
trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java
trunk/samples/jbossesb/trailblazer/banks/test/
trunk/samples/jbossesb/trailblazer/banks/test/src/
trunk/samples/jbossesb/trailblazer/banks/test/src/org/
trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/
trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/
trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/
trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/
trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/
trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/
trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReplyTest.java
trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequestTest.java
trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java
trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java
trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java
trunk/samples/jbossesb/trailblazer/build.xml
trunk/samples/jbossesb/trailblazer/client/
trunk/samples/jbossesb/trailblazer/client/java-files/
trunk/samples/jbossesb/trailblazer/client/java-files/FailedLoanBroker.java
trunk/samples/jbossesb/trailblazer/client/java-files/SuccessfulLoanBroker.java
trunk/samples/jbossesb/trailblazer/client/jsp/
trunk/samples/jbossesb/trailblazer/client/jsp/index.jsp
trunk/samples/jbossesb/trailblazer/client/lib/
trunk/samples/jbossesb/trailblazer/client/lib/ext/
trunk/samples/jbossesb/trailblazer/client/lib/ext/Licenses.txt
trunk/samples/jbossesb/trailblazer/client/lib/ext/jaxb-api.jar
trunk/samples/jbossesb/trailblazer/client/lib/ext/jboss-jaxws.jar
trunk/samples/jbossesb/trailblazer/client/lib/ext/jbossws-client.jar
trunk/samples/jbossesb/trailblazer/client/lib/ext/jbossws-core.jar
trunk/samples/jbossesb/trailblazer/client/resources/
trunk/samples/jbossesb/trailblazer/client/resources/jaxrpc-mapping.xml
trunk/samples/jbossesb/trailblazer/client/resources/web.xml
trunk/samples/jbossesb/trailblazer/client/resources/webservices.xml
trunk/samples/jbossesb/trailblazer/client/resources/wsdl/
trunk/samples/jbossesb/trailblazer/client/resources/wsdl/LoanBrokerService.wsdl
trunk/samples/jbossesb/trailblazer/client/resources/wstools-config.xml
trunk/samples/jbossesb/trailblazer/client/src/
trunk/samples/jbossesb/trailblazer/client/src/org/
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/Customer.java
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/CustomerMasterFile.java
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanRequester.java
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/QuoteRequest.java
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/LoanBrokerBean.java
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/LoanBrokerInterface.java
trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/WebCustomer.java
trunk/samples/jbossesb/trailblazer/esb/
trunk/samples/jbossesb/trailblazer/esb/build.xml
trunk/samples/jbossesb/trailblazer/esb/conf/
trunk/samples/jbossesb/trailblazer/esb/conf/deployment.xml
trunk/samples/jbossesb/trailblazer/esb/conf/jbm-queue-service.xml
trunk/samples/jbossesb/trailblazer/esb/conf/jbmq-queue-service.xml
trunk/samples/jbossesb/trailblazer/esb/conf/jboss-esb.xml
trunk/samples/jbossesb/trailblazer/esb/conf/jbossesb-properties-monitor.xml
trunk/samples/jbossesb/trailblazer/esb/conf/jbossesb-properties.xml
trunk/samples/jbossesb/trailblazer/esb/conf/log4j.xml
trunk/samples/jbossesb/trailblazer/esb/conf/smooks-csv2xml.xml
trunk/samples/jbossesb/trailblazer/esb/conf/smooks-xml2csv.xml
trunk/samples/jbossesb/trailblazer/esb/conf/xml2csv.xsl
trunk/samples/jbossesb/trailblazer/esb/lib/
trunk/samples/jbossesb/trailblazer/esb/lib/ext/
trunk/samples/jbossesb/trailblazer/esb/lib/ext/c3p0-0.9.1-pre9.jar
trunk/samples/jbossesb/trailblazer/esb/lib/ext/commons-logging.jar
trunk/samples/jbossesb/trailblazer/esb/lib/ext/hsqldb.jar
trunk/samples/jbossesb/trailblazer/esb/lib/ext/milyn-smooks-csv-0.1.jar
trunk/samples/jbossesb/trailblazer/esb/lib/ext/opencsv-1.6.jar
trunk/samples/jbossesb/trailblazer/esb/src/
trunk/samples/jbossesb/trailblazer/esb/src/org/
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/BankResponseActions.java
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditAgencyActions.java
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditCheckCSVToXMLActions.java
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditCheckXMLToCSVActions.java
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/FileBankRequestActions.java
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/NotifyCustomerActions.java
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/HsqldbUtil.java
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/ProcessEmail.java
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TbBootStrapper.java
trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TrailblazerProperties.java
trunk/samples/jbossesb/trailblazer/esb/test/
trunk/samples/jbossesb/trailblazer/esb/test/src/
trunk/samples/jbossesb/trailblazer/juddi.properties
trunk/samples/jbossesb/trailblazer/log4j.xml
trunk/samples/jbossesb/trailblazer/models/
trunk/samples/jbossesb/trailblazer/models/LoanRequest.scn
trunk/samples/jbossesb/trailblazer/models/TrailBlazer.cdm
trunk/samples/jbossesb/trailblazer/readme.txt
trunk/samples/jbossesb/trailblazer/template/
trunk/samples/jbossesb/trailblazer/template/quote.st
trunk/samples/jbossesb/trailblazer/trailblazer.properties
trunk/samples/purchasing/
trunk/samples/purchasing/.project
trunk/samples/purchasing/BuyConfirmed.xml
trunk/samples/purchasing/BuyRequest.xml
trunk/samples/purchasing/CreditCheckInvalid.xml
trunk/samples/purchasing/CreditCheckOk.xml
trunk/samples/purchasing/CreditCheckRequest.xml
trunk/samples/purchasing/InvalidPurchase.scn
trunk/samples/purchasing/PurchaseGoods.cdm
trunk/samples/purchasing/SuccessfulPurchase.scn
trunk/samples/purchasing/completed/
trunk/samples/purchasing/completed/creditAgency/
trunk/samples/purchasing/completed/creditAgency/PurchaseGoodsProcess_CreditAgency.bpel
trunk/samples/purchasing/completed/creditAgency/bpel-deploy.xml
trunk/samples/purchasing/completed/store/
trunk/samples/purchasing/completed/store/PurchaseGoodsProcess_Store.bpel
trunk/samples/purchasing/completed/store/bpel-deploy.xml
trunk/samples/purchasing/creditAgency.xsd
trunk/samples/purchasing/purchasing.tap
trunk/samples/purchasing/store.xsd
trunk/tools/
trunk/tools/features/
trunk/tools/features/org.jboss.savara.tools.feature/
trunk/tools/features/org.jboss.savara.tools.feature/Copyright.txt
trunk/tools/features/org.jboss.savara.tools.feature/build.properties
trunk/tools/features/org.jboss.savara.tools.feature/feature.xml
trunk/tools/features/org.jboss.savara.tools.feature/pom.xml
trunk/tools/features/org.savara.tools.feature/
trunk/tools/features/org.savara.tools.feature/Copyright.txt
trunk/tools/features/org.savara.tools.feature/build.properties
trunk/tools/features/org.savara.tools.feature/feature.xml
trunk/tools/features/org.savara.tools.feature/pom.xml
trunk/tools/features/org.scribble.protocol.feature/
trunk/tools/features/org.scribble.protocol.feature/LICENSE.txt
trunk/tools/features/org.scribble.protocol.feature/build.properties
trunk/tools/features/org.scribble.protocol.feature/feature.xml
trunk/tools/features/org.scribble.protocol.feature/pom.xml
trunk/tools/features/pom.xml
trunk/tools/plugins/
trunk/tools/plugins/org.savara.pi4soa.cdm/
trunk/tools/plugins/org.savara.pi4soa.cdm/.classpath
trunk/tools/plugins/org.savara.pi4soa.cdm/.project
trunk/tools/plugins/org.savara.pi4soa.cdm/Copyright.txt
trunk/tools/plugins/org.savara.pi4soa.cdm/META-INF/
trunk/tools/plugins/org.savara.pi4soa.cdm/META-INF/MANIFEST.MF
trunk/tools/plugins/org.savara.pi4soa.cdm/build.properties
trunk/tools/plugins/org.savara.pi4soa.cdm/pom.xml
trunk/tools/plugins/org.savara.pi4soa.cdm/src/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/CDMDefinitions.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/editor/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/editor/CDMEditorManager.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/editor/SCNEditorManager.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/model/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/model/CDMNotation.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/model/SCNNotation.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/osgi/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/osgi/Activator.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/CDMModelParserRule.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/CDMTokenizer.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterContext.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterRule.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/validation/
trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java
trunk/tools/plugins/org.savara.protocol.contract/
trunk/tools/plugins/org.savara.protocol.contract/.classpath
trunk/tools/plugins/org.savara.protocol.contract/.project
trunk/tools/plugins/org.savara.protocol.contract/Copyright.txt
trunk/tools/plugins/org.savara.protocol.contract/META-INF/
trunk/tools/plugins/org.savara.protocol.contract/META-INF/MANIFEST.MF
trunk/tools/plugins/org.savara.protocol.contract/build.properties
trunk/tools/plugins/org.savara.protocol.contract/pom.xml
trunk/tools/plugins/org.savara.protocol.contract/src/
trunk/tools/plugins/org.savara.protocol.contract/src/java/
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/ContractGenerator.java
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/ContractGeneratorFactory.java
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/Messages.properties
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/impl/
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/impl/ContractGeneratorImpl.java
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/impl/ContractIntrospector.java
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/osgi/
trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/osgi/Activator.java
trunk/tools/plugins/org.savara.tap.eclipse/
trunk/tools/plugins/org.savara.tap.eclipse/.classpath
trunk/tools/plugins/org.savara.tap.eclipse/.project
trunk/tools/plugins/org.savara.tap.eclipse/META-INF/
trunk/tools/plugins/org.savara.tap.eclipse/META-INF/MANIFEST.MF
trunk/tools/plugins/org.savara.tap.eclipse/OSGI-INF/
trunk/tools/plugins/org.savara.tap.eclipse/OSGI-INF/eclipse-resource-loader.xml
trunk/tools/plugins/org.savara.tap.eclipse/build.properties
trunk/tools/plugins/org.savara.tap.eclipse/plugin.xml
trunk/tools/plugins/org.savara.tap.eclipse/pom.xml
trunk/tools/plugins/org.savara.tap.eclipse/src/
trunk/tools/plugins/org.savara.tap.eclipse/src/java/
trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/
trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/
trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/
trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/
trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/Activator.java
trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/EclipseResourceLoader.java
trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/actions/
trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/actions/ValidateAction.java
trunk/tools/plugins/org.savara.tap.model/
trunk/tools/plugins/org.savara.tap.model/.classpath
trunk/tools/plugins/org.savara.tap.model/.project
trunk/tools/plugins/org.savara.tap.model/Copyright.txt
trunk/tools/plugins/org.savara.tap.model/META-INF/
trunk/tools/plugins/org.savara.tap.model/META-INF/MANIFEST.MF
trunk/tools/plugins/org.savara.tap.model/build.properties
trunk/tools/plugins/org.savara.tap.model/pom.xml
trunk/tools/plugins/org.savara.tap.model/schema/
trunk/tools/plugins/org.savara.tap.model/schema/tap.xsd
trunk/tools/plugins/org.savara.tap.model/src/
trunk/tools/plugins/org.savara.tap.model/src/java/
trunk/tools/plugins/org.savara.tap.model/src/java/org/
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Link.java
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/ObjectFactory.java
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Phase.java
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Project.java
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Relationship.java
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Resource.java
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Root.java
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/URI.java
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/admin/
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/admin/ResourceLoader.java
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/admin/TAPModelUtil.java
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/osgi/
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/osgi/Activator.java
trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/package-info.java
trunk/tools/plugins/org.savara.tap.validation/
trunk/tools/plugins/org.savara.tap.validation/.classpath
trunk/tools/plugins/org.savara.tap.validation/.project
trunk/tools/plugins/org.savara.tap.validation/Copyright.txt
trunk/tools/plugins/org.savara.tap.validation/META-INF/
trunk/tools/plugins/org.savara.tap.validation/META-INF/MANIFEST.MF
trunk/tools/plugins/org.savara.tap.validation/OSGI-INF/
trunk/tools/plugins/org.savara.tap.validation/OSGI-INF/bpel-cdm-relationship-validator.xml
trunk/tools/plugins/org.savara.tap.validation/OSGI-INF/cdm-scenario-relationship-validator.xml
trunk/tools/plugins/org.savara.tap.validation/build.properties
trunk/tools/plugins/org.savara.tap.validation/plugin.xml
trunk/tools/plugins/org.savara.tap.validation/pom.xml
trunk/tools/plugins/org.savara.tap.validation/src/
trunk/tools/plugins/org.savara.tap.validation/src/java/
trunk/tools/plugins/org.savara.tap.validation/src/java/org/
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/Messages.properties
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/RelationshipValidator.java
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/ResourceValidator.java
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/TAPValidator.java
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/cdl/
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/cdl/CDMScenarioRelationshipValidator.java
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/osgi/
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/osgi/Activator.java
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/ws/
trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/ws/BPELCDMRelationshipValidator.java
trunk/tools/plugins/org.savara.tap.validation/src/resources/
trunk/tools/plugins/org.savara.tap.validation/src/resources/tap.xsd
trunk/tools/plugins/org.savara.tools.bpel/
trunk/tools/plugins/org.savara.tools.bpel/.classpath
trunk/tools/plugins/org.savara.tools.bpel/.project
trunk/tools/plugins/org.savara.tools.bpel/Copyright.txt
trunk/tools/plugins/org.savara.tools.bpel/META-INF/
trunk/tools/plugins/org.savara.tools.bpel/META-INF/MANIFEST.MF
trunk/tools/plugins/org.savara.tools.bpel/build.properties
trunk/tools/plugins/org.savara.tools.bpel/plugin.xml
trunk/tools/plugins/org.savara.tools.bpel/pom.xml
trunk/tools/plugins/org.savara.tools.bpel/src/
trunk/tools/plugins/org.savara.tools.bpel/src/java/
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/actions/
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/actions/GenerateAction.java
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/dialogs/
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/dialogs/GenerateDialog.java
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/editor/
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/editor/BPELEditorManager.java
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/GeneratorException.java
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/GeneratorUtil.java
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/template/
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/template/Ant.template
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/template/Maven.template
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/osgi/
trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/osgi/Activator.java
trunk/tools/plugins/org.savara.tools.bpmn/
trunk/tools/plugins/org.savara.tools.bpmn/.classpath
trunk/tools/plugins/org.savara.tools.bpmn/.project
trunk/tools/plugins/org.savara.tools.bpmn/META-INF/
trunk/tools/plugins/org.savara.tools.bpmn/META-INF/MANIFEST.MF
trunk/tools/plugins/org.savara.tools.bpmn/build.properties
trunk/tools/plugins/org.savara.tools.bpmn/plugin.xml
trunk/tools/plugins/org.savara.tools.bpmn/pom.xml
trunk/tools/plugins/org.savara.tools.bpmn/src/
trunk/tools/plugins/org.savara.tools.bpmn/src/java/
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/Activator.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/ExportBPMNWizard.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/FolderSelectionPage.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNConfiguration.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNGenerationException.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNGenerator.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNModelFactory.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNNotationFactory.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/DefaultBPMNConfiguration.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/AbstractBPMNActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNDiagram.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNPool.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ChoiceActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ConditionalActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/JunctionActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ParallelActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/PerformActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ReceiveActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/SequenceActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/SimpleActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/WhenActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/WhileActivity.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/gmf/
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/gmf/GMFBPMNNotationFactoryImpl.java
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/stp/
trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/stp/STPBPMNModelFactoryImpl.java
trunk/tools/plugins/org.savara.tools.monitor/
trunk/tools/plugins/org.savara.tools.monitor/.classpath
trunk/tools/plugins/org.savara.tools.monitor/.project
trunk/tools/plugins/org.savara.tools.monitor/LICENSE.txt
trunk/tools/plugins/org.savara.tools.monitor/META-INF/
trunk/tools/plugins/org.savara.tools.monitor/META-INF/MANIFEST.MF
trunk/tools/plugins/org.savara.tools.monitor/build.properties
trunk/tools/plugins/org.savara.tools.monitor/plugin.xml
trunk/tools/plugins/org.savara.tools.monitor/pom.xml
trunk/tools/plugins/org.savara.tools.monitor/src/
trunk/tools/plugins/org.savara.tools.monitor/src/java/
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/CorrelationManagerListener.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ExchangeEvent.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/TxnMonitor.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/Activator.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorAction.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorLaunchConfigurationConstants.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorLauncher.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorMainTab.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorTabGroup.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/MonitorPreferencePage.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/MonitorPreferences.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/PreferenceInitializer.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ChannelJPanel.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ExchangeEventWrapper.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ExchangeEventsData.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/Monitor.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorExchangeEvent.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorFileFilter.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorMainPanel.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorMenuBar.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorTreeModelListener.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/SpringUtilities.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/XmlPrettyPrinter.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelclosed.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelempty.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelleaf.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelopen.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/errorsleaf.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/issuesclosed.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/issuesempty.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/issuesopen.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/monitor.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnclosed.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnempty.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnleaf.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnopen.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/unexpectedleaf.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/warningsleaf.png
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/table/
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/table/TableSorter.java
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/preferences/
trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/preferences/SavaraPreferencePage.java
trunk/tools/plugins/org.savara.tools.validator/
trunk/tools/plugins/org.savara.tools.validator/.classpath
trunk/tools/plugins/org.savara.tools.validator/.project
trunk/tools/plugins/org.savara.tools.validator/Copyright.txt
trunk/tools/plugins/org.savara.tools.validator/META-INF/
trunk/tools/plugins/org.savara.tools.validator/META-INF/MANIFEST.MF
trunk/tools/plugins/org.savara.tools.validator/build.properties
trunk/tools/plugins/org.savara.tools.validator/plugin.xml
trunk/tools/plugins/org.savara.tools.validator/pom.xml
trunk/tools/plugins/org.savara.tools.validator/src/
trunk/tools/plugins/org.savara.tools.validator/src/java/
trunk/tools/plugins/org.savara.tools.validator/src/java/org/
trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/
trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/
trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/
trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/
trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/Activator.java
trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/ValidatorAnnotations.java
trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/
trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/annotations.xml
trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/cdl/
trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/cdl/validator.presentation
trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/cdl/validator.template
trunk/tools/plugins/org.savara.tools.wsdl/
trunk/tools/plugins/org.savara.tools.wsdl/.classpath
trunk/tools/plugins/org.savara.tools.wsdl/.project
trunk/tools/plugins/org.savara.tools.wsdl/Copyright.txt
trunk/tools/plugins/org.savara.tools.wsdl/META-INF/
trunk/tools/plugins/org.savara.tools.wsdl/META-INF/MANIFEST.MF
trunk/tools/plugins/org.savara.tools.wsdl/build.properties
trunk/tools/plugins/org.savara.tools.wsdl/plugin.xml
trunk/tools/plugins/org.savara.tools.wsdl/pom.xml
trunk/tools/plugins/org.savara.tools.wsdl/src/
trunk/tools/plugins/org.savara.tools.wsdl/src/java/
trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/
trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/
trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/
trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/
trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/actions/
trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/actions/GenerateAction.java
trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/osgi/
trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/osgi/Activator.java
trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/util/
trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/util/XMLUtils.java
trunk/tools/plugins/org.scribble.eclipse/
trunk/tools/plugins/org.scribble.eclipse/.classpath
trunk/tools/plugins/org.scribble.eclipse/.project
trunk/tools/plugins/org.scribble.eclipse/LICENSE.txt
trunk/tools/plugins/org.scribble.eclipse/META-INF/
trunk/tools/plugins/org.scribble.eclipse/META-INF/MANIFEST.MF
trunk/tools/plugins/org.scribble.eclipse/build.properties
trunk/tools/plugins/org.scribble.eclipse/plugin.xml
trunk/tools/plugins/org.scribble.eclipse/pom.xml
trunk/tools/plugins/org.scribble.eclipse/src/
trunk/tools/plugins/org.scribble.eclipse/src/java/
trunk/tools/plugins/org.scribble.eclipse/src/java/org/
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIDefinitions.java
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelListener.java
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelRepository.java
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelResource.java
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/osgi/
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/osgi/Activator.java
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/util/
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/util/ResourceUtil.java
trunk/tools/plugins/pom.xml
trunk/tools/pom.xml
trunk/tools/pomOrig.xml
trunk/tools/site/
trunk/tools/site/pom.xml
trunk/tools/site/site.xml
trunk/tools/tests/
trunk/tools/tests/org.savara.protocol.contract.tests/
trunk/tools/tests/org.savara.protocol.contract.tests/.classpath
trunk/tools/tests/org.savara.protocol.contract.tests/.project
trunk/tools/tests/org.savara.protocol.contract.tests/Copyright.txt
trunk/tools/tests/org.savara.protocol.contract.tests/META-INF/
trunk/tools/tests/org.savara.protocol.contract.tests/META-INF/MANIFEST.MF
trunk/tools/tests/org.savara.protocol.contract.tests/build.properties
trunk/tools/tests/org.savara.protocol.contract.tests/pom.xml
trunk/tools/tests/org.savara.protocol.contract.tests/src/
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/ContractGeneratorTest.java
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/ProtocolContractAllTests.java
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/impl/
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/impl/ContractIntrospectorTest.java
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/tests/
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/tests/osgi/
trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/tests/osgi/Activator.java
trunk/tools/tests/org.savara.tools.bpel.tests/
trunk/tools/tests/org.savara.tools.bpel.tests/.classpath
trunk/tools/tests/org.savara.tools.bpel.tests/.project
trunk/tools/tests/org.savara.tools.bpel.tests/META-INF/
trunk/tools/tests/org.savara.tools.bpel.tests/META-INF/MANIFEST.MF
trunk/tools/tests/org.savara.tools.bpel.tests/build.properties
trunk/tools/tests/org.savara.tools.bpel.tests/pom.xml
trunk/tools/tests/org.savara.tools.bpel.tests/src/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/GeneratorTest.java
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Broker.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Buyer.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at CreditAgency.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Supplier.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at SupplierQuoteEngine.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at SupplierTxnProcessor.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at Buyer.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at CreditAgency.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at Store.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ReqRespFault at Buyer.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ReqRespFault at Seller.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/ESBBroker.cdm
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/PurchaseGoods.cdm
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/ReqRespFault.cdm
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/ParserTest.java
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at Broker.scv
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at Buyer.scv
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at CreditAgency.scv
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at SupplierQuoteEngine.scv
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at SupplierTxnProcessor.scv
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/LoanApprovalService at Service.scv
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at Buyer.scv
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at CreditAgency.scv
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at Store.scv
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ReqRespFault at Buyer.scv
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ReqRespFault at Seller.scv
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessor.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessor.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessorArtifacts.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Broker.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Broker.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_BrokerArtifacts.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Buyer.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_BuyerArtifacts.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgency.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgency.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgencyArtifacts.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Supplier.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/LoanApprovalService at Service.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Buyer.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_BuyerArtifacts.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgency.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgency.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgencyArtifacts.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Store.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Store.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_StoreArtifacts.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Buyer.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_BuyerArtifacts.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Seller.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Seller.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_SellerArtifacts.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngine.bpel
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngine.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngineArtifacts.wsdl
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/tests/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/tests/AllTests.java
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/tests/osgi/
trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/tests/osgi/Activator.java
trunk/tools/tests/pom.xml
trunk/validators/
trunk/validators/jboss/
trunk/validators/jboss/common/
trunk/validators/jboss/common/pom.xml
trunk/validators/jboss/common/src/
trunk/validators/jboss/common/src/main/
trunk/validators/jboss/common/src/main/configs/
trunk/validators/jboss/common/src/main/configs/META-INF/
trunk/validators/jboss/common/src/main/configs/META-INF/jbm-queue-service.xml
trunk/validators/jboss/common/src/main/configs/META-INF/jboss-beans.xml
trunk/validators/jboss/common/src/main/configs/META-INF/jboss-scanning.xml
trunk/validators/jboss/common/src/main/configs/META-INF/jboss-structure.xml
trunk/validators/jboss/common/src/main/configs/common-assembly.xml
trunk/validators/jboss/common/src/main/configs/models/
trunk/validators/jboss/common/src/main/configs/models/PurchaseGoods.cdm
trunk/validators/jboss/common/src/main/configs/models/TrailBlazer.cdm
trunk/validators/jboss/common/src/main/configs/pi4soa.xml
trunk/validators/jboss/common/src/main/configs/validator-config.xml
trunk/validators/jboss/common/src/main/java/
trunk/validators/jboss/common/src/main/java/org/
trunk/validators/jboss/common/src/main/java/org/savara/
trunk/validators/jboss/common/src/main/java/org/savara/validator/
trunk/validators/jboss/common/src/main/java/org/savara/validator/AbstractServiceValidator.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/DefaultValidatorConfig.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/Endpoint.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidator.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidatorFactory.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidatorManager.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfig.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfigFactory.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfigLoader.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorName.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/
trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/JMSServiceTracker.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceRecorder.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceValidator.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAValidatorConfigLoader.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/ValidatorConfigGenerator.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/service/
trunk/validators/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorService.java
trunk/validators/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorServiceMBean.java
trunk/validators/jboss/common/src/main/resources/
trunk/validators/jboss/esb/
trunk/validators/jboss/esb/pom.xml
trunk/validators/jboss/esb/src/
trunk/validators/jboss/esb/src/main/
trunk/validators/jboss/esb/src/main/configs/
trunk/validators/jboss/esb/src/main/configs/META-INF/
trunk/validators/jboss/esb/src/main/configs/META-INF/deployment.xml
trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-esb.xml
trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-scanning.xml
trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-structure.xml
trunk/validators/jboss/esb/src/main/configs/esb-assembly.xml
trunk/validators/jboss/esb/src/main/java/
trunk/validators/jboss/esb/src/main/java/org/
trunk/validators/jboss/esb/src/main/java/org/savara/
trunk/validators/jboss/esb/src/main/java/org/savara/validator/
trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/
trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/ESBUtil.java
trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/JBossESBInterceptor.java
trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/ValidatorFilter.java
trunk/validators/jboss/esb/src/main/resources/
trunk/validators/jboss/esb/src/test/
trunk/validators/jboss/esb/src/test/java/
trunk/validators/jboss/esb/src/test/java/org/
trunk/validators/jboss/esb/src/test/java/org/savara/
trunk/validators/jboss/esb/src/test/java/org/savara/validator/
trunk/validators/jboss/esb/src/test/java/org/savara/validator/jbossesb/
trunk/validators/jboss/esb/src/test/java/org/savara/validator/jbossesb/ESBUtilTest.java
trunk/validators/jboss/esb/src/test/resources/
trunk/validators/jboss/pom.xml
trunk/validators/jboss/wsnative/
trunk/validators/jboss/wsnative/pom.xml
trunk/validators/jboss/wsnative/src/
trunk/validators/jboss/wsnative/src/main/
trunk/validators/jboss/wsnative/src/main/configs/
trunk/validators/jboss/wsnative/src/main/configs/META-INF/
trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-beans.xml
trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-scanning.xml
trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-structure.xml
trunk/validators/jboss/wsnative/src/main/configs/ws-native-assembly.xml
trunk/validators/jboss/wsnative/src/main/java/
trunk/validators/jboss/wsnative/src/main/java/org/
trunk/validators/jboss/wsnative/src/main/java/org/savara/
trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/
trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/
trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/AbstractJBossWSNativeInterceptor.java
trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java
trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java
trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/service/
trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/service/JBossWSNativeServiceValidatorService.java
trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/service/JBossWSNativeServiceValidatorServiceMBean.java
trunk/validators/jboss/wsnative/src/main/resources/
trunk/validators/jboss/wsnative/src/test/
trunk/validators/jboss/wsnative/src/test/java/
trunk/validators/jboss/wsnative/src/test/resources/
trunk/validators/pom.xml
Log:
New build structure with OSGi bundles separate from Tycho built eclipse plugins and update site
Added: trunk/.project
===================================================================
--- trunk/.project (rev 0)
+++ trunk/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>trunk</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
Added: trunk/bundles/org.savara.bpel/.classpath
===================================================================
--- trunk/bundles/org.savara.bpel/.classpath (rev 0)
+++ trunk/bundles/org.savara.bpel/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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
+ * < 0 || index > 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 < 0 || index >= 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 < 0 || index > 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
+ * < 0 || index >= 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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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-21 00:29:50 UTC (rev 496)
@@ -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/org.scribble.expression.xpath/.classpath
===================================================================
--- trunk/bundles/org.scribble.expression.xpath/.classpath (rev 0)
+++ trunk/bundles/org.scribble.expression.xpath/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
Added: trunk/bundles/org.scribble.expression.xpath/.project
===================================================================
--- trunk/bundles/org.scribble.expression.xpath/.project (rev 0)
+++ trunk/bundles/org.scribble.expression.xpath/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.scribble.expression.xpath</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.expression.xpath/LICENSE.txt
===================================================================
--- trunk/bundles/org.scribble.expression.xpath/LICENSE.txt (rev 0)
+++ trunk/bundles/org.scribble.expression.xpath/LICENSE.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.expression.xpath/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.scribble.expression.xpath/META-INF/MANIFEST.MF (rev 0)
+++ trunk/bundles/org.scribble.expression.xpath/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scribble Expression Xpath Plug-in
+Bundle-SymbolicName: org.scribble.expression.xpath;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.scribble.expression.xpath.osgi.Activator
+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
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: www.scribble.org
+Scribble-Extensions: org.scribble.expression.xpath.validation.XPathExpressionValidationRule,
+ org.scribble.expression.xpath.export.text.XPathExpressionTextExportRule,
+ org.scribble.expression.xpath.model.types.XPathExpressionTypeResolverRule
+Export-Package: org.scribble.expression.xpath.model
Added: trunk/bundles/org.scribble.expression.xpath/build.properties
===================================================================
--- trunk/bundles/org.scribble.expression.xpath/build.properties (rev 0)
+++ trunk/bundles/org.scribble.expression.xpath/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,5 @@
+source.. = src/main/java/
+output.. = classes/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: trunk/bundles/org.scribble.expression.xpath/pom.xml
===================================================================
--- trunk/bundles/org.scribble.expression.xpath/pom.xml (rev 0)
+++ trunk/bundles/org.scribble.expression.xpath/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.expression.xpath</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Savara::Bundles::ScribbleExpressionXPath</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.expression.xpath/src/main/java/org/scribble/expression/xpath/export/text/XPathExpressionTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/export/text/XPathExpressionTextExportRule.java (rev 0)
+++ trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/export/text/XPathExpressionTextExportRule.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,69 @@
+/*
+ * 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:
+ * 8 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.expression.xpath.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.expression.xpath.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * XPathExpression entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class XPathExpressionTextExportRule 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(XPathExpression.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 {
+ XPathExpression expr=(XPathExpression)modelObject;
+ TextFormatter formatter=(TextFormatter)context.getFormatter();
+
+ formatter.record("xpath[");
+
+ if (expr.getQuery() != null) {
+ formatter.record(expr.getQuery());
+ }
+
+ formatter.record("]");
+ }
+}
Added: trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/model/XPathExpression.java
===================================================================
--- trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/model/XPathExpression.java (rev 0)
+++ trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/model/XPathExpression.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.expression.xpath.model;
+
+/**
+ * This class represents an xpath expression.
+ */
+public class XPathExpression extends org.scribble.conversation.model.Expression {
+
+ private static final long serialVersionUID = 6297823747605191013L;
+
+ /**
+ * This method sets the query string associated with the
+ * expression.
+ *
+ * @param query The query
+ */
+ public void setQuery(String query) {
+ m_query = query;
+ }
+
+ /**
+ * This method returns the query string associated with
+ * the xpath expression.
+ *
+ * @return The query
+ */
+ public String getQuery() {
+ return(m_query);
+ }
+
+ private String m_query=null;
+}
Added: trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/model/types/XPathExpressionTypeResolverRule.java
===================================================================
--- trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/model/types/XPathExpressionTypeResolverRule.java (rev 0)
+++ trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/model/types/XPathExpressionTypeResolverRule.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 25 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.expression.xpath.model.types;
+
+import org.scribble.model.ModelObject;
+import org.scribble.model.TypeReference;
+import org.scribble.model.types.*;
+import org.scribble.expression.xpath.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class implements the type resolver rule for the
+ * XPathExpression model object.
+ */
+ at RegistryInfo(extension=TypeResolverRule.class)
+public class XPathExpressionTypeResolverRule implements 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) {
+ return(modelObject instanceof XPathExpression);
+ }
+
+ /**
+ * 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;
+ XPathExpression expr=(XPathExpression)modelObject;
+
+ // TODO: Identify the resulting type from the expression
+
+ return(ret);
+ }
+}
Added: trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/osgi/Activator.java
===================================================================
--- trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/osgi/Activator.java (rev 0)
+++ trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,48 @@
+package org.scribble.expression.xpath.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.expression.xpath";
+
+ // 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.expression.xpath/src/main/java/org/scribble/expression/xpath/validation/XPathExpressionValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/validation/XPathExpressionValidationRule.java (rev 0)
+++ trunk/bundles/org.scribble.expression.xpath/src/main/java/org/scribble/expression/xpath/validation/XPathExpressionValidationRule.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,66 @@
+/*
+ * 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:
+ * 25 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.expression.xpath.validation;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.expression.xpath.model.*;
+import org.scribble.validation.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class implements the validation rule for the
+ * XPathExpression construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class)
+public class XPathExpressionValidationRule extends AbstractValidationRule {
+
+ /**
+ * This is the default constructor.
+ */
+ public XPathExpressionValidationRule() {
+ }
+
+ /**
+ * 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 XPathExpression);
+ }
+
+ /**
+ * 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) {
+ XPathExpression elem=(XPathExpression)obj;
+
+ // TODO: Use an appropriate xpath parser to validate the
+ // expression and that the referenced variables exist
+ }
+}
Added: trunk/bundles/org.scribble.lang.model/.classpath
===================================================================
--- trunk/bundles/org.scribble.lang.model/.classpath (rev 0)
+++ trunk/bundles/org.scribble.lang.model/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.lang.model/.project
===================================================================
--- trunk/bundles/org.scribble.lang.model/.project (rev 0)
+++ trunk/bundles/org.scribble.lang.model/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.scribble.lang.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.lang.model/LICENSE.txt
===================================================================
--- trunk/bundles/org.scribble.lang.model/LICENSE.txt (rev 0)
+++ trunk/bundles/org.scribble.lang.model/LICENSE.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.lang.model/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.scribble.lang.model/META-INF/MANIFEST.MF (rev 0)
+++ trunk/bundles/org.scribble.lang.model/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scribble Language Model Plug-in
+Bundle-SymbolicName: org.scribble.lang.model;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.scribble.lang.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)",
+ org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)"
+Eclipse-LazyStart: true
+Export-Package: org.scribble.lang.model
+Scribble-Extensions: org.scribble.lang.model.JavaLanguageModel
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added: trunk/bundles/org.scribble.lang.model/build.properties
===================================================================
--- trunk/bundles/org.scribble.lang.model/build.properties (rev 0)
+++ trunk/bundles/org.scribble.lang.model/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,5 @@
+source.. = src/main/java/
+output.. = classes/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: trunk/bundles/org.scribble.lang.model/pom.xml
===================================================================
--- trunk/bundles/org.scribble.lang.model/pom.xml (rev 0)
+++ trunk/bundles/org.scribble.lang.model/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.lang.model</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Savara::Bundles::ScribbleLangModel</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.lang.model/src/main/java/org/scribble/lang/model/JavaLanguageModel.java
===================================================================
--- trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/JavaLanguageModel.java (rev 0)
+++ trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/JavaLanguageModel.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,43 @@
+/*
+ * 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 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.lang.model;
+
+import org.scribble.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This class represents the Java language model.
+ *
+ */
+ at RegistryInfo(extension=Model.class,notation=JavaLanguageModel.JAVA_LANGUAGE)
+public class JavaLanguageModel extends LanguageModel {
+
+ /**
+ * This method returns the notation associated with
+ * the model.
+ *
+ * @return The notation
+ */
+ public String getNotation() {
+ return(JAVA_LANGUAGE);
+ }
+
+ public static final String JAVA_LANGUAGE="java";
+}
Added: trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/LanguageModel.java
===================================================================
--- trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/LanguageModel.java (rev 0)
+++ trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/LanguageModel.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,125 @@
+/*
+ * 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 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.lang.model;
+
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class represents the language model.
+ *
+ */
+public abstract class LanguageModel extends Model {
+
+ /**
+ * This method returns the model name associated with
+ * the model.
+ *
+ * @return The model name
+ */
+ public LocatedName getModelName() {
+ return(m_modelName);
+ }
+
+ /**
+ * This method sets 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
+ */
+ public java.util.List<Role> getRoles() {
+ java.util.List<Role> ret=null;
+ final java.util.List<Role> roles=
+ new java.util.Vector<Role>();
+
+ if (m_conversations != null) {
+ // Identify all of the roles defined in the
+ // top level conversations
+ for (int i=0; i < m_conversations.size(); i++) {
+ m_conversations.get(i).visit(new Visitor() {
+
+ public boolean visit(ModelObject obj) {
+ boolean ret=true;
+
+ if (obj instanceof Conversation &&
+ m_conversations.contains(obj)) {
+ ret = false;
+
+ } else if (obj instanceof RoleList) {
+ RoleList plist=(RoleList)obj;
+
+ roles.addAll(plist.getRoles());
+ }
+
+ return(ret);
+ }
+ });
+ }
+ }
+
+ ret = new java.util.Vector<Role>(roles) {
+ public boolean add(Role obj) {
+ throw new java.lang.RuntimeException("Read only list");
+ }
+ };
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the protocol.
+ *
+ * @return The protocol
+ */
+ @Reference(containment=true)
+ public java.util.List<Conversation> getConversations() {
+ return(m_conversations);
+ }
+
+ /**
+ * 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.addAll(getConversations());
+
+ return(ret);
+ }
+
+ private LocatedName m_modelName=null;
+ private java.util.List<Conversation> m_conversations=
+ new ContainmentList<Conversation>(this, Conversation.class);
+}
Added: trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/osgi/Activator.java
===================================================================
--- trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/osgi/Activator.java (rev 0)
+++ trunk/bundles/org.scribble.lang.model/src/main/java/org/scribble/lang/model/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,48 @@
+package org.scribble.lang.model.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.lang.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/pom.xml
===================================================================
--- trunk/bundles/pom.xml (rev 0)
+++ trunk/bundles/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -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>
+
Added: trunk/distribution/pom.xml
===================================================================
--- trunk/distribution/pom.xml (rev 0)
+++ trunk/distribution/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,112 @@
+<!--
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008
+-->
+<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</groupId>
+ <artifactId>distribution</artifactId>
+ <packaging>pom</packaging>
+ <name>Savara::Distribution</name>
+ <version>1.2.0-SNAPSHOT</version>
+ <url>http://www.jboss.org/savara</url>
+
+ <parent>
+ <groupId>org</groupId>
+ <artifactId>savara</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.savara.validators</groupId>
+ <artifactId>savara-validator-jboss</artifactId>
+ <version>${pom.version}</version>
+ <classifier>dist</classifier>
+ <type>zip</type>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.validators</groupId>
+ <artifactId>savara-validator-jbossesb</artifactId>
+ <version>${pom.version}</version>
+ <classifier>dist</classifier>
+ <type>zip</type>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.validators</groupId>
+ <artifactId>savara-validator-jbossws-native</artifactId>
+ <version>${pom.version}</version>
+ <classifier>dist</classifier>
+ <type>zip</type>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-2</version>
+ <executions>
+ <execution>
+ <id>bin</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>savara-${project.version}</finalName>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>src/main/assembly/bin.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>distribution-package-source</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>savara-${project.version}-src</finalName>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>src/main/assembly/src.xml</descriptor>
+ </descriptors>
+ <tarLongFileMode>gnu</tarLongFileMode>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: trunk/distribution/src/files/jbossesb/jbossesb-properties-original.xml
===================================================================
--- trunk/distribution/src/files/jbossesb/jbossesb-properties-original.xml (rev 0)
+++ trunk/distribution/src/files/jbossesb/jbossesb-properties-original.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., 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.
+
+ (C) 2005-2006,
+ @author JBoss Inc.
+-->
+<!-- $Id: jbossesb-unittest-properties.xml $ -->
+<!--
+ These options are described in the JBossESB manual.
+ Defaults are provided here for convenience only.
+
+ Please read through this file prior to using the system, and consider
+ updating the specified entries.
+-->
+<esb
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="jbossesb-1_0.xsd">
+ <properties name="core">
+ <property name="org.jboss.soa.esb.jndi.server.context.factory" value="org.jnp.interfaces.NamingContextFactory"/>
+ <property name="org.jboss.soa.esb.jndi.server.url" value="${jboss.esb.bind.address}:1099"/>
+ <property name="org.jboss.soa.esb.persistence.connection.factory" value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
+ <property name="org.jboss.soa.esb.loadbalancer.policy" value="org.jboss.soa.esb.listeners.ha.RoundRobin"/>
+ <property name="org.jboss.soa.esb.mime.text.types" value="text/*;application/xml;application/*-xml"/>
+ <property name="jboss.esb.invm.scope.default" value="NONE"/>
+ </properties>
+ <properties name="security">
+ <property name="org.jboss.soa.esb.services.security.implementationClass" value="org.jboss.internal.soa.esb.services.security.JaasSecurityService"/>
+ <property name="org.jboss.soa.esb.services.security.callbackHandler" value="org.jboss.internal.soa.esb.services.security.UserPassCallbackHandler"/>
+
+ <!-- Algorithm and key size for internal sealing of objects -->
+ <property name="org.jboss.soa.esb.services.security.sealAlgorithm" value="TripleDES"/>
+ <property name="org.jboss.soa.esb.services.security.sealKeySize" value="168"/>
+
+ <!-- Timeout in milliseconds. After which the context is considered invalid -->
+ <property name="org.jboss.soa.esb.services.security.contextTimeout" value="30000"/>
+ <property name="org.jboss.soa.esb.services.security.contextPropagatorImplementationClass" value="org.jboss.internal.soa.esb.services.security.JBossASContextPropagator"/>
+
+ <!-- Public keystore configuration used to hold keys for encryption/decryption -->
+ <property name="org.jboss.soa.esb.services.security.publicKeystore" value="/publicKeyStore"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeystorePassword" value="testKeystorePassword"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeyAlias" value="testAlias"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeyPassword" value="testPassword"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeyTransformation" value="RSA/ECB/PKCS1Padding"/>
+
+ </properties>
+ <properties name="registry">
+ <property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.v3.client.transport.wrapper.UDDIInquiryService#inquire"/>
+ <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.v3.client.transport.wrapper.UDDIPublicationService#publish"/>
+ <property name="org.jboss.soa.esb.registry.securityManagerURI" value="org.apache.juddi.v3.client.transport.wrapper.UDDISecurityService#secure"/>
+ <property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
+ <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
+ <property name="org.jboss.soa.esb.registry.user" value="root"/>
+ <property name="org.jboss.soa.esb.registry.password" value="root"/>
+ <!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
+ <property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/>
+ <property name="org.jboss.soa.esb.scout.proxy.uddiVersion" value="3.0"/>
+ <property name="org.jboss.soa.esb.scout.proxy.uddiNameSpace" value="urn:uddi-org:api_v3"/>
+
+ <!-- specify the interceptors, in order -->
+ <property name="org.jboss.soa.esb.registry.interceptors" value="org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor"/>
+ <!-- Example of specifying multiple registry interceptors
+ <property name="org.jboss.soa.esb.registry.interceptors"
+ value="org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor, org.jboss.internal.soa.esb.services.registry.CachingRegistryInterceptor"/>
+ -->
+
+ <!-- The following properties modify the cache interceptor behaviour -->
+ <property name="org.jboss.soa.esb.registry.cache.maxSize" value="100"/>
+ <property name="org.jboss.soa.esb.registry.cache.validityPeriod" value="600000"/>
+
+ <!-- Organization Category to be used by this deployment. -->
+ <property name="org.jboss.soa.esb.registry.orgCategory" value="org.jboss.soa.esb.:category"/>
+ </properties>
+ <properties name="transports" depends="core">
+ <property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>
+ <property name="org.jboss.soa.esb.mail.smtp.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.mail.smtp.password" value=""/>
+ <property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
+ <property name="org.jboss.soa.esb.mail.smtp.auth" value="true"/>
+ <property name="org.jboss.soa.esb.ftp.localdir" value="/tmp"/>
+ <property name="org.jboss.soa.esb.ftp.remotedir" value="/tmp"/>
+ <property name="org.jboss.soa.esb.jms.connectionPool" value="20"/>
+ <property name="org.jboss.soa.esb.jms.sessionSleep" value="30"/>
+ <!-- expiry of messages to temporary invm destinations (default replies)
+ expire after the following timeout, specified in milliseconds (5 mins) -->
+ <property name="org.jboss.soa.esb.invm.expiryTime" value="300000"/>
+
+ <!-- Uncomment this to return stack traces when exposing an ESB service through WS
+ <property name="org.jboss.soa.esb.ws.returnStackTrace" value="true"/>
+ -->
+ <!-- Uncomment this to specify the WS response timeout when exposing an ESB service through WS
+ <property name="org.jboss.soa.esb.ws.timeout" value="30000"/>
+ -->
+ </properties>
+ <properties name="connection">
+ <property name="min-pool-size" value="5"/>
+ <property name="max-pool-size" value="10"/>
+ <property name="blocking-timeout-millis" value="5000"/>
+ <property name="abandoned-connection-timeout" value="10000"/>
+ <property name="abandoned-connection-time-interval" value="30000"/>
+ </properties>
+ <properties name="jca">
+ <property name="org.jboss.soa.esb.jca.activation.mapper.jms-ra.rar" value="org.jboss.soa.esb.listeners.jca.JBossActivationMapper"/>
+ <property name="org.jboss.soa.esb.jca.activation.mapper.wmq.jmsra.rar" value="org.jboss.soa.esb.listeners.jca.WMQActivationMapper"/>
+ </properties>
+
+ <properties name="dbstore">
+
+ <!-- connection manager type -->
+ <!-- <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.StandaloneConnectionManager"/> -->
+ <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.J2eeConnectionManager"/>
+
+ <!-- this property is only used if using the j2ee connection manager -->
+ <property name="org.jboss.soa.esb.persistence.db.datasource.name" value="java:/JBossESBDS"/>
+
+ <!-- standalone connection pooling settings -->
+ <property name="org.jboss.soa.esb.persistence.db.connection.url" value="jdbc:hsqldb:hsql://localhost:9001/"/>
+ <property name="org.jboss.soa.esb.persistence.db.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+ <property name="org.jboss.soa.esb.persistence.db.user" value="sa"/>
+ <property name="org.jboss.soa.esb.persistence.db.pwd" value=""/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.initial.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.min.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.max.size" value="5"/>
+ <!--table managed by pool to test for valid connections - created by pool automatically -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.test.table" value="pooltest"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis" value="5000"/>
+
+ </properties>
+ <properties name="filters">
+ <property name="org.jboss.soa.esb.filter.1" value="org.jboss.internal.soa.esb.message.filter.MetaDataFilter"/>
+ <property name="org.jboss.soa.esb.filter.2" value="org.jboss.internal.soa.esb.message.filter.GatewayFilter"/>
+ </properties>
+
+ <properties name="rules">
+ <!-- change this to true if you wish to have the same behaviour as ESB4.6 and prior (including SOA 4.3) -->
+ <property name="org.jboss.soa.esb.services.rules.continueState" value="false"/>
+ </properties>
+</esb>
Added: trunk/distribution/src/files/jbossesb/jbossesb-properties-validator.xml
===================================================================
--- trunk/distribution/src/files/jbossesb/jbossesb-properties-validator.xml (rev 0)
+++ trunk/distribution/src/files/jbossesb/jbossesb-properties-validator.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., 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.
+
+ (C) 2005-2006,
+ @author JBoss Inc.
+-->
+<!-- $Id: jbossesb-unittest-properties.xml $ -->
+<!--
+ These options are described in the JBossESB manual.
+ Defaults are provided here for convenience only.
+
+ Please read through this file prior to using the system, and consider
+ updating the specified entries.
+-->
+<esb
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="jbossesb-1_0.xsd">
+ <properties name="core">
+ <property name="org.jboss.soa.esb.jndi.server.context.factory" value="org.jnp.interfaces.NamingContextFactory"/>
+ <property name="org.jboss.soa.esb.jndi.server.url" value="${jboss.esb.bind.address}:1099"/>
+ <property name="org.jboss.soa.esb.persistence.connection.factory" value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
+ <property name="org.jboss.soa.esb.loadbalancer.policy" value="org.jboss.soa.esb.listeners.ha.RoundRobin"/>
+ <property name="org.jboss.soa.esb.mime.text.types" value="text/*;application/xml;application/*-xml"/>
+ <property name="jboss.esb.invm.scope.default" value="NONE"/>
+ </properties>
+ <properties name="security">
+ <property name="org.jboss.soa.esb.services.security.implementationClass" value="org.jboss.internal.soa.esb.services.security.JaasSecurityService"/>
+ <property name="org.jboss.soa.esb.services.security.callbackHandler" value="org.jboss.internal.soa.esb.services.security.UserPassCallbackHandler"/>
+
+ <!-- Algorithm and key size for internal sealing of objects -->
+ <property name="org.jboss.soa.esb.services.security.sealAlgorithm" value="TripleDES"/>
+ <property name="org.jboss.soa.esb.services.security.sealKeySize" value="168"/>
+
+ <!-- Timeout in milliseconds. After which the context is considered invalid -->
+ <property name="org.jboss.soa.esb.services.security.contextTimeout" value="30000"/>
+ <property name="org.jboss.soa.esb.services.security.contextPropagatorImplementationClass" value="org.jboss.internal.soa.esb.services.security.JBossASContextPropagator"/>
+
+ <!-- Public keystore configuration used to hold keys for encryption/decryption -->
+ <property name="org.jboss.soa.esb.services.security.publicKeystore" value="/publicKeyStore"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeystorePassword" value="testKeystorePassword"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeyAlias" value="testAlias"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeyPassword" value="testPassword"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeyTransformation" value="RSA/ECB/PKCS1Padding"/>
+
+ </properties>
+ <properties name="registry">
+ <property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.v3.client.transport.wrapper.UDDIInquiryService#inquire"/>
+ <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.v3.client.transport.wrapper.UDDIPublicationService#publish"/>
+ <property name="org.jboss.soa.esb.registry.securityManagerURI" value="org.apache.juddi.v3.client.transport.wrapper.UDDISecurityService#secure"/>
+ <property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
+ <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
+ <property name="org.jboss.soa.esb.registry.user" value="root"/>
+ <property name="org.jboss.soa.esb.registry.password" value="root"/>
+ <!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
+ <property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/>
+ <property name="org.jboss.soa.esb.scout.proxy.uddiVersion" value="3.0"/>
+ <property name="org.jboss.soa.esb.scout.proxy.uddiNameSpace" value="urn:uddi-org:api_v3"/>
+
+ <!-- specify the interceptors, in order -->
+ <property name="org.jboss.soa.esb.registry.interceptors" value="org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor"/>
+ <!-- Example of specifying multiple registry interceptors
+ <property name="org.jboss.soa.esb.registry.interceptors"
+ value="org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor, org.jboss.internal.soa.esb.services.registry.CachingRegistryInterceptor"/>
+ -->
+
+ <!-- The following properties modify the cache interceptor behaviour -->
+ <property name="org.jboss.soa.esb.registry.cache.maxSize" value="100"/>
+ <property name="org.jboss.soa.esb.registry.cache.validityPeriod" value="600000"/>
+
+ <!-- Organization Category to be used by this deployment. -->
+ <property name="org.jboss.soa.esb.registry.orgCategory" value="org.jboss.soa.esb.:category"/>
+ </properties>
+ <properties name="transports" depends="core">
+ <property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>
+ <property name="org.jboss.soa.esb.mail.smtp.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.mail.smtp.password" value=""/>
+ <property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
+ <property name="org.jboss.soa.esb.mail.smtp.auth" value="true"/>
+ <property name="org.jboss.soa.esb.ftp.localdir" value="/tmp"/>
+ <property name="org.jboss.soa.esb.ftp.remotedir" value="/tmp"/>
+ <property name="org.jboss.soa.esb.jms.connectionPool" value="20"/>
+ <property name="org.jboss.soa.esb.jms.sessionSleep" value="30"/>
+ <!-- expiry of messages to temporary invm destinations (default replies)
+ expire after the following timeout, specified in milliseconds (5 mins) -->
+ <property name="org.jboss.soa.esb.invm.expiryTime" value="300000"/>
+
+ <!-- Uncomment this to return stack traces when exposing an ESB service through WS
+ <property name="org.jboss.soa.esb.ws.returnStackTrace" value="true"/>
+ -->
+ <!-- Uncomment this to specify the WS response timeout when exposing an ESB service through WS
+ <property name="org.jboss.soa.esb.ws.timeout" value="30000"/>
+ -->
+ </properties>
+ <properties name="connection">
+ <property name="min-pool-size" value="5"/>
+ <property name="max-pool-size" value="10"/>
+ <property name="blocking-timeout-millis" value="5000"/>
+ <property name="abandoned-connection-timeout" value="10000"/>
+ <property name="abandoned-connection-time-interval" value="30000"/>
+ </properties>
+ <properties name="jca">
+ <property name="org.jboss.soa.esb.jca.activation.mapper.jms-ra.rar" value="org.jboss.soa.esb.listeners.jca.JBossActivationMapper"/>
+ <property name="org.jboss.soa.esb.jca.activation.mapper.wmq.jmsra.rar" value="org.jboss.soa.esb.listeners.jca.WMQActivationMapper"/>
+ </properties>
+
+ <properties name="dbstore">
+
+ <!-- connection manager type -->
+ <!-- <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.StandaloneConnectionManager"/> -->
+ <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.J2eeConnectionManager"/>
+
+ <!-- this property is only used if using the j2ee connection manager -->
+ <property name="org.jboss.soa.esb.persistence.db.datasource.name" value="java:/JBossESBDS"/>
+
+ <!-- standalone connection pooling settings -->
+ <property name="org.jboss.soa.esb.persistence.db.connection.url" value="jdbc:hsqldb:hsql://localhost:9001/"/>
+ <property name="org.jboss.soa.esb.persistence.db.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+ <property name="org.jboss.soa.esb.persistence.db.user" value="sa"/>
+ <property name="org.jboss.soa.esb.persistence.db.pwd" value=""/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.initial.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.min.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.max.size" value="5"/>
+ <!--table managed by pool to test for valid connections - created by pool automatically -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.test.table" value="pooltest"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis" value="5000"/>
+
+ </properties>
+ <properties name="filters">
+ <property name="org.jboss.soa.esb.filter.1" value="org.jboss.internal.soa.esb.message.filter.MetaDataFilter"/>
+ <property name="org.jboss.soa.esb.filter.2" value="org.jboss.internal.soa.esb.message.filter.GatewayFilter"/>
+ <property name="org.jboss.soa.esb.filter.10" value="org.savara.validator.jbossesb.JBossESBInterceptor" />
+ </properties>
+
+ <properties name="rules">
+ <!-- change this to true if you wish to have the same behaviour as ESB4.6 and prior (including SOA 4.3) -->
+ <property name="org.jboss.soa.esb.services.rules.continueState" value="false"/>
+ </properties>
+</esb>
Added: trunk/distribution/src/files/jbossws-native/standard-jaxws-client-config-original.xml
===================================================================
--- trunk/distribution/src/files/jbossws-native/standard-jaxws-client-config-original.xml (rev 0)
+++ trunk/distribution/src/files/jbossws-native/standard-jaxws-client-config-original.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jaxws-config xmlns="urn:jboss:jaxws-config:2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="urn:jboss:jaxws-config:2.0 schema/jaxws-config_2_0.xsd">
+
+ <client-config>
+ <config-name>Standard Client</config-name>
+ <feature>http://org.jboss.ws/dispatch/validate</feature>
+ <property>
+ <property-name>http://org.jboss.ws/http#chunksize</property-name>
+ <property-value>2048</property-value>
+ </property>
+ </client-config>
+
+ <client-config>
+ <config-name>HTTP 1.0 Client</config-name>
+ <feature>http://org.jboss.ws/dispatch/validate</feature>
+ </client-config>
+
+ <client-config>
+ <config-name>Standard WSAddressing Client</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSAddressing Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </client-config>
+
+ <client-config>
+ <config-name>Standard SOAP 1.2 WSAddressing Client</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP12_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSAddressing Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </client-config>
+
+ <client-config>
+ <config-name>Standard WSSecurity Client</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP ##SOAP11_HTTP_MTOM</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSSecurityHandlerOutbound</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerClient</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </client-config>
+
+</jaxws-config>
Added: trunk/distribution/src/files/jbossws-native/standard-jaxws-client-config-validator.xml
===================================================================
--- trunk/distribution/src/files/jbossws-native/standard-jaxws-client-config-validator.xml (rev 0)
+++ trunk/distribution/src/files/jbossws-native/standard-jaxws-client-config-validator.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jaxws-config xmlns="urn:jboss:jaxws-config:2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="urn:jboss:jaxws-config:2.0 schema/jaxws-config_2_0.xsd">
+
+ <client-config>
+ <config-name>Standard Client</config-name>
+ <pre-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>SAVARA JBossWS-Native Service Validator Interceptor</javaee:handler-name>
+ <javaee:handler-class>org.savara.validator.jbosswsnative.JBossWSNativeClientInterceptor</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </pre-handler-chains>
+ <feature>http://org.jboss.ws/dispatch/validate</feature>
+ <property>
+ <property-name>http://org.jboss.ws/http#chunksize</property-name>
+ <property-value>2048</property-value>
+ </property>
+ </client-config>
+
+ <client-config>
+ <config-name>HTTP 1.0 Client</config-name>
+ <feature>http://org.jboss.ws/dispatch/validate</feature>
+ </client-config>
+
+ <client-config>
+ <config-name>Standard WSAddressing Client</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSAddressing Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </client-config>
+
+ <client-config>
+ <config-name>Standard SOAP 1.2 WSAddressing Client</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP12_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSAddressing Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </client-config>
+
+ <client-config>
+ <config-name>Standard WSSecurity Client</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP ##SOAP11_HTTP_MTOM</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSSecurityHandlerOutbound</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerClient</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </client-config>
+
+</jaxws-config>
Added: trunk/distribution/src/files/jbossws-native/standard-jaxws-endpoint-config-original.xml
===================================================================
--- trunk/distribution/src/files/jbossws-native/standard-jaxws-endpoint-config-original.xml (rev 0)
+++ trunk/distribution/src/files/jbossws-native/standard-jaxws-endpoint-config-original.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jaxws-config xmlns="urn:jboss:jaxws-config:2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="urn:jboss:jaxws-config:2.0 schema/jaxws-config_2_0.xsd">
+
+ <endpoint-config>
+ <config-name>Standard Endpoint</config-name>
+ <pre-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>Recording Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.wsf.framework.invocation.RecordingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </pre-handler-chains>
+ </endpoint-config>
+
+ <!--
+ Generates message part names 'parameters' in WSDL for document/literal/wapped.
+ See: [JBWS-771] Use part names that are friendly to .NET
+ -->
+ <endpoint-config>
+ <config-name>.NET friendly Endpoint</config-name>
+ <feature>http://org.jboss.ws/binding/wsdl/dotnet</feature>
+ </endpoint-config>
+
+ <endpoint-config>
+ <config-name>Standard WSAddressing Endpoint</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSAddressing Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.addressing.jaxws.WSAddressingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ <javaee:handler>
+ <javaee:handler-name>Recording Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.wsf.framework.invocation.RecordingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </endpoint-config>
+
+ <endpoint-config>
+ <config-name>Standard SOAP 1.2 WSAddressing Endpoint</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP12_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSAddressing Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.addressing.jaxws.WSAddressingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ <javaee:handler>
+ <javaee:handler-name>Recording Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.wsf.framework.invocation.RecordingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </endpoint-config>
+
+ <endpoint-config>
+ <config-name>Standard WSSecurity Endpoint</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP ##SOAP11_HTTP_MTOM</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSSecurity Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerServer</javaee:handler-class>
+ </javaee:handler>
+ <javaee:handler>
+ <javaee:handler-name>Recording Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.wsf.framework.invocation.RecordingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </endpoint-config>
+
+</jaxws-config>
Added: trunk/distribution/src/files/jbossws-native/standard-jaxws-endpoint-config-validator.xml
===================================================================
--- trunk/distribution/src/files/jbossws-native/standard-jaxws-endpoint-config-validator.xml (rev 0)
+++ trunk/distribution/src/files/jbossws-native/standard-jaxws-endpoint-config-validator.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jaxws-config xmlns="urn:jboss:jaxws-config:2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="urn:jboss:jaxws-config:2.0 schema/jaxws-config_2_0.xsd">
+
+ <endpoint-config>
+ <config-name>Standard Endpoint</config-name>
+ <pre-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>Recording Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.wsf.framework.invocation.RecordingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>SAVARA JBossWS-Native Service Validator Interceptor</javaee:handler-name>
+ <javaee:handler-class>org.savara.validator.jbosswsnative.JBossWSNativeServerInterceptor</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </pre-handler-chains>
+ </endpoint-config>
+
+ <!--
+ Generates message part names 'parameters' in WSDL for document/literal/wapped.
+ See: [JBWS-771] Use part names that are friendly to .NET
+ -->
+ <endpoint-config>
+ <config-name>.NET friendly Endpoint</config-name>
+ <feature>http://org.jboss.ws/binding/wsdl/dotnet</feature>
+ </endpoint-config>
+
+ <endpoint-config>
+ <config-name>Standard WSAddressing Endpoint</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSAddressing Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.addressing.jaxws.WSAddressingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ <javaee:handler>
+ <javaee:handler-name>Recording Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.wsf.framework.invocation.RecordingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </endpoint-config>
+
+ <endpoint-config>
+ <config-name>Standard SOAP 1.2 WSAddressing Endpoint</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP12_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSAddressing Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.addressing.jaxws.WSAddressingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ <javaee:handler>
+ <javaee:handler-name>Recording Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.wsf.framework.invocation.RecordingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </endpoint-config>
+
+ <endpoint-config>
+ <config-name>Standard WSSecurity Endpoint</config-name>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP ##SOAP11_HTTP_MTOM</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSSecurity Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerServer</javaee:handler-class>
+ </javaee:handler>
+ <javaee:handler>
+ <javaee:handler-name>Recording Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.wsf.framework.invocation.RecordingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </endpoint-config>
+
+</jaxws-config>
Added: trunk/distribution/src/main/assembly/bin.xml
===================================================================
--- trunk/distribution/src/main/assembly/bin.xml (rev 0)
+++ trunk/distribution/src/main/assembly/bin.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008
+-->
+<assembly>
+ <!-- id typically identifies the "type" (src vs bin etc) of the assembly -->
+ <id>bin</id>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <fileSets>
+
+ <!--Copy files like License and samples etc -->
+ <fileSet>
+ <directory>src/main/release</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>*.txt</include>
+ <include>*.properties</include>
+ </includes>
+ </fileSet>
+
+ <fileSet>
+ <directory>src/main/release/install</directory>
+ <outputDirectory>/install</outputDirectory>
+ </fileSet>
+
+ <fileSet>
+ <directory>src/files/jbossesb</directory>
+ <outputDirectory>/modules/conf/jbossesb</outputDirectory>
+ </fileSet>
+
+ <fileSet>
+ <directory>src/files/jbossws-native</directory>
+ <outputDirectory>/modules/conf/jbossws-native</outputDirectory>
+ </fileSet>
+
+ <!-- copy samples -->
+ <fileSet>
+ <directory>../samples</directory>
+ <outputDirectory>samples</outputDirectory>
+ </fileSet>
+
+ <!-- copy documents -->
+ <fileSet>
+ <directory>../docs/userguide/target/docbook/publish/en-US</directory>
+ <outputDirectory>docs/userguide</outputDirectory>
+ </fileSet>
+
+ <fileSet>
+ <directory>../docs/gettingstartedguide/target/docbook/publish/en-US</directory>
+ <outputDirectory>docs/gettingstartedguide</outputDirectory>
+ </fileSet>
+
+ <fileSet>
+ <directory>../docs/samplesguide/target/docbook/publish/en-US</directory>
+ <outputDirectory>docs/samplesguide</outputDirectory>
+ </fileSet>
+
+ <fileSet>
+ <directory>../docs/trailblazer</directory>
+ <outputDirectory>docs/trailblazer</outputDirectory>
+ <includes>
+ <include>*.pdf</include>
+ </includes>
+ </fileSet>
+
+ <!-- copy samples -->
+
+ <fileSet>
+ <directory>src/main/release/samples</directory>
+ <outputDirectory>samples</outputDirectory>
+ </fileSet>
+
+ <!-- End of copying documents -->
+
+ </fileSets>
+
+ <dependencySets>
+
+ <dependencySet>
+ <outputDirectory>modules</outputDirectory>
+ <unpack>true</unpack>
+ <includes>
+ <include>org.savara.validators:savara-validator-jboss:zip:dist</include>
+ <include>org.savara.validators:savara-validator-jbossesb:zip:dist</include>
+ <include>org.savara.validators:savara-validator-jbossws-native:zip:dist</include>
+ </includes>
+ </dependencySet>
+
+ </dependencySets>
+
+</assembly>
Added: trunk/distribution/src/main/assembly/src.xml
===================================================================
--- trunk/distribution/src/main/assembly/src.xml (rev 0)
+++ trunk/distribution/src/main/assembly/src.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008
+-->
+<assembly>
+ <!-- id typically identifies the "type" (src vs bin etc) of the assembly -->
+ <id>src</id>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <fileSets>
+ <fileSet>
+ <directory>../distribution</directory>
+ <outputDirectory>/distribution</outputDirectory>
+ <excludes>
+ <exclude>**/.project</exclude>
+ <exclude>**/.classpath</exclude>
+ <exclude>**/.settings</exclude>
+ <exclude>**/.settings/**/*</exclude>
+ <exclude>**/target</exclude>
+ <exclude>**/target/**/*</exclude>
+ <exclude>**/*.iml</exclude>
+ <exclude>**/*.ipr</exclude>
+ <exclude>**/*.iws</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet>
+ <directory>../docs</directory>
+ <outputDirectory>/docs</outputDirectory>
+ <excludes>
+ <exclude>**/.project</exclude>
+ <exclude>**/.classpath</exclude>
+ <exclude>**/.settings</exclude>
+ <exclude>**/.settings/**/*</exclude>
+ <exclude>**/target</exclude>
+ <exclude>**/target/**/*</exclude>
+ <exclude>**/*.iml</exclude>
+ <exclude>**/*.ipr</exclude>
+ <exclude>**/*.iws</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet>
+ <directory>../validators</directory>
+ <outputDirectory>/validators</outputDirectory>
+ <excludes>
+ <exclude>**/.project</exclude>
+ <exclude>**/.classpath</exclude>
+ <exclude>**/.settings</exclude>
+ <exclude>**/.settings/**/*</exclude>
+ <exclude>**/target</exclude>
+ <exclude>**/target/**/*</exclude>
+ <exclude>**/*.iml</exclude>
+ <exclude>**/*.ipr</exclude>
+ <exclude>**/*.iws</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet>
+ <directory>../tools</directory>
+ <outputDirectory>/tools</outputDirectory>
+ <excludes>
+ <exclude>**/.settings</exclude>
+ <exclude>**/.settings/**/*</exclude>
+ <exclude>**/target</exclude>
+ <exclude>**/target/**/*</exclude>
+ <exclude>**/bin</exclude>
+ <exclude>**/bin/**/*</exclude>
+ <exclude>**/*.iml</exclude>
+ <exclude>**/*.ipr</exclude>
+ <exclude>**/*.iws</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet>
+ <directory>../samples</directory>
+ <outputDirectory>/samples</outputDirectory>
+ <excludes>
+ <exclude>**/.project</exclude>
+ <exclude>**/.classpath</exclude>
+ <exclude>**/.settings</exclude>
+ <exclude>**/.settings/**/*</exclude>
+ <exclude>**/target</exclude>
+ <exclude>**/target/**/*</exclude>
+ <exclude>**/*.iml</exclude>
+ <exclude>**/*.ipr</exclude>
+ <exclude>**/*.iws</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet>
+ <directory>..</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>pom.xml</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
Added: trunk/distribution/src/main/release/JBossORG-EULA.txt
===================================================================
--- trunk/distribution/src/main/release/JBossORG-EULA.txt (rev 0)
+++ trunk/distribution/src/main/release/JBossORG-EULA.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,107 @@
+LICENSE AGREEMENT
+JBOSS(r)
+
+This License Agreement governs the use of the Software Packages and any updates to the Software
+Packages, regardless of the delivery mechanism. Each Software Package is a collective work
+under U.S. Copyright Law. Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to
+the user ("Client") a license to the applicable collective work(s) pursuant to the
+GNU Lesser General Public License v. 2.1 except for the following Software Packages:
+(a) JBoss Portal Forums and JBoss Transactions JTS, each of which is licensed pursuant to the
+GNU General Public License v.2;
+
+(b) JBoss Rules, which is licensed pursuant to the Apache License v.2.0;
+
+(c) an optional download for JBoss Cache for the Berkeley DB for Java database, which is licensed under the
+(open source) Sleepycat License (if Client does not wish to use the open source version of this database,
+it may purchase a license from Sleepycat Software);
+
+and (d) the BPEL extension for JBoss jBPM, which is licensed under the Common Public License v.1,
+and, pursuant to the OASIS BPEL4WS standard, requires parties wishing to redistribute to enter various
+royalty-free patent licenses.
+
+Each of the foregoing licenses is available at http://www.opensource.org/licenses/index.php.
+
+1. The Software. "Software Packages" refer to the various software modules that are created and made available
+for distribution by the JBoss.org open source community at http://www.jboss.org. Each of the Software Packages
+may be comprised of hundreds of software components. The end user license agreement for each component is located in
+the component's source code. With the exception of certain image files identified in Section 2 below,
+the license terms for the components permit Client to copy, modify, and redistribute the component,
+in both source code and binary code forms. This agreement does not limit Client's rights under,
+or grant Client rights that supersede, the license terms of any particular component.
+
+2. Intellectual Property Rights. The Software Packages are owned by Red Hat and others and are protected under copyright
+and other laws. Title to the Software Packages and any component, or to any copy, modification, or merged portion shall
+remain with the aforementioned, subject to the applicable license. The "JBoss" trademark, "Red Hat" trademark, the
+individual Software Package trademarks, and the "Shadowman" logo are registered trademarks of Red Hat and its affiliates
+in the U.S. and other countries. This agreement permits Client to distribute unmodified copies of the Software Packages
+using the Red Hat trademarks that Red Hat has inserted in the Software Packages on the condition that Client follows Red Hat's
+trademark guidelines for those trademarks located at http://www.redhat.com/about/corporate/trademark/. Client must abide by
+these trademark guidelines when distributing the Software Packages, regardless of whether the Software Packages have been modified.
+If Client modifies the Software Packages, then Client must replace all Red Hat trademarks and logos identified at
+http://www.jboss.com/company/logos, unless a separate agreement with Red Hat is executed or other permission granted.
+Merely deleting the files containing the Red Hat trademarks may corrupt the Software Packages.
+
+3. Limited Warranty. Except as specifically stated in this Paragraph 3 or a license for a particular
+component, to the maximum extent permitted under applicable law, the Software Packages and the
+components are provided and licensed "as is" without warranty of any kind, expressed or implied,
+including the implied warranties of merchantability, non-infringement or fitness for a particular purpose.
+Red Hat warrants that the media on which Software Packages may be furnished will be free from defects in
+materials and manufacture under normal use for a period of 30 days from the date of delivery to Client.
+Red Hat does not warrant that the functions contained in the Software Packages will meet Client's requirements
+or that the operation of the Software Packages will be entirely error free or appear precisely as described
+in the accompanying documentation. This warranty extends only to the party that purchases the Services
+pertaining to the Software Packages from Red Hat or a Red Hat authorized distributor.
+
+4. Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, the remedies
+described below are accepted by Client as its only remedies. Red Hat's entire liability, and Client's
+exclusive remedies, shall be: If the Software media is defective, Client may return it within 30 days of
+delivery along with a copy of Client's payment receipt and Red Hat, at its option, will replace it or
+refund the money paid by Client for the Software. To the maximum extent permitted by applicable law,
+Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential
+damages, including lost profits or lost savings arising out of the use or inability to use the Software,
+even if Red Hat or such dealer has been advised of the possibility of such damages. In no event shall
+Red Hat's liability under this agreement exceed the amount that Client paid to Red Hat under this
+Agreement during the twelve months preceding the action.
+
+5. Export Control. As required by U.S. law, Client represents and warrants that it:
+(a) understands that the Software Packages are subject to export controls under the
+U.S. Commerce Department's Export Administration Regulations ("EAR");
+
+(b) is not located in a prohibited destination country under the EAR or U.S. sanctions regulations
+(currently Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria);
+
+(c) will not export, re-export, or transfer the Software Packages to any prohibited destination, entity,
+or individual without the necessary export license(s) or authorizations(s) from the U.S. Government;
+
+(d) will not use or transfer the Software Packages for use in any sensitive nuclear, chemical or
+biological weapons, or missile technology end-uses unless authorized by the U.S. Government by
+regulation or specific license;
+
+(e) understands and agrees that if it is in the United States and exports or transfers the Software
+Packages to eligible end users, it will, as required by EAR Section 740.17(e), submit semi-annual
+reports to the Commerce Department's Bureau of Industry & Security (BIS), which include the name and
+address (including country) of each transferee;
+
+and (f) understands that countries other than the United States may restrict the import, use, or
+export of encryption products and that it shall be solely responsible for compliance with any such
+import, use, or export restrictions.
+
+6. Third Party Programs. Red Hat may distribute third party software programs with the Software Packages
+that are not part of the Software Packages and which Client must install separately. These third party
+programs are subject to their own license terms. The license terms either accompany the programs or
+can be viewed at http://www.redhat.com/licenses/. If Client does not agree to abide by the applicable
+license terms for such programs, then Client may not install them. If Client wishes to install the programs
+on more than one system or transfer the programs to another party, then Client must contact the licensor
+of the programs.
+
+7. General. If any provision of this agreement is held to be unenforceable, that shall not affect the
+enforceability of the remaining provisions. This License Agreement shall be governed by the laws of the
+State of North Carolina and of the United States, without regard to any conflict of laws provisions,
+except that the United Nations Convention on the International Sale of Goods shall not apply.
+
+Copyright 2006 Red Hat, Inc. All rights reserved.
+"JBoss" and the JBoss logo are registered trademarks of Red Hat, Inc.
+All other trademarks are the property of their respective owners.
+
+ Page 1 of 1 18 October 2006
+
Added: trunk/distribution/src/main/release/README.txt
===================================================================
--- trunk/distribution/src/main/release/README.txt (rev 0)
+++ trunk/distribution/src/main/release/README.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,8 @@
+SAVARA README
+=============
+
+A Getting Started Guide and User Guide can be found in the docs folder.
+
+The Getting Started Guide is intended to provide an overview of how the Eclipse
+tools, and other SAVARA modules, can be used to develop a "Testable Integration Architecture".
+
Added: trunk/distribution/src/main/release/ReleaseNotes.txt
===================================================================
--- trunk/distribution/src/main/release/ReleaseNotes.txt (rev 0)
+++ trunk/distribution/src/main/release/ReleaseNotes.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,78 @@
+SAVARA 1.1.0.CR1
+================
+
+This is the first Candidate Release of version 1.1.0 of SAVARA.
+
+The main new features within this release are service validators for
+Web Services based on the jbossws-native stack (which includes BPEL
+processes deployed in RiftSaw), and the first use of the TAP
+(Testable Architecture Project) file as a means of representing artifacts
+and their relationships, and being able to validate them.
+
+The detailed release notes can be found at:
+https://jira.jboss.org/secure/ReleaseNote.jspa?projectId=12310870&version=12315104
+
+
+SAVARA 1.0.0.Final
+==================
+
+This is the Final Release of version 1.0.0 of SAVARA.
+
+This release is primarily a bug fix release, to clear up remaining issues found
+in the candidate releases.
+
+The detailed release notes can be found at:
+https://jira.jboss.org/secure/ReleaseNote.jspa?projectId=12310870&version=12315141
+
+
+SAVARA 1.0.0.CR2
+================
+
+This is the second Candidate Release of version 1.0.0 of SAVARA.
+
+This release is primarily a bug fix release, with a number of issues being resolved
+with the BPEL and WSDL generation.
+
+The detailed release notes can be found at:
+https://jira.jboss.org/secure/ReleaseNote.jspa?projectId=12310870&version=12314160
+
+
+SAVARA 1.0.0.CR1
+================
+
+This is the first Candidate Release of version 1.0.0 of SAVARA.
+
+This release has resulted in a number of significant changes to the structure of the project.
+Rather than have three separate distributions, we have consolidated all functionality into
+one main distribution, and an Eclipse update site for the plugins.
+
+The functionality associated with 'conversation aware' ESB actions has been removed from the
+main distribution, and moved into a separate 'experimental' branch. This work has provided
+some useful insight in to some possible features for the future, however the ideas are
+not mature enough to remain as part of the first release.
+
+NOTE: The annotation used for runtime validation has been renamed. Therefore if any choreographies
+have been written, that include this annotation, you will need to update the annotation name and
+the top level node of the XML fragment included in the annotation, from 'jbossesb' to 'validator'.
+This can either be achieved by create new annotations and copying the destinations, or by
+opening the .cdm files in a text editor, and updating the <semanticAnnotation> elements directly.
+
+The detailed release notes can be found at:
+https://jira.jboss.org/secure/ReleaseNote.jspa?projectId=12310870&version=12313913
+
+
+SAVARA Tools Eclipse 1.0-M1
+===========================
+
+This is the first milestone of version 1.0 of the SAVARA tools for Eclipse.
+
+This distribution includes:
+- early access work on checking the conformance of a choreography, defined using the pi4soa
+choreography editor, against service implementations in BPEL and JBossESB "conversation aware"
+actions
+- generation of a choreography to BPEL services
+- generation of a choreography to JBossESB services (using "conversation aware" ESB actions)
+- generation of a choreography as a BPMN collaboration diagram
+
+The details release notes for all SAVARA 1.0-M1 components can be found at:
+https://jira.jboss.org/jira/secure/ReleaseNote.jspa?version=12313912&styleName=Html&projectId=12310870&Create=Create
Added: trunk/distribution/src/main/release/install/README.txt
===================================================================
--- trunk/distribution/src/main/release/install/README.txt (rev 0)
+++ trunk/distribution/src/main/release/install/README.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,23 @@
+SAVARA Installation Instructions
+================================
+
+Service Validator for JBossESB:
+
+1) Download JBossAS (http://www.jboss.org/jbossas) - version 5.1.0.GA or higher. Follow the installation
+instructions that accompany this distribution.
+
+2) Download JBossESB (http://www.jboss.org/jbossesb) - version 4.7 or higher. Follow the installation
+instructions that accompany this distribution, on how to install the ESB into the JBossAS environment.
+
+3) Edit the deployment.properties file in this ${SAVARA}/install folder. Set the org.jboss.as.home
+property to the root directory where the JBossAS environment is located, and change the
+org.jboss.as.config property from default if you wish to start your JBossAS using a different
+configuration. Set the org.jboss.esb.home property to the root directory where the JBossESB
+environmet is located.
+
+4) Start a command window and execute the command 'ant deploy'.
+
+5) You should now start your JBossAS server.
+
+When you wish to uninstall this component, simply go back to the ${SAVARA}/install folder
+and execute the command 'ant undeploy'.
Added: trunk/distribution/src/main/release/install/build.xml
===================================================================
--- trunk/distribution/src/main/release/install/build.xml (rev 0)
+++ trunk/distribution/src/main/release/install/build.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,82 @@
+<project name="SAVARA_Validator_Installer" default="deploy" basedir=".">
+
+ <!-- Set deployment properties filename -->
+ <property name="org.jboss.as.deployment.properties" location="deployment.properties"/>
+
+ <!-- Load Build Properties File -->
+ <property file="${org.jboss.as.deployment.properties}"/>
+
+ <property name="server.dir" value="${org.jboss.as.home}/server/${org.jboss.as.config}"/>
+ <property name="conf.dir" value="${server.dir}/conf"/>
+ <property name="deploy.dir" value="${server.dir}/deploy"/>
+ <property name="deployers.dir" value="${server.dir}/deployers"/>
+ <property name="server.lib.dir" value="${server.dir}/lib"/>
+
+ <property name="modules" value="../modules" />
+
+ <target name="check.deploy.props">
+ <condition property="as.configured">
+ <and>
+ <isset property="org.jboss.as.home"/>
+ <isset property="org.jboss.as.config"/>
+ </and>
+ </condition>
+
+ <fail unless="as.configured" message="Cannot determine target deployment, please check deployment.properties"/>
+ </target>
+
+ <target name="deploy" depends="check.deploy.props,register-jbossesb-interceptor,register-jbossws-native-interceptor"
+ description="Deploys SAVARA Validator to the server">
+ <echo message="Deploy SAVARA Validators to JBossAS" />
+ <copy todir="${deploy.dir}/savara-validator-jboss.sar">
+ <fileset dir="${modules}/savara-validator-jboss.sar"/>
+ </copy>
+ <copy todir="${deploy.dir}/savara-validator-jbossesb.esb">
+ <fileset dir="${modules}/savara-validator-jbossesb.esb"/>
+ </copy>
+ <copy todir="${deploy.dir}/savara-validator-jbossws-native.sar">
+ <fileset dir="${modules}/savara-validator-jbossws-native.sar"/>
+ </copy>
+ </target>
+
+ <target name="undeploy" depends="unregister-jbossesb-interceptor,unregister-jbossws-native-interceptor"
+ description="Undeploys SAVARA Validator">
+ <echo message="Undeploy the SAVARA Validators from JBossAS" />
+ <delete dir="${deploy.dir}/savara-validator-jboss.sar" />
+ <delete dir="${deploy.dir}/savara-validator-jbossesb.esb" />
+ <delete dir="${deploy.dir}/savara-validator-jbossws-native.sar" />
+ </target>
+
+ <target name="register-jbossesb-interceptor">
+ <echo message="register the jbossesb interceptor" />
+ <delete file="${deployers.dir}/esb.deployer/jbossesb-properties.xml" />
+ <copy file="${modules}/conf/jbossesb/jbossesb-properties-validator.xml" tofile="${deployers.dir}/esb.deployer/jbossesb-properties.xml" />
+ </target>
+
+ <target name="unregister-jbossesb-interceptor">
+ <echo message="unregister the jbossesb interceptor" />
+ <delete file="${deployers.dir}/esb.deployer/jbossesb-properties.xml" />
+ <copy file="${modules}/conf/jbossesb/jbossesb-properties-original.xml" tofile="${deployers.dir}/esb.deployer/jbossesb-properties.xml" />
+ </target>
+
+ <target name="register-jbossws-native-interceptor">
+ <echo message="register the jbossws-native interceptor" />
+ <delete file="${deployers.dir}/jbossws.deployer/META-INF/standard-jaxws-client-config.xml" />
+ <delete file="${deployers.dir}/jbossws.deployer/META-INF/standard-jaxws-endpoint-config.xml" />
+ <copy file="${modules}/conf/jbossws-native/standard-jaxws-client-config-validator.xml"
+ tofile="${deployers.dir}/jbossws.deployer/META-INF/standard-jaxws-client-config.xml" />
+ <copy file="${modules}/conf/jbossws-native/standard-jaxws-endpoint-config-validator.xml"
+ tofile="${deployers.dir}/jbossws.deployer/META-INF/standard-jaxws-endpoint-config.xml" />
+ </target>
+
+ <target name="unregister-jbossws-native-interceptor">
+ <echo message="unregister the jbossws-native interceptor" />
+ <delete file="${deployers.dir}/jbossws.deployer/META-INF/standard-jaxws-client-config.xml" />
+ <delete file="${deployers.dir}/jbossws.deployer/META-INF/standard-jaxws-endpoint-config.xml" />
+ <copy file="${modules}/conf/jbossws-native/standard-jaxws-client-config-original.xml"
+ tofile="${deployers.dir}/jbossws.deployer/META-INF/standard-jaxws-client-config.xml" />
+ <copy file="${modules}/conf/jbossws-native/standard-jaxws-endpoint-config-original.xml"
+ tofile="${deployers.dir}/jbossws.deployer/META-INF/standard-jaxws-endpoint-config.xml" />
+ </target>
+
+</project>
Added: trunk/distribution/src/main/release/install/deployment.properties
===================================================================
--- trunk/distribution/src/main/release/install/deployment.properties (rev 0)
+++ trunk/distribution/src/main/release/install/deployment.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,16 @@
+######################################################################
+# SAVARA Configuration
+######################################################################
+# The directory in which JBoss AS is installed.
+# Use of relative paths or paths with spaces will cause runtime errors
+# when deploying and executing the samples.
+# (e.g. /local/deploy/jboss-5.1.0.GA)
+org.jboss.as.home=/local/deploy/jboss-5.1.0.GA
+
+# The Configuration of JBoss AS to use.
+# (e.g. default)
+org.jboss.as.config=default
+
+# The directory for JBossESB home.
+# (e.g. /local/deploy/jbossesb-4.8)
+org.jboss.esb.home=/local/deploy/jbossesb-4.8
Added: trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.classpath
===================================================================
--- trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.classpath (rev 0)
+++ trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.project
===================================================================
--- trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.project (rev 0)
+++ trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>trailblazer-models</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.settings/org.eclipse.core.resources.prefs
===================================================================
--- trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.settings/org.eclipse.core.resources.prefs (rev 0)
+++ trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/.settings/org.eclipse.core.resources.prefs 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,3 @@
+#Mon Sep 22 11:55:10 BST 2008
+eclipse.preferences.version=1
+encoding/TrailBlazer.cdm=UTF-8
Added: trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/src/pi4soa.xml
===================================================================
--- trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/src/pi4soa.xml (rev 0)
+++ trunk/distribution/src/main/release/samples/jbossesb/trailblazer/models/src/pi4soa.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+# * 14, April 2008 : Initial version created by gary
+# */
+-->
+
+<pi4soa>
+ <tracker>
+ <jndi>
+ <initialContextFactory>org.jnp.interfaces.NamingContextFactory</initialContextFactory>
+ <providerURL>jnp://localhost:1099</providerURL>
+ <factoryURLPackages>org.jboss.naming:org.jnp.interfaces</factoryURLPackages>
+ </jndi>
+ <jms>
+ <connectionFactory>ConnectionFactory</connectionFactory>
+ <connectionFactoryAlternate>ConnectionFactory</connectionFactoryAlternate>
+ <destination>topic/tracker</destination>
+ </jms>
+ </tracker>
+</pi4soa>
+
Added: trunk/docs/gettingstartedguide/pom.xml
===================================================================
--- trunk/docs/gettingstartedguide/pom.xml (rev 0)
+++ trunk/docs/gettingstartedguide/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,87 @@
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.savara.docs</groupId>
+ <artifactId>gettingstartedguide</artifactId>
+ <packaging>jdocbook</packaging>
+ <name>Savara::Docs::GettingStartedGuide</name>
+ <version>1.2.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.savara</groupId>
+ <artifactId>docs</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.2.3</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>generate-docbook</id>
+ <phase>package</phase>
+ <goals>
+ <goal>resources</goal>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-docbook-xslt</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-jdocbook-style</artifactId>
+ <version>1.1.0</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <sourceDocumentName>master.xml</sourceDocumentName>
+ <sourceDirectory>${basedir}/src/main</sourceDirectory>
+ <imageResource>
+ <directory>${basedir}/src/main</directory>
+ <includes>
+ <include>**/images/**/*</include>
+ </includes>
+ </imageResource>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>file:///${basedir}/src/main/en-US/xslt/pdf.xsl</stylesheetResource>
+ <finalName>SAVARA-GettingStartedGuide.pdf</finalName>
+ </format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <docbookVersion>1.72.0</docbookVersion>
+ </options>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ChoreoMonReady.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ChoreoMonReady.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ConformanceCheckError.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ConformanceCheckError.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ConformanceCheckErrorMessage.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ConformanceCheckErrorMessage.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ConformanceCheckErrorMessageMenu.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ConformanceCheckErrorMessageMenu.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ExpectedToFail.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ExpectedToFail.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ExportBPMNMenu.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ExportBPMNMenu.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ExportHTMLDialog.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ExportHTMLDialog.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ExportHTMLMenu.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ExportHTMLMenu.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ExportedBPMN.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ExportedBPMN.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ExportedHTML.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ExportedHTML.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/GenerateESBServicesDialog.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/GenerateESBServicesDialog.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/GenerateESBServicesMenu.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/GenerateESBServicesMenu.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/GenerateESBServicesNav.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/GenerateESBServicesNav.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ImportDialog.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ImportDialog.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ImportFileDialog.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ImportFileDialog.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ImportMenu.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ImportMenu.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ImportProjectsDialog.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ImportProjectsDialog.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ImportedProject.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ImportedProject.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/InvalidPurchasePostTest.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/InvalidPurchasePostTest.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/JavaCompiler1-5Compliant.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/JavaCompiler1-5Compliant.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/MonitorMenu.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/MonitorMenu.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ParticipantAndOtherTypes.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ParticipantAndOtherTypes.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/PurchaseGoods.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/PurchaseGoods.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/QuickFixDialog.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/QuickFixDialog.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/RolesAndRelationships.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/RolesAndRelationships.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/SAVARAMonitorPurchasing1.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/SAVARAMonitorPurchasing1.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/SAVARAMonitorPurchasing2.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/SAVARAMonitorPurchasing2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/ShowReferencedDescription.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/ShowReferencedDescription.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/SuccessfulPurchasePostTest.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/SuccessfulPurchasePostTest.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/SuccessfulPurchasePreTest.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/SuccessfulPurchasePreTest.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/TrailBlazerMonitorError.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/TrailBlazerMonitorError.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/TrailblazerWebPage.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/TrailblazerWebPage.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/editvalidatorann.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/editvalidatorann.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/validatorannotation.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/validatorannotation.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/images/validatortooltip.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/gettingstartedguide/src/main/en-US/images/validatortooltip.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/gettingstartedguide/src/main/en-US/master.xml
===================================================================
--- trunk/docs/gettingstartedguide/src/main/en-US/master.xml (rev 0)
+++ trunk/docs/gettingstartedguide/src/main/en-US/master.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % RH-ENTITIES SYSTEM "Common_Config/rh-entities.ent">
+]>
+
+<book lang="en">
+ <bookinfo>
+ <title>SAVARA 1.2</title>
+ <subtitle>Getting Started Guide</subtitle>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/author_group.xml"/>
+ </bookinfo>
+
+ <toc/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/overview.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/installation.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/businessanalysis.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/architecture.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/serviceanalysisdesign.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/servicedev.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/tap.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/runtimevalidation.xml"/>
+</book>
Added: trunk/docs/gettingstartedguide/src/main/en-US/module/architecture.xml
===================================================================
--- trunk/docs/gettingstartedguide/src/main/en-US/module/architecture.xml (rev 0)
+++ trunk/docs/gettingstartedguide/src/main/en-US/module/architecture.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="architecture">
+ <title>Architecture</title>
+
+ <para>
+ </para>
+
+ <section>
+ <title>Define Information Model</title>
+
+ <para>
+ One of the stages within the architecture phase is to define the information model
+ for the message types associated with the messages exchanges between the
+ interacting participants.
+ </para>
+
+ <para>
+ This involves defining message schema for each example message. The schema could
+ already exist and be reused, it could be based on existing schema and just need
+ to be upgraded to support new requirements, or it may need to be defined from
+ scratch.
+ </para>
+
+ <para>
+ An example of a schema associated with the purchasing model is the
+ <filename>store.xsd</filename> shown here:
+ </para>
+
+ <informalexample>
+ <programlisting role="XML" ><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.jboss.org/examples/store"
+ xmlns:tns="http://www.jboss.org/examples/store"
+ elementFormDefault="qualified">
+
+ <element name="BuyRequest" type="tns:StoreType"></element>
+ <element name="BuyConfirmed" type="tns:StoreType"></element>
+ <element name="BuyFailed" type="tns:StoreType"></element>
+
+ <complexType name="StoreType">
+ <attribute name="id" type="string"></attribute>
+ </complexType>
+</schema>
+ ]]></programlisting>
+ </informalexample>
+
+ <para>
+ Once the schema has been defined, then the example messages need to be updated
+ to reference the schema, as shown in the following <filename>BuyRequest.xml</filename>
+ example message:
+ </para>
+
+ <informalexample>
+ <programlisting role="XML" ><![CDATA[
+<tns:BuyRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tns="http://www.jboss.org/examples/store"
+ xsi:schemaLocation="http://www.jboss.org/examples/store store.xsd "
+ id="1" />
+ ]]></programlisting>
+ </informalexample>
+
+ <section>
+ <title>Validating Example Messages against Schema</title>
+
+ <para>
+ Once the association between example messages and the schema has been
+ established, it is possible to validate the messages against the
+ schema.
+ </para>
+
+ <para>
+ For information on how to use the validation capabilities within
+ Eclipse, please read the
+ <ulink url="http://www.eclipse.org/webtools/community/tutorials/XMLValidation/XMLValidationTutorial.html">Eclipse XML Validation Tutorial</ulink>.
+ </para>
+ </section>
+ </section>
+
+ <section>
+ <title>Define Choreography Model</title>
+
+ <para>
+The next step in the development process is to specify a Choreography Model to implement
+the requirements described within the set of scenarios.
+ </para>
+
+ <para>
+The current representation used to define Choreography Models within SAVARA is the W3C Web Service
+Choreography Description Language (WS-CDL). The pi4soa tools provide a WS-CDL (or choreography
+description) editor. Although this standard is associated with web services, it does not mean
+that a system specified using this standard needs to be implemented using web services. The
+actual WS-CDL language is used for defining the interactions between any distributed system.
+ </para>
+
+ <para>
+The choreography description for the Purchasing example can be found in
+<filename>purchasing/PurchaseGoods.cdm</filename>. When the
+choreography editor has been launched, by double-clicking on this file within the Eclipse
+environment, then navigate to the <emphasis>Choreography Flows</emphasis> tab to see the
+definition of the purchasing process:
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/PurchaseGoods.jpg" align="center" width="5in" />
+ </imageobject>
+
+ <section>
+ <title>Validating Requirements against Choreography Model</title>
+
+ <para>
+The pi4soa tools can be used to test the scenarios against the choreography description, to
+ensure that the choreography correctly implements the requirements. To test the
+<filename>SuccessfulPurchase.scn</filename> scenario against the choreography, launch
+the scenario editor by double-clicking on the scenario file, and then pressing the
+green <emphasis>play</emphasis> button in the toolbar. When complete, the scenario
+should look like the following image, indicating that the scenario completed successfully.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/SuccessfulPurchasePostTest.jpg" align="center" width="5in" />
+ </imageobject>
+
+ <para>
+To view a scenario that demonstrates a test failure, open the
+<filename>InvalidPurchase.scn</filename> scenario by double-clicking on the file, and
+then initiate the test using the green <emphasis>play</emphasis> button in the toolbar.
+When complete, the scenario should look like the following image.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/InvalidPurchasePostTest.jpg" align="center" width="5in" />
+ </imageobject>
+
+ <para>
+You will notice that the <emphasis>Store</emphasis> participant has a red 'send' node,
+indicating that this action was not expected behaviour when compared with the choreography
+description. The reason this is considered an error, is that the <emphasis>Store</emphasis>
+participant should only send a <emphasis>BuyFailed</emphasis> message following an invalid
+credit check.
+ </para>
+
+ <para>
+When an error is detected in a scenario, the choreography designer can then determine whether
+the scenario is wrong (i.e. it does not correctly describe a business requirement), or whether
+the choreography is wrong and needs to be updated to accomodate the scenario.
+ </para>
+ </section>
+
+ <section>
+ <title>Create Documentation</title>
+
+ <para>
+Once the choreography description has been successfully tested against the scenarios, the
+next step may be to obtain approval to proceed to the analysis/design phase. To help support
+this effort, the pi4soa tools provide the means to export the choreography description to
+a range of representations. HTML documentation generation is discussed below, and BPMN
+diagram generation is discussed in the Service Oriented Analysis and Design section.
+ </para>
+
+ <para>
+ To generate HTML documentation, select the <emphasis>Export->Other->HTML</emphasis>
+ menu item associated with the choreography description file.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/ExportHTMLMenu.png" align="center" width="4in" />
+ </imageobject>
+
+ <para>
+ The next step is to provide the location and name of the HTML file to be
+ generated.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/ExportHTMLDialog.png" align="center" width="4in" />
+ </imageobject>
+
+ <para>
+ If the HTML has been generated within the scope of Eclipse project, then refresh
+ the relevant folder to show the file and open the file with the Eclipse web
+ browser (as shown below). If outside the Eclipse project, then use a normal
+ web browser to view the file.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/ExportedHTML.png" align="center" width="6in" />
+ </imageobject>
+
+ </section>
+ </section>
+
+</chapter>
Added: trunk/docs/gettingstartedguide/src/main/en-US/module/author_group.xml
===================================================================
--- trunk/docs/gettingstartedguide/src/main/en-US/module/author_group.xml (rev 0)
+++ trunk/docs/gettingstartedguide/src/main/en-US/module/author_group.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE authorgroup PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<authorgroup>
+ <corpauthor>Gary Brown</corpauthor>
+ <corpauthor>Jeff Yu</corpauthor>
+</authorgroup>
Added: trunk/docs/gettingstartedguide/src/main/en-US/module/businessanalysis.xml
===================================================================
--- trunk/docs/gettingstartedguide/src/main/en-US/module/businessanalysis.xml (rev 0)
+++ trunk/docs/gettingstartedguide/src/main/en-US/module/businessanalysis.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="businessanalysis">
+ <title>Business Analysis</title>
+
+ <para>
+ </para>
+
+ <section>
+ <title>Define Participants</title>
+
+ <para>
+ In the current Eclipse tools, that use the pi4soa Scenario and Choreography based
+ models for defining requirements and architectural models, this phase would be
+ achieved by defining the Participants and Roles within the choreography model.
+ </para>
+
+ <para>
+ When a choreography description is initially created, using the
+ <emphasis>New->Other->Choreography->Choreography Description</emphasis> menu
+ item, the roles and relationships can be defined on the first tab.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/RolesAndRelationships.png" align="center" width="4in" />
+ </imageobject>
+
+ <para>
+ Default participant types are automatically created, one per role, and can be
+ found on the <emphasis>Base Types</emphasis> tab. For example,
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/ParticipantAndOtherTypes.png" align="center" width="3in" />
+ </imageobject>
+
+ <para>
+ Only these components need to be specified in the choreography model. This enables
+ them to be referenced in the subsequently defined scenarios. Otherwise it would be
+ necessary to return to the scenarios, once the choreography model had been defined
+ in the <emphasis>Architecture</emphasis> phase.
+ </para>
+ </section>
+
+ <section>
+ <title>Outline Scenarios</title>
+
+ <para>
+When designing a system, it is necessary to capture requirements. Various approaches can be
+used for this, but currently there are no mechanisms that enable the requirements to be
+documented in such a way to enable an implementation to be validated back against the requirements.
+ </para>
+
+ <para>
+The pi4soa tools provide a means of describing requirements, representing specific use cases
+for the interactions between a set of cooperating services, using scenarios - which can be
+considered similar to UML sequence diagrams that have been enhanced to include example messages.
+ </para>
+
+ <para>
+In the <filename>purchasing</filename> Eclipse project, the
+<filename>SuccessfulPurchase.scn</filename> scenario looks like this:
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/SuccessfulPurchasePreTest.jpg" align="center" width="5in" />
+ </imageobject>
+
+ <para>
+ The business requirements can therefore defined as a set of scenarios, each demonstrating
+ a specific use-case, or path through the business process being enacted.
+ </para>
+
+ </section>
+
+ <section>
+ <title>Create Example Messages</title>
+
+ <para>
+ The next step is to create the example messages required by the scenarios.
+ </para>
+
+ <para>
+ Some previously defined examples can be found in the <filename>purchasing</filename>
+ Eclipse project. For example, the Buy request is defined as:
+ </para>
+
+ <informalexample>
+ <programlisting role="XML" ><![CDATA[
+<tns:BuyRequest xmlns:tns="http://www.jboss.org/examples/store"
+ id="1" />
+ ]]></programlisting>
+ </informalexample>
+
+ <para>
+ Although a schema may not have been defined at this stage, unless one previously
+ existed that is being reused, it is a good idea to define a namespace for the
+ message type. This is because it will be used within the scenarios and
+ architectural models defined in the following stage. If the namespace was not
+ specified at this stage, then the example messages, scenarios and architectural
+ models would need to be updated at a later stage.
+ </para>
+
+ <para>
+ Although this phase has been defined following the definition of the scenarios,
+ in practice these phases are iterative. So scenarios and example messages would be
+ defined concurrently. Similarly, new participants may be added in an evolutionary
+ manner, as scenarios are created that require them.
+ </para>
+
+ </section>
+
+
+</chapter>
Added: trunk/docs/gettingstartedguide/src/main/en-US/module/installation.xml
===================================================================
--- trunk/docs/gettingstartedguide/src/main/en-US/module/installation.xml (rev 0)
+++ trunk/docs/gettingstartedguide/src/main/en-US/module/installation.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="installation">
+ <title>Installation</title>
+
+ <para>
+ This section describes the installation procedure for SAVARA tools and runtime modules.
+ </para>
+
+ <section>
+ <title>Prerequisites</title>
+ <para>
+ The pre-requisites for the SAVARA Eclipse Tools are:
+ </para>
+ <orderedlist>
+ <listitem>Eclipse JEE (3.6 or higher) <ulink url="http://www.eclipse.org">http://www.eclipse.org</ulink></listitem>
+ <listitem>JBoss Tools (3.2 or higher) <ulink url="http://www.jboss.org/tools">http://www.jboss.org/tools</ulink>
+ available from an update site</listitem>
+ </orderedlist>
+
+ <para>
+ The pre-requisites for the SAVARA Service Validator are:
+ </para>
+ <orderedlist>
+ <listitem>JBossAS (5.1.0.GA or higher) <ulink url="http://www.jboss.org/jbossas">http://www.jboss.org/jbossas</ulink></listitem>
+ <listitem>JBossAS (4.8 or higher) <ulink url="http://www.jboss.org/jbossesb">http://www.jboss.org/jbossesb</ulink></listitem>
+ <listitem>SAVARA (version 1.1.0 or higher), available from <ulink url="http://www.jboss.org/savara/downloads">http://www.jboss.org/savara/downloads</ulink></listitem>
+ </orderedlist>
+ </section>
+
+ <section>
+ <title>Installation Instructions</title>
+ <para>
+ The installation instructions for the SAVARA Eclipse tools are:
+ </para>
+ <orderedlist>
+ <listitem>
+ Eclipse
+ <para>
+ Download the latest version of Eclipse JEE, and install in your environment.
+ </para>
+ </listitem>
+
+ <listitem>
+ BPMN Modeller
+ <para>
+ When Eclipse has been lauched, go to the <emphasis>Help->Install New Software..</emphasis>
+ menu item. Select the Eclipse update site
+ for the version of Eclipse (e.g. Helios). Within the SOA Development
+ category, select the BPMN Project Feature. Follow the instructions to accept
+ the license and then restart Eclipse after the plugins have been
+ installed.
+ </para>
+ </listitem>
+ <listitem>
+ JBoss Tools
+ <para>
+ Start up your Eclipse environment, and go to the <emphasis>Help->Install New Software..</emphasis>
+ menu item. Select the appropriate update site URL from the JBoss Tools download
+ page, and enter it into the top text field in the dialog window, and press the
+ <emphasis>Add</emphasis> button. Once the contents of the update site is available,
+ then select the appropriate components and follow the instructions to install
+ them within your Eclipse environment.
+ </para>
+ <para>
+ The <emphasis>JBoss Savara Tools</emphasis> feature should be selected from the
+ <emphasis>SOA Development</emphasis> category.
+ </para>
+ <para>
+ If you wish to view the generated BPEL using a BPEL editor, rather than
+ XML, then you should also select the <emphasis>JBoss BPEL Editor</emphasis> from the
+ <emphasis>SOA Development</emphasis> category.
+ </para>
+ <para>
+ NOTE: If you don't install the BPEL Editor, then you will have to install
+ GMF. This can be found on the Helios update site, under the <emphasis>Modeling</emphasis>
+ category. Select the <emphasis>Graphical Modeling Framework</emphasis> entry, and
+ following the instructions to install.
+ </para>
+
+ <para>
+ It is also recommended that you install the JBoss WebServices Tools, and JBossAS Tools,
+ from the All category. These are required to define and launch a JBossAS
+ server from within Eclipse, generate a JAX-WS web service from a WSDL definition,
+ and test a Web Service.
+ </para>
+ </listitem>
+
+ </orderedlist>
+
+ <para>
+ The installation instructions for the SAVARA Service Validator are:
+ </para>
+ <orderedlist>
+ <listitem>
+ JBossAS
+ <para>
+ Download the latest version and follow its installation instructions.
+ </para>
+ </listitem>
+
+ <listitem>
+ JBossESB
+ <para>
+ Download the latest version and follow the instructions for installing it
+ into the JBossAS environment.
+ </para>
+ </listitem>
+
+ <listitem>
+ SAVARA
+ <para>
+ Unpack the SAVARA distribution and edit the
+ <filename>deployment.properties</filename> file
+ in this <filename>${SAVARA}/install</filename> folder.
+ Set the <emphasis>org.jboss.as.home</emphasis> property to the root
+ directory where the JBossAS environment is located, and change the
+ <emphasis>org.jboss.as.config</emphasis> property from default
+ if you wish to start your JBossAS using a different configuration. Set the
+ <emphasis>org.jboss.esb.home</emphasis> property to the root directory
+ where the JBossESB environment is located.
+ </para>
+ <para>
+ Start a command window and execute the command <emphasis>ant deploy</emphasis>.
+ </para>
+ </listitem>
+
+ </orderedlist>
+ </section>
+
+ <section>
+ <title>Importing Samples into Eclipse</title>
+
+ <para>
+ Once the SAVARA Eclipse Tool distribution has been correctly installed, if you wish to try out
+ any of the examples then the following steps should be followed to import the relevant
+ projects into the previously configured Eclipse environment.
+ </para>
+
+ <orderedlist>
+ <listitem>
+ <para>
+Select the 'Import...' menu item, associated with the popup menu on the background of the left
+panal (Navigator or Package depending on perspective being viewed).
+ </para>
+ <imageobject>
+ <imagedata fileref="en-US/images/ImportMenu.jpg" align="center" width="2in" />
+ </imageobject>
+ </listitem>
+ <listitem>
+ <para>
+When the import dialog appears, select the <emphasis>General->ExistingProject from Workspace</emphasis>
+option and press the 'Next' button.
+ </para>
+ <imageobject>
+ <imagedata fileref="en-US/images/ImportDialog.jpg" align="center" width="4in" />
+ </imageobject>
+ </listitem>
+ <listitem>
+ <para>
+Ensuring that the 'Select root directory' radio button is selected, press the 'Browse' button and
+navigate to the <filename>${SAVARA-Tools}/samples</filename> folder, then press 'Ok'.
+ </para>
+ <imageobject>
+ <imagedata fileref="en-US/images/ImportFileDialog.jpg" align="center" width="3in" />
+ </imageobject>
+ </listitem>
+ <listitem>
+ <para>
+All of the Eclipse projects contained within the <filename>${SAVARA-Tools}/samples</filename> directory structure
+will be listed. Press the 'Finish' button to import them all.
+ </para>
+ <imageobject>
+ <imagedata fileref="en-US/images/ImportProjectsDialog.jpg" align="center" width="4in" />
+ </imageobject>
+ <para>
+ Once imported, the Eclipse navigator will list the sample projects:
+ </para>
+ <imageobject>
+ <imagedata fileref="en-US/images/ImportedProject.jpg" align="center" width="2in" />
+ </imageobject>
+ </listitem>
+ </orderedlist>
+
+ </section>
+
+</chapter>
Added: trunk/docs/gettingstartedguide/src/main/en-US/module/overview.xml
===================================================================
--- trunk/docs/gettingstartedguide/src/main/en-US/module/overview.xml (rev 0)
+++ trunk/docs/gettingstartedguide/src/main/en-US/module/overview.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="overview">
+ <title>Overview</title>
+
+ <para>
+ This is the Getting Started Guide for SAVARA. This guide starts with the
+ installation instructions for the SAVARA tools and runtime modules.
+ </para>
+
+ <para>
+ The remainder of the document is organised to reflect phases within the SAVARA
+ Methodology, and how the current tools can be used in support of that methodology.
+ The tools are still in development, and therefore not all phases will have tools,
+ and the tools in some phases will not necessarily be complete.
+ </para>
+
+ <para>
+ As an overview, the tools currently include capabilities for:
+ </para>
+
+ <itemizedlist>
+ <listitem>Definition of business requirements as scenarios</listitem>
+ <listitem>Creation of a choreography (global model) to represent the architecture for a system
+ that delivers the requirements</listitem>
+ <listitem>Generation of documentation based on the choreography</listitem>
+ <listitem>Generation of service implementation using WS-BPEL</listitem>
+ <listitem>Generation of service interfaces using WSDL</listitem>
+ <listitem>Conformance checking a WS-BPEL service implementation against a choreography</listitem>
+ <listitem>Runtime validation of an ESB service against a choreography description</listitem>
+ </itemizedlist>
+
+</chapter>
Added: trunk/docs/gettingstartedguide/src/main/en-US/module/runtimevalidation.xml
===================================================================
--- trunk/docs/gettingstartedguide/src/main/en-US/module/runtimevalidation.xml (rev 0)
+++ trunk/docs/gettingstartedguide/src/main/en-US/module/runtimevalidation.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,402 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="runtimevalidation">
+ <title>Runtime Validation</title>
+
+ <note>
+ <para>
+ Before you can deploy and run the runtime validation example, you will
+ need to install the SAVARA Validator module for JBoss.
+ </para>
+ </note>
+
+ <para>
+ The previous sections have provided a brief introduction to the design-time
+ SOA governance features provided within the SAVARA Eclipse Tools distribution.
+ The aim of these capabilities are to enable verification of an implementation, initially
+ defined just using BPEL process definitions, against a
+ choreography, which in turn has been verified against business requirements defined using
+ scenarios. Therefore this helps to ensure that the implemented system meets the original
+ business requirements.
+ </para>
+
+ <para>
+ Being able to statically check that the implementation should send or receive messages
+ in the correct order is important, as it will reduce the amount of testing required
+ to ensure the service behaves correctly. However it does not enable the internal
+ implementation details to be verified, which may result in invalid decisions being
+ made at runtime, resulting in unexpected paths being taken.
+ </para>
+
+ <para>
+ Therefore, to ensure this situation does not occur, we also need runtime governance.
+ We still need to be able to verify that the services continue to conform to the
+ choreography description.
+ The <emphasis>Service Validator</emphasis> capability within the SAVARA distribution
+ can be used to validate the behaviour of each service.
+ </para>
+
+ <para>
+ In this section, we will use the <emphasis>purchasing</emphasis> example found in the
+ <filename>${SAVARA}/samples/purchasing</filename> folder.
+ </para>
+
+ <section>
+ <title>Service Validator Configuration</title>
+
+ <para>
+ The service validator configuration is defined using specific annotation, that is associated
+ with the 'exchange details' components (contained within interactions), within the
+ choreography description.
+ </para>
+
+ <para>
+ To view the pre-configured service validator configuration defined for the Purchasing
+ example, edit the <filename>PurchaseGoods.cdm</filename> file, navigate to the
+ <emphasis>Choreography Flows</emphasis> tab and then select the
+ <emphasis>Choreography->Edit Annotations</emphasis> menu item associated with the first
+ 'exchange details' component (as shown below).
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/editvalidatorann.png" align="center" width="3in" />
+ </imageobject>
+
+ <para>
+ This will display the annotation editor, with the single configured annotation called
+ 'validator'. This annotation defines the information required for the Service Validator
+ to monitor this specific message exchange (e.g. the JMS destination
+ on which the message will be passed, or in this case the Service Name for the target
+ Web Service).
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/validatorannotation.png" align="center" width="3in" />
+ </imageobject>
+
+ <para>
+ Once an annotation has been defined, it will also be displayed as part of the tooltip
+ for the associated model component, for example:
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/validatortooltip.png" align="center" width="4in" />
+ </imageobject>
+
+ <para>
+ Once the annotations have been defined for all relevant 'exchange details' components
+ in the choreography description, the choreography file can be copied to the
+ <filename>${JBossAS}/server/default/deploy/savara-validator-jboss.sar/models</filename>
+ folder in the JBossAS environment. The service validator configuration for the
+ <emphasis>purchasing</emphasis> example has been preconfigured to be deployed as part of
+ the installation procedure.
+ </para>
+
+ <note>
+ <para>
+ If the <filename>savara-validator-jboss.sar/validator-config.xml</filename> within the JBossAS
+ environment is modified, or choreography description files added, removed or updated within
+ the <filename>savara-validator-jboss.sar/models</filename> sub-folder, then the changes will
+ automatically be detected and used to re-configure the service validators without having to
+ restart the server.
+ </para>
+ </note>
+
+ </section>
+
+ <section>
+ <title>SAVARA Monitor</title>
+
+ <para>
+ The SAVARA Monitor is an Eclipse based tool that can be used to help develop,
+ test and validate a business process (encoded as a choreography) executing across
+ a distributed system. (Future releases will include equivalent web based tooling
+ to enable production based logging and query of the validation information).
+ </para>
+
+ <para>
+ The tool is used to observe a correlated view of the executing business
+ transactions. Each service validator can be configured to report activites (i.e. sent
+ and received messages) that it validates, to enable the correlator to reconstitute a
+ global interpretation of each transaction.
+ </para>
+
+ <para>
+ This correlated view of each transaction can be used to understand where each
+ transaction is within the process. It can also be used to report
+ <emphasis>out of sequence</emphasis>, <emphasis>unexpected messages</emphasis> and
+ more general errors in the context of the business process.
+ </para>
+
+ <para>
+ Once the following examples have been deployed to the JBossAS environment, and the
+ server is running, then the monitoring tool can be launched from the Eclipse environment
+ by selecting the <emphasis>Savara->Monitor</emphasis> menu item from the popup menu
+ associated with the choreography (.cdm) file.
+ </para>
+
+ <para>
+ Wait for the monitor window to start, and indicate that the choreography is being monitored,
+ shown in the status line at the bottom of the window.
+ </para>
+
+ </section>
+
+ <section>
+ <title>Web Service / WS-BPEL Example - Purchasing</title>
+
+ <para>
+ Savara includes the ability to validate web services (and therefore BPEL
+ processes) that use the jbossws-native stack. However the ODE engine, used
+ to execute BPEL processes within RiftSaw, currently optimises communications
+ between BPEL processes executing within the same engine, so that the communications
+ do not occur using the Web Service stack. This means that Savara is currently
+ unable to validate these interactions by default.
+ </para>
+
+ <para>
+ There are two solutions to this problem. The first is to disable the interprocess
+ communications used between the two BPEL processes, which will be the approach
+ described in this section. The other approach is to implement the 'Credit Agency'
+ participant as a JAX-WS service.
+ </para>
+
+ <section>
+ <title>Deploying the Example</title>
+
+ <para>
+ Once the BPEL processes have been generated, and the implementation details
+ added, it is currently necessary to disable the 'inter-process' communication
+ that is used to communicate between the two processes (an ODE optimization
+ when the processes are running in the same engine). This is achieved by
+ editing the deployment descriptor for the Store process (using a text editor
+ rather than the Eclipse form editor), and add the attribute
+ <emphasis>usePeer2Peer="false"</emphasis> to the <emphasis>invoke</emphasis> element.
+ </para>
+
+ <para>
+ The next step is to deploy the BPEL processes for the Store and CreditAgency
+ participants to a JBossAS server running RiftSaw. This can be achieved
+ using the Eclipse Web Tooling Project (WTP) server support, in conjunction with
+ the JBoss Tools features mentioned in the installation section.
+ </para>
+
+ <para>
+ Create a JBossAS server entry in the <emphasis>Servers</emphasis> view, using
+ the <emphasis>New->Server</emphasis> menu item on the view's context menu.
+ Configure the server entry to point to a JBossAS environment that has
+ previously been configured to run RiftSaw. Select the server in the
+ <emphasis>Servers</emphasis> view, and then select the <emphasis>Add and Remove ...</emphasis>
+ menu item. This will show a dialog window that will include the CreditAgency
+ and Store BPEL projects on the left. Select both projects, and press the
+ <emphasis>Add</emphasis> button. When the <emphasis>Finish</emphasis> button
+ is selected, the BPEL processes will be associated with the server.
+ </para>
+ </section>
+
+ <section>
+ <title>Running the Example</title>
+
+ <para>
+ Start the server using the <emphasis>Start</emphasis> menu item associated with
+ the JBossAS server in the <emphasis>Servers</emphasis> view, or manually from
+ a terminal window in the JBossAS server's <filename>bin</filename> folder using
+ the <emphasis>run</emphasis> script. Once the server
+ has fully started, the BPEL processes should have been deployed.
+ </para>
+
+ <para>
+ The next step is to start the <emphasis>Savara->Monitor</emphasis> associated
+ with the <filename>PurchaseGoods.cdm</filename> choreography description.
+ </para>
+
+ <para>
+ The final step is to send a test message to the <emphasis>Store</emphasis>
+ BPEL process. This can be achieved by selecting the <filename>PurchaseGoodsProcess_Store.wsdl</filename>
+ file, within the <emphasis>PurchaseGoodsProcess_Store</emphasis> project
+ (<filename>bpelContents</filename> folder), and then select the menu
+ item <emphasis>Web Services->Test with Web Services Explorer</emphasis>.
+ </para>
+
+ <para>
+ Expand the 'StoreInterfaceBinding' node, in the left hand panel of the explorer,
+ and select the 'buy' operation. Then select the 'Source' link, which will show the
+ various sections of the SOAP message to be sent. Edit the message body to be:
+ </para>
+
+ <informalexample>
+ <programlisting role="XML" ><![CDATA[
+ <q0:BuyRequest id="1" amount="200" />
+ ]]></programlisting>
+ </informalexample>
+
+ <para>
+ Then press the 'Ok' button further down the panel. This will send the message to the
+ Store process, and eventually cause a response to appear in the lower panel.
+ </para>
+
+ <para>
+ Four entries should appear in the SAVARA monitor, the buy request, credit check
+ request, credit check ok (response) and buy confirmed (response).
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/SAVARAMonitorPurchasing1.png" align="center" width="6in" />
+ </imageobject>
+
+ <para>
+ To demonstrate how an error would be detected and reported, issue a new request
+ such as:
+ </para>
+
+ <informalexample>
+ <programlisting role="XML" ><![CDATA[
+ <q0:BuyRequest id="2" amount="300" />
+ ]]></programlisting>
+ </informalexample>
+
+ <para>
+ This will result in an unexpected message to be reported, as there is a difference
+ between the choreography and the CreditAgency BPEL process (implementation).
+ The choreography defines that a valid credit check should be returned if the
+ amount is less than 250. However the BPEL process has implemented this condition
+ as a valid credit check is where the amount is less or equal to 500.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/SAVARAMonitorPurchasing2.png" align="center" width="6in" />
+ </imageobject>
+
+ </section>
+ </section>
+
+ <section>
+ <title>JBossESB Example - Trailblazer</title>
+
+ <section>
+ <title>Deploying the Example</title>
+
+ <para>
+ The first step to deploying the Trailblazer example is to configure the JBossAS environment:
+ </para>
+
+ <orderedlist>
+ <listitem>
+ Update the <filename>${JBossAS}/server/default/deployers/esb.deployer/jbossesb-properties.xml</filename>
+ file, in the section entitled "transports" and specify all of the SMTP mail server settings for
+ your environment.
+ </listitem>
+ <listitem>
+ Update the <filename>trailblazer/trailblazer.properties</filename>
+ <para>
+ Update the <property>file.bank.monitored.directory</property> and
+ <property>file.output.directory</property> properties. These are folders
+ used by the File Based Bank, and are set to <filename>/tmp/input</filename>
+ and <filename>/tmp/output</filename> by default.
+ </para>
+ </listitem>
+ <listitem>
+ Update the <filename>trailblazer/esb/conf/jboss-esb.xml</filename>
+ <para>
+ There is a <emphasis>fs-provider</emphasis> block, update the
+ <property>directory</property> attribute value to be the same as the
+ <property>file.output.directory</property> value in
+ <filename>trailblazer.properties</filename> file.
+ </para>
+ </listitem>
+ <listitem>
+ Start the JBossAS server
+ </listitem>
+ </orderedlist>
+
+ <para>
+ One the server has been started, the next step is to deploy the relevant
+ components into the JBossAS environment. This is achieved by:
+ </para>
+
+ <orderedlist>
+ <listitem>
+ From the <filename>trailblazer</filename> folder, execute the following
+ command to deploy the example to the ESB:
+ <emphasis role="bold">ant deploy</emphasis>
+ <para>
+ this should deploy the ESB and WAR files to your JBoss AS
+ <filename>server/default</filename>.
+ </para>
+ </listitem>
+ <listitem>
+ From the <filename>trailblazer/banks</filename> folder, execute the command
+ to start the JMS Bank service: <emphasis role="bold">ant runJMSBank</emphasis>.
+ </listitem>
+ <listitem>
+ From the <filename>trailblazer/banks</filename> folder, execute the command
+ to start the JMS Bank service: <emphasis role="bold">ant runFileBank</emphasis>.
+ </listitem>
+ </orderedlist>
+
+ </section>
+
+ <section>
+ <title>Running the Example</title>
+
+ <para>
+ To run the example, you need to start a browser and select the URL
+ <ulink url="http://localhost:8080/trailblazer">localhost:8080/trailblazer</ulink>. This will
+ show the following page, if the server has been configured correctly and the TrailBlazer
+ example deployed:
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/TrailblazerWebPage.jpg" align="center" width="4in" />
+ </imageobject>
+
+ <para>
+ Now you can submit quotes, You will see either a loan request rejected (single email) because
+ the score is less than 4, or two emails (one from JMS bank and one from FileBased bank) with
+ valid quotes. When entering subsequent quotes, make sure that the quote reference is updated,
+ so that each session has a unique id.
+ </para>
+
+ </section>
+
+ <section>
+ <title>Detecting a Validation Error</title>
+
+ <para>
+ To demonstrate the detection of validation errors, there is an alternative implementation of the
+ trailblazer modules that behaviour differently to the choreography that is being monitored.
+ Specifically, the credit score threshold used to determine whether a loan request should be
+ issued to the banks, is raised from 4 to 7.
+ </para>
+
+ <para>
+ To deploy the version of the TrailBlazer example that results in validation errors, then:
+ </para>
+
+ <itemizedlist>
+ <listitem>
+ From the <filename>${SAVARA}/samples/trailblazer</filename> folder, execute the
+ following command to deploy the example to the ESB:
+ <emphasis role="bold">ant deploy-error-client</emphasis>.
+ </listitem>
+ </itemizedlist>
+
+ <para>
+ The next step is to issue more transactions, until a credit check score occurs that is between
+ 4 and 6 inclusive. This will result in a <emphasis>insufficientCredit</emphasis> interaction
+ being reported, which would be unexpected in terms of the choreography.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/TrailBlazerMonitorError.jpg" align="center" width="4in" />
+ </imageobject>
+
+ <para>
+ When errors, such as unexpected messages, are detected by the service validators and reported
+ to the SAVARA Monitor, they are displayed in red.
+ </para>
+
+ </section>
+ </section>
+</chapter>
Added: trunk/docs/gettingstartedguide/src/main/en-US/module/serviceanalysisdesign.xml
===================================================================
--- trunk/docs/gettingstartedguide/src/main/en-US/module/serviceanalysisdesign.xml (rev 0)
+++ trunk/docs/gettingstartedguide/src/main/en-US/module/serviceanalysisdesign.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="serviceanalysisdesign">
+ <title>Service Oriented Analysis and Design</title>
+
+ <para>
+ At this point in the lifecycle, various activities would occur related to reviewing
+ services (i.e. in a SOA Repository) and understanding whether existing services
+ meet requirements, need to be modified, or whether new services need to be
+ developed from scratch.
+ </para>
+
+ <section>
+ <title>Service Oriented Design</title>
+
+ <para>
+ In the current SAVARA tooling, the main functionality in the Service Oriented
+ Design phase is the generation of BPMN (version 1) diagrams. These diagrams
+ can be used as guidance for the development teams that are implementing the
+ individual services.
+ </para>
+
+ <para>
+ It is also possible to extend the generated BPMN (version 1) diagrams to include
+ service logic. However it should be noted that changes to the choreography or
+ BPMN diagrams will not be synchronized/merged. So changes in the choreography will
+ not be checked for conformance against previously generated BPMN diagrams,
+ and it will be necessary to generate new 'service contract' BPMN (version 1)
+ diagrams to reflect changes in behaviour of a service within the updated
+ choreography.
+ </para>
+
+ <para>
+ In future versions of the SAVARA, based on BPMN2, it will be possible to
+ formally check BPMN2 process models for conformance against a choreography
+ model, and potentially synchronize differences in <emphasis>externally
+ observable behaviour</emphasis> between them.
+ </para>
+
+ <para>
+ To generate a BPMN (version 1) diagram from a choreography, select the
+ <emphasis>Export</emphasis> menu item associated with the choreography file,
+ and select the <emphasis>Other->BPMN</emphasis> option.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/ExportBPMNMenu.png" align="center" width="4in" />
+ </imageobject>
+
+ <para>
+ Once the option has been selected, you will be asked to select the location
+ where the generated BPMN diagrams should be stored. A diagram will be
+ created containing all of the participants involved in the choreography in
+ a single collaboration diagram.
+ </para>
+
+ <para>
+ Select a folder that is located within a project in your Eclipse workspace.
+ Once the folder has been chosen, the diagrams will be generated. To see
+ them within the Eclipse project, you will need to <emphasis>refresh</emphasis>
+ the relevant folder.
+ </para>
+
+ <para>
+ The generated diagram will appear as two files, one contains the underlying
+ BPMN model (i.e. the information about the tasks, control links, message links,
+ etc.) and the other file contains the diagram information (i.e. node positions,
+ etc). Double click on the file with the <filename>.bpmn_diagram</filename>
+ suffix to view the diagram in the Eclipse BPMN editor.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/ExportedBPMN.png" align="center" width="6in" />
+ </imageobject>
+
+ </section>
+
+</chapter>
Added: trunk/docs/gettingstartedguide/src/main/en-US/module/servicedev.xml
===================================================================
--- trunk/docs/gettingstartedguide/src/main/en-US/module/servicedev.xml (rev 0)
+++ trunk/docs/gettingstartedguide/src/main/en-US/module/servicedev.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="servicedev">
+ <title>Service Development</title>
+
+ <para>
+Services can be developed by generating initial development artifacts, based on artifacts
+created in preceding phases (e.g. global model or service contracts/designs).
+ </para>
+
+ <para>
+To ensure that the services continue to conform to the artifacts defined in the previous
+phases, the tools perform conformance checking between the service implementation and
+the existing architecture/design artifacts. This is not possible with all implementation
+languages - they must provide the means to extract the communication structure for
+comparison.
+ </para>
+
+ <para>
+The following sections explain how the generation and conformance checking can be achieved
+for the WS-BPEL implementation language.
+ </para>
+
+ <section>
+ <title>WS-BPEL</title>
+
+ <para>
+This tools include a capability to generate a service implementation, for a participant in a choreography,
+using WS-BPEL. A completed version of the <emphasis>PurchasingGoods</emphasis> example can be
+found in the samples directory (which can be imported into Eclipse).
+ </para>
+
+ <para>
+However if you wish to generate the example from scratch, the follow the instructions in this section.
+More information about how to use this feature can be found in the User Guide.
+ </para>
+
+ <section>
+ <title>Generating WS-BPEL based Services</title>
+
+ <para>
+When a choreography description has been created, it is possible to generate a BPEL Process (and associated
+WSDL files and deployment descriptor) for each of the participants defined within the choreography.
+To try this out, select the <emphasis>Savara->Generate->WS-BPEL</emphasis> menu item from the popup menu
+associated with the <filename>PurchaseGoods.cdm</filename>.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/GenerateBPELMenu.jpg" align="center" width="3in" />
+ </imageobject>
+
+ <para>
+This will display a dialog listing the possible services that can be generated from this choreography,
+with a proposed Eclipse project name.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/GenerateBPELDialog.jpg" align="center" width="3in" />
+ </imageobject>
+
+ <para>
+To test out this feature, uncheck the <emphasis>Buyer</emphasis> participant, leave the build system
+as <emphasis>Ant</emphasis>, and
+press the 'Ok' button. This will create a single new project for the <emphasis>Store</emphasis> and
+<emphasis>CreditAgency</emphasis> participants.
+ </para>
+
+ <para>
+Each project will contain a single <filename>bpel</filename> folder containing the WS-BPEL process
+definition for the participant, a list of relevant WSDL files and a deployment descriptor file
+for use with RiftSaw. Howeve the WS-BPEL and WSDL files are standard, so can be deployed to any
+WS-BPEL 2.0 compliant engine.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/GenerateBPELNav.jpg" align="center" width="2in" />
+ </imageobject>
+
+ </section>
+
+ <section>
+ <title>Adding implementation details</title>
+
+ <para>
+ The generated BPEL processes and deployment descriptors are incomplete, due to
+ lack of implementation details in the choreography description. The choreography
+ simply represents the externally observable interactions between the parties,
+ and therefore cannot provide internal implementation details.
+ </para>
+
+ <para>
+ Therefore a completed version of the deployment descriptor and BPEL process files,
+ for both the creditAgency and store participants, can be found in the
+ <emphasis>purchasing</emphasis> example's <filename>completed</filename> folder.
+ </para>
+
+ <para>
+ To highlight the differences between the original generated version, and the completed
+ version, simply select both files and use the <emphasis>Compare With->Each Other</emphasis>
+ menu item.
+ </para>
+
+ </section>
+
+ </section>
+</chapter>
Added: trunk/docs/gettingstartedguide/src/main/en-US/module/tap.xml
===================================================================
--- trunk/docs/gettingstartedguide/src/main/en-US/module/tap.xml (rev 0)
+++ trunk/docs/gettingstartedguide/src/main/en-US/module/tap.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="tap">
+ <title>Testable Architecture Project</title>
+
+ <section>
+ <title>Managing Dependencies</title>
+
+ <para>
+ The previous sections have discussed the various phases of the software development
+ lifecycle, and the artifacts that can be created. They have also outlined some
+ validation performed between the scenarios and choreography, when a specific link
+ has been established from the scenario.
+ </para>
+
+ <para>
+ However the aim of the "Testable Architecture" methodology is to provide validation
+ between all artifacts, to ensure that artifacts defined at any particular phase
+ can be shown to be valid against the artifacts in preceding phases.
+ </para>
+
+ <para>
+ Therefore the concept of a "Testable Architecture Project" or TAP has been introduced.
+ This is essentially a file that records information about the artifacts defined in
+ each phase of the software development lifecycle, and the relationships between them.
+ This file can then be validated to ensure that each artifact, and its dependencies,
+ are valid in respect of each other.
+ </para>
+
+ <para>
+ For example, the <filename>purchasing</filename> example contains a TAP file with
+ the following contents:
+ </para>
+
+ <informalexample>
+ <programlisting role="XML" ><![CDATA[
+<project xmlns="http://www.savara.org/ta/project" xmlns:xsi="http://www.w3.org/2001/XMLSchema"
+ xsi:schemaLocation="http://www.savara.org/ta/project tap.xsd"
+ name="Purchasing" version="1.0.0">
+
+ <phase name="requirements">
+ <resource id="SuccessfulPurchase.scn">
+ <uri type="eclipse" context="purchasing" locator="/SuccessfulPurchase.scn" />
+ </resource>
+ <resource id="InvalidPurchase.scn">
+ <uri type="eclipse" context="purchasing" locator="/InvalidPurchase.scn" />
+ </resource>
+ </phase>
+
+ <phase name="architecture">
+ <resource id="PurchaseGoods.cdm">
+ <uri type="eclipse" context="purchasing" locator="/PurchaseGoods.cdm" />
+ <relationship type="depends" ref="SuccessfulPurchase.scn" />
+ <relationship type="depends" ref="InvalidPurchase.scn" />
+ </resource>
+ </phase>
+
+ <phase name="implementation">
+ <resource id="PurchaseGoodsProcess_Store.bpel">
+ <uri type="eclipse" context="PurchaseGoodsProcess-Store"
+ locator="/bpelContent/PurchaseGoodsProcess_Store.bpel" />
+ <relationship type="depends" ref="PurchaseGoods.cdm" >
+ <description>
+ Link from the BPEL process to the 'Store' participant
+ within the choreography
+ </description>
+ <link type="role" to="Store" />
+ </relationship>
+ </resource>
+ <resource id="PurchaseGoodsProcess_CreditAgency.bpel">
+ <uri type="eclipse" context="PurchaseGoodsProcess-CreditAgency"
+ locator="/bpelContent/PurchaseGoodsProcess_CreditAgency.bpel" />
+ <relationship type="depends" ref="PurchaseGoods.cdm" >
+ <description>
+ Link from the BPEL process to the 'CreditAgency' participant
+ within the choreography
+ </description>
+ <link type="role" to="CreditAgency" />
+ </relationship>
+ </resource>
+ </phase>
+</project>
+ ]]></programlisting>
+ </informalexample>
+
+ <para>
+ The top level element is <emphasis>project</emphasis>, with the <emphasis>name</emphasis>
+ and <emphasis>version</emphasis> attributes to define the details of the Testable Architecture
+ Project.
+ </para>
+
+ <para>
+ The project then contains <emphasis>phase</emphasis> elements, one for each stage of the
+ software development lifecycle we are interested in. These elements are only used to
+ segment the artifacts into the different phases, which can be useful for tasks such as
+ project management or documentation generation.
+ </para>
+
+ <para>
+ The phase element contains <emphasis>resource</emphasis> elements, one per artifact. A
+ resource represents an artifact that is of interest in the Testable Architecture Project.
+ </para>
+
+ <para>
+ The resource element contains one or more of the following elements:
+ </para>
+
+ <orderedlist>
+ <listitem>
+ uri
+ <para>
+ This element is used to define the location of a resource. A URI element is required for
+ each environent in which the resource may be accessed, for example, within Eclipse and
+ within an SOA Repository.
+ </para>
+ <para>
+ The <emphasis>type</emphasis> attribute defines the type of locator, which will usually
+ map onto the environment in which the resource exists. So in this case we are only
+ defining URI elements associated with the Eclipse environment.
+ </para>
+ <para>
+ The <emphasis>context</emphasis> attribute defines the local information that can be used
+ in the particular environment, to determine where the resource is contained. For example,
+ if the environment is Eclipse, the context would be the project name.
+ </para>
+ <para>
+ The <emphasis>locator</emphasis> attribute is used to specify the specific location of
+ the resource, within the particular specified context, in the environment type. For example,
+ if the environment was Eclipse, then the locator would be the relative path of the resource
+ within the project identified in the context attribute.
+ </para>
+ </listitem>
+ <listitem>
+ relationship
+ <para>
+ This element establishes a relationship from the containing resource, to another resource
+ identifed by the <emphasis>ref</emphasis> attribute.
+ </para>
+ <para>
+ The relationship element can optionally have additional information associated with it,
+ to help clarify the nature of the relationship between the two resources.
+ </para>
+ <para>
+ For example, in the TAP file illustrated above, the two BPEL resources (in the implementation
+ phase) have a relationship to the choreography file - however the relationship needs to be
+ more specific. We need to indicate what <emphasis>role</emphasis> within that choreography
+ the BPEL processes are associated with. The <emphasis>link</emphasis> element enables
+ the <emphasis>type</emphasis> to be defined, and a value to be specified in the
+ <emphasis>to</emphasis> attribute.
+ </para>
+ </listitem>
+ </orderedlist>
+ </section>
+
+ <section>
+ <title>Validating a Testable Architecture Project</title>
+
+ <para>
+ To trigger validation of a Testable Architecture Project (TAP), select the <filename>.tap</filename>
+ file and choose the <emphasis>Savara->Validate</emphasis> menu item. If any errors or warnings are
+ detected, they will be recorded as errors in the Problems or Markers view (depending on which
+ perspective is being used).
+ </para>
+
+ <para>
+ If you invoke the validation on the TAP file within the <emphasis>purchasing</emphasis> project,
+ you will find that it will create an error associated with the choreography file, indicating
+ that it does not meet the scenario "InvalidPurchase.scn". This is because this scenario has
+ specifically been created to demonstrate how an error is reported.
+ </para>
+
+ <para>
+ If the scenario is simulated against the choreography, using the green <emphasis>play</emphasis> button on the
+ toolbar, then it will be possible to see specifically where the scenario is not met by the
+ choreography.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/InvalidPurchasePostTest.jpg" align="center" width="5in" />
+ </imageobject>
+
+ <para>
+ In this case, it is because the CreditAgency has returned a credit check failed message, but the
+ Store is still attempting to return a buy confirmed message.
+ </para>
+
+ <para>
+ Its possible that this scenario is valid, and therefore the choreography needs to be updated
+ to cater for this scenario. However in this case, we may just be wanting to represent a
+ <emphasis>negative</emphasis> use case, and therefore deliberately describe a situation we
+ do not want the choreography to handle. Therefore we need to configure the scenario to
+ indicate that the failure is expected.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/ExpectedToFail.png" align="center" width="5in" />
+ </imageobject>
+
+ <para>
+ Simply select the 'send' node for the final interaction between the Store and Buyer, and
+ set the 'Expected to Fail' property to true. This will cause a red boundary to be displayed
+ around the node, indicating that it is expected to fail. Now when the scenario is simulated
+ or validated, if that node does not fail, that will be reported as an error. However if the
+ node does fail as expected, that will be treated as a valid case.
+ </para>
+
+ <para>
+ If the validation of the TAP file is performed again, the error associated with the
+ <filename>InvalidPurchase.scn</filename> should no disappear.
+ </para>
+
+ <para>
+ To experiment with other types of validation that are performed, open the <filename>PurchaseGoods.cdm</filename>
+ and go to the <emphasis>Base Types</emphasis> tab. Then open up the node for
+ <emphasis>Information Types</emphasis> and select the <emphasis>CreditCheckOk</emphasis>
+ entry. In the <emphasis>Properties</emphasis> view, change the <emphasis>element</emphasis>
+ attribute, e.g. appending an 'X' to the "ca:CreditCheckOk" value.
+ </para>
+
+ <para>
+ When the choreography has been saved, re-perform the validation on the TAP file. This
+ should now display 'Type Mismatch' errors against the previously generated BPEL
+ processes, and also flag errors associated with the scenarios.
+ </para>
+
+ </section>
+
+</chapter>
Added: trunk/docs/gettingstartedguide/src/main/en-US/xslt/pdf.xsl
===================================================================
--- trunk/docs/gettingstartedguide/src/main/en-US/xslt/pdf.xsl (rev 0)
+++ trunk/docs/gettingstartedguide/src/main/en-US/xslt/pdf.xsl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ version="1.0">
+
+ <xsl:import href="http://docbook.sourceforge.net/release/xsl/1.72.0/fo/docbook.xsl" />
+ <xsl:import href="classpath:/xslt/org/jboss/pdf.xsl" />
+
+ <!-- Override the default font settings -->
+ <xsl:param name="body.font.family" select="'Times New Roman, serif'" />
+ <xsl:param name="monospace.font.family" select="'DejaVu Sans Mono, monospace'" />
+ <xsl:param name="sans.font.family" select="'Arial, sans-serif'" />
+ <xsl:param name="title.font.family" select="$body.font.family" />
+ <xsl:param name="programlisting.font" select="$monospace.font.family" />
+ <xsl:param name="programlisting.font.size" select="'75%'" />
+
+ <!-- Remove the blank pages between the chapters -->
+ <xsl:param name="double.sided" select="0" />
+
+ <!-- Use SVG for callout images instead of PNG -->
+ <xsl:param name="callout.graphics" select="1" />
+ <xsl:param name="callout.graphics.extension" select="'.svg'" />
+
+ <!-- Hide URL -->
+ <xsl:param name="ulink.show" select="0"/>
+
+ <!-- Don't use italic font for links -->
+ <xsl:attribute-set name="xref.properties">
+ <xsl:attribute name="font-style">normal</xsl:attribute>
+ </xsl:attribute-set>
+
+ <!-- Decrease the link font size in the program listing -->
+ <xsl:attribute-set name="monospace.properties">
+ <xsl:attribute name="font-size">1em</xsl:attribute>
+ <xsl:attribute name="font-family">
+ <xsl:value-of select="$monospace.font.family"/>
+ </xsl:attribute>
+ </xsl:attribute-set>
+
+ <!-- Add some spacing between callout listing items -->
+ <xsl:template match="callout">
+ <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+ <fo:list-item id="{$id}" space-before="1em">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>
+ <xsl:call-template name="callout.arearefs">
+ <xsl:with-param name="arearefs" select="@arearefs"/>
+ </xsl:call-template>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block padding-top="0.2em">
+ <xsl:apply-templates/>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </xsl:template>
+
+ <!-- Slight baseline-shift for callouts in the program listing -->
+ <xsl:template name="callout-bug">
+ <xsl:param name="conum" select='1'/>
+ <xsl:choose>
+ <xsl:when test="$conum <= $callout.graphics.number.limit">
+ <xsl:variable name="filename"
+ select="concat($callout.graphics.path, $conum,
+ $callout.graphics.extension)"/>
+
+ <fo:external-graphic content-width="{$callout.icon.size}"
+ width="{$callout.icon.size}"
+ padding="0.0em" margin="0.0em"
+ baseline-shift="-0.375em">
+ <xsl:attribute name="src">
+ <xsl:choose>
+ <xsl:when test="$passivetex.extensions != 0
+ or $fop.extensions != 0
+ or $arbortext.extensions != 0">
+ <xsl:value-of select="$filename"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>url(</xsl:text>
+ <xsl:value-of select="$filename"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </fo:external-graphic>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+</xsl:stylesheet>
+
Added: trunk/docs/pom.xml
===================================================================
--- trunk/docs/pom.xml (rev 0)
+++ trunk/docs/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,36 @@
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.savara</groupId>
+ <artifactId>docs</artifactId>
+ <packaging>pom</packaging>
+ <name>Savara::Docs</name>
+ <version>1.2.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org</groupId>
+ <artifactId>savara</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <modules>
+ <module>userguide</module>
+ <module>gettingstartedguide</module>
+ <module>samplesguide</module>
+ </modules>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <id>jboss.release</id>
+ <name>JBoss releases</name>
+ <url>http://repository.jboss.org/maven2</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+</project>
Added: trunk/docs/samplesguide/pom.xml
===================================================================
--- trunk/docs/samplesguide/pom.xml (rev 0)
+++ trunk/docs/samplesguide/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,86 @@
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.savara.docs</groupId>
+ <artifactId>samplesguide</artifactId>
+ <packaging>jdocbook</packaging>
+ <name>Savara::Docs::SamplesGuide</name>
+ <version>1.2.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.savara</groupId>
+ <artifactId>docs</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.2.3</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>generate-docbook</id>
+ <phase>package</phase>
+ <goals>
+ <goal>resources</goal>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-docbook-xslt</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-jdocbook-style</artifactId>
+ <version>1.1.0</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <sourceDocumentName>master.xml</sourceDocumentName>
+ <sourceDirectory>${basedir}/src/main</sourceDirectory>
+ <imageResource>
+ <directory>${basedir}/src/main</directory>
+ <includes>
+ <include>**/images/**/*</include>
+ </includes>
+ </imageResource>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>file:///${basedir}/src/main/en-US/xslt/pdf.xsl</stylesheetResource>
+ <finalName>SAVARA-SamplesGuide.pdf</finalName>
+ </format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <docbookVersion>1.72.0</docbookVersion>
+ </options>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: trunk/docs/samplesguide/src/main/en-US/images/ChoreoMonReady.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/samplesguide/src/main/en-US/images/ChoreoMonReady.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/samplesguide/src/main/en-US/images/MonitorMenu.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/samplesguide/src/main/en-US/images/MonitorMenu.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/samplesguide/src/main/en-US/images/TrailblazerWebPage.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/docs/samplesguide/src/main/en-US/images/TrailblazerWebPage.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/samplesguide/src/main/en-US/master.xml
===================================================================
--- trunk/docs/samplesguide/src/main/en-US/master.xml (rev 0)
+++ trunk/docs/samplesguide/src/main/en-US/master.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % RH-ENTITIES SYSTEM "Common_Config/rh-entities.ent">
+]>
+
+<book lang="en">
+ <bookinfo>
+ <title>SAVARA 1.2</title>
+ <subtitle>Samples Guide</subtitle>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/author_group.xml"/>
+ </bookinfo>
+
+ <toc/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/overview.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/servicevalidator.xml"/>
+
+</book>
Added: trunk/docs/samplesguide/src/main/en-US/module/author_group.xml
===================================================================
--- trunk/docs/samplesguide/src/main/en-US/module/author_group.xml (rev 0)
+++ trunk/docs/samplesguide/src/main/en-US/module/author_group.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE authorgroup PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<authorgroup>
+ <corpauthor>Gary Brown</corpauthor>
+ <corpauthor>Jeff Yu</corpauthor>
+</authorgroup>
Added: trunk/docs/samplesguide/src/main/en-US/module/overview.xml
===================================================================
--- trunk/docs/samplesguide/src/main/en-US/module/overview.xml (rev 0)
+++ trunk/docs/samplesguide/src/main/en-US/module/overview.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="overview">
+ <title>Overview</title>
+ <para>The SAVARA Validator component provides the ability to validate executing services
+ against a choreography description, demonstrating a form runtime governance.
+ </para>
+
+ <para>
+ Further information about configuring the runtime validation of services against a choreography
+ can be found in the <emphasis role="bold">SAVARA User Guide</emphasis>.
+ </para>
+
+ <note>
+ <para>
+ Before attempting to deploy and run these examples, you must follow the instructions
+ in the <filename>${SAVARA}/install</filename> folder. To be able to
+ examine and modify the examples, it is advisable to install the SAVARA Eclipse tools,
+ and import the samples into the Eclipse environment.
+ </para>
+ </note>
+
+</chapter>
Added: trunk/docs/samplesguide/src/main/en-US/module/servicevalidator.xml
===================================================================
--- trunk/docs/samplesguide/src/main/en-US/module/servicevalidator.xml (rev 0)
+++ trunk/docs/samplesguide/src/main/en-US/module/servicevalidator.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="servicevalidator">
+ <title>Service Validator</title>
+
+ <section>
+ <title>Trailblazer Example</title>
+
+ <para>
+This example can be found in the <filename>trailblazer</filename> folder. See the TrailBlazer Guide
+(<filename>${SAVARA}/docs/trailblazer/TBGuide.pdf</filename>) for more information about the example.
+ </para>
+
+<note>
+ <para>
+The choreography description for the Trailblazer example can be found in the
+<emphasis>trailblazer-models</emphasis> project in the Eclipse environment. If the project has
+not yet been imported, then please refer to the instructions in the
+<emphasis>SAVARA Getting Started Guide</emphasis>.
+ </para>
+ <para>
+You can open the choreography for the trailblazer (trailblazer.cdm) and also a scenario representing
+a valid transaction associated with the choreography (LoanRequest.scn). In the choreography description
+editor, view the "Choreography Flows" tab to see the structure of the process.
+ </para>
+ <para>
+To simulate the scenario against the choreography, to ensure that the choreography correctly caters
+for the valid business scenario, the user should press the green 'play' button in the toolbar, associated
+with the Scenario Editor.
+ </para>
+</note>
+
+
+ <orderedlist>
+ <listitem>
+Update the <filename>${JBossAS}/server/default/deployers/esb.deployer/jbossesb-properties.xml</filename>
+file, in the section entitled "transports" and specify all of the SMTP mail server settings for your
+environment.
+ </listitem>
+ <listitem>
+Update the <filename>${SAVARA}/samples/trailblazer/trailblazer.properties</filename>
+ <para>
+Update the <property>file.bank.monitored.directory</property> and
+<property>file.output.directory</property> properties. These are folders used by the File Based Bank,
+and are set to <filename>/tmp/input</filename> and <filename>/tmp/output</filename> by default.
+If the selected folders do not exist, then please ensure they are created prior to running the example.
+ </para>
+ </listitem>
+ <listitem>
+Update the <filename>trailblazer/esb/conf/jboss-esb.xml</filename>
+ <para>
+There is a <emphasis>fs-provider</emphasis> block, update the <property>directory</property>
+attribute value to be the same as the <property>file.output.directory</property> value in
+<filename>trailblazer.properties</filename> file.
+ </para>
+ </listitem>
+ <listitem>
+Start the JBossAS server
+ </listitem>
+ <listitem>
+From the <filename>trailblazer</filename> folder, execute the command to start the ESB:
+<emphasis role="bold">ant deploy</emphasis>
+ <para>
+this should deploy the ESB and WAR files to your JBoss AS <filename>server/default</filename>.
+ </para>
+ </listitem>
+ <listitem>
+From the <filename>trailblazer/banks</filename> folder, execute the command to start the JMS
+Bank service: <emphasis role="bold">ant runJMSBank</emphasis>.
+ </listitem>
+ <listitem>
+From the <filename>trailblazer/banks</filename> folder, execute the command to start the File based
+Bank service: <emphasis role="bold">ant runFileBank</emphasis>.
+ </listitem>
+ <listitem>
+ <para>
+In the Eclipse environment, select the popup menu associated with the <filename>trailblazer.cdm</filename>
+file, and choose the <emphasis>Choreography->Monitor</emphasis> menu item.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/MonitorMenu.jpg" align="center" width="2in" />
+ </imageobject>
+
+ <para>
+Wait for the monitor window to start, and indicate that the choreography is being monitored, shown in the
+status line at the bottom of the window.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/ChoreoMonReady.jpg" align="center" width="4in" />
+ </imageobject>
+
+ </listitem>
+ <listitem>
+ <para>
+Start a browser and enter the URL:
+<ulink url="http://localhost:8080/trailblazer">localhost:8080/trailblazer</ulink>.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/TrailblazerWebPage.jpg" align="center" width="4in" />
+ </imageobject>
+
+ </listitem>
+ <listitem>
+Now you can submit quotes, You will see either a loan request rejected (single email) because the
+score is less than 4, or two emails (one from JMS bank and one from FileBased bank) with valid quotes.
+When entering subsequent quotes, make sure that the quote reference is updated, so that each session
+has a unique id.
+ </listitem>
+ </orderedlist>
+ <para>
+To demonstrate what occurs when the implementation deviates from the expected behaviour as defined
+in the choreography description, try the following steps:
+ </para>
+ <orderedlist>
+ <listitem>
+ Run the ant task <emphasis role="bold">ant deploy-error-client</emphasis> to redeploy the
+ trailblaizer example.
+ </listitem>
+ <listitem>
+ Run the commands from step 6 above.
+ </listitem>
+ </orderedlist>
+ <para>
+ The above steps show how changing the service implementation without updating a choreography
+ can result in behavioural validation errors being detected.
+ </para>
+ <tip>
+ <title>What is changed when we run ant deploy-error-client</title>
+ <para>
+ Compared to command of <emphasis role="bold">ant deploy</emphasis>, basically, we have
+ just updated the following code in
+ <emphasis role="bold">${SAVARA}/samples/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java</emphasis> file.
+ </para>
+ <para>
+ In the following code within the <emphasis role="bold">processLoanRequest</emphasis>
+ method, we've changed the "4" to "7"
+
+<programlisting>
+ //step 2 - check if score is acceptable
+ if (score >= 4) {
+</programlisting>
+ </para>
+ </tip>
+
+ <para>
+ Issue further loan requests, remembering to change the quote reference each time, until a Credit
+ Check result of between 4 and 6 inclusive occurs, which will result in an out of sequence message
+ being reported (in red) to the Choreography Monitor
+ </para>
+
+ <note>
+ <para>
+ It is currently a requirement that the choreography used within the Choreography Monitor is
+ the same as the description used to locally monitor the services
+ (i.e. within the savara-validator-jbossesb.esb/models directory).
+ </para>
+ </note>
+
+ </section>
+
+</chapter>
Added: trunk/docs/samplesguide/src/main/en-US/xslt/pdf.xsl
===================================================================
--- trunk/docs/samplesguide/src/main/en-US/xslt/pdf.xsl (rev 0)
+++ trunk/docs/samplesguide/src/main/en-US/xslt/pdf.xsl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ version="1.0">
+
+ <xsl:import href="http://docbook.sourceforge.net/release/xsl/1.72.0/fo/docbook.xsl" />
+ <xsl:import href="classpath:/xslt/org/jboss/pdf.xsl" />
+
+ <!-- Override the default font settings -->
+ <xsl:param name="body.font.family" select="'Times New Roman, serif'" />
+ <xsl:param name="monospace.font.family" select="'DejaVu Sans Mono, monospace'" />
+ <xsl:param name="sans.font.family" select="'Arial, sans-serif'" />
+ <xsl:param name="title.font.family" select="$body.font.family" />
+ <xsl:param name="programlisting.font" select="$monospace.font.family" />
+ <xsl:param name="programlisting.font.size" select="'75%'" />
+
+ <!-- Remove the blank pages between the chapters -->
+ <xsl:param name="double.sided" select="0" />
+
+ <!-- Use SVG for callout images instead of PNG -->
+ <xsl:param name="callout.graphics" select="1" />
+ <xsl:param name="callout.graphics.extension" select="'.svg'" />
+
+ <!-- Hide URL -->
+ <xsl:param name="ulink.show" select="0"/>
+
+ <!-- Don't use italic font for links -->
+ <xsl:attribute-set name="xref.properties">
+ <xsl:attribute name="font-style">normal</xsl:attribute>
+ </xsl:attribute-set>
+
+ <!-- Decrease the link font size in the program listing -->
+ <xsl:attribute-set name="monospace.properties">
+ <xsl:attribute name="font-size">1em</xsl:attribute>
+ <xsl:attribute name="font-family">
+ <xsl:value-of select="$monospace.font.family"/>
+ </xsl:attribute>
+ </xsl:attribute-set>
+
+ <!-- Add some spacing between callout listing items -->
+ <xsl:template match="callout">
+ <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+ <fo:list-item id="{$id}" space-before="1em">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>
+ <xsl:call-template name="callout.arearefs">
+ <xsl:with-param name="arearefs" select="@arearefs"/>
+ </xsl:call-template>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block padding-top="0.2em">
+ <xsl:apply-templates/>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </xsl:template>
+
+ <!-- Slight baseline-shift for callouts in the program listing -->
+ <xsl:template name="callout-bug">
+ <xsl:param name="conum" select='1'/>
+ <xsl:choose>
+ <xsl:when test="$conum <= $callout.graphics.number.limit">
+ <xsl:variable name="filename"
+ select="concat($callout.graphics.path, $conum,
+ $callout.graphics.extension)"/>
+
+ <fo:external-graphic content-width="{$callout.icon.size}"
+ width="{$callout.icon.size}"
+ padding="0.0em" margin="0.0em"
+ baseline-shift="-0.375em">
+ <xsl:attribute name="src">
+ <xsl:choose>
+ <xsl:when test="$passivetex.extensions != 0
+ or $fop.extensions != 0
+ or $arbortext.extensions != 0">
+ <xsl:value-of select="$filename"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>url(</xsl:text>
+ <xsl:value-of select="$filename"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </fo:external-graphic>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+</xsl:stylesheet>
+
Added: trunk/docs/trailblazer/TBGuide.odt
===================================================================
(Binary files differ)
Property changes on: trunk/docs/trailblazer/TBGuide.odt
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/trailblazer/TBGuide.pdf
===================================================================
(Binary files differ)
Property changes on: trunk/docs/trailblazer/TBGuide.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/pom.xml
===================================================================
--- trunk/docs/userguide/pom.xml (rev 0)
+++ trunk/docs/userguide/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,87 @@
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.savara.docs</groupId>
+ <artifactId>userguide</artifactId>
+ <packaging>jdocbook</packaging>
+ <name>Savara::Docs::UserGuide</name>
+ <version>1.2.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.savara</groupId>
+ <artifactId>docs</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.2.3</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>generate-docbook</id>
+ <phase>package</phase>
+ <goals>
+ <goal>resources</goal>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-docbook-xslt</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-jdocbook-style</artifactId>
+ <version>1.1.0</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <sourceDocumentName>master.xml</sourceDocumentName>
+ <sourceDirectory>${basedir}/src/main</sourceDirectory>
+ <imageResource>
+ <directory>${basedir}/src/main</directory>
+ <includes>
+ <include>**/images/**/*</include>
+ </includes>
+ </imageResource>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>file:///${basedir}/src/main/en-US/xslt/pdf.xsl</stylesheetResource>
+ <finalName>SAVARA-UserGuide.pdf</finalName>
+ </format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <docbookVersion>1.72.0</docbookVersion>
+ </options>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
Added: trunk/docs/userguide/src/main/en-US/images/editvalidatorann.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/editvalidatorann.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/editvalidatoranndiag.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/editvalidatoranndiag.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/editvalidatorannselect.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/editvalidatorannselect.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/genbpel1.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/genbpel1.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/genbpel2.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/genbpel2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/genbpel3.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/genbpel3.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/genesbconfig1.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/genesbconfig1.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/genesbconfig2.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/genesbconfig2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/genesbconfig3.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/genesbconfig3.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/genvalidatordialog.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/genvalidatordialog.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/genvalidatormenu.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/genvalidatormenu.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/monitorprefs.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/monitorprefs.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/monitorui.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/monitorui.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/setconversationtype.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/setconversationtype.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/images/validatorannotation.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/src/main/en-US/images/validatorannotation.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/src/main/en-US/master.xml
===================================================================
--- trunk/docs/userguide/src/main/en-US/master.xml (rev 0)
+++ trunk/docs/userguide/src/main/en-US/master.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % RH-ENTITIES SYSTEM "Common_Config/rh-entities.ent">
+]>
+
+<book lang="en">
+ <bookinfo>
+ <title>SAVARA 1.2</title>
+ <subtitle>User Guide</subtitle>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/author_group.xml"/>
+ </bookinfo>
+
+ <toc/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/overview.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/bpel.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/conversation-validation.xml"/>
+
+</book>
Added: trunk/docs/userguide/src/main/en-US/module/author_group.xml
===================================================================
--- trunk/docs/userguide/src/main/en-US/module/author_group.xml (rev 0)
+++ trunk/docs/userguide/src/main/en-US/module/author_group.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE authorgroup PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<authorgroup>
+ <corpauthor>Gary Brown</corpauthor>
+ <corpauthor>Jeff Yu</corpauthor>
+</authorgroup>
Added: trunk/docs/userguide/src/main/en-US/module/bpel.xml
===================================================================
--- trunk/docs/userguide/src/main/en-US/module/bpel.xml (rev 0)
+++ trunk/docs/userguide/src/main/en-US/module/bpel.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="bpel">
+ <title>BPEL</title>
+
+ <section>
+ <title>Overview</title>
+ <para>
+This section will describe generation and conformance checking features related to WS-BPEL.
+ </para>
+
+ <para>
+This initial release provides basic support for generating BPEL processes from a choreography
+description. Subsequent releases will also provide conformance checking, to ensure that changes
+to a BPEL process are validated to ensure the process remains conformant with the choreography.
+ </para>
+ </section>
+
+ <section>
+ <title>Generating a BPEL process</title>
+ <section>
+ <title>Overview</title>
+ <para>
+This section explains how to generate a template BPEL process from architectural and design
+artifacts.
+ </para>
+ </section>
+ <section>
+ <title>Generating the BPEL Process from a Choreography Description</title>
+ <para>
+When the choreography description has been completed, and has no errors, the user should select
+the "SAVARA->Generate->WS-BPEL" menu item from the popup menu associated with the choreography
+description (.cdm) file.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/genbpel1.png" width="4in" />
+ </imageobject>
+
+ <para>
+When the dialog window is displayed, it will contain the list of services that can be generated,
+along with the project names that will be created. The user can unselect the services they do not
+wish to generate (also using the 'Check All' or 'Clear All' buttons).
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/genbpel2.png" width="4in" />
+ </imageobject>
+
+ <para>
+The user can also select their preferred build system, which will create the relevant build structure.
+ </para>
+ <para>
+If there is a problem with the name of the project select, such as invalid characters used in the name,
+or the project name already exists, then it will be displayed in red.
+ </para>
+
+ <para>
+Once the BPEL is generated, it can be viewed using the Eclipse BPEL editor, e.g.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/genbpel3.png" width="4in" />
+ </imageobject>
+
+ </section>
+
+ <section>
+ <title>Limitations with the current CDL to BPEL mapping</title>
+
+ <para>
+This initial version of the BPEL generation is primarily targeted at generating the interactions
+and grouping constructs. These are the important components that will be required when doing
+conformance checking as part of the next milestone.
+ </para>
+
+ <para>
+This means that assignments and conditional expressions are not currently generated. The 'when'
+construct in CDL (also known as the blocking workunit) is also not currently handled. This may possible
+be implemented using flow links.
+ </para>
+ </section>
+ </section>
+
+</chapter>
+
Added: trunk/docs/userguide/src/main/en-US/module/conversation-validation.xml
===================================================================
--- trunk/docs/userguide/src/main/en-US/module/conversation-validation.xml (rev 0)
+++ trunk/docs/userguide/src/main/en-US/module/conversation-validation.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,432 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="conversationvalidationwithcdl">
+ <title>Conversation Validation with CDL</title>
+ <section>
+ <title>Overview</title>
+ <para>
+Conversation validation is a form of runtime governance concerned with the dynamic behaviour of a system.
+ </para>
+ <para>
+When coupled with a choreography description model of a system, this means having the ability to ensure that the way a collection of services interact correctly adheres to a description of the business process being enacted.
+ </para>
+ <para>
+This section introduces the choreography description language (CDL) defined by W3C, and the <emphasis>pi4soa</emphasis> open source project which provides an editor for creating choreography descriptions, as well as utilizing these descriptions for runtime validation and execution purposes.
+
+ </para>
+
+ </section>
+
+ <section>
+ <title>Configuration of Conversation Validation</title>
+
+ <para>
+ This section explains how to configure the conversation validation mechanism to validate services
+ against a choreography description. The first sub-section describes how the mechanism is hooked into the
+ JBossESB and JBossWS-Native environments. The following two sub-sections explain two alternate ways that relevant endpoint
+ references can be configured for validation.
+ </para>
+
+ <section>
+ <title>Installing the Conversation Validation Mechanism</title>
+
+ <section>
+ <title>JBossWS-Native</title>
+
+ <para>
+ The principle mechanism used for validating conversations within the JBossWS Native stack
+ is through the use of a global filter registered in the
+ <filename>standard-jaxws-client-config.xml</filename> and
+ <filename>standard-jaxws-endpoint-config.xml</filename> files.
+ These files are located in the <emphasis>$JBossAS/server/default/deployers/jbossws.deployter/META-INF</emphasis>
+ folder.
+ </para>
+
+ <para>
+ The <filename>standard-jaxws-client-config.xml</filename> is updated to include a
+ <emphaiss>pre handler</emphaiss> implemented by a Savara client interceptor.
+ </para>
+
+ <informalexample>
+ <programlisting role="XML" ><![CDATA[
+ <client-config>
+ <config-name>Standard Client</config-name>
+ <pre-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>SAVARA JBossWS-Native Client Validator Interceptor</javaee:handler-name>
+ <javaee:handler-class>org.savara.validator.jbosswsnative.JBossWSNativeClientInterceptor</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </pre-handler-chains>
+ <feature>http://org.jboss.ws/dispatch/validate</feature>
+ <property>
+ <property-name>http://org.jboss.ws/http#chunksize</property-name>
+ <property-value>2048</property-value>
+ </property>
+ </client-config>
+ ]]></programlisting>
+ </informalexample>
+
+ <para>
+ The <filename>standard-jaxws-endpoint-config.xml</filename> is updated to include a
+ <emphaiss>pre handler</emphaiss> implemented by a Savara server interceptor.
+ </para>
+
+ <informalexample>
+ <programlisting role="XML" ><![CDATA[
+ <endpoint-config>
+ <config-name>Standard Endpoint</config-name>
+ <pre-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>Recording Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.wsf.framework.invocation.RecordingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>SAVARA JBossWS-Native Service Validator Interceptor</javaee:handler-name>
+ <javaee:handler-class>org.savara.validator.jbosswsnative.JBossWSNativeServerInterceptor</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </pre-handler-chains>
+ </endpoint-config>
+ ]]></programlisting>
+ </informalexample>
+
+ <para>
+ These interceptors are installed as part of the installation process for the SAVARA
+ distribution.
+ </para>
+ </section>
+
+ <section>
+ <title>JBossESB</title>
+
+ <para>
+ The principle mechanism used for validating conversations within an ESB is through the use
+ of a global filter registered with the <emphasis>jbossesb-properties.xml</emphasis>.
+ This file is located in the <emphasis>$JBossAS/server/default/deployers/esb.deployer</emphasis>
+ folder.
+ </para>
+ <informalexample>
+ <programlisting role="XML" ><![CDATA[
+ <properties name="filters">
+ ...
+ <property name="org.jboss.soa.esb.filter.10"
+ value="org.savara.validator.jbossesb.ValidatorFilter"/>
+ </properties>
+ ]]></programlisting>
+ </informalexample>
+
+ <para>
+ This filter is installed as part of the installation process for the SAVARA distribution.
+ </para>
+ </section>
+ </section>
+
+ <section>
+ <title>Explicit Configuration</title>
+
+ <para>
+ The information concerning which destinations will be validated, and to which model/role
+ they relate, can be explicitly defined within the <emphasis>validator-config.xml</emphasis>
+ file, contained within the <emphasis>savara-validator-jbossesb.esb</emphasis> bundle.
+ </para>
+
+ <para>
+An example of the contents of this file, that would related to the TrailBlazer example, is:
+ </para>
+ <informalexample>
+ <programlisting role="XML" ><![CDATA[
+ <validator mode="monitor" replyToTimeout="10000" >
+ <service model="TrailBlazer.cdm"
+ role="LoanBrokerParticipant" >
+ <output epr="jms:queue/esb-tb-creditAgencyQueue" />
+ <input epr="jms:queue/esb-tb-creditAgencyQueue_reply" />
+ <output epr="jms:queue/esb-tb-jmsBankRequestQueue" />
+ <output epr="jms:queue/esb-tb-fileBankRequestQueue" />
+ <input epr="jms:queue/esb-tb-jmsBankResponseQueue" />
+ <output epr="jms:queue/esb-tb-customerNotifier" />
+ <input epr="jms:queue/esb-tb-fileBankResponseQueue" />
+ </service>
+ <service model="TrailBlazer.cdm"
+ role="CreditAgencyParticipant" >
+ <input epr="jms:queue/esb-tb-creditAgencyQueue" />
+ <output epr="jms:queue/esb-tb-creditAgencyQueue_reply" />
+ </service>
+ <service model="TrailBlazer.cdm"
+ role="BankParticipant" >
+ <input epr="jms:queue/esb-tb-jmsBankRequestQueue" />
+ <input epr="jms:queue/esb-tb-fileBankRequestQueue" />
+ <output epr="jms:queue/esb-tb-jmsBankResponseQueue" />
+ <output epr="jms:queue/esb-tb-fileBankResponseQueue" />
+ </service>
+ <service model="TrailBlazer.cdm"
+ role="NotifierParticipant" >
+ <input epr="jms:queue/esb-tb-customerNotifier" />
+ </service>
+ </validator>
+ ]]></programlisting>
+ </informalexample>
+
+ <para>
+ The 'validator' element has an optional attribute called 'mode', with the possible values
+ of 'monitor' or 'manage'. If the mode is 'monitor' (which is the default), then any messages
+ that result in validation errors being detected will continue to be received or sent, with
+ the errors only be reported for information purposes. If the mode is 'manage', then any
+ erronous messages detected during validation, that conflict with the behaviour as described
+ in the choreography, will be prevented from being received or sent.
+ </para>
+ <note>
+ <para>
+ It is important to note that if 'manage' validation mode is used, then the validation
+ mechanism will be an integral part of the message flow. This may have a slight performance
+ impact on the delivery of messages between services.
+ </para>
+ </note>
+
+ <para>
+ The optional 'replyToTimeout' (defined in milliseconds) is used to determine how long a dynamic
+ reply-to destination should be monitored for validation purposes. In some message exchanges,
+ the response destination will not always be known in advance. Therefore the configuration can
+ identify such situations, and monitor the reply-to destination for the response. However, if a
+ response is not delivered in a particular time period, we need to be able to discontinue the
+ validation of the dynamic endpoint. If this did not occur, then over time too many endpoints
+ would be monitored, which may result in out-of-memory problems. The default timeout period is
+ 10 seconds.
+ </para>
+ <para>
+ Within the 'validator' element is a list of 'service' elements, one per service being validated.
+ The behaviour of the service being validated is identified by specifying the model (e.g.
+ choreography description file) and the role (e.g. participant type) within the model. Therefore,
+ within the above configuration, the first set of destinations (eprs) are associated with the
+ <emphasis>LoanBrokerParticipant</emphasis> defined within the choreography description model
+ found in the file <filename>TrailBlazer.cdm</filename>, which will be located within the
+ <filename>models</filename> folder contained within the
+ <emphasis>savara-validator-jboss.sar</emphasis> bundle.
+ </para>
+ <para>
+ The elements contained within the 'service' element define the <emphasis>input</emphasis> and
+ <emphasis>output</emphasis> eprs (Endpoint References) that are associated with the service.
+ The <emphasis>input</emphasis> eprs are the destinations on which messages will be received and
+ the <emphasis>output</emphasis> eprs are the destinations on which messages will be sent by the
+ service.
+ </para>
+ <para>
+ The format of the 'epr' attribute will be specific to the type of transport being validated.
+ Currently JMS is supported, and can be identified by the protocol prefix 'jms:', or a
+ Web Service endpoint using a service name with the QName style of '{namespace}localpart'.
+ </para>
+ <para>
+ Each 'input' and 'output' element can also define an optional 'dynamicReplyTo' boolean attribute.
+ If defined, it will indicate to the Service Validator that the message on the specified endpoint
+ (epr) will contain a dynamically defined 'reply-to' destination that needs to be monitored for
+ a response.
+ </para>
+
+ </section>
+
+ <section>
+ <title>Defining the Validator Configuration within a Choreography</title>
+
+ <para>
+ The first step to configuring the validator is to associate the endpoint references (EPRs)
+ against the relevant choreography interactions. This is achieved by defining an
+ annotation for each 'exchange details' component (i.e. each request and response/notification).
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/editvalidatorann.png" width="5in" />
+ </imageobject>
+
+ <para>
+ When the annotation editor is displayed for the relevant 'exchange details' component,
+ the <emphasis>validator</emphasis> annotation should be added. This is achieved by
+ selecting the popup menu associated with the background of the lefthand panel,
+ and selecting the <emphasis>Add Defined Annotation</emphasis> menu item.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/editvalidatoranndiag.png" width="5in" />
+ </imageobject>
+
+ <para>
+ When the list of defined annotations is displayed, select the
+ <emphasis>validator</emphasis> annotation.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/editvalidatorannselect.png" width="3in" />
+ </imageobject>
+
+ <para>
+ After pressing the <emphasis>Ok</emphasis> button, the annotation editor
+ will configure the righthand panel with the parameters associated with this
+ annotation.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/validatorannotation.png" width="5in" />
+ </imageobject>
+
+ <para>
+ To specify the Endpoint Reference (EPR) for a particular message exchange, enter the EPR into the
+ <emphasis>Destination</emphasis> field. The value specified in this field will
+ be dependent upon the technology being validated. For example, if the JBossESB
+ is being monitored, then the value will be a physical address associated with the
+ ESB service endpoint (e.g. jms:queue/esb-quotes). If the technology being validated is a Web
+ Service (or BPEL process), then the field will represent the WSDL service name
+ specified using the QName style (e.g. {namespace}localpart).
+ </para>
+
+ <para>
+ The <emphasis>Type</emphasis> field is used to define the style of endpoint being
+ validated. In the image above, the endpoint being validated is a Web Service (or
+ BPEL process), and therefore the type is specified as a 'service name'. However if
+ the technology being validated identifies a different endpoint address, for the request
+ and response (as in the case of JBossESB), then the type should be set to
+ 'endpoint address'.
+ </para>
+
+ <para>
+ If the exchange is a request, that
+ will result in a response being sent on a dynamically provided "reply-to"
+ destination, then the <emphasis>Dynamic Reply-To</emphasis> checkbox should be selected.
+ This situation may occur in the case of validating a JBossESB service, where a
+ well-defined endpoint address has not been defined for the response.
+ </para>
+
+ <para>
+ Once the annotation has been defined, then press the <emphasis>Save</emphasis>
+ button to save the annotation against the interaction's exchange details.
+ </para>
+
+ <para>
+ When all of the relevant 'exchange details' components have been configured with
+ a <emphasis>validator</emphasis> annotation, defining the EPR to be validated,
+ then the choreography description file can be copied into the
+ <filename>savara-validator-jboss.sar/models</filename> folder. This will cause
+ the validation mechanism to derive the configuration information from the choreography
+ description model, and begin validating the defined destinations against that
+ choreography description model.
+ </para>
+
+ </section>
+
+ </section>
+
+ <section>
+ <title>Monitoring the Choreography Description</title>
+
+ <para>
+ Once the server environment has been configured, to perform service validation of a set of
+ services against a choreography description, and the server has been started, then the next
+ step is to configure the monitoring tool. This can be achieved by opening the
+ <emphasis>Window->Preferences->Savara->Monitor</emphasis> dialog, as shown in the following
+ image.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/monitorprefs.png" width="5in" />
+ </imageobject>
+
+ <para>
+ In general, the default values specified for the JNDI and JMS properties will be fine.
+ The only information that should need to be provided is a path to the JMS and JNDI
+ libraries. When using the JBossAS server, this path can be set to the top level
+ <filename>client</filename> folder.
+ </para>
+
+ <para>
+ The next step is to launch the monitoring tool. This is located on the popup menu, for
+ the choreography description (i.e. .cdm) file, by selecting the Savara->Monitor menu
+ item. Once the tool has been launched, it will load the choreography description, subscribe
+ to the relevant event destination, and then indicate via a message in the bottom status line
+ that it is ready to monitor.
+ </para>
+
+ <imageobject>
+ <imagedata fileref="en-US/images/monitorui.png" width="5in" />
+ </imageobject>
+
+ <para>
+ When the information is received, from the service validators representing the different
+ participants (services), it is correlated to show the global status of the business
+ transaction. The list of correlated interactions is shown in reverse time order in the
+ image.
+ </para>
+
+ <para>
+ If any <emphasis>out of sequence</emphasis> or other error situations arise, these are
+ displayed in red.
+ </para>
+ </section>
+
+ <section>
+ <title>Configuration for Conversation Recording</title>
+
+ <para>
+ As well as validating the interactions between a set of
+ services, against a pre-defined choreography description,
+ it is also possible to use the <emphasis>Service Validators</emphasis>
+ in a non-validating record mode.
+ </para>
+
+ <para>
+ This will be useful in situations where a choreography
+ description does not currently exist, and we wish to
+ use the stream of business events being sent and received
+ by each identified service (or participant type) to
+ gain an understanding of the current business process.
+ </para>
+
+ <para>
+ An example of this type of configuration, associated
+ with the TrailBlazer example, is:
+ </para>
+ <informalexample>
+ <programlisting role="XML" ><![CDATA[
+ <validator>
+ <service role="LoanBrokerParticipant" validate="false" >
+ <output epr="jms:queue/esb-tb-creditAgencyQueue" />
+ <input epr="jms:queue/esb-tb-creditAgencyQueue_reply" />
+ <output epr="jms:queue/esb-tb-jmsBankRequestQueue" />
+ <output epr="jms:queue/esb-tb-fileBankRequestQueue" />
+ <input epr="jms:queue/esb-tb-jmsBankResponseQueue" />
+ <output epr="jms:queue/esb-tb-customerNotifier" />
+ <input epr="jms:queue/esb-tb-fileBankResponseQueue" />
+ </service>
+ <service role="CreditAgencyParticipant" validate="false" >
+ <input epr="jms:queue/esb-tb-creditAgencyQueue" />
+ <output epr="jms:queue/esb-tb-creditAgencyQueue_reply" />
+ </service>
+ <service role="BankParticipant" validate="false" >
+ <input epr="jms:queue/esb-tb-jmsBankRequestQueue" />
+ <input epr="jms:queue/esb-tb-fileBankRequestQueue" />
+ <output epr="jms:queue/esb-tb-jmsBankResponseQueue" />
+ <output epr="jms:queue/esb-tb-fileBankResponseQueue" />
+ </service>
+ <service role="NotifierParticipant" validate="false" >
+ <input epr="jms:queue/esb-tb-customerNotifier" />
+ </service>
+ </validator>
+ ]]></programlisting>
+ </informalexample>
+
+ <para>
+ To define a <emphasis>Service Validator</emphasis> in record
+ only mode, the <emphasis>model</emphasis> attribute
+ is not specified (because no choreography description exists
+ to be validated against), and the optional <emphasis>validate</emphasis>
+ attribute should be set to <emphasis role="bold">false</emphasis> (by default
+ this attribute is <emphasis role="bold">true</emphasis>).
+ </para>
+ </section>
+
+</chapter>
Added: trunk/docs/userguide/src/main/en-US/module/overview.xml
===================================================================
--- trunk/docs/userguide/src/main/en-US/module/overview.xml (rev 0)
+++ trunk/docs/userguide/src/main/en-US/module/overview.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="overview">
+ <title>Overview</title>
+
+ <para>
+ The SAVARA project aims to leverage the concept of a choreography (or conversation)
+ description to provide design-time and run-time governance of an SOA.
+ </para>
+ <para>
+ A Choreography provides the means to describe the service interactions between multiple parties from a global (or service neutral) perspective.
+ This means that it is possible for an organisation to define how an end-to-end business process should function, regardless of whether orchestrated
+ or peer-to-peer service collaboration will be used.
+ </para>
+ <para>
+ Although in simple situations, a BPEL process description can provide a description of the interactions between multiple services, this only works where a
+ single orchestrating process is in control. The benefit of the choreography description is that it can be used to provide a global view of a process across multiple
+ orchestrated service domains.
+ </para>
+ <para>
+ This document will outline how the Choreography Description is being used as part of SAVARA to provide SOA governance capabilities
+ for each phase of the SOA lifecycle.
+ </para>
+ <para>
+ When a validated design has been approved by the users, it can be used to generate an initial skeleton of the implementation for each service.
+ The current version of SAVARA enables a skeleton implementation to be generated as a service
+ implementation (e.g. WS-BPEL process).
+ </para>
+
+ <section>
+ <title>WS-CDL</title>
+
+ <para>
+WS-CDL, or Web Service Choreography Description Language, is a candidate recommendation from W3C. Although associated with W3C and Web Services, it is important to begin by stating that the Choreography Description Language (CDL) is <emphasis role="bold">not</emphasis> web service specific.
+ </para>
+ <para>
+The purpose of CDL is to enable the interactions between a collection of peer to peer services to be described from a neutral (or global) perspective. This is different to other standards, such as WS-BPEL, that describe interactions from a service specific viewpoint.
+ </para>
+ <para>
+In essence a choreography description declares roles which will pass messages between each other, called interactions. The interactions are ordered based on a number of structuring mechanism which enables loops, conditional, choices and parallelism to be described. In CDL variables used for messages and for conditionals are all situated at roles. There is no shared state rather there is a precise description of the state at each role and a precise description of how these roles interact in order to reach some notion of common state in which information is exchanged and processed between them.
+ </para>
+ <para>
+In CDL we use interactions and these structuring mechanisms to describe the observable behaviour, the messages exchanges and the rules for those exchanges and any supporting observable state on which they depend, of a system.
+ </para>
+ </section>
+
+ <section>
+ <title>pi4soa</title>
+ <para>
+<emphasis>pi4soa</emphasis> is an open source project established to demonstrate the potential benefits that a global model (as described using CDL) can provide when building an SOA. The open source project is managed by the Pi4 Technologies Foundation, which is a collaboration between industry and academia.
+ </para>
+ <para>
+Building complex distributed systems, without introducing unintended consequences, is a real challenge. Although the Choreography Description Language provides a means of describing complex systems at a higher level, and therefore help to reduce such complexity, it does not necessarily guarantee that erronous situations cannot occur due to inappropriately specified interactions. The research, being carried out by members of the Pi4 Technologies Foundation, into the global model and endpoint projection is targeted at identifying potential unintended consequences, to ensure that a global description of a system can be reliably executed and can be free from unintended consequences.
+ </para>
+ <para>
+The tool suite currently offers the ability to:
+ </para>
+ <para>
+ <itemizedlist>
+ <listitem>
+ Define a choreography description
+ </listitem>
+ <listitem>
+ Export the description to a range of other formats, such as BPMN, UML activity/state/sequence models, and HTML
+ </listitem>
+ <listitem>
+ Define scenarios (equivalent to sequence diagrams), with example messages, which can then be simulated against an associated choreography
+ </listitem>
+ </itemizedlist>
+ </para>
+ </section>
+
+ <section>
+ <title> SOA Lifecycle Governance </title>
+
+ <section>
+ <title>Design Time Governance</title>
+ <para>
+ Design-time governance is concerned with ensuring that the resulting system correctly implements requirements (whether functional or non-functional).
+ A choreography description can be used to ensure that the implemented system meets the behavioural requirements.
+ </para>
+ <para>
+ The behavioural requirements can be captured as a collection of scenarios (e.g. sequence diagrams) with associated example messages.
+ This enables an unambiguous representation of the business requirements to be stored in a machine processable form, which can subsequently
+ be used to validate other phases of the SOA lifecycle.
+ </para>
+ <para>
+ Once the choreography description for the SOA has been defined, it can be validated against the scenarios,
+ to ensure that the choreography correctly handles all of the business requirements.
+ </para>
+ <para>
+ Once the service enters the implementation phase, it is important to ensure that it continues to adhere to the design
+ and therefore meets the business requirements. Currently this is achieved through the use of techniques such as continuous testing.
+ However this is only as reliable as the quality of the unit tests that have been written.
+ </para>
+ <para>
+ When a 'structured' implementation language has been used, such as WS-BPEL,
+ it will be possible to infer the behaviour of the service being implemented, to compare it against the choreography description.
+ </para>
+ <para>
+ Detecting incorrectly implemented behaviour at the earliest possible time saves on downstream costs associated with finding and fixing errors.
+ By using static validation against the original design, it ensures that the implemented service will deliver its expected behaviour first time.
+ This is important in building large scale SOAs where different services may be implemented in different locations.
+ </para>
+ <para>
+ There are two other areas where a choreography description can be used as part of design-time governance,
+ that are not currently implemented in SAVARA:
+ </para>
+ <itemizedlist>
+ <listitem>
+ Service lookup – the choreography description can be used to determine if a service already exists in the Service Repository that meets the appropriate behavioural requirements.
+ </listitem>
+ <listitem>
+ Service unit testing - this can be achieved using the scenarios originally specified to document the behavioural requirements.
+ Rather than develop an independent source of test data, the scenarios can be used to validate the sequence of messages sent to,
+ and received from, a service, as well as validating the contents of the messages returned from the service under test.
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Runtime Governance</title>
+ <para>
+ Runtime governance ensures that the SOA executes as expected according to predefined policies. In this context, a choreography description can be used in two ways.
+ </para>
+
+ <section>
+ <title> Service validator</title>
+ <para>
+ The choreography description represents the interactions between multiple services to deliver a business goal.
+ To validate the behaviour of each individual service, within the choreography description, the behaviour of each service can be derived from the choreography.
+ </para>
+ <para>
+ The derived behaviour (or “endpoint projection”) of a service can be used within a 'service validator' to monitor the inbound and outbound messages for the service,
+ to ensure they conform to the expected behaviour.
+ If an invalid message is detected, it would be possible to block it, to prevent it from causing subsequent problems in downstream systems.
+ The error can also be reported to a central management capability.
+ </para>
+ <para>
+ The SAVARA Validator provides the ability to configure service validators to monitor the behaviour of individual services.
+ An enhanced version of the JBossESB trailblazer example has been included, with the appropriate validator configuration, to demonstrate this mechanism.
+ </para>
+ </section>
+
+ <section>
+ <title>Process correlation</title>
+ <para>
+ Validating each service locally can enable errors to be detected quickly,
+ and the effects of the error prevented from contaminating other systems by blocking the erroneous messages.
+ </para>
+ <para>
+ However local service specific validation may not be adequate to identify errors that would affect the end-to-end business process.
+ Therefore the message activity at each service validator can be reported to a central 'process correlation engine' which can reconstitute a global view of the business transaction,
+ and determine if it matches the expected behaviour as defined in the choreography description.
+ </para>
+ <para>
+ The benefit of a correlated global view of the distributed business transaction is that it can be further analysed to ensure other governance polices have been followed – e.g. SLAs.
+ </para>
+ <para>
+ The pi4soa tool suite includes a simple GUI based monitoring tool to display the information obtained from correlating message events associated with individual services.
+ The trailblazer example has been written to cause out of sequence messages under certain circumstances. See the “Samples Guide” for more information on how to run this example.
+ </para>
+ </section>
+ </section>
+ </section>
+
+ <section>
+ <title> First Steps </title>
+ <para>The first step will be to follow the instructions in the Getting Started Guide to install SAVARA. </para>
+ <para> Once installed, the next step should be to try out the examples in the samples folder. The examples consistent of:</para>
+ <itemizedlist>
+ <listitem>
+ Choreography related examples
+ <para>
+ These examples provide an illustration of how to use scenarios, choreographies
+ and other associated artifacts.
+ </para>
+ </listitem>
+ <listitem>
+ Service Validation related examples
+ <para>
+ The samples folder contains an enhanced version of the trailblazer example from the
+ JBossESB, with the addition of a File Based Bank, and message content including a
+ conversation id to enable the messages to be correlated with a specific session.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </section>
+</chapter>
Added: trunk/docs/userguide/src/main/en-US/xslt/pdf.xsl
===================================================================
--- trunk/docs/userguide/src/main/en-US/xslt/pdf.xsl (rev 0)
+++ trunk/docs/userguide/src/main/en-US/xslt/pdf.xsl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ version="1.0">
+
+ <xsl:import href="http://docbook.sourceforge.net/release/xsl/1.72.0/fo/docbook.xsl" />
+ <xsl:import href="classpath:/xslt/org/jboss/pdf.xsl" />
+
+ <!-- Override the default font settings -->
+ <xsl:param name="body.font.family" select="'Times New Roman, serif'" />
+ <xsl:param name="monospace.font.family" select="'DejaVu Sans Mono, monospace'" />
+ <xsl:param name="sans.font.family" select="'Arial, sans-serif'" />
+ <xsl:param name="title.font.family" select="$body.font.family" />
+ <xsl:param name="programlisting.font" select="$monospace.font.family" />
+ <xsl:param name="programlisting.font.size" select="'75%'" />
+
+ <!-- Remove the blank pages between the chapters -->
+ <xsl:param name="double.sided" select="0" />
+
+ <!-- Use SVG for callout images instead of PNG -->
+ <xsl:param name="callout.graphics" select="1" />
+ <xsl:param name="callout.graphics.extension" select="'.svg'" />
+
+ <!-- Hide URL -->
+ <xsl:param name="ulink.show" select="0"/>
+
+ <!-- Don't use italic font for links -->
+ <xsl:attribute-set name="xref.properties">
+ <xsl:attribute name="font-style">normal</xsl:attribute>
+ </xsl:attribute-set>
+
+ <!-- Decrease the link font size in the program listing -->
+ <xsl:attribute-set name="monospace.properties">
+ <xsl:attribute name="font-size">1em</xsl:attribute>
+ <xsl:attribute name="font-family">
+ <xsl:value-of select="$monospace.font.family"/>
+ </xsl:attribute>
+ </xsl:attribute-set>
+
+ <!-- Add some spacing between callout listing items -->
+ <xsl:template match="callout">
+ <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+ <fo:list-item id="{$id}" space-before="1em">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>
+ <xsl:call-template name="callout.arearefs">
+ <xsl:with-param name="arearefs" select="@arearefs"/>
+ </xsl:call-template>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block padding-top="0.2em">
+ <xsl:apply-templates/>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </xsl:template>
+
+ <!-- Slight baseline-shift for callouts in the program listing -->
+ <xsl:template name="callout-bug">
+ <xsl:param name="conum" select='1'/>
+ <xsl:choose>
+ <xsl:when test="$conum <= $callout.graphics.number.limit">
+ <xsl:variable name="filename"
+ select="concat($callout.graphics.path, $conum,
+ $callout.graphics.extension)"/>
+
+ <fo:external-graphic content-width="{$callout.icon.size}"
+ width="{$callout.icon.size}"
+ padding="0.0em" margin="0.0em"
+ baseline-shift="-0.375em">
+ <xsl:attribute name="src">
+ <xsl:choose>
+ <xsl:when test="$passivetex.extensions != 0
+ or $fop.extensions != 0
+ or $arbortext.extensions != 0">
+ <xsl:value-of select="$filename"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>url(</xsl:text>
+ <xsl:value-of select="$filename"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </fo:external-graphic>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+</xsl:stylesheet>
+
Added: trunk/pom.xml
===================================================================
--- trunk/pom.xml (rev 0)
+++ trunk/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,158 @@
+<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</groupId>
+ <artifactId>savara</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Savara</name>
+ <url>http://www.savara.org</url>
+ <description>
+ The SAVARA project
+ </description>
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/savara</connection>
+ </scm>
+ <developers>
+ <developer>
+ <name>Jeff Yu</name>
+ <id>jeff.yuchang</id>
+ <email>cyu at redhat.com</email>
+ <organization>Red Hat</organization>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ <timezone>+8</timezone>
+ </developer>
+ <developer>
+ <name>Gary Brown</name>
+ <id>objectiser</id>
+ <email>gbrown at redhat.com</email>
+ <organization>Red Hat</organization>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ <timezone>+1</timezone>
+ </developer>
+ </developers>
+
+ <properties>
+ <savara.version>1.2.0-SNAPSHOT</savara.version>
+ <pi4soa.version>3.1.0.Final</pi4soa.version>
+ <junit.version>4.4</junit.version>
+ <rosetta.version>4.7</rosetta.version>
+ <log4j.version>1.2.14</log4j.version>
+ <mvel.version>1.3.4-java1.5</mvel.version>
+ <jaxb.version>2.1</jaxb.version>
+ <jboss.version>5.1.0.GA</jboss.version>
+ <jbossws.version>3.2.2.GA</jbossws.version>
+ </properties>
+
+ <modules>
+ <module>validators</module>
+ <module>bundles</module>
+ <module>docs</module>
+ <module>distribution</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>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <aggregate>true</aggregate>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <!-- Specify the compiler options and settings -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <showDeprecation>false</showDeprecation>
+ <showWarnings>false</showWarnings>
+ </configuration>
+ </plugin>
+ <!-- Produce source jars during the 'verify' phase -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*TestCase.java</include>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <repositories>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public/</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <!-- No need for distribution details as there are no artifacts to publish
+ <distributionManagement>
+ <repository>
+ <id>jboss-releases-repository</id>
+ <name>JBoss Releases Repository</name>
+ <url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</url>
+ </repository>
+ <snapshotRepository>
+ <id>jboss-snapshots-repository</id>
+ <name>JBoss Snapshots Repository</name>
+ <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
+ </snapshotRepository>
+ </distributionManagement>
+ -->
+
+</project>
Added: trunk/samples/jbossesb/trailblazer/banks/JBoss ESB Loan Broker Banks Guide.html
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/JBoss ESB Loan Broker Banks Guide.html (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/JBoss ESB Loan Broker Banks Guide.html 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,489 @@
+<html xmlns:o="urn:schemas-microsoft-com:office:office"
+xmlns:w="urn:schemas-microsoft-com:office:word"
+xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
+xmlns="http://www.w3.org/TR/REC-html40">
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
+<meta name=ProgId content=Word.Document>
+<meta name=Generator content="Microsoft Word 11">
+<meta name=Originator content="Microsoft Word 11">
+<link rel=File-List
+href="JBoss%20ESB%20Loan%20Broker%20Banks%20Guide_files/filelist.xml">
+<title>BANKS FOR THE LOANBROKER DEMO</title>
+<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
+ name="country-region"/>
+<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
+ name="Street"/>
+<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
+ name="address"/>
+<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
+ name="place"/>
+<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
+ name="City"/>
+<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
+ name="State"/>
+<!--[if gte mso 9]><xml>
+ <o:DocumentProperties>
+ <o:Author>kstam</o:Author>
+ <o:LastAuthor>kstam</o:LastAuthor>
+ <o:Revision>2</o:Revision>
+ <o:TotalTime>7</o:TotalTime>
+ <o:Created>2006-08-03T14:42:00Z</o:Created>
+ <o:LastSaved>2006-08-03T14:42:00Z</o:LastSaved>
+ <o:Pages>1</o:Pages>
+ <o:Words>743</o:Words>
+ <o:Characters>4237</o:Characters>
+ <o:Company>JBoss, Inc.</o:Company>
+ <o:Lines>35</o:Lines>
+ <o:Paragraphs>9</o:Paragraphs>
+ <o:CharactersWithSpaces>4971</o:CharactersWithSpaces>
+ <o:Version>11.6568</o:Version>
+ </o:DocumentProperties>
+</xml><![endif]--><!--[if gte mso 9]><xml>
+ <w:WordDocument>
+ <w:SpellingState>Clean</w:SpellingState>
+ <w:GrammarState>Clean</w:GrammarState>
+ <w:PunctuationKerning/>
+ <w:ValidateAgainstSchemas/>
+ <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
+ <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
+ <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
+ <w:Compatibility>
+ <w:BreakWrappedTables/>
+ <w:SnapToGridInCell/>
+ <w:WrapTextWithPunct/>
+ <w:UseAsianBreakRules/>
+ <w:DontGrowAutofit/>
+ </w:Compatibility>
+ <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
+ </w:WordDocument>
+</xml><![endif]--><!--[if gte mso 9]><xml>
+ <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
+ </w:LatentStyles>
+</xml><![endif]--><!--[if !mso]><object
+ classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object>
+<style>
+st1\:*{behavior:url(#ieooui) }
+</style>
+<![endif]-->
+<style>
+<!--
+ /* Style Definitions */
+ p.MsoNormal, li.MsoNormal, div.MsoNormal
+ {mso-style-parent:"";
+ margin:0in;
+ margin-bottom:.0001pt;
+ mso-pagination:widow-orphan;
+ font-size:12.0pt;
+ font-family:"Times New Roman";
+ mso-fareast-font-family:"Times New Roman";}
+h1
+ {mso-style-link:"Heading 1 Char";
+ mso-style-next:Normal;
+ margin-top:12.0pt;
+ margin-right:0in;
+ margin-bottom:3.0pt;
+ margin-left:0in;
+ mso-pagination:widow-orphan;
+ page-break-after:avoid;
+ mso-outline-level:1;
+ font-size:16.0pt;
+ font-family:Arial;
+ mso-font-kerning:16.0pt;}
+h2
+ {mso-style-next:Normal;
+ margin-top:12.0pt;
+ margin-right:0in;
+ margin-bottom:3.0pt;
+ margin-left:0in;
+ mso-pagination:widow-orphan;
+ page-break-after:avoid;
+ mso-outline-level:2;
+ font-size:14.0pt;
+ font-family:Arial;
+ font-style:italic;}
+h3
+ {mso-style-next:Normal;
+ margin-top:12.0pt;
+ margin-right:0in;
+ margin-bottom:3.0pt;
+ margin-left:0in;
+ mso-pagination:widow-orphan;
+ page-break-after:avoid;
+ mso-outline-level:3;
+ font-size:13.0pt;
+ font-family:Arial;}
+a:link, span.MsoHyperlink
+ {color:blue;
+ text-decoration:underline;
+ text-underline:single;}
+a:visited, span.MsoHyperlinkFollowed
+ {color:purple;
+ text-decoration:underline;
+ text-underline:single;}
+span.Heading1Char
+ {mso-style-name:"Heading 1 Char";
+ mso-style-locked:yes;
+ mso-style-link:"Heading 1";
+ mso-ansi-font-size:16.0pt;
+ mso-bidi-font-size:16.0pt;
+ font-family:Arial;
+ mso-ascii-font-family:Arial;
+ mso-hansi-font-family:Arial;
+ mso-bidi-font-family:Arial;
+ mso-font-kerning:16.0pt;
+ mso-ansi-language:EN-US;
+ mso-fareast-language:EN-US;
+ mso-bidi-language:AR-SA;
+ font-weight:bold;}
+span.SpellE
+ {mso-style-name:"";
+ mso-spl-e:yes;}
+span.GramE
+ {mso-style-name:"";
+ mso-gram-e:yes;}
+ at page Section1
+ {size:8.5in 11.0in;
+ margin:1.0in 1.25in 1.0in 1.25in;
+ mso-header-margin:.5in;
+ mso-footer-margin:.5in;
+ mso-paper-source:0;}
+div.Section1
+ {page:Section1;}
+-->
+</style>
+<!--[if gte mso 10]>
+<style>
+ /* Style Definitions */
+ table.MsoNormalTable
+ {mso-style-name:"Table Normal";
+ mso-tstyle-rowband-size:0;
+ mso-tstyle-colband-size:0;
+ mso-style-noshow:yes;
+ mso-style-parent:"";
+ mso-padding-alt:0in 5.4pt 0in 5.4pt;
+ mso-para-margin:0in;
+ mso-para-margin-bottom:.0001pt;
+ mso-pagination:widow-orphan;
+ font-size:10.0pt;
+ font-family:"Times New Roman";
+ mso-ansi-language:#0400;
+ mso-fareast-language:#0400;
+ mso-bidi-language:#0400;}
+</style>
+<![endif]-->
+</head>
+
+<body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
+
+<div class=Section1>
+
+<h1>JBoss ESB Loan Broker Banks Guide</h1>
+
+<p class=MsoNormal><o:p> </o:p></p>
+
+<p class=MsoNormal>By: Kurt Stam (<a href="mailto:kurt.stam at jboss.com">kurt.stam at jboss.com</a>)</p>
+
+<p class=MsoNormal><o:p> </o:p></p>
+
+<p class=MsoNormal>JBoss ESB JBoss Labs Home Page: <a
+href="http://labs.jboss.com/portal/jbossesb">http://labs.jboss.com/portal/jbossesb</a></p>
+
+<p class=MsoNormal><o:p> </o:p></p>
+
+<p class=MsoNormal>JBoss ESB Developer Community Forums: <a
+href="http://www.jboss.com/index.html?module=bb&op=viewforum&f=220">http://www.jboss.com/index.html?module=bb&op=viewforum&f=220</a></p>
+
+<p class=MsoNormal><o:p> </o:p></p>
+
+<p class=MsoNormal>########################################################################</p>
+
+<p class=MsoNormal># JBoss, Home of Professional Open Source</p>
+
+<p class=MsoNormal># Copyright 2006, JBoss Inc., and individual contributors as
+indicated</p>
+
+<p class=MsoNormal># <span class=GramE>by</span> the @authors tag. See the
+copyright.txt in the distribution for a</p>
+
+<p class=MsoNormal># <span class=GramE>full</span> listing of individual
+contributors.</p>
+
+<p class=MsoNormal>#</p>
+
+<p class=MsoNormal># <span class=GramE>This</span> is free software; you can
+redistribute it and/or modify it</p>
+
+<p class=MsoNormal># <span class=GramE>under</span> the terms of the GNU Lesser
+General Public License as</p>
+
+<p class=MsoNormal># published by the Free Software Foundation; either version
+2.1 of</p>
+
+<p class=MsoNormal># <span class=GramE>the</span> License, or (at your option)
+any later version.</p>
+
+<p class=MsoNormal>#</p>
+
+<p class=MsoNormal># <span class=GramE>This</span> software is distributed in
+the hope that it will be useful,</p>
+
+<p class=MsoNormal># <span class=GramE>but</span> WITHOUT ANY WARRANTY; without
+even the implied warranty of</p>
+
+<p class=MsoNormal><span class=GramE># MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE.</span> See the GNU</p>
+
+<p class=MsoNormal><span class=GramE># Lesser General Public License for more
+details.</span></p>
+
+<p class=MsoNormal>#</p>
+
+<p class=MsoNormal># <span class=GramE>You</span> should have received a copy
+of the GNU Lesser General Public</p>
+
+<p class=MsoNormal># License along with this software; if not, write to the
+Free</p>
+
+<p class=MsoNormal># Software Foundation, Inc., <st1:Street w:st="on"><st1:address
+ w:st="on">51 Franklin St</st1:address></st1:Street>, Fifth Floor, <st1:place
+w:st="on"><st1:City w:st="on">Boston</st1:City>, <st1:State w:st="on">MA</st1:State></st1:place></p>
+
+<p class=MsoNormal># 02110-1301 <st1:place w:st="on"><st1:country-region w:st="on">USA</st1:country-region></st1:place>,
+or see the FSF site: http://www.fsf.org.</p>
+
+<p class=MsoNormal>########################################################################</p>
+
+<p class=MsoNormal><b><span style='font-size:16.0pt;font-family:Arial;
+background:white;mso-highlight:white;mso-font-kerning:16.0pt'><o:p> </o:p></span></b></p>
+
+<p class=MsoNormal><b><span style='font-size:16.0pt;font-family:Arial;
+background:white;mso-highlight:white;mso-font-kerning:16.0pt'><o:p> </o:p></span></b></p>
+
+<b><span style='font-size:16.0pt;font-family:Arial;mso-fareast-font-family:
+"Times New Roman";background:white;mso-highlight:white;mso-font-kerning:16.0pt;
+mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><br
+clear=all style='page-break-before:always'>
+</span></b>
+
+<p class=MsoNormal><span class=Heading1Char><span style='font-size:16.0pt;
+background:white;mso-highlight:white'>1. Introduction</span></span><span
+class=Heading1Char><span style='font-size:16.0pt'><o:p></o:p></span></span></p>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>As part
+of the Loan Broker Demo, the broker goes out to a few banks to obtain loan
+quotes.</span></p>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>This
+folder contains two banks:</span></p>
+
+<p class=MsoNormal><o:p> </o:p></p>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>1. <span
+class=GramE>a</span> Flat File Based Bank, and</span></p>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>2. <span
+class=GramE>a</span> JMS Based bank.</span></p>
+
+<p class=MsoNormal><o:p> </o:p></p>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>To make
+the demo a little more interesting we have the banks use two different
+protocols (flat file and JMS), and two</span> <span style='background:white;
+mso-highlight:white'>different message formats (<span class=SpellE>csv</span>,
+xml). You can customize some of the configuration in the <span class=SpellE>bank.properties</span>
+file. Not that</span> <span style='background:white;mso-highlight:white'>the
+banks use to log4j.xml in the current directory. </span></p>
+
+<h2><span style='background:white;mso-highlight:white'>2. Flat File Based Bank</span></h2>
+
+<h3><span style='background:white;mso-highlight:white'>2.1 Starting the bank</span></h3>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>The Flat
+File Based Bank uses the property '<span class=SpellE>file.monitored.directory</span>'
+which by default is set to 'C<span class=GramE>:\</span>Temp\<span
+class=SpellE>BankInput</span>'.</span> <span style='background:white;
+mso-highlight:white'>You can start this bank by typing:</span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+class=GramE><span style='font-size:10.0pt;font-family:"Courier New";background:
+white;mso-highlight:white'>ant</span></span><span style='font-size:10.0pt;
+font-family:"Courier New";background:white;mso-highlight:white'> <span
+class=SpellE>runFileBank</span></span><span style='font-size:10.0pt;font-family:
+"Courier New"'><o:p></o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New"'>* Not of caution, there is
+no filter set in the <span class=SpellE>poller</span> code, so it will pick up
+and try to move any files it finds.<o:p></o:p></span></p>
+
+<h3><span style='background:white;mso-highlight:white'>2.2 Processing details</span></h3>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>The <span
+class=SpellE>FlatFilePollManager</span> monitors a directory specified in the
+configuration. When a file arrives it</span> <span style='background:white;
+mso-highlight:white'>tries to process the content assuming it contains one line
+with loan request information.</span> <span style='background:white;mso-highlight:
+white'>So for example the content of the file could read something like </span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New";background:white;mso-highlight:
+white'><o:p> </o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New";background:white;mso-highlight:
+white'>23456890<span class=GramE>,3,4,20000,5</span></span><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>The order
+of values needs to be <span class=SpellE>SocialSecurityNumber</span>, <span
+class=SpellE>CreditScore</span>, <span class=SpellE>HistoryLength</span>
+[month], <span class=SpellE>LoanAmount</span> [dollar],</span> <span
+style='background:white;mso-highlight:white'>and finally the <span
+class=SpellE>LoanTerm</span> [month]. The request will be processed and a <span
+class=SpellE>BankQouteReply</span> is generated. The</span> <span
+style='background:white;mso-highlight:white'>original file is moved to a
+'processed' directory, and the <span class=SpellE>BankQuoteReply</span> is
+serialized to an 'outgoing' directory from <span class=GramE>the it</span> can
+be picked up by the system that dropped the request.</span></p>
+
+<h3><span style='background:white;mso-highlight:white'>2.3 Testing</span></h3>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>You can
+test whether or not the bank is working by dropping a file in the monitored
+directory (C:\Temp\BankInput).Let's say we</span> <span style='background:white;
+mso-highlight:white'>use a file with name 'request.txt'. The file should be
+ASCII and can contain the following line:</span></p>
+
+<p class=MsoNormal><o:p> </o:p></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New";background:white;mso-highlight:
+white'>23456890<span class=GramE>,3,4,20000,5</span></span><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>The file
+should get moved to the C:\Temp\BankInput\processed directory, and in the
+C:\Temp\ <span class=SpellE>BankInput</span>\outgoing directory a reply file
+should</span> <span style='background:white;mso-highlight:white'>appear with
+the name 'reply_to_request.txt'. It should contain the line:</span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New";background:white;mso-highlight:
+white'>8.29<span class=GramE>,FileBasedBank</span>-1,0</span><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
+
+<p class=MsoNormal><span class=GramE><span style='background:white;mso-highlight:
+white'>which</span></span><span style='background:white;mso-highlight:white'>
+means the </span><span class=SpellE><span style='font-size:10.0pt;mso-bidi-font-size:
+12.0pt;font-family:"Courier New";mso-bidi-font-family:"Times New Roman";
+background:white;mso-highlight:white'>QuoteId</span></span><span
+style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:"Courier New";
+mso-bidi-font-family:"Times New Roman";background:white;mso-highlight:white'>=FileBasedBank-1</span><span
+style='background:white;mso-highlight:white'>, the </span><span
+style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:"Courier New";
+mso-bidi-font-family:"Times New Roman";background:white;mso-highlight:white'>interest=8.29</span><span
+style='background:white;mso-highlight:white'> and the </span><span
+class=SpellE><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
+font-family:"Courier New";mso-bidi-font-family:"Times New Roman";background:
+white;mso-highlight:white'>errorCode</span></span><span style='font-size:10.0pt;
+mso-bidi-font-size:12.0pt;font-family:"Courier New";mso-bidi-font-family:"Times New Roman";
+background:white;mso-highlight:white'>=0</span><span style='background:white;
+mso-highlight:white'> (which means success). You can check the logging for</span>
+<span style='background:white;mso-highlight:white'>additional details.</span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
+
+<h2><span style='background:white;mso-highlight:white'>3. JMS Based Bank</span></h2>
+
+<h3><span style='background:white;mso-highlight:white'>3.1 Starting the bank</span></h3>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>Before
+starting the bank you need to bring up your JMS provider. For the example this
+is the JBoss AS. We are using</span> <span style='background:white;mso-highlight:
+white'>the default queues (C and D). The JMS bank uses the properties: <span
+class=SpellE>jms.provider.url</span>, <span class=SpellE>jms.queue.in</span>
+and <span class=SpellE>jms.queue.out</span>. By</span> <span style='background:
+white;mso-highlight:white'>default these are set to '<span class=SpellE>localhost</span>',
+'queue/C' and 'queue/D'. So, by default, it assumes <st1:place w:st="on"><st1:City
+ w:st="on">JBoss</st1:City> <st1:State w:st="on">AS</st1:State></st1:place> is
+running on the <span class=SpellE>localhost</span>.</span> <span
+style='background:white;mso-highlight:white'>Next you can start the JMS Based
+bank by typing:</span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+class=GramE><span style='font-size:10.0pt;font-family:"Courier New";background:
+white;mso-highlight:white'>ant</span></span><span style='font-size:10.0pt;
+font-family:"Courier New";background:white;mso-highlight:white'> <span
+class=SpellE>runJMSBank</span></span><span style='font-size:10.0pt;font-family:
+"Courier New"'><o:p></o:p></span></p>
+
+<h3><span style='background:white;mso-highlight:white'>3.2 Processing details</span></h3>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>The <span
+class=SpellE>JMSManager</span> listens to an incoming queue (by default queue/C
+on <span class=SpellE>localhost</span>). It consumes the</span> <span
+style='background:white;mso-highlight:white'>message assuming it is a <span
+class=SpellE>TextMessage</span>, and that the text is an XML structure that can
+be marshaled</span> <span style='background:white;mso-highlight:white'>into a <span
+class=SpellE>BankQuoteRequest</span>. The request will be processed and a <span
+class=SpellE>BankQuote</span> Reply will be serialized to XML</span> <span
+style='background:white;mso-highlight:white'>and send to the outgoing queue (by
+default this is queue/D on <span class=SpellE>localhost</span>). If the
+processing results</span> <span style='background:white;mso-highlight:white'>in
+an error a <span class=SpellE>BankQuoteReply</span> with <span class=SpellE>ErrorCode</span>
+other then 0 is send to the outgoing queue.</span></p>
+
+<h3><span style='background:white;mso-highlight:white'>3.3 Testing</span></h3>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>The unit
+test <span class=SpellE>JMSProcessorTest</span> drops a <span class=SpellE>BankQuoteRequest</span>
+Message on the queue/C of <span class=SpellE>localhost</span>. You can use</span></p>
+
+<p class=MsoNormal><span class=GramE><span style='background:white;mso-highlight:
+white'>this</span></span><span style='background:white;mso-highlight:white'>
+test to check the health of the <span class=SpellE>JMSBank</span>. The tests
+can be executed by typing</span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span
+class=GramE><span style='font-size:10.0pt;font-family:"Courier New";background:
+white;mso-highlight:white'>ant</span></span><span style='font-size:10.0pt;
+font-family:"Courier New";background:white;mso-highlight:white'> test</span><span
+style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>
+
+<h1><span style='background:white;mso-highlight:white'>4. Finally</span></h1>
+
+<p class=MsoNormal><span style='background:white;mso-highlight:white'>You are
+now ready to run the larger Load Broker Demo itself.</span></p>
+
+</div>
+
+</body>
+
+</html>
Added: trunk/samples/jbossesb/trailblazer/banks/JBoss ESB Loan Broker Banks Guide.odt
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/banks/JBoss ESB Loan Broker Banks Guide.odt
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/banks/build.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/build.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/build.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,134 @@
+<project name="BANKS" default="compile" basedir=".">
+
+ <property file="../trailblazer.properties"/>
+ <property name="install.dir" value="../../../../install"/>
+ <property file="${install.dir}/deployment.properties"/>
+ <property name="org.jboss.as.server" value="${org.jboss.as.home}/server/${org.jboss.as.config}" />
+ <property name="org.jboss.as.deploy.dir" value="${org.jboss.as.server}/deploy" />
+
+ <!-- Some default build locations -->
+
+ <property name="org.jboss.esb.samples.loanbroker.banks.dest" value="${basedir}/build"/>
+ <property name="org.jboss.esb.samples.loanbroker.banks.classes.dir" value="${basedir}/build/classes/banks/"/>
+ <property name="org.jboss.esb.samples.loanbroker.banks.testclasses.dir" value="${basedir}/build/classes/tests/"/>
+ <property name="org.jboss.esb.samples.loanbroker.banks.src.dir" value="${basedir}/src"/>
+ <property name="org.jboss.esb.samples.loanbroker.banks.test.dir" value="${basedir}/test"/>
+ <property name="org.jboss.esb.samples.loanbroker.banks.jar.dest" value="${basedir}/build/dist/lib/"/>
+ <property name="org.jboss.esb.samples.loanbroker.banks.lib.ext.dir" value="${basedir}/lib/ext"/>
+ <property name="org.jboss.esb.samples.loanbroker.banks.tests.report.dir" value="${basedir}/build/tests"/>
+
+ <path id="org.jboss.esb.samples.loanbroker.banks.classpath">
+ <fileset dir="${org.jboss.as.home}/client" includes="jboss-remoting.jar jboss-javaee.jar jboss-messaging-client.jar jboss-aop-client.jar jboss-mdr.jar" /> <!-- Required for JMS Client Code. -->
+ <fileset dir="${org.jboss.as.server}/lib" includes="hibernate3.jar commons-collections.jar hsqldb.jar" /> <!-- Required for jbpm Client Code. -->
+ <fileset dir="${org.jboss.as.server}/lib" includes="bsh.jar" /> <!-- Required for scripting Client Code. -->
+ <fileset dir="${org.jboss.as.home}/lib/endorsed" includes="*.jar" /> <!-- Required for JMS Client Code. -->
+ <!-- fileset dir="${org.jboss.as.deploy.dir}/jboss-aop-jdk50.deployer" includes="jboss-aop-jdk50.jar" / --> <!-- Required for JMS Client Code. -->
+ <fileset dir="${org.jboss.esb.samples.loanbroker.banks.lib.ext.dir}" includes="*.jar"/>
+ </path>
+ <path id="org.jboss.esb.samples.loanbroker.banks.testclasspath">
+ <fileset dir="${org.jboss.as.home}/client" includes="jboss-remoting.jar jboss-javaee.jar jboss-messaging-client.jar jboss-aop-client.jar jboss-mdr.jar" /> <!-- Required for JMS Client Code. -->
+ <fileset dir="${org.jboss.as.home}/lib/endorsed" includes="*.jar" /> <!-- Required for JMS Client Code. -->
+ <!-- fileset dir="${org.jboss.as.deploy.dir}/jboss-aop-jdk50.deployer" includes="jboss-aop-jdk50.jar" / --> <!-- Required for JMS Client Code. -->
+ <fileset dir="${org.jboss.esb.samples.loanbroker.banks.lib.ext.dir}" includes="*.jar"/>
+ <pathelement location="${org.jboss.esb.samples.loanbroker.banks.classes.dir}"/>
+ <pathelement location="${org.jboss.esb.samples.loanbroker.banks.testclasses.dir}"/>
+ <pathelement location="."/>
+ </path>
+
+ <target name="clean">
+ <delete dir="${org.jboss.esb.samples.loanbroker.banks.dest}" />
+ </target>
+ <!-- =================================================================== -->
+ <!-- Prepares the directory structure -->
+ <!-- =================================================================== -->
+ <target name="org.jboss.esb.samples.loanbroker.banks.prepare">
+ <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}"/>
+ <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}/dist"/>
+ <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}/classes/banks"/>
+ <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}/classes/tests"/>
+ <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}/tests"/>
+ <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}/dist/lib"/>
+ </target>
+
+ <!-- Compilation targets -->
+ <target name="org.jboss.esb.samples.loanbroker.banks.compile" depends="org.jboss.esb.samples.loanbroker.banks.prepare"
+ description="Compile all classes">
+
+ <javac
+ destdir="${org.jboss.esb.samples.loanbroker.banks.classes.dir}"
+ classpathref="org.jboss.esb.samples.loanbroker.banks.classpath"
+ debug="true"
+ >
+ <src path="${org.jboss.esb.samples.loanbroker.banks.src.dir}"/>
+ </javac>
+ <javac
+ destdir="${org.jboss.esb.samples.loanbroker.banks.testclasses.dir}"
+ debug="true"
+ classpathref="org.jboss.esb.samples.loanbroker.banks.testclasspath"
+ >
+ <src path="${org.jboss.esb.samples.loanbroker.banks.test.dir}"/>
+ </javac>
+ </target>
+
+ <!-- javadocs paths -->
+ <path id="org.jboss.esb.samples.loanbroker.banks.javadocs.path">
+ <pathelement path="esb/classes"/>
+ </path>
+
+ <!-- Jar targets -->
+ <target name="org.jboss.esb.samples.loanbroker.banks.jar" depends="org.jboss.esb.samples.loanbroker.banks.compile">
+ <echo message="Building jar file"/>
+ <delete file="${org.jboss.esb.samples.loanbroker.banks.dest}/dist/lib/bank.jar" />
+ <jar destfile="${org.jboss.esb.samples.loanbroker.banks.dest}/dist/lib/bank.jar"
+ basedir="${org.jboss.esb.samples.loanbroker.banks.classes.dir}"
+ includes="**/*.class"
+ />
+ </target>
+
+ <target name="runJMSBank" depends="org.jboss.esb.samples.loanbroker.banks.jar">
+ <echo>Running JMS Based Bank</echo>
+ <echo>Note that your app-server on host: localhost needs to be up and running!</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.loanbroker.banks.ManagerJMS" failonerror="true">
+ <arg value="${jms.provider.url}"/>
+ <arg value="${jms.queue.in}"/>
+ <arg value="${jms.queue.out}"/>
+ <classpath refid="org.jboss.esb.samples.loanbroker.banks.testclasspath"/>
+ </java>
+ </target>
+
+ <target name="runFileBank" depends="org.jboss.esb.samples.loanbroker.banks.jar">
+ <echo>Running File Based Bank</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.loanbroker.banks.ManagerFlatFile" failonerror="true" >
+ <classpath refid="org.jboss.esb.samples.loanbroker.banks.testclasspath"/>
+ <arg value="${file.bank.monitored.dir}" />
+ <arg value="${file.output.directory}" />
+ </java>
+ </target>
+
+ <!-- Short target names -->
+ <target name="compile" depends="org.jboss.esb.samples.loanbroker.banks.compile"/>
+ <target name="test" depends="org.jboss.esb.samples.loanbroker.banks.test"/>
+ <target name="jar" depends="org.jboss.esb.samples.loanbroker.banks.jar"/>
+
+ <!-- ====================================================================== -->
+ <!-- U N I T T E S T S -->
+ <!-- ====================================================================== -->
+ <target name="org.jboss.esb.samples.loanbroker.banks.test" depends="org.jboss.esb.samples.loanbroker.banks.compile">
+ <echo message="Running tests for banks"/>
+ <junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true">
+ <formatter type="plain" usefile="false"/>
+ <formatter type="xml"/>
+ <batchtest todir="${org.jboss.esb.samples.loanbroker.banks.tests.report.dir}">
+ <fileset dir="${org.jboss.esb.samples.loanbroker.banks.test.dir}">
+ <include name="**/**Test.java"/>
+ </fileset>
+ </batchtest>
+ <classpath>
+ <!-- Need the tests src folder because there may be non-compiled test resources -->
+ <pathelement location="${org.jboss.esb.samples.loanbroker.banks.test.dir}"/>
+ <path refid="org.jboss.esb.samples.loanbroker.banks.testclasspath"/>
+ </classpath>
+ </junit>
+ </target>
+
+</project>
Added: trunk/samples/jbossesb/trailblazer/banks/lib/ext/Licenses.txt
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/lib/ext/Licenses.txt (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/lib/ext/Licenses.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,445 @@
+The jars in this directory are covered by a range of licences, as described
+below.
+
+JBoss jars:
+
+/*
+ *
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ */
+
+JUnit
+
+ Common Public License Version 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC
+LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
+CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are
+distributed by that particular Contributor. A Contribution 'originates' from a
+Contributor if it was added to the Program by such Contributor itself or anyone
+acting on such Contributor's behalf. Contributions do not include additions to
+the Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii) are not
+derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are
+necessarily infringed by the use or sale of its Contribution alone or when
+combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement,
+including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free copyright license to
+reproduce, prepare derivative works of, publicly display, publicly perform,
+distribute and sublicense the Contribution of such Contributor, if any, and such
+derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed
+Patents to make, use, sell, offer to sell, import and otherwise transfer the
+Contribution of such Contributor, if any, in source code and object code form.
+This patent license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor, such
+addition of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other combinations
+which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses
+to its Contributions set forth herein, no assurances are provided by any
+Contributor that the Program does not infringe the patent or other intellectual
+property rights of any other entity. Each Contributor disclaims any liability to
+Recipient for claims brought by any other entity based on infringement of
+intellectual property rights or otherwise. As a condition to exercising the
+rights and licenses granted hereunder, each Recipient hereby assumes sole
+responsibility to secure any other intellectual property rights needed, if any.
+For example, if a third party patent license is required to allow Recipient to
+distribute the Program, it is Recipient's responsibility to acquire that license
+before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright license set
+forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its
+own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and
+conditions, express and implied, including warranties or conditions of title and
+non-infringement, and implied warranties or conditions of merchantability and
+fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for
+damages, including direct, indirect, special, incidental and consequential
+damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered
+by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such
+Contributor, and informs licensees how to obtain it in a reasonable manner on or
+through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the
+Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if
+any, in a manner that reasonably allows subsequent Recipients to identify the
+originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with
+respect to end users, business partners and the like. While this license is
+intended to facilitate the commercial use of the Program, the Contributor who
+includes the Program in a commercial product offering should do so in a manner
+which does not create potential liability for other Contributors. Therefore, if
+a Contributor includes the Program in a commercial product offering, such
+Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
+every other Contributor ("Indemnified Contributor") against any losses, damages
+and costs (collectively "Losses") arising from claims, lawsuits and other legal
+actions brought by a third party against the Indemnified Contributor to the
+extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor to
+control, and cooperate with the Commercial Contributor in, the defense and any
+related settlement negotiations. The Indemnified Contributor may participate in
+any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product
+offering, Product X. That Contributor is then a Commercial Contributor. If that
+Commercial Contributor then makes performance claims, or offers warranties
+related to Product X, those performance claims and warranties are such
+Commercial Contributor's responsibility alone. Under this section, the
+Commercial Contributor would have to defend claims against the other
+Contributors related to those performance claims and warranties, and if a court
+requires any other Contributor to pay any damages as a result, the Commercial
+Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED 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. Each
+Recipient is solely responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its exercise of
+rights under this Agreement, including but not limited to the risks and costs of
+program errors, compliance with applicable laws, damage to or loss of data,
+programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
+CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
+GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable
+law, it shall not affect the validity or enforceability of the remainder of the
+terms of this Agreement, and without further action by the parties hereto, such
+provision shall be reformed to the minimum extent necessary to make such
+provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to
+a patent applicable to software (including a cross-claim or counterclaim in a
+lawsuit), then any patent licenses granted by that Contributor to such Recipient
+under this Agreement shall terminate as of the date such litigation is filed. In
+addition, if Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the Program
+itself (excluding combinations of the Program with other software or hardware)
+infringes such Recipient's patent(s), then such Recipient's rights granted under
+Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to
+comply with any of the material terms or conditions of this Agreement and does
+not cure such failure in a reasonable period of time after becoming aware of
+such noncompliance. If all Recipient's rights under this Agreement terminate,
+Recipient agrees to cease use and distribution of the Program as soon as
+reasonably practicable. However, Recipient's obligations under this Agreement
+and any licenses granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in
+order to avoid inconsistency the Agreement is copyrighted and may only be
+modified in the following manner. The Agreement Steward reserves the right to
+publish new versions (including revisions) of this Agreement from time to time.
+No one other than the Agreement Steward has the right to modify this Agreement.
+IBM is the initial Agreement Steward. IBM may assign the responsibility to serve
+as the Agreement Steward to a suitable separate entity. Each new version of the
+Agreement will be given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the Agreement
+under which it was received. In addition, after a new version of the Agreement
+is published, Contributor may elect to distribute the Program (including its
+Contributions) under the new version. Except as expressly stated in Sections
+2(a) and 2(b) above, Recipient receives no rights or licenses to the
+intellectual property of any Contributor under this Agreement, whether
+expressly, by implication, estoppel or otherwise. All rights in the Program not
+expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the
+intellectual property laws of the United States of America. No party to this
+Agreement will bring a legal action under this Agreement more than one year
+after the cause of action arose. Each party waives its rights to a jury trial in
+any resulting litigation.
+
+
+
+XStream, Antlr, Stingtemplate BSD License
+
+Copyright (c) 2003-2005, Joe Walnes
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of XStream nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+
+
+pollmgt.jar, org.sadun.util.jar
+
+GNU Lesser General Public License
+
+Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+
+ [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.]
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
+
+This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
+
+When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
+
+To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
+
+For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
+
+We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
+
+To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
+
+Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
+
+Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
+
+When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
+
+We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
+
+For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
+
+In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
+
+Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
+
+The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
+
+A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
+
+The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
+
+"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
+
+1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
+
+ These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+ Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
+
+ In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
+
+Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
+
+This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
+
+4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
+
+If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
+
+5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
+
+However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
+
+When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
+
+If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
+
+Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
+
+6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
+
+You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
+
+ a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
+
+For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
+
+7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
+
+ b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
+
+8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
+
+10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
+
+11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
+
+14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+END OF TERMS AND CONDITIONS
+How to Apply These Terms to Your New Libraries
+If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).
+
+To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and an idea of what it does.> Copyright (C) <year> <name of author>
+
+ This library 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 library 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 library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ signature of Ty Coon, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
Added: trunk/samples/jbossesb/trailblazer/banks/lib/ext/jbossall-client.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/banks/lib/ext/jbossall-client.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/banks/lib/ext/junit-4.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/banks/lib/ext/junit-4.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/banks/lib/ext/log4j.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/banks/lib/ext/log4j.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/banks/lib/ext/org.sadun.util.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/banks/lib/ext/org.sadun.util.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/banks/lib/ext/pollmgt.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/banks/lib/ext/pollmgt.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/banks/lib/ext/trove.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/banks/lib/ext/trove.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/banks/lib/ext/xstream-1.2.2.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/banks/lib/ext/xstream-1.2.2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/banks/log4j.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/log4j.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/log4j.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,287 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.5 2005/09/15 09:31:02 dimitris Exp $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="./banks.log"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- A size based file rolling appender
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ====================== -->
+ <!-- More Appender examples -->
+ <!-- ====================== -->
+
+ <!-- Buffer events and log them asynchronously
+ <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="SMTP"/>
+ </appender>
+ -->
+
+ <!-- EMail events to an administrator
+ <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="To" value="admin at myhost.domain.com"/>
+ <param name="From" value="nobody at myhost.domain.com"/>
+ <param name="Subject" value="JBoss Sever Errors"/>
+ <param name="SMTPHost" value="localhost"/>
+ <param name="BufferSize" value="10"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Syslog events
+ <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Facility" value="LOCAL7"/>
+ <param name="FacilityPrinting" value="true"/>
+ <param name="SyslogHost" value="localhost"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Log events to JMS (requires a topic to be created)
+ <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
+ <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
+ </appender>
+ -->
+
+ <!-- Log events through SNMP
+ <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="ImplementationClassName" value="org.apache.log4j.ext.JoeSNMPTrapSender"/>
+ <param name="ManagementHost" value="127.0.0.1"/>
+ <param name="ManagementHostTrapListenPort" value="162"/>
+ <param name="EnterpriseOID" value="1.3.6.1.4.1.24.0"/>
+ <param name="LocalIPAddress" value="127.0.0.1"/>
+ <param name="LocalTrapSendPort" value="161"/>
+ <param name="GenericTrapType" value="6"/>
+ <param name="SpecificTrapType" value="12345678"/>
+ <param name="CommunityString" value="public"/>
+ <param name="ForwardStackTraceWithTrap" value="true"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="ApplicationTrapOID" value="1.3.6.1.4.1.24.12.10.22.64"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Emit events as JMX notifications
+ <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+
+ <param name="Threshold" value="WARN"/>
+ <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
+ <category name="org.apache">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
+ <category name="org.jgroups">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit jboss axis to INFO as its DEBUG is even more verbose -->
+ <category name="org.jboss.axis">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit JBoss categories
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+ -->
+
+ <!-- Limit the JSR77 categories -->
+ <category name="org.jboss.management">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit JBoss webservice category
+ <category name="org.jboss.webservice">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!-- Decrease the priority threshold for the org.jboss.varia category
+ <category name="org.jboss.varia">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
+ <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <!--
+ | An example of enabling the custom TRACE level priority that is used
+ | by the JBoss internals to diagnose low level details. This example
+ | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
+ | subpackages. This will produce A LOT of logging output.
+ <category name="org.jboss.system">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ <category name="org.jboss.ejb.plugins">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <!--
+ | Logs these events to SNMP:
+ - server starts/stops
+ - cluster evolution (node death/startup)
+ - When an EJB archive is deployed (and associated verified messages)
+ - When an EAR archive is deployed
+
+ <category name="org.jboss.system.server.Server">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.MainDeployer">
+ <priority value="ERROR" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ejb.EJBDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.EARDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ -->
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+ <!-- Clustering logging -->
+ <!-- Uncomment the following to redirect the org.jgroups and
+ org.jboss.ha categories to a cluster.log file.
+
+ <appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.home.dir}/log/cluster.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ <category name="org.jgroups">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ <category name="org.jboss.ha">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ -->
+
+</log4j:configuration>
Added: trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/Bank.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/Bank.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/Bank.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,153 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.math.BigDecimal;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+/**
+ * This Bank is pretty well focussed on doing one thing, which is giving out loans. On the
+ * reception of a BankQuoteRequest it will compute the interest rate it will return
+ * in the BankQuoteReply.
+ *
+ * Each bank instance can be customized using the parameters bankName, RatePremium and MaxLoanTerm.
+ *
+ * @author kstam
+ *
+ */
+public class Bank
+{
+ private Logger logger = Logger.getLogger(this.getClass());
+
+ private static final BigDecimal PRIME_RATE = BigDecimal.valueOf(8.0);
+ private static final BigDecimal DEFAULT_RATE_PREMIUM = BigDecimal.valueOf(0.5);
+ private static final int DEFAULT_MAX_LOAN_TERM = 30;
+ private static final String DEFAULT_BANK_NAME = "DefaultBank";
+ private static int _quoteCounter = 0;
+
+ //Default values for bank
+ private String bankName = DEFAULT_BANK_NAME;
+ private BigDecimal ratePremium = DEFAULT_RATE_PREMIUM;
+ private int maxLoanTerm = DEFAULT_MAX_LOAN_TERM;
+
+ /**
+ * The Bank's constructor.
+ *
+ * @param bankName - the name of the bank
+ * @param ratePremium - the premium it charges for the loan
+ * @param maxLoanTerm - the maximum loan term
+ */
+ public Bank(String bankName, BigDecimal ratePremium, int maxLoanTerm) {
+ super();
+ if (bankName!=null) {
+ this.bankName=bankName;
+ }
+ if (ratePremium!=null) {
+ this.ratePremium=ratePremium;
+ }
+ if (maxLoanTerm > 0) {
+ this.maxLoanTerm=maxLoanTerm;
+ }
+ }
+ /**
+ * The bank computes the interest rate based on configuration parameters of the bank and
+ * the information in the {@link BankQuoteRequest.
+ * @param bankQuoteRequest - the bank quote request containing requests parameters
+ * @return bankQuoteReply - the bank quote replay contaning the interest rate
+ */
+ private BankQuoteReply computeBankQuoteReply(BankQuoteRequest bankQuoteRequest)
+ {
+ BankQuoteReply bankQuoteReply = new BankQuoteReply();
+ if (bankQuoteRequest.loanTerm <= maxLoanTerm) {
+ BigDecimal interestRate=BigDecimal.valueOf((bankQuoteRequest.loanTerm/12.0)/10.0);
+ interestRate=PRIME_RATE.add(ratePremium).add(interestRate);
+ bankQuoteReply.setInterestRate(interestRate.setScale(2, BigDecimal.ROUND_HALF_UP));
+ bankQuoteReply.setErrorCode(0);
+ } else {
+ bankQuoteReply.setInterestRate(BigDecimal.valueOf(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
+ bankQuoteReply.setErrorCode(1);
+ }
+ String quoteId=bankName + "-" + _quoteCounter++;
+ bankQuoteReply.setQuoteId(quoteId);
+ bankQuoteReply.setRef(bankQuoteRequest.getRef());
+ bankQuoteReply.setCustomerUID(bankQuoteRequest.getCustomerUID());
+ bankQuoteReply.setCustomerEmail(bankQuoteRequest.customerEmail);
+ return bankQuoteReply;
+ }
+ /**
+ * Processes the Loan Quote request and returns the banks reply.
+ *
+ * @param bankQuoteRequest - the bank quote request
+ * @return bankQuoteReply - the bank quote reply
+ */
+ protected BankQuoteReply processMessage(BankQuoteRequest bankQuoteRequest)
+ {
+ logger.log(Level.INFO, "Bank '" + bankName + "' received a request for SSN="
+ + bankQuoteRequest.getSsn()
+ + " for $" + bankQuoteRequest.loanAmount
+ + " over " + bankQuoteRequest.loanTerm + " months.");
+ logger.log(Level.DEBUG, bankQuoteRequest);
+
+ BankQuoteReply bankQuoteReply = computeBankQuoteReply(bankQuoteRequest);
+ logger.log(Level.INFO, "Bank '" + bankName + " offers SSN="
+ + bankQuoteRequest.getSsn() + " " + bankQuoteReply);
+
+ return bankQuoteReply;
+ }
+
+ protected BankQuoteRequest getQuoteFromXML(String xml) {
+ BankQuoteRequest quote = new BankQuoteRequest();
+
+ try {
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ java.io.InputStream xmlstr=
+ new java.io.ByteArrayInputStream(xml.getBytes());
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=builder.parse(xmlstr);
+
+ org.w3c.dom.Element tree = doc.getDocumentElement();
+
+ quote.setSsn(Integer.parseInt(tree.getAttribute("ssn")));
+ quote.setRef(tree.getAttribute("ref"));
+ quote.setCreditScore(Integer.parseInt(tree.getAttribute("creditScore")));
+ quote.setHistoryLength(Integer.parseInt(tree.getAttribute("creditHistoryLen")));
+ quote.setLoanAmount(Integer.parseInt(tree.getAttribute("amount")));
+ quote.setLoanTerm(Integer.parseInt(tree.getAttribute("term")));
+ quote.setCustomerUID(tree.getAttribute("customerUID"));
+ quote.customerEmail=tree.getAttribute("customerEmail");
+
+ } catch(Exception ex) {
+ logger.error(ex.getMessage(), ex);
+ }
+
+ return quote;
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReply.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReply.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReply.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,180 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+public class BankQuoteReply implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private BigDecimal interestRate;
+ private String quoteId;
+ private String ref;
+ private int errorCode;
+ private String customerUID;
+ private String customerEmail;
+ private String customerSSN;
+ private String customerName;
+ private String customerAddress;
+ private String customerSalary;
+ private String loanAmount;
+ private String loanDuration;
+
+ /**
+ * Gets the SerialVersionUID.
+ * @return serialVersionUID
+ */
+ public static long getSerialVersionUID() {
+ return serialVersionUID;
+ }
+ /**
+ * Gets the errorCode.
+ * <li>0 - success
+ * <li>1 - loan term exceeds the maximum available loan term
+ * <li>2 - invalid SSN
+ * <li>3 - invalid credit score
+ * <li>4 - invalid credit history length
+ * <li>5 - invalid loan term
+ * <li>6 - invalid message
+ * <li>7 - invalid customerUID
+ * @return errorCode
+ */
+ public int getErrorCode() {
+ return errorCode;
+ }
+ /**
+ * Sets the errorCode.
+ * <li>0 - success
+ * <li>1 - loan term exceeds the maximum available loan term
+ * <li>2 - invalid SSN
+ * <li>3 - invalid credit score
+ * <li>4 - invalid credit history length
+ * <li>5 - invalid loan term
+ * @param errorCode
+ */
+ public void setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ }
+ /**
+ * Gets the quoted interest rate.
+ * @return interestRate
+ */
+ public BigDecimal getInterestRate() {
+ return interestRate;
+ }
+ /**
+ * Sets the quoted interest rate.
+ * @param interestRate
+ */
+ public void setInterestRate(BigDecimal interestRate) {
+ this.interestRate = interestRate;
+ }
+ /**
+ * Gets the Quote ID.
+ * @return quoteId
+ */
+ public String getQuoteId() {
+ return quoteId;
+ }
+ /**
+ * Sets the quoteId.
+ * @param quoteId
+ */
+ public void setQuoteId(String quoteId) {
+ this.quoteId = quoteId;
+ }
+ /**
+ * Gets the ref.
+ * @return ref
+ */
+ public String getRef() {
+ return ref;
+ }
+ /**
+ * Sets the ref.
+ * @param ref
+ */
+ public void setRef(String ref) {
+ this.ref = ref;
+ }
+ /**
+ * Returns a human readable string representation of this object.
+ * @return toString
+ */
+ public String toString() {
+ return this.getClass().getSimpleName() + "=["
+ + "interestRate=" + interestRate
+ + ", quoteId=" + quoteId
+ + ", errorCode=" + errorCode
+ + ", customerUID=" + customerUID + "]";
+ }
+ public String getCustomerUID() {
+ return customerUID;
+ }
+ public void setCustomerUID(String customerUID) {
+ this.customerUID = customerUID;
+ }
+ public String getCustomerAddress() {
+ return customerAddress;
+ }
+ public void setCustomerAddress(String customerAddress) {
+ this.customerAddress = customerAddress;
+ }
+ public String getCustomerEmail() {
+ return customerEmail;
+ }
+ public void setCustomerEmail(String customerEmail) {
+ this.customerEmail = customerEmail;
+ }
+ public String getCustomerName() {
+ return customerName;
+ }
+ public void setCustomerName(String customerName) {
+ this.customerName = customerName;
+ }
+ public String getCustomerSalary() {
+ return customerSalary;
+ }
+ public void setCustomerSalary(String customerSalary) {
+ this.customerSalary = customerSalary;
+ }
+ public String getCustomerSSN() {
+ return customerSSN;
+ }
+ public void setCustomerSSN(String customerSSN) {
+ this.customerSSN = customerSSN;
+ }
+ public String getLoanAmount() {
+ return loanAmount;
+ }
+ public void setLoanAmount(String loanAmount) {
+ this.loanAmount = loanAmount;
+ }
+ public String getLoanDuration() {
+ return loanDuration;
+ }
+ public void setLoanDuration(String loanDuration) {
+ this.loanDuration = loanDuration;
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,149 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.io.Serializable;
+
+
+public class BankQuoteRequest implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+ public int ssn;
+ public String ref;
+ public int creditScore;
+ public int historyLength;
+ public int loanAmount;
+ public int loanTerm;
+ public String customerUID;
+ public String customerEmail;
+ public String customerSSN;
+ public String customerName;
+ public String customerAddress;
+ public String customerSalary;
+ public String loanDuration;
+
+ /**
+ * Gets for the credit score.
+ * @return credit score
+ */
+ public int getCreditScore() {
+ return creditScore;
+ }
+ /**
+ * Sets the credit score.
+ * @param creditScore
+ */
+ public void setCreditScore(int creditScore) {
+ this.creditScore = creditScore;
+ }
+ /**
+ * Gets the credit history length (in months).
+ * @return credit history length
+ */
+ public int getHistoryLength() {
+ return historyLength;
+ }
+ /**
+ * Sets the credit history length (in months).
+ * @param historyLength
+ */
+ public void setHistoryLength(int historyLength) {
+ this.historyLength = historyLength;
+ }
+ /**
+ * Gets the requested loan amount (in dollar).
+ * @return the loan amount
+ */
+ public int getLoanAmount() {
+ return loanAmount;
+ }
+ /**
+ * Sets the loan amount.
+ * @param loanAmount - the loan amount (in dollar).
+ */
+ public void setLoanAmount(int loanAmount) {
+ this.loanAmount = loanAmount;
+ }
+ /**
+ * Gets the duration of the loan, the term, (in months).
+ * @return loanTerm
+ */
+ public int getLoanTerm() {
+ return loanTerm;
+ }
+ /**
+ * Sets the term (duration) of the loan (in months)
+ * @param loanTerm
+ */
+ public void setLoanTerm(int loanTerm) {
+ this.loanTerm = loanTerm;
+ }
+ /**
+ * Sets the Social Security Number (SSN).
+ * @return ssn
+ */
+ public int getSsn() {
+ return ssn;
+ }
+ /**
+ * Sets the Social Security Number (SSN).
+ * @param ssn
+ */
+ public void setSsn(int ssn) {
+ this.ssn = ssn;
+ }
+ /**
+ * Gets the ref.
+ * @return ref
+ */
+ public String getRef() {
+ return ref;
+ }
+ /**
+ * Sets the ref.
+ * @param ref
+ */
+ public void setRef(String ref) {
+ this.ref = ref;
+ }
+ /**
+ * Returns a human readable string representation of this object.
+ * @return toString
+ */
+ public String toString() {
+ return this.getClass().getSimpleName() + "=["
+ + "ssn=" + ssn
+ + "ref=" + ref
+ + ", creditScore=" + creditScore
+ + ", historyLength=" + historyLength
+ + ", loanAmount=" + loanAmount
+ + ", loanTerm=" + loanTerm
+ + ", customerUID="+ customerUID + "]";
+ }
+
+ public String getCustomerUID() {
+ return customerUID;
+ }
+ public void setCustomerUID(String customerUID) {
+ this.customerUID = customerUID;
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FileUtil.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FileUtil.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FileUtil.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+/**
+ * Utility class for reading a file into a String and back.
+ * @author kstam
+ */
+public class FileUtil {
+ /**
+ * Read the file into a String.
+ * @param file - the file to be read
+ * @return String with the content of the file
+ * @throws IOException - when we can't read the file
+ */
+ public static String readTextFile(File file) throws IOException
+ {
+ StringBuffer sb = new StringBuffer(1024);
+ BufferedReader reader = new BufferedReader(new FileReader(file.getPath()));
+ char[] chars = new char[1];
+ while( (reader.read(chars)) > -1){
+ sb.append(String.valueOf(chars));
+ chars = new char[1];
+ }
+ reader.close();
+ return sb.toString();
+ }
+ /**
+ * Write a String into a file.
+ * @param file - File to which we write the String
+ * @param str - string which will be written
+ * @throws IOException - when we can't write to the file
+ */
+ public static void writeTextFile(File file, String str) throws IOException
+ {
+ BufferedWriter writer = new BufferedWriter(new FileWriter(file.getPath()));
+ writer.write(str);
+ writer.close();
+ }
+
+}
Added: trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,208 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.io.File;
+import java.math.BigDecimal;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.sadun.util.polling.BasePollManager;
+import org.sadun.util.polling.CycleEndEvent;
+import org.sadun.util.polling.CycleStartEvent;
+import org.sadun.util.polling.DirectoryLookupEndEvent;
+import org.sadun.util.polling.DirectoryLookupStartEvent;
+import org.sadun.util.polling.DirectoryPoller;
+import org.sadun.util.polling.FileFoundEvent;
+import org.sadun.util.polling.FileSetFoundEvent;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.DomDriver;
+
+/**
+ * The FlatFilePollManager monitors a directory specified in the configuration. When a file arrives it
+ * tries to process the content assuming it contains one line with loan request information.
+ * So for example the content of the file could read some like <br>23456890,3,4,20000,5<br>
+ * The order of values needs to be SocialSecurityNumber, CreditScore, HistoryLength [month], LoanAmount [dollar],
+ * and finally the LoanTerm [month]. The request will be processed and a BankQouteReply is generated. The
+ * original file is moved to a 'processed' directory, and the BankQuoteReply is serialized to an 'outgoing'
+ * directory from the it can be picked up by the system that dropped the request.
+ *
+ * @author kstam
+ *
+ */
+class ManagerFlatFile extends BasePollManager
+{
+ private Logger logger = Logger.getLogger(this.getClass());
+
+ private static final String BANK_NAME = "FileBasedBank";
+ private static final BigDecimal RATE_PREMIUM = BigDecimal.valueOf(0.25);
+ private static final int MAXLOANTERM = 120;
+ private static final String QUOTE_SUFFIX = "quote";
+ private String m_outputDir=null;
+
+ public ManagerFlatFile(String outputDir) {
+ m_outputDir = outputDir;
+ }
+
+ /**
+ * Handle to the cycle start event.
+ */
+ public void cycleStarted(CycleStartEvent evt) {
+ logger.log(Level.DEBUG, "Poller awakened "
+ + (evt.getPoller().getFilter() == null ? "(no filtering)" : evt
+ .getPoller().getFilter().toString()));
+ }
+ /**
+ * Handle to the cycle end event.
+ */
+ public void cycleEnded(CycleEndEvent evt) {
+ logger.log(Level.DEBUG, "Poller going to sleep");
+ }
+ /**
+ * Handle to the directory lookup start event.
+ */
+ public void directoryLookupStarted(DirectoryLookupStartEvent evt) {
+ logger.log(Level.DEBUG, "Scanning " + evt.getDirectory());
+ }
+ /**
+ * Handle to the directory lookup end event.
+ */
+ public void directoryLookupEnded(DirectoryLookupEndEvent evt) {
+ logger.log(Level.DEBUG, "Finished scanning " + evt.getDirectory());
+ }
+ /**
+ * Handle to the file set found event. Currenty this is the only event that
+ * is actually used to proces the incoming loan quote requests. Each file
+ * is send to be processed.
+ */
+ public void fileSetFound(FileSetFoundEvent evt) {
+ File[] files = evt.getFiles();
+
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ processFile(file);
+ }
+ }
+ /**
+ * Handle to the file found event.
+ */
+ public void fileFound(FileFoundEvent evt) {
+ logger.log(Level.DEBUG, evt);
+ // Add artificial delay
+ }
+ /**
+ * Returns the name of this PollManager and a quick summary of what it does.
+ */
+ public String toString() {
+ return "FlatFilePollManager - a pollmanager which processed incoming -flat file based- loan requests";
+ }
+ /**
+ * Each file is processed assuming it contains one line with loan request information.
+ * So for example the content of the file could read some like <br>23456890,3,4,20000,5<br>
+ * The order of values needs to be SocialSecurityNumber, CreditScore, HistoryLength [month], LoanAmount [dollar],
+ * and finally the LoanTerm [month]. The BankQuoteRequest is processed and a BankQouteReply is generated. The
+ * original file is moved to a processed directory, and the BankQuoteReply is serialized to an 'outgoing'
+ * directory from the it can be picked up by the system that dropped the request.
+ *
+ * @param file - incoming flat file with loan quote request info.
+ */
+ protected void processFile(File file)
+ {
+ BankQuoteReply bankQuoteReply=new BankQuoteReply();
+ bankQuoteReply.setQuoteId(BANK_NAME);
+ int errorCode=7;
+ String message=null;
+ logger.log(Level.INFO, "Found " + file.getAbsolutePath() );
+
+ try {
+ //Read the content of the file into a String
+ message=FileUtil.readTextFile(file);
+
+ Bank fileBasedBank = new Bank(BANK_NAME, RATE_PREMIUM, MAXLOANTERM);
+
+ BankQuoteRequest bankQuoteRequest = fileBasedBank.getQuoteFromXML(message);
+
+ bankQuoteReply = fileBasedBank.processMessage(bankQuoteRequest);
+ } catch (Throwable e) {
+ //Package up the error, so it can be processed
+ logger.log(Level.ERROR, e.getMessage());
+ bankQuoteReply.setErrorCode(errorCode);
+ }
+
+ try {
+ //Create the outgoing response file
+ File outgoingDir = new File(m_outputDir);
+ if (!outgoingDir.exists()) {
+ outgoingDir.mkdir();
+ }
+ File outgoingFile = new File(outgoingDir + "/" + file.getName()+"."+QUOTE_SUFFIX);
+
+ logger.log(Level.INFO, "Creating outgoing file " + outgoingFile.getAbsolutePath());
+ outgoingFile.createNewFile();
+
+ XStream xstream = new XStream(new DomDriver());
+ xstream.alias("quote", BankQuoteReply.class);
+
+ String reply = xstream.toXML(bankQuoteReply);
+
+ logger.log(Level.INFO, "Writing reply " + reply);
+ FileUtil.writeTextFile(outgoingFile, reply);
+
+ // Delete file
+ file.delete();
+
+ } catch (Exception e) {
+ logger.log(Level.ERROR, e.getMessage(), e);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ DOMConfigurator.configure("log4j.xml");
+ String monitoredDir = "C:/tmp/input";
+ String outputDir = "C:/tmp/output";
+ if (args!=null && args.length > 0) {
+ monitoredDir=args[0];
+ if (args.length > 1) {
+ outputDir=args[1];
+ }
+ }
+System.out.println("MONITOR="+monitoredDir+" OUTPUT="+outputDir);
+ File monitoredDirectory = new File(monitoredDir);
+ if (!monitoredDirectory.exists() || !monitoredDirectory.isDirectory()){
+ System.err.println("Invalid directory " + monitoredDirectory.getAbsolutePath());
+ System.out.println("Trying to create the directory.");
+ try {
+ monitoredDirectory.mkdir();
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ }
+ }
+ DirectoryPoller poller = new DirectoryPoller(monitoredDirectory);
+ poller.addPollManager(new ManagerFlatFile(outputDir));
+ poller.start();
+ }
+
+
+}
\ No newline at end of file
Added: trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,276 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.math.BigDecimal;
+import java.util.Properties;
+
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import org.apache.log4j.xml.DOMConfigurator;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.DomDriver;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+/**
+ * The JMS Manager listens to an incoming queue (by default queue/A on localhost). It consumes the
+ * message assuming it is a TextMessage, and that the text is an XML structure that can be marshalled
+ * into a BankQuoteRequest. The request will be processed and a BankQuoteRequest Reply will be serialized to XML
+ * and send to the outgoing queue (by default this is queue/B on localhost).
+ *
+ * @author kstam
+ */
+public class ManagerJMS implements javax.jms.MessageListener, ExceptionListener {
+ private static Logger logger = Logger.getLogger(ManagerJMS.class);
+ /** Name of the Bank */
+ private static final String BANK_NAME = "JMSBasedBank";
+ /** Rate premium the bank charges */
+ private static final BigDecimal RATE_PREMIUM = BigDecimal.valueOf(0.50);
+ /** Maximum duration of the loan the bank will accept [months] */
+ private static final int MAXLOANTERM = 120;
+ /** Default incoming queue */
+ private static String QUEUE_IN = "queue/C";
+ /** Default outgoing queue */
+ private static String QUEUE_OUT = "queue/D";
+ /** Properties used when constructing the InitialContext */
+ private static Properties properties = new Properties();
+ /** Queue connection for incoming queue */
+ private QueueConnection inQueueConnection;
+
+ /**
+ * The minimum error delay.
+ */
+ private static final long MIN_ERROR_DELAY = 1000 ;
+ /**
+ * The maximum error delay.
+ */
+ private static final long MAX_ERROR_DELAY = (MIN_ERROR_DELAY << 5) ;
+ /**
+ * The error delay.
+ */
+ private long errorDelay ;
+
+
+ /**
+ * Sets up the queue listener. By default is listenes to queue/A on localhost.
+ */
+ public void listen() throws NamingException, JMSException {
+ //MQ Series
+ //properties.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.mq.jms.context.WMQInitialContextFactory");
+ //properties.put(Context.PROVIDER_URL , "dev38:1415/SYSTEM.DEF.SVRCONN");
+ //ActiveMQ
+ //properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
+ //properties.put(Context.PROVIDER_URL , "tcp://localhost:61616");
+ //JBossMQ
+ /** Context used to lookup the Queues */
+ InitialContext ctx = getContext();
+ try {
+ logger.info("Looking up connection factory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) ctx
+ .lookup("ConnectionFactory");
+ logger.info("Creating connection");
+ inQueueConnection = qcf.createQueueConnection();
+ logger.info("Creating session");
+ QueueSession qs = inQueueConnection.createQueueSession(false,
+ Session.DUPS_OK_ACKNOWLEDGE);
+ logger.info("Looking up queue=" + QUEUE_IN);
+ Queue inQueue=null;
+ try {
+ inQueue = (Queue) ctx.lookup(QUEUE_IN);
+ } catch (NamingException ne) {
+ inQueue = qs.createQueue(QUEUE_IN);
+ }
+ //Queue
+ QueueReceiver qr = qs.createReceiver(inQueue);
+ qr.setMessageListener(this);
+ inQueueConnection.setExceptionListener(this);
+ inQueueConnection.start();
+ } finally {
+ ctx.close();
+ }
+ }
+
+ private InitialContext getContext() throws NamingException {
+ InitialContext ctx;
+ properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ properties.put(Context.PROVIDER_URL , "localhost");
+ ctx = new InitialContext(properties);
+ return ctx;
+ }
+
+ /**
+ * Sets up the queue listener. By default is listenes to queue/A on localhost. It consumes the
+ * message assuming it is a TextMessage, and that the text is an XML structure that can be marshalled
+ * into a BankQuoteRequest. The request will be processed and a BankQuoteRequest Reply will be serialized to XML
+ * and send to the outgoing queue (by default this is queue/B on localhost). If the processing results
+ * in an error a BankQuoteReply with ErrorCode other then 0 is send to the outgoing queue.
+ *
+ * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
+ * changed this to use a CSV from the request, left the reply as is - dbrum
+ */
+ public void onMessage(Message message) {
+ QueueConnection outQueueConnection;
+ logger.info("Got message: " + message);
+ try {
+ TextMessage textMessage = (TextMessage) message;
+ String xml = textMessage.getText();
+
+ Bank bank = new Bank(BANK_NAME, RATE_PREMIUM, MAXLOANTERM);
+
+ BankQuoteRequest bankQuoteRequest = bank.getQuoteFromXML(xml);
+
+ BankQuoteReply bankQuoteReply = bank
+ .processMessage(bankQuoteRequest);
+
+ XStream xstream = new XStream(new DomDriver());
+ xstream.alias("quote", BankQuoteReply.class);
+
+ String bankQuoteReplyXML = xstream.toXML(bankQuoteReply);
+
+ logger.log(Level.INFO, "Looking up connection factory");
+ InitialContext ctx = getContext();
+ QueueConnectionFactory qcf = (QueueConnectionFactory) ctx
+ .lookup("ConnectionFactory");
+
+ logger.log(Level.INFO, "Creating connection");
+ outQueueConnection = qcf.createQueueConnection();
+ try {
+ logger.log(Level.INFO, "Creating session");
+ QueueSession qs = outQueueConnection.createQueueSession(false,
+ Session.DUPS_OK_ACKNOWLEDGE);
+ Queue outQueue;
+ try {
+ outQueue = (Queue) ctx.lookup(QUEUE_OUT);
+ } catch (NamingException ne) {
+ outQueue = qs.createQueue(QUEUE_OUT);
+ }
+ TextMessage responseTextMessage = qs.createTextMessage(bankQuoteReplyXML);
+
+ QueueSender queueSender = qs.createSender(outQueue);
+
+ queueSender.send(responseTextMessage);
+ logger.info("message being sent back on " + QUEUE_OUT + "\n" + responseTextMessage);
+ System.out.println("message being sent back on " + QUEUE_OUT + "\n" + responseTextMessage);
+ } catch (JMSException je) {
+ logger.log(Level.ERROR, je.getMessage(), je);
+ } finally {
+ outQueueConnection.close();
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Handle an asynchronous exception.
+ * @param jmsException The asynchronous exception
+ */
+ public void onException(final JMSException jmsException) {
+ errorDelay = MIN_ERROR_DELAY ;
+ logger.warn("JMS Connection lost, attempting to reconnect") ;
+
+ while(true)
+ {
+ try {
+ close() ;
+ } catch (final Exception ex) {} // ignore
+
+ try {
+ listen() ;
+ logger.warn("Established connection, continuing with processing") ;
+ break ;
+ } catch (final Exception ex) {} // ignore
+
+ logger.warn("Error establishing connection, backing off for " + errorDelay + " milliseconds") ;
+
+ try {
+ Thread.sleep(errorDelay) ;
+ } catch (final InterruptedException ie) {} // ignore
+
+ if (errorDelay < MAX_ERROR_DELAY)
+ {
+ errorDelay <<= 1 ;
+ }
+ }
+
+
+ }
+
+ /**
+ * Closing the queue connection as to not leak connection resources.
+ */
+ public void close() throws JMSException {
+ if (inQueueConnection != null) {
+ inQueueConnection.close();
+ inQueueConnection = null ;
+ }
+ }
+ /**
+ * Invokes an instance of JMS based bank listener.
+ * @param args - provider url, queue_in, queue_out
+ */
+ public static void main(String[] args) {
+ if (args != null && args.length > 0) {
+ if (args.length > 0) {
+ QUEUE_IN = args[1];
+ if (args.length > 1) {
+ QUEUE_OUT = args[2];
+ }
+ }
+ } else {
+ System.out.println(
+ "Usage: ManagerJMS providerURL, queueIn, queueOut");
+ }
+ System.out.println("Starting JMS Bank Listener...");
+ System.out.println("Listening to Queue '" + QUEUE_IN + "'.");
+ System.out.println("Responding to Queue '" + QUEUE_OUT + "'.");
+ DOMConfigurator.configure("log4j.xml");
+ ManagerJMS managerJMS = new ManagerJMS();
+ try {
+ managerJMS.listen();
+
+ synchronized(managerJMS) {
+ managerJMS.wait();
+ }
+ } catch (final Exception ex) {
+ logger.error(ex.getMessage(), ex) ;
+ }
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReplyTest.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReplyTest.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReplyTest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import static org.junit.Assert.assertTrue;
+
+import java.math.BigDecimal;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.junit.Test;
+
+import com.thoughtworks.xstream.XStream;
+
+public class BankQuoteReplyTest {
+
+ private Logger logger = Logger.getLogger(this.getClass());
+
+ /**
+ * Testing the XML layout of a BankQuoteReply
+ */
+ @Test public void obtainExampleXML(){
+ BankQuoteReply bankQuoteReply = new BankQuoteReply();
+ bankQuoteReply.setErrorCode(0);
+ bankQuoteReply.setCustomerUID("unique");
+ bankQuoteReply.setInterestRate(BigDecimal.valueOf(11.7));
+ bankQuoteReply.setQuoteId("JBBANK_1");
+
+ XStream xstream = new XStream();
+ String bankQuoteReplyXml=xstream.toXML(bankQuoteReply);
+ logger.info("xml=\n" + bankQuoteReplyXml);
+ String expectedXml =
+ "<org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteReply>\n"
+ + " <interestRate>11.7</interestRate>\n"
+ + " <quoteId>JBBANK_1</quoteId>\n"
+ + " <errorCode>0</errorCode>\n"
+ + " <customerUID>unique</customerUID>\n"
+ + "</org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteReply>";
+ assertTrue(expectedXml.equals(bankQuoteReplyXml));
+ }
+
+ public static junit.framework.Test suite() {
+ return new JUnit4TestAdapter(BankQuoteReplyTest.class);
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequestTest.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequestTest.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequestTest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import static org.junit.Assert.assertTrue;
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.junit.Test;
+
+import com.thoughtworks.xstream.XStream;
+
+public class BankQuoteRequestTest {
+
+ private Logger logger = Logger.getLogger(this.getClass());
+
+ /**
+ * Testing the XML layout of a BankQuoteRequest
+ */
+ @Test public void obtainExampleXML(){
+ BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
+ bankQuoteRequest.setSsn(123456890);
+ bankQuoteRequest.setCreditScore(3);
+ bankQuoteRequest.setHistoryLength(4);
+ bankQuoteRequest.setLoanTerm(5);
+ bankQuoteRequest.setLoanAmount(20000);
+ bankQuoteRequest.setCustomerUID("unique");
+
+ XStream xstream = new XStream();
+ String bankQuoteRequestXml=xstream.toXML(bankQuoteRequest);
+ logger.info("xml=\n" + bankQuoteRequestXml);
+ String expectedXml =
+ "<org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteRequest>\n"
+ + " <ssn>123456890</ssn>\n"
+ + " <creditScore>3</creditScore>\n"
+ + " <historyLength>4</historyLength>\n"
+ + " <loanAmount>20000</loanAmount>\n"
+ + " <loanTerm>5</loanTerm>\n"
+ + " <customerUID>unique</customerUID>\n"
+ + "</org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteRequest>";
+ assertTrue(expectedXml.equals(bankQuoteRequestXml));
+ }
+
+ public static junit.framework.Test suite() {
+ return new JUnit4TestAdapter(BankQuoteRequestTest.class);
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,72 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import static org.junit.Assert.assertTrue;
+
+import java.math.BigDecimal;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import org.junit.Test;
+
+public class BankTest {
+
+ private Logger logger = Logger.getLogger(this.getClass());
+
+ /**
+ * Tests the computation of the interestRate for the TestBank.
+ *
+ */
+ @Test public void processLoanRequest(){
+
+ //Building a BankQuoteRequest
+ BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
+ bankQuoteRequest.setSsn(123456890);
+ bankQuoteRequest.setCreditScore(3);
+ bankQuoteRequest.setHistoryLength(4);
+ bankQuoteRequest.setLoanTerm(72);
+ bankQuoteRequest.setLoanAmount(20000);
+ bankQuoteRequest.setCustomerUID("unique");
+ logger.log(Level.INFO, bankQuoteRequest);
+
+ //Getting a Bank Instance
+ String bankName = "TestBank";
+ BigDecimal ratePrimium = BigDecimal.valueOf(0.25);
+ int maxLoanTerm = 120;
+ Bank bank = new Bank(bankName, ratePrimium, maxLoanTerm);
+
+ //Getting a quote from this bank
+ BankQuoteReply bankQuoteReply = bank.processMessage(bankQuoteRequest);
+ logger.log(Level.INFO, bankQuoteReply);
+
+ //Checking for validity
+ BigDecimal expectedInterestRate = BigDecimal.valueOf(8.85);
+ assertTrue(bankQuoteReply.getInterestRate().equals(expectedInterestRate));
+ }
+
+ public static junit.framework.Test suite() {
+ return new JUnit4TestAdapter(BankTest.class);
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,104 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import org.junit.Test;
+
+public class FlatFileProcessorTest {
+
+ private Logger logger = Logger.getLogger(this.getClass());
+ private static String FLAT_FILE = "FlatFileProcessorTest.txt";
+ /**
+ * Tests the processing of flat file containing a loan quote request. First
+ * we try to find a temporary directory. When this succeeds we drop a
+ * loan request file in there and try to process it.
+ *
+ */
+ @Test public void processRequest()
+ {
+ File writableDir=null;
+ logger.log(Level.INFO, "Check to see if I can write to /tmp");
+ File tmpDir = new File("/tmp");
+ if (tmpDir.exists() && tmpDir.canWrite()) {
+ writableDir=tmpDir;
+ } else {
+ File tempDir = new File("C:/temp");
+ if (tempDir.exists() && tempDir.canWrite()) {
+ writableDir=tempDir;
+ } else {
+ logger.log(Level.ERROR, "Could not find either /tmp or C:\\Temp for a temporary "
+ + "writing space.");
+ assertTrue(false);
+ }
+ }
+// We found a temp space so now we can drop in a load request file.
+ try {
+ logger.log(Level.INFO, "Creating " + FLAT_FILE + " file in " + writableDir.getAbsolutePath());
+ File loanRequestFile = new File(writableDir.getAbsolutePath() + "/"+ FLAT_FILE);
+ if (loanRequestFile.exists()) {
+ loanRequestFile.delete();
+ }
+ loanRequestFile.createNewFile();
+ String str="23456890,3,4,20000,5,unique";
+ FileUtil.writeTextFile(loanRequestFile, str);
+
+ logger.log(Level.INFO, "Processing FlatFileProcessorTest.txt");
+ ManagerFlatFile pollManager = new ManagerFlatFile(null);
+ pollManager.processFile(loanRequestFile);
+
+ //Check to see if the file is now moved.
+ assertFalse(loanRequestFile.exists());
+
+ File replyToFile = null;//new File(writableDir.getAbsolutePath() + "/"
+ // + ManagerFlatFile.OUTGOING_DIR + "/" + ManagerFlatFile.PREFIX
+ // + FLAT_FILE);
+ logger.log(Level.INFO, "Check to see if " + replyToFile.getAbsolutePath()
+ + " exists");
+ assertTrue(replyToFile.exists());
+ logger.log(Level.INFO, "OK");
+
+ //Checking the content of the reply
+ logger.log(Level.INFO, "Check the reply, should be ('8.29,FileBasedBank-0,0,unique'");
+ assertTrue("8.29,FileBasedBank-0,0,unique".equals(FileUtil.readTextFile(replyToFile)));
+ logger.log(Level.INFO, "OK");
+ //Cleaning up
+ replyToFile.delete();
+
+ } catch (Throwable e) {
+ logger.log(Level.ERROR,e.getMessage(),e);
+ assertTrue(false);
+ }
+ }
+
+ public static junit.framework.Test suite() {
+ return new JUnit4TestAdapter(FlatFileProcessorTest.class);
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/banks/test/src/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,93 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Properties;
+
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import org.junit.Test;
+
+public class JmsProcessorTest {
+
+ private Logger logger = Logger.getLogger(this.getClass());
+
+ /**
+ * This can be activate if the server is running and you want
+ * to drop a message on the queue
+ *
+ */
+ @Test public void sendLoanRequestXML()
+ {
+
+ QueueSession sess;
+ Queue queue;
+ try {
+ Properties properties = new Properties();
+
+ //ActiveMQ
+ //properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
+ //properties.put(Context.PROVIDER_URL , "tcp://localhost:61616");
+ //JBossMQ
+ properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ properties.put(Context.PROVIDER_URL , "localhost");
+ InitialContext ctx = new InitialContext(properties);
+
+ QueueConnectionFactory factory = (QueueConnectionFactory) ctx
+ .lookup("ConnectionFactory");
+ QueueConnection cnn = factory.createQueueConnection();
+ sess = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ queue = sess.createQueue("queue/C");
+ //queue = sess.createQueue("queue/C");
+ String str="23456890,3,4,20000,5,unique,kurt.stam at jboss.com";
+ TextMessage msg = sess.createTextMessage(str);
+ QueueSender sender = sess.createSender(queue);
+ sender.send(msg);
+ ctx.close();
+ //if the test gets here without errors it passes.
+ assertTrue(true);
+ } catch (Exception e) {
+ //if it fails it may be because the server is not up and the Queue is not found
+ //I'm not letting the test fail, since we may want to do nightly build/test runs
+ //which may not have the server up.
+ logger.log(Level.ERROR, e.getMessage(), e);
+ logger.log(Level.ERROR, "Is the server up and running?");
+ }
+ }
+
+ public static junit.framework.Test suite() {
+ return new JUnit4TestAdapter(JmsProcessorTest.class);
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/build.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/build.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/build.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,268 @@
+<project name="TRAILBLAZER" default="war" basedir=".">
+
+ <!-- UPDATE THIS WITH YOUR JBOSS_HOME AND SERVER -->
+ <property name="trailblazer.dir" location="."/>
+ <property name="install.dir" value="../../../install"/>
+ <property file="${install.dir}/deployment.properties"/>
+
+ <property name="esb.home.dir" value="${org.jboss.esb.home}"/>
+ <property name="org.jboss.as.home" value="${org.jboss.as.home}"/>
+ <property name="org.jboss.as.config" value="${org.jboss.as.config}"/>
+
+ <!-- properties for the esb part of the trailblazer -->
+ <property name="esb.dest" value="${basedir}/esb/build"/>
+ <property name="classes.dir" value="${basedir}/esb/build/classes"/>
+ <property name="esb.testclasses.dir" value="${basedir}/esb/build/classes/tests/"/>
+ <property name="esb.src.dir" value="${basedir}/esb/src"/>
+ <property name="esb.test.dir" value="${basedir}/esb/test"/>
+ <property name="esb.lib.dir" value="${basedir}/esb/lib"/>
+ <property name="report.dir" value="${basedir}/esb/build/tests"/>
+
+ <!-- properties for the client(web) part of the trailblazer -->
+ <property name="client.dir" value="${basedir}/client"/>
+ <property name="esb.samples.trailblazer.client.dest"
+ value="${basedir}/client/build"/>
+ <property name="esb.samples.trailblazer.client.classes.dir"
+ value="${basedir}/client/build/classes"/>
+ <property name="esb.samples.trailblazer.client.testclasses.dir"
+ value="${basedir}/client/build/classes/tests/"/>
+ <property name="esb.samples.trailblazer.client.src.dir"
+ value="${basedir}/client/src"/>
+ <property name="esb.samples.trailblazer.client.test.dir"
+ value="${basedir}/client/test"/>
+ <property name="esb.samples.trailblazer.client.lib.dir"
+ value="${basedir}/client/lib"/>
+ <property name="esb.samples.trailblazer.client.tests.report.dir"
+ value="${basedir}/client/build/tests"/>
+
+ <property environment="env" />
+
+ <property name="esb.lib.file" value="jbossesb-rosetta.jar"/>
+ <property name="soa.esb.lib.dist.dir" value="${esb.home.dir}/lib"/>
+ <property name="soa.esb.lib.src.dir" value="../../build/jbossesb/lib"/>
+
+ <available file="${esb.lib.file}"
+ filepath="${soa.esb.lib.dist.dir}"
+ property="soa.esb.lib.dir"
+ value="${soa.esb.lib.dist.dir}"/>
+
+ <available file="${esb.lib.file}"
+ filepath="${soa.esb.lib.src.dir}"
+ property="soa.esb.lib.dir"
+ value="${soa.esb.lib.src.dir}"/>
+
+ <property name="soa.esb.lib.ext.dir" value="${soa.esb.lib.dir}/ext"/>
+
+ <property name="target-server" value="${org.jboss.as.home}/server/${org.jboss.as.config}" />
+
+ <!-- classpath -->
+ <path id="esb.samples.trailblazer.esb.classpath">
+ <fileset dir="${soa.esb.lib.dir}/ext" includes="*.jar"/>
+ <fileset dir="${esb.lib.dir}/ext" includes="*.jar"/>
+ <fileset dir="${org.jboss.as.home}/client" includes="jbossall-client.jar jbossws-client.jar mail.jar"/>
+ <fileset dir="${soa.esb.lib.dir}" includes="*.jar"/>
+ <fileset dir="${esb.samples.trailblazer.client.lib.dir}/ext" includes="*.jar"/>
+ </path>
+
+ <!-- classpath for running the listener-->
+ <path id="esb.samples.trailblazer.esb.classpath.run">
+ <fileset dir="${soa.esb.lib.ext.dir}"
+ includes="jaxr-api*.jar,scout*.jar,juddi*.jar"/>
+ <fileset dir="${esb.dest}/dist" includes="trailblazer-esb.jar"/>
+ <fileset dir="${esb.home.dir}/lib/ext" includes="*.jar" excludes="jaxr-api*.jar,scout*.jar,juddi*.jar"/>
+ <fileset dir="${soa.esb.lib.ext.dir}" includes="*.jar" excludes="jaxr-api*.jar,scout*.jar,juddi*.jar"/>
+ <fileset dir="${org.jboss.as.home}/client" includes="jbossall-client.jar jbossws-client.jar mail.jar"/>
+ <fileset dir="${soa.esb.lib.dir}" includes="*.jar"/>
+ <fileset dir="${esb.lib.dir}/ext" includes="*.jar"/>
+ <!-- for finding the jbossesb-properties.xml file -->
+ <pathelement location="${basedir}"/>
+ </path>
+
+ <path id="esb.samples.trailblazer.esb.classpath.client">
+ <fileset dir="${soa.esb.lib.ext.dir}"/>
+ <fileset dir="${esb.lib.dir}/ext" includes="*.jar"/>
+ <fileset dir="${org.jboss.as.home}/client" includes="jboss-jaxrpc.jar jbossall-client.jar jbossws-client.jar mail.jar"/>
+ <fileset dir="${soa.esb.lib.dir}" includes="*.jar"/>
+ <fileset dir="${esb.samples.trailblazer.client.lib.dir}/ext" includes="*.jar"/>
+ <fileset dir="${esb.dest}/dist" includes="trailblazer-esb.jar"/>
+ <pathelement location="${classes.dir}"/>
+ </path>
+
+ <target name="clean">
+ <delete dir="${esb.dest}"/>
+ <delete dir="${esb.samples.trailblazer.client.dest}"/>
+ </target>
+
+ <target name="messaging-config">
+ <property name="org.jboss.as.deploy.dir"
+ value="${org.jboss.as.home}/server/${org.jboss.as.config}/deploy"/>
+ <condition property="messaging.present">
+ <available file="${org.jboss.as.deploy.dir}/jboss-messaging"/>
+ </condition>
+ <condition property="messaging.present">
+ <available file="${org.jboss.as.deploy.dir}/jboss-messaging.sar"/>
+ </condition>
+
+ <condition property="jbossmq.present">
+ <not>
+ <isset property="messaging.present"/>
+ </not>
+ </condition>
+ </target>
+
+ <!-- dependencies specific to JBoss Messaging -->
+ <target name="messaging-dependencies" if="messaging.present">
+ <property name="jms.service.file" value="jbm-queue-service.xml"/>
+ <property name="jms.description" value="JBoss Messaging"/>
+ </target>
+
+ <!-- dependencies specific to JBoss MQ -->
+ <target name="jbossmq-dependencies" if="jbossmq.present">
+ <property name="jms.service.file" value="jbmq-queue-service.xml"/>
+ <property name="jms.description" value="JBoss MQ"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Prepares the directory structure -->
+ <!-- =================================================================== -->
+ <target name="esb.built" unless="soa.esb.lib.dir">
+ <echo>Please build the ESB with "ant dist" in the ESB parent</echo>
+ <echo>directory in order to run the Trailblazer application.</echo>
+ <fail>Please build ESB first.</fail>
+ </target>
+
+ <target name="trailblazer.prepare" depends="esb.built,clean" if="soa.esb.lib.dir">
+ <mkdir dir="${esb.dest}"/>
+ <mkdir dir="${esb.dest}/dist"/>
+ <mkdir dir="${esb.dest}/classes"/>
+ <mkdir dir="${esb.samples.trailblazer.client.dest}"/>
+ <mkdir dir="${esb.samples.trailblazer.client.dest}/dist"/>
+ <mkdir dir="${esb.samples.trailblazer.client.dest}/classes"/>
+ </target>
+
+ <!-- Compilation targets -->
+ <!-- ___________________ -->
+
+ <!-- ESB COMPILATION -->
+ <target name="esb.compile"
+ depends="trailblazer.prepare"
+ description="Compiling Trailblazer ESB classes">
+ <javac
+ destdir="${classes.dir}"
+ classpathref="esb.samples.trailblazer.esb.classpath"
+ target="1.5"
+ debug="true">
+ <src path="${esb.src.dir}"/>
+ </javac>
+ </target>
+
+ <!-- CLIENT(WEB) COMPILATION -->
+ <target name="client.compile"
+ depends="trailblazer.prepare"
+ description="Compiling Trailblazer client classes">
+ <javac destdir="${esb.samples.trailblazer.client.classes.dir}"
+ classpathref="esb.samples.trailblazer.esb.classpath.client"
+ target="1.5"
+ debug="true">
+ <src path="${esb.samples.trailblazer.client.src.dir}"/>
+ </javac>
+ </target>
+
+ <!-- JAR/WAR targets -->
+ <target name="esb.jar" depends="messaging-config, messaging-dependencies, jbossmq-dependencies, compile" >
+ <property name="esb.build.dir" value="${esb.dest}" />
+
+ <echo>${jms.service.file}</echo>
+
+ <!-- ESB Client JAR -->
+ <echo message="Building Trailblazer ESB archives"/>
+ <jar destfile="${esb.build.dir}/dist/trailblazer-esb.jar"
+ basedir="${classes.dir}"
+ includes="**/*.class" excludes="**/web/*.class">
+ </jar>
+ <!-- ESB Deployment (.esb) -->
+ <copy todir="${esb.build.dir}/META-INF">
+ <fileset dir="esb/conf" includes="jboss-esb.xml,deployment.xml" />
+ </copy>
+ <jar destfile="${esb.build.dir}/dist/trailblazer.esb">
+ <fileset dir="${classes.dir}" excludes="**/web/*.class" />
+ <fileset dir="${esb.build.dir}" includes="META-INF/**" />
+ <fileset dir="${basedir}/esb/conf" includes="${jms.service.file}"/>
+ <fileset dir="${basedir}/esb/conf" includes="smooks-*.xml,*.xsl" />
+ <fileset dir="${basedir}/esb/conf" includes="jbossesb-properties.xml" />
+ <fileset dir="${basedir}" includes="trailblazer.properties,template/**,models/**" />
+ </jar>
+ </target>
+
+ <target name="war" depends="compile">
+
+ <!-- Web side WAR -->
+ <echo message="Building Trailblazer WAR file"/>
+ <delete file="${esb.samples.trailblazer.client.dest}/dist/trailblazer.war" />
+ <war warfile="${esb.samples.trailblazer.client.dest}/dist/trailblazer.war"
+ webxml="${basedir}/client/resources/web.xml">
+ <classes dir="${esb.samples.trailblazer.client.classes.dir}">
+ <include name="**/loanbroker/*.class"/>
+ <include name="**/trailblazer/web/*.class"/>
+ <include name="trailblazer.properties"/>
+ </classes>
+ <webinf dir="${basedir}/client/resources">
+ <include name="wsdl/*"/>
+ </webinf>
+ <lib dir="${esb.dest}/dist">
+ <include name="trailblazer-esb.jar"/>
+ </lib>
+ <fileset dir="client/jsp">
+ <include name="**/*.jsp"/>
+ </fileset>
+ </war>
+ </target>
+
+ <target name="deploy">
+ <copy file="${basedir}/client/java-files/SuccessfulLoanBroker.java" tofile="${basedir}/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java" overwrite="true"/>
+ <antcall target="common-deploy" />
+ </target>
+
+ <target name="deploy-error-client">
+ <echo message="update the error client file" />
+ <copy file="${basedir}/client/java-files/FailedLoanBroker.java" tofile="${basedir}/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java" overwrite="true"/>
+ <antcall target="common-deploy" />
+ </target>
+
+ <target name="common-deploy" depends="jar, war">
+ <echo message="Deploying Trailblazer EAR and WAR files to target server '${target-server}'."/>
+ <copy todir="${target-server}/deploy">
+ <fileset dir="${esb.dest}/dist/" includes="trailblazer.esb" />
+ <fileset dir="${esb.samples.trailblazer.client.dest}/dist/" includes="trailblazer.war" />
+ </copy>
+ </target>
+
+ <target name="undeploy">
+ <delete file="${target-server}/deploy/trailblazer.esb" />
+ <delete file="${target-server}/deploy/trailblazer.war" />
+ </target>
+
+
+ <!-- Short target names -->
+ <target name="compile" depends="esb.compile,client.compile"/>
+ <target name="jar" depends="esb.jar"/>
+
+ <!-- run the ESB listeners -->
+ <!-- set the first argument to 0 for an indefinite run for the listener launcher -->
+ <!-- arg1 = # of seconds to let the listener threads run -->
+ <!-- arg2 = location of the esb config file which describes the listener configurations for a Message aware listener config -->
+ <!-- arg3 (if any) = location of the esb config file which describes the listener configurations for a NON-Message aware listener config (gateway)-->
+ <target name="runESB" depends="jar">
+ <echo>Running ESB Trailblazer listeners</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.listeners.StandAloneBootStrapper" failonerror="true">
+ <jvmarg value="-Dorg.jboss.soa.esb.propertyFile=${trailblazer.dir}/esb/jbossesb-properties.xml"/>
+ <arg value="${trailblazer.dir}/esb/conf/jboss-esb.xml"/>
+ <classpath refid="esb.samples.trailblazer.esb.classpath.run"/>
+ </java>
+ </target>
+
+ <!-- javadocs paths -->
+ <path id="esb.samples.trailblazer.esb.javadocs.path">
+ <pathelement path="esb/classes"/>
+ </path>
+</project>
Added: trunk/samples/jbossesb/trailblazer/client/java-files/FailedLoanBroker.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/java-files/FailedLoanBroker.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/java-files/FailedLoanBroker.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,228 @@
+package org.jboss.soa.esb.samples.trailblazer.loanbroker;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.jboss.soa.esb.samples.trailblazer.util.TrailblazerProperties;
+import org.jboss.soa.esb.samples.trailblazer.web.WebCustomer;
+import org.jboss.soa.esb.client.ServiceInvoker;
+
+/*
+ * LoanBroker is responsible for getting customer requests for loans onto the JBoss ESB
+ * Requests will come from a JSR-181 pojo web service (@org.jboss.soa.esb.samples.trailblazer.web.LoanBrokerWS)
+ * The sequence of events from the LoanBroker are:
+ * 1 - Prepare a request for the CreditAgency (transform the customer into a XML representation)
+ * 2 - Send to CreditAgency and get response (lookup the customer using the SSN (see @CustomerMasterFile)
+ * 3 - Prepare a LoanRequest for each of the banks in their unique data structures and send
+ * 4 - Collect the response(s) from the bank(s) and send an email to the customer with the quote offers
+ */
+
+public class LoanBroker {
+
+ private static Logger logger = Logger.getLogger(LoanBroker.class);
+ //used to locate our entries in the trailblazer-properties
+ private final String CREDIT_AGENCY_SERVICE_NAME = "creditagency.service.epr.name";
+ private final String CREDIT_AGENCY_SERVICE_CAT = "creditagency.service.category";
+ private final String BANK1_SERVICE_NAME = "bank1.service.epr.name";
+ private final String BANK1_SERVICE_CAT = "bank1.service.category";
+ private final String BANK2_SERVICE_NAME = "bank2.service.epr.name";
+ private final String BANK2_SERVICE_CAT = "bank2.service.category";
+ private final String NOTIFIER_SERVICE_NAME = "notifier.service.epr.name";
+ private final String NOTIFIER_SERVICE_CAT = "notifier.service.category";
+ private Properties properties = new TrailblazerProperties();
+ private ServiceInvoker serviceInvoker;
+ private ServiceInvoker bank1Invoker;
+ private ServiceInvoker bank2Invoker;
+ private ServiceInvoker notifierInvoker;
+
+ public LoanBroker() {
+ String serviceCategoryName = properties.getProperty(CREDIT_AGENCY_SERVICE_CAT);
+ String serviceName = properties.getProperty(CREDIT_AGENCY_SERVICE_NAME);
+ String bank1ServiceCategoryName = properties.getProperty(BANK1_SERVICE_CAT);
+ String bank1ServiceName = properties.getProperty(BANK1_SERVICE_NAME);
+ String bank2ServiceCategoryName = properties.getProperty(BANK2_SERVICE_CAT);
+ String bank2ServiceName = properties.getProperty(BANK2_SERVICE_NAME);
+ String notifierServiceCategoryName = properties.getProperty(NOTIFIER_SERVICE_CAT);
+ String notifierServiceName = properties.getProperty(NOTIFIER_SERVICE_NAME);
+
+ try {
+ serviceInvoker = new ServiceInvoker(serviceCategoryName, serviceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + serviceCategoryName + ":" + serviceName + "'.", e);
+ }
+
+ try {
+ bank1Invoker = new ServiceInvoker(bank1ServiceCategoryName, bank1ServiceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + bank1ServiceCategoryName + ":" + bank1ServiceName + "'.", e);
+ }
+
+ try {
+ bank2Invoker = new ServiceInvoker(bank2ServiceCategoryName, bank2ServiceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + bank2ServiceCategoryName + ":" + bank2ServiceName + "'.", e);
+ }
+
+ try {
+ notifierInvoker = new ServiceInvoker(notifierServiceCategoryName, notifierServiceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + notifierServiceCategoryName + ":" + notifierServiceName + "'.", e);
+ }
+ }
+
+ public void processLoanRequest(WebCustomer wCustomer) {
+
+ Customer customer = getCustomer(wCustomer);
+ //keep the customer in a file someplace for later use, if needed
+ CustomerMasterFile.addCustomer(String.valueOf(customer.ssn), customer);
+
+ //step 1 - send to credit agency for credit score if available
+
+ int score=sendToCreditAgency(customer);
+
+ //added a pause here to give the creditagency some time to reply
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ //step 2 - check if score is acceptable
+
+ if (score >= 7) {
+ //step 3a - send to Bank - async
+ System.out.println("sending to first Bank...");
+ sendToBank(bank1Invoker, customer, "b1");
+
+ System.out.println("sending to second Bank...");
+ sendToBank(bank2Invoker, customer, "b2");
+ } else {
+ //step 3b - notify customer that credit is not acceptable
+ String invalidCredit="<insufficientCredit><customerUID>"+customer.ssn+"</customerUID>" +
+ "<ref>0</ref>"+
+ "<customerEmail>"+customer.email+"</customerEmail>" +
+ "<errorCode>3</errorCode></insufficientCredit>";
+
+ Message notifyMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+ notifyMessage.getBody().add(invalidCredit);
+
+ try {
+ notifierInvoker.deliverAsync(notifyMessage);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+ }
+
+ private Customer getCustomer(WebCustomer wCustomer) {
+ Customer customer = new Customer();
+ customer.ssn = wCustomer.getSsn();
+ customer.name = wCustomer.getName();
+ customer.address = wCustomer.getAddress();
+ customer.email = wCustomer.getEmail();
+ customer.salary = wCustomer.getSalary();
+ customer.loanAmount = wCustomer.getLoanAmount();
+ customer.loanDuration = wCustomer.getLoanDuration();
+ customer.creditScore = 0;
+
+ return customer;
+ }
+
+
+ private void sendToBank(ServiceInvoker invoker, Customer customer, String ref) {
+ Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+ try {
+ //create a Quote Request that the bank expects
+ QuoteRequest quote = new QuoteRequest();
+ quote.ssn = customer.ssn;
+ quote.ref = ref;
+ quote.amount = (int) customer.loanAmount;
+ quote.creditScore = customer.creditScore;
+ quote.creditHistoryLen = 0; //not sure who added this one
+ quote.term = customer.loanDuration;
+ quote.customerEmail = customer.email;
+
+ message.getBody().add(quote.getXML());
+ invoker.deliverAsync(message);
+
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ private int sendToCreditAgency(Customer customer) {
+ Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+ Message replyMessage;
+ int score = 0;
+
+ try {
+ logger.debug("sending to credit agency");
+
+ //set the customer details inside the message
+ message.getBody().add(customer.getXML());
+
+ logger.info("Sending request to creditAgency: " + message.getBody().get());
+
+ replyMessage = serviceInvoker.deliverSync(message, 5000);
+ if (replyMessage != null) {
+ logger.info("received reply from creditAgency action: " + replyMessage.getBody().get());
+
+ String xml =(String)replyMessage.getBody().get();
+
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ java.io.InputStream xmlstr=
+ new java.io.ByteArrayInputStream(xml.getBytes());
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=builder.parse(xmlstr);
+
+ org.w3c.dom.Element tree = doc.getDocumentElement();
+
+ score = Integer.parseInt(tree.getAttribute("score"));
+
+ logger.debug("Score from XML is: "+score);
+ } else {
+ logger.debug("reply not received from credit agency - setting a value of 5");
+ score = 5;
+ }
+ } catch (Exception ex2) {
+ logger.error("exception occured: " + ex2);
+ }
+
+ return score;
+ }
+
+
+}
Added: trunk/samples/jbossesb/trailblazer/client/java-files/SuccessfulLoanBroker.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/java-files/SuccessfulLoanBroker.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/java-files/SuccessfulLoanBroker.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,228 @@
+package org.jboss.soa.esb.samples.trailblazer.loanbroker;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.jboss.soa.esb.samples.trailblazer.util.TrailblazerProperties;
+import org.jboss.soa.esb.samples.trailblazer.web.WebCustomer;
+import org.jboss.soa.esb.client.ServiceInvoker;
+
+/*
+ * LoanBroker is responsible for getting customer requests for loans onto the JBoss ESB
+ * Requests will come from a JSR-181 pojo web service (@org.jboss.soa.esb.samples.trailblazer.web.LoanBrokerWS)
+ * The sequence of events from the LoanBroker are:
+ * 1 - Prepare a request for the CreditAgency (transform the customer into a XML representation)
+ * 2 - Send to CreditAgency and get response (lookup the customer using the SSN (see @CustomerMasterFile)
+ * 3 - Prepare a LoanRequest for each of the banks in their unique data structures and send
+ * 4 - Collect the response(s) from the bank(s) and send an email to the customer with the quote offers
+ */
+
+public class LoanBroker {
+
+ private static Logger logger = Logger.getLogger(LoanBroker.class);
+ //used to locate our entries in the trailblazer-properties
+ private final String CREDIT_AGENCY_SERVICE_NAME = "creditagency.service.epr.name";
+ private final String CREDIT_AGENCY_SERVICE_CAT = "creditagency.service.category";
+ private final String BANK1_SERVICE_NAME = "bank1.service.epr.name";
+ private final String BANK1_SERVICE_CAT = "bank1.service.category";
+ private final String BANK2_SERVICE_NAME = "bank2.service.epr.name";
+ private final String BANK2_SERVICE_CAT = "bank2.service.category";
+ private final String NOTIFIER_SERVICE_NAME = "notifier.service.epr.name";
+ private final String NOTIFIER_SERVICE_CAT = "notifier.service.category";
+ private Properties properties = new TrailblazerProperties();
+ private ServiceInvoker serviceInvoker;
+ private ServiceInvoker bank1Invoker;
+ private ServiceInvoker bank2Invoker;
+ private ServiceInvoker notifierInvoker;
+
+ public LoanBroker() {
+ String serviceCategoryName = properties.getProperty(CREDIT_AGENCY_SERVICE_CAT);
+ String serviceName = properties.getProperty(CREDIT_AGENCY_SERVICE_NAME);
+ String bank1ServiceCategoryName = properties.getProperty(BANK1_SERVICE_CAT);
+ String bank1ServiceName = properties.getProperty(BANK1_SERVICE_NAME);
+ String bank2ServiceCategoryName = properties.getProperty(BANK2_SERVICE_CAT);
+ String bank2ServiceName = properties.getProperty(BANK2_SERVICE_NAME);
+ String notifierServiceCategoryName = properties.getProperty(NOTIFIER_SERVICE_CAT);
+ String notifierServiceName = properties.getProperty(NOTIFIER_SERVICE_NAME);
+
+ try {
+ serviceInvoker = new ServiceInvoker(serviceCategoryName, serviceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + serviceCategoryName + ":" + serviceName + "'.", e);
+ }
+
+ try {
+ bank1Invoker = new ServiceInvoker(bank1ServiceCategoryName, bank1ServiceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + bank1ServiceCategoryName + ":" + bank1ServiceName + "'.", e);
+ }
+
+ try {
+ bank2Invoker = new ServiceInvoker(bank2ServiceCategoryName, bank2ServiceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + bank2ServiceCategoryName + ":" + bank2ServiceName + "'.", e);
+ }
+
+ try {
+ notifierInvoker = new ServiceInvoker(notifierServiceCategoryName, notifierServiceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + notifierServiceCategoryName + ":" + notifierServiceName + "'.", e);
+ }
+ }
+
+ public void processLoanRequest(WebCustomer wCustomer) {
+
+ Customer customer = getCustomer(wCustomer);
+ //keep the customer in a file someplace for later use, if needed
+ CustomerMasterFile.addCustomer(String.valueOf(customer.ssn), customer);
+
+ //step 1 - send to credit agency for credit score if available
+
+ int score=sendToCreditAgency(customer);
+
+ //added a pause here to give the creditagency some time to reply
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ //step 2 - check if score is acceptable
+
+ if (score >= 4) {
+ //step 3a - send to Bank - async
+ System.out.println("sending to first Bank...");
+ sendToBank(bank1Invoker, customer, "b1");
+
+ System.out.println("sending to second Bank...");
+ sendToBank(bank2Invoker, customer, "b2");
+ } else {
+ //step 3b - notify customer that credit is not acceptable
+ String invalidCredit="<insufficientCredit><customerUID>"+customer.ssn+"</customerUID>" +
+ "<ref>0</ref>"+
+ "<customerEmail>"+customer.email+"</customerEmail>" +
+ "<errorCode>3</errorCode></insufficientCredit>";
+
+ Message notifyMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+ notifyMessage.getBody().add(invalidCredit);
+
+ try {
+ notifierInvoker.deliverAsync(notifyMessage);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+ }
+
+ private Customer getCustomer(WebCustomer wCustomer) {
+ Customer customer = new Customer();
+ customer.ssn = wCustomer.getSsn();
+ customer.name = wCustomer.getName();
+ customer.address = wCustomer.getAddress();
+ customer.email = wCustomer.getEmail();
+ customer.salary = wCustomer.getSalary();
+ customer.loanAmount = wCustomer.getLoanAmount();
+ customer.loanDuration = wCustomer.getLoanDuration();
+ customer.creditScore = 0;
+
+ return customer;
+ }
+
+
+ private void sendToBank(ServiceInvoker invoker, Customer customer, String ref) {
+ Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+ try {
+ //create a Quote Request that the bank expects
+ QuoteRequest quote = new QuoteRequest();
+ quote.ssn = customer.ssn;
+ quote.ref = ref;
+ quote.amount = (int) customer.loanAmount;
+ quote.creditScore = customer.creditScore;
+ quote.creditHistoryLen = 0; //not sure who added this one
+ quote.term = customer.loanDuration;
+ quote.customerEmail = customer.email;
+
+ message.getBody().add(quote.getXML());
+ invoker.deliverAsync(message);
+
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ private int sendToCreditAgency(Customer customer) {
+ Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+ Message replyMessage;
+ int score = 0;
+
+ try {
+ logger.debug("sending to credit agency");
+
+ //set the customer details inside the message
+ message.getBody().add(customer.getXML());
+
+ logger.info("Sending request to creditAgency: " + message.getBody().get());
+
+ replyMessage = serviceInvoker.deliverSync(message, 5000);
+ if (replyMessage != null) {
+ logger.info("received reply from creditAgency action: " + replyMessage.getBody().get());
+
+ String xml =(String)replyMessage.getBody().get();
+
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ java.io.InputStream xmlstr=
+ new java.io.ByteArrayInputStream(xml.getBytes());
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=builder.parse(xmlstr);
+
+ org.w3c.dom.Element tree = doc.getDocumentElement();
+
+ score = Integer.parseInt(tree.getAttribute("score"));
+
+ logger.debug("Score from XML is: "+score);
+ } else {
+ logger.debug("reply not received from credit agency - setting a value of 5");
+ score = 5;
+ }
+ } catch (Exception ex2) {
+ logger.error("exception occured: " + ex2);
+ }
+
+ return score;
+ }
+
+
+}
Added: trunk/samples/jbossesb/trailblazer/client/jsp/index.jsp
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/jsp/index.jsp (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/jsp/index.jsp 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,134 @@
+<%@ page import="org.jboss.soa.esb.samples.trailblazer.web.WebCustomer"%>
+<%@ page import="org.jboss.soa.esb.samples.trailblazer.loanbroker.LoanRequester"%>
+<%
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+String[] formHeader = {"Name", "Address", "SSN", "Email", "Salary", "Employer", "LoanAmount", "LoanDuration"};
+String[] formValue = new String[formHeader.length];
+
+String errors = "";
+int errorCount=0;
+
+for (int i=0; i<formValue.length;i++) {
+ formValue[i] = String.valueOf(request.getParameter(formHeader[i]));
+ //out.write(formHeader[i] + "=" + formValue[i] + "<br>");
+ if ("null".equals(formValue[i]) || formValue[i]==null || "".equals(formValue[i])) {
+ formValue[i]="";
+ errorCount++;
+ errors += formHeader[i] + " is a required field<br>";
+ }
+}
+//It's a new form. Let's set some default values.
+if (errorCount==formHeader.length) {
+ formValue[0]="Joe Broke";
+ formValue[1]="1 Spenditall Str., BrokeTown 99999 DC";
+ formValue[2]="1234567890";
+ formValue[3]="joe at iliketospendit.com";
+ formValue[4]="50000.00";
+ formValue[5]="Wesayso & Co";
+ formValue[6]="1000.00";
+ formValue[7]="12";
+}
+
+%>
+<html>
+<head>
+<title>JBossESB Loan Broker</title>
+<link rel="shortcut icon" href="/favicon.ico"/>
+<link rel="stylesheet" href="http://www.jboss.com/themes/jbosstheme/style/custom.css" type="text/css" media="all">
+<link rel="stylesheet" href="http://www.jboss.com/themes/jbosstheme/style/global.css" type="text/css" media="all">
+<link rel="stylesheet" href="http://www.jboss.com/themes/jbosstheme/style/headings.css" type="text/css" media="all">
+<link rel="stylesheet" href="http://www.jboss.com/themes/jbosstheme/style/layout.css" type="text/css" media="all">
+<link rel="stylesheet" href="http://www.jboss.com/themes/jbosstheme/style/navigation.css" type="text/css" media="all">
+<link rel="stylesheet" href="http://www.jboss.com/themes/jbosstheme/style/pagelayout.css" type="text/css" media="all">
+<link rel="stylesheet" href="http://www.jboss.com/themes/jbosstheme/style/tables.css" type="text/css" media="all">
+
+<link rel="stylesheet" href="http://www.jboss.com/themes/jbosstheme/style/screen.css" type="text/css" media="screen">
+<link rel="stylesheet" href="http://www.jboss.com/themes/jbosstheme/style/print.css" type="text/css" media="print">
+<link rel="stylesheet" href="http://www.jboss.com/themes/jbosstheme/style/common.css" type="text/css" media="all">
+</head>
+<body>
+
+<div id="TopLogo">
+ <a href="http://www.jboss.com"><img src="http://www.jboss.com/themes/jbosstheme/img/logo.gif" alt="JBoss - The Professional Open Source Company" border="0" /></a>
+</div>
+
+<div id="TopMenu">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="menu_JBnetwork"><a href="http://network.jboss.com/">subscription</a></td>
+ <td class="menu_JBcom"><a href="http://www.jboss.com/">jboss.com</a></td>
+
+ <td class="menu_JBorg"><a href="http://labs.jboss.com">jboss.org</a></td>
+ <td class="menu_RH"><a href="http://www.redhat.com">redhat.com</a></td>
+ </tr>
+ </table>
+</div>
+
+
+<% if (errorCount!=0) { %>
+<form id="formLoanBrokerRequest" action="index.jsp" method="post">
+
+<table width="100%" border="0" cellpadding="10" cellspacing="3">
+ <tr><td colspan="2"><br><br><br><br>
+ <tr><td colspan="2"><h1>Loan Broker Request Form</h1></td></tr>
+ <% if (errorCount < formHeader.length) { %>
+ <tr><td colspan="2"><font color="red"><%=errors %></font></td></tr>
+ <% } %>
+ <% for (int i=0; i<formHeader.length;i++) { %>
+ <tr>
+ <td width="30%" nowrap><%=formHeader[i] %></td>
+ <td width="70%"><input id="<%=formHeader[i] %>" name="<%=formHeader[i] %>" type="text"
+ class="textBox" tabindex="1" size="60" value="<%=formValue[i] %>" /></td>
+ </tr>
+ <% } %>
+
+ <tr>
+ <td><INPUT TYPE="submit" VALUE="submit loan request"> </td>
+ </tr>
+</table>
+
+</form>
+
+<% } else {
+ //Setting the values in the request
+ WebCustomer webCustomer = new WebCustomer();
+ webCustomer.setName(formValue[0]);
+ webCustomer.setAddress(formValue[1]);
+ webCustomer.setSsn(Integer.valueOf(formValue[2]).intValue());
+ webCustomer.setEmail(formValue[3]);
+ webCustomer.setSalary(Double.valueOf(formValue[4]).doubleValue());
+ webCustomer.setEmployerName(formValue[5]);
+ webCustomer.setLoanAmount(Double.valueOf(formValue[6]).doubleValue());
+ webCustomer.setLoanDuration(Integer.valueOf(formValue[7]).intValue());
+ LoanRequester.request(webCustomer);
+%>
+ <table width="100%" border="0" cellpadding="10" cellspacing="3">
+ <tr><td><br><br><br><br>
+ <tr><td><h1>Loan Broker</h1></td></tr>
+ <tr><td><h2>Request was submitted</h2></td></tr>
+ <tr><td><a href="index.jsp">Fill out another request</a></td></tr>
+
+ <% } %>
+</body>
+</html>
Added: trunk/samples/jbossesb/trailblazer/client/lib/ext/Licenses.txt
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/lib/ext/Licenses.txt (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/lib/ext/Licenses.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,479 @@
+The jars in this directory are covered by a range of licences, as described
+below.
+
+JBoss jars:
+
+/*
+ *
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ */
+
+
+Apache Jakarta Commons Collections/Commons Logging/Axis/Log4j:
+
+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.
+
+
+ JUnit
+
+ Common Public License Version 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC
+LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
+CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are
+distributed by that particular Contributor. A Contribution 'originates' from a
+Contributor if it was added to the Program by such Contributor itself or anyone
+acting on such Contributor's behalf. Contributions do not include additions to
+the Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii) are not
+derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are
+necessarily infringed by the use or sale of its Contribution alone or when
+combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement,
+including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free copyright license to
+reproduce, prepare derivative works of, publicly display, publicly perform,
+distribute and sublicense the Contribution of such Contributor, if any, and such
+derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed
+Patents to make, use, sell, offer to sell, import and otherwise transfer the
+Contribution of such Contributor, if any, in source code and object code form.
+This patent license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor, such
+addition of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other combinations
+which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses
+to its Contributions set forth herein, no assurances are provided by any
+Contributor that the Program does not infringe the patent or other intellectual
+property rights of any other entity. Each Contributor disclaims any liability to
+Recipient for claims brought by any other entity based on infringement of
+intellectual property rights or otherwise. As a condition to exercising the
+rights and licenses granted hereunder, each Recipient hereby assumes sole
+responsibility to secure any other intellectual property rights needed, if any.
+For example, if a third party patent license is required to allow Recipient to
+distribute the Program, it is Recipient's responsibility to acquire that license
+before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright license set
+forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its
+own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and
+conditions, express and implied, including warranties or conditions of title and
+non-infringement, and implied warranties or conditions of merchantability and
+fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for
+damages, including direct, indirect, special, incidental and consequential
+damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered
+by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such
+Contributor, and informs licensees how to obtain it in a reasonable manner on or
+through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the
+Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if
+any, in a manner that reasonably allows subsequent Recipients to identify the
+originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with
+respect to end users, business partners and the like. While this license is
+intended to facilitate the commercial use of the Program, the Contributor who
+includes the Program in a commercial product offering should do so in a manner
+which does not create potential liability for other Contributors. Therefore, if
+a Contributor includes the Program in a commercial product offering, such
+Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
+every other Contributor ("Indemnified Contributor") against any losses, damages
+and costs (collectively "Losses") arising from claims, lawsuits and other legal
+actions brought by a third party against the Indemnified Contributor to the
+extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor to
+control, and cooperate with the Commercial Contributor in, the defense and any
+related settlement negotiations. The Indemnified Contributor may participate in
+any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product
+offering, Product X. That Contributor is then a Commercial Contributor. If that
+Commercial Contributor then makes performance claims, or offers warranties
+related to Product X, those performance claims and warranties are such
+Commercial Contributor's responsibility alone. Under this section, the
+Commercial Contributor would have to defend claims against the other
+Contributors related to those performance claims and warranties, and if a court
+requires any other Contributor to pay any damages as a result, the Commercial
+Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED 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. Each
+Recipient is solely responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its exercise of
+rights under this Agreement, including but not limited to the risks and costs of
+program errors, compliance with applicable laws, damage to or loss of data,
+programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
+CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
+GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable
+law, it shall not affect the validity or enforceability of the remainder of the
+terms of this Agreement, and without further action by the parties hereto, such
+provision shall be reformed to the minimum extent necessary to make such
+provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to
+a patent applicable to software (including a cross-claim or counterclaim in a
+lawsuit), then any patent licenses granted by that Contributor to such Recipient
+under this Agreement shall terminate as of the date such litigation is filed. In
+addition, if Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the Program
+itself (excluding combinations of the Program with other software or hardware)
+infringes such Recipient's patent(s), then such Recipient's rights granted under
+Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to
+comply with any of the material terms or conditions of this Agreement and does
+not cure such failure in a reasonable period of time after becoming aware of
+such noncompliance. If all Recipient's rights under this Agreement terminate,
+Recipient agrees to cease use and distribution of the Program as soon as
+reasonably practicable. However, Recipient's obligations under this Agreement
+and any licenses granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in
+order to avoid inconsistency the Agreement is copyrighted and may only be
+modified in the following manner. The Agreement Steward reserves the right to
+publish new versions (including revisions) of this Agreement from time to time.
+No one other than the Agreement Steward has the right to modify this Agreement.
+IBM is the initial Agreement Steward. IBM may assign the responsibility to serve
+as the Agreement Steward to a suitable separate entity. Each new version of the
+Agreement will be given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the Agreement
+under which it was received. In addition, after a new version of the Agreement
+is published, Contributor may elect to distribute the Program (including its
+Contributions) under the new version. Except as expressly stated in Sections
+2(a) and 2(b) above, Recipient receives no rights or licenses to the
+intellectual property of any Contributor under this Agreement, whether
+expressly, by implication, estoppel or otherwise. All rights in the Program not
+expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the
+intellectual property laws of the United States of America. No party to this
+Agreement will bring a legal action under this Agreement more than one year
+after the cause of action arose. Each party waives its rights to a jury trial in
+any resulting litigation.
+
+
+
+XStream, Antlr, Stingtemplate BSD License
+
+Copyright (c) 2003-2005, Joe Walnes
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of XStream nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+
Added: trunk/samples/jbossesb/trailblazer/client/lib/ext/jaxb-api.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/client/lib/ext/jaxb-api.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/client/lib/ext/jboss-jaxws.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/client/lib/ext/jboss-jaxws.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/client/lib/ext/jbossws-client.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/client/lib/ext/jbossws-client.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/client/lib/ext/jbossws-core.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/client/lib/ext/jbossws-core.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/client/resources/jaxrpc-mapping.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/resources/jaxrpc-mapping.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/resources/jaxrpc-mapping.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,69 @@
+<?xml version='1.0' encoding='UTF-8'?><java-wsdl-mapping version='1.1' xmlns='http://java.sun.com/xml/ns/j2ee' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd'>
+ <package-mapping>
+ <package-type>org.jboss.soa.esb.samples.trailblazer.web</package-type>
+ <namespaceURI>http://org.jboss.ws/samples/rpcstyle/types</namespaceURI>
+ </package-mapping>
+ <java-xml-type-mapping>
+ <java-type>org.jboss.soa.esb.samples.trailblazer.web.WebCustomer</java-type>
+ <root-type-qname xmlns:typeNS='http://org.jboss.ws/samples/rpcstyle/types'>typeNS:WebCustomer</root-type-qname>
+ <qname-scope>complexType</qname-scope>
+ <variable-mapping>
+ <java-variable-name>address</java-variable-name>
+ <xml-element-name>address</xml-element-name>
+ </variable-mapping>
+ <variable-mapping>
+ <java-variable-name>email</java-variable-name>
+ <xml-element-name>email</xml-element-name>
+ </variable-mapping>
+ <variable-mapping>
+ <java-variable-name>employerName</java-variable-name>
+ <xml-element-name>employerName</xml-element-name>
+ </variable-mapping>
+ <variable-mapping>
+ <java-variable-name>loanAmount</java-variable-name>
+ <xml-element-name>loanAmount</xml-element-name>
+ </variable-mapping>
+ <variable-mapping>
+ <java-variable-name>loanDuration</java-variable-name>
+ <xml-element-name>loanDuration</xml-element-name>
+ </variable-mapping>
+ <variable-mapping>
+ <java-variable-name>name</java-variable-name>
+ <xml-element-name>name</xml-element-name>
+ </variable-mapping>
+ <variable-mapping>
+ <java-variable-name>salary</java-variable-name>
+ <xml-element-name>salary</xml-element-name>
+ </variable-mapping>
+ <variable-mapping>
+ <java-variable-name>ssn</java-variable-name>
+ <xml-element-name>ssn</xml-element-name>
+ </variable-mapping>
+ </java-xml-type-mapping>
+ <service-interface-mapping>
+ <service-interface>org.jboss.soa.esb.samples.trailblazer.web.LoanBrokerService</service-interface>
+ <wsdl-service-name xmlns:serviceNS='http://org.jboss.ws/samples/rpcstyle'>serviceNS:LoanBrokerService</wsdl-service-name>
+ <port-mapping>
+ <port-name>LoanBrokerInterfacePort</port-name>
+ <java-port-name>LoanBrokerInterfacePort</java-port-name>
+ </port-mapping>
+ </service-interface-mapping>
+ <service-endpoint-interface-mapping>
+ <service-endpoint-interface>org.jboss.soa.esb.samples.trailblazer.web.LoanBrokerInterface</service-endpoint-interface>
+ <wsdl-port-type xmlns:portTypeNS='http://org.jboss.ws/samples/rpcstyle'>portTypeNS:LoanBrokerInterface</wsdl-port-type>
+ <wsdl-binding xmlns:bindingNS='http://org.jboss.ws/samples/rpcstyle'>bindingNS:LoanBrokerInterfaceBinding</wsdl-binding>
+ <service-endpoint-method-mapping>
+ <java-method-name>RequestLoan</java-method-name>
+ <wsdl-operation>RequestLoan</wsdl-operation>
+ <method-param-parts-mapping>
+ <param-position>0</param-position>
+ <param-type>org.jboss.soa.esb.samples.trailblazer.web.WebCustomer</param-type>
+ <wsdl-message-mapping>
+ <wsdl-message xmlns:wsdlMsgNS='http://org.jboss.ws/samples/rpcstyle'>wsdlMsgNS:LoanBrokerInterface_RequestLoan</wsdl-message>
+ <wsdl-message-part-name>WebCustomer_1</wsdl-message-part-name>
+ <parameter-mode>IN</parameter-mode>
+ </wsdl-message-mapping>
+ </method-param-parts-mapping>
+ </service-endpoint-method-mapping>
+ </service-endpoint-interface-mapping>
+</java-wsdl-mapping>
\ No newline at end of file
Added: trunk/samples/jbossesb/trailblazer/client/resources/web.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/resources/web.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/resources/web.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
+ <servlet>
+ <servlet-name>LoanBroker</servlet-name>
+ <servlet-class>org.jboss.soa.esb.samples.trailblazer.web.LoanBrokerBean</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>LoanBroker</servlet-name>
+ <url-pattern>/LoanBroker</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: trunk/samples/jbossesb/trailblazer/client/resources/webservices.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/resources/webservices.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/resources/webservices.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,15 @@
+<webservices version='1.1' xmlns='http://java.sun.com/xml/ns/j2ee' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd'>
+ <webservice-description>
+ <webservice-description-name>LoanBrokerService</webservice-description-name>
+ <wsdl-file>WEB-INF/wsdl/LoanBrokerService.wsdl</wsdl-file>
+ <jaxrpc-mapping-file>WEB-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
+ <port-component>
+ <port-component-name>LoanBrokerInterfacePort</port-component-name>
+ <wsdl-port xmlns:portNS='http://org.jboss.ws/samples/rpcstyle'>portNS:LoanBrokerInterfacePort</wsdl-port>
+ <service-endpoint-interface>org.jboss.soa.esb.samples.trailblazer.web.LoanBrokerInterface</service-endpoint-interface>
+ <service-impl-bean>
+ <servlet-link>LoanBroker</servlet-link>
+ </service-impl-bean>
+ </port-component>
+ </webservice-description>
+</webservices>
Added: trunk/samples/jbossesb/trailblazer/client/resources/wsdl/LoanBrokerService.wsdl
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/resources/wsdl/LoanBrokerService.wsdl (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/resources/wsdl/LoanBrokerService.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,45 @@
+<definitions name='LoanBrokerService' targetNamespace='http://localhost/trailblazer' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://localhost/trailblazer' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <types>
+ <xs:schema targetNamespace='http://localhost/trailblazer' version='1.0' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
+ <xs:complexType name='webCustomer'>
+ <xs:sequence>
+ <xs:element minOccurs='0' name='address' type='xs:string'/>
+ <xs:element minOccurs='0' name='email' type='xs:string'/>
+ <xs:element minOccurs='0' name='employerName' type='xs:string'/>
+ <xs:element name='loanAmount' type='xs:double'/>
+ <xs:element name='loanDuration' type='xs:int'/>
+ <xs:element minOccurs='0' name='name' type='xs:string'/>
+ <xs:element name='salary' type='xs:double'/>
+ <xs:element name='ssn' type='xs:int'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ </types>
+ <message name='LoanBrokerInterface_RequestLoan'>
+ <part name='webCustomer_1' type='tns:webCustomer'></part>
+ </message>
+ <message name='LoanBrokerInterface_RequestLoanResponse'></message>
+ <portType name='LoanBrokerInterface'>
+ <operation name='RequestLoan' parameterOrder='webCustomer_1'>
+ <input message='tns:LoanBrokerInterface_RequestLoan'></input>
+ <output message='tns:LoanBrokerInterface_RequestLoanResponse'></output>
+ </operation>
+ </portType>
+ <binding name='LoanBrokerInterfaceBinding' type='tns:LoanBrokerInterface'>
+ <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='RequestLoan'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body namespace='http://localhost/trailblazer' use='literal'/>
+ </input>
+ <output>
+ <soap:body namespace='http://localhost/trailblazer' use='literal'/>
+ </output>
+ </operation>
+ </binding>
+ <service name='LoanBrokerService'>
+ <port binding='tns:LoanBrokerInterfaceBinding' name='LoanBrokerInterfacePort'>
+ <soap:address location='http://127.0.0.1:8080/trailblazer/LoanBroker'/>
+ </port>
+ </service>
+</definitions>
Added: trunk/samples/jbossesb/trailblazer/client/resources/wstools-config.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/resources/wstools-config.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/resources/wstools-config.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ wstools -cp ../../../output/classes -config wstools-config.xml
+-->
+
+<configuration xmlns="http://www.jboss.org/jbossws-tools"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.org/jbossws-tools http://www.jboss.org/jbossws-tools/schema/jbossws-tool_1_0.xsd">
+
+ <java-wsdl>
+ <service name="LoanBrokerService" style="rpc" endpoint="org.jboss.soa.esb.samples.trailblazer.web.LoanBrokerInterface"/>
+ <namespaces target-namespace="http://org.jboss.ws/samples/rpcstyle" type-namespace="http://org.jboss.ws/samples/rpcstyle/types"/>
+ <mapping file="jaxrpc-mapping.xml"/>
+ <webservices servlet-link="LoanBrokerEndpoint"/>
+ </java-wsdl>
+
+</configuration>
Added: trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/Customer.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/Customer.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/Customer.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,59 @@
+package org.jboss.soa.esb.samples.trailblazer.loanbroker;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+import java.io.Serializable;
+
+public class Customer implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ public String name="" ,address="" ,employerName="";
+ public double salary=0.0 ,loanAmount=0.0;
+ public int loanDuration=0;
+ public int ssn=0;
+ public String email="";
+ public int creditScore=0;
+ public String quoteID, rateOffered, quoteCode;
+
+ public String getCSV() {
+ String buff = (name+","+ssn+","+address+","+employerName+","+salary+","
+ +loanAmount+","+loanDuration+","+email+","+creditScore);
+
+ return buff;
+ }
+
+ public String getXML() {
+ StringBuffer ret=new StringBuffer();
+
+ ret.append("<creditCheck name=\""+name+"\" ");
+ ret.append("ssn=\""+ssn+"\" ");
+ ret.append("address=\""+address+"\" ");
+ ret.append("employerName=\""+employerName+"\" ");
+ ret.append("salary=\""+salary+"\" ");
+ ret.append("loanAmount=\""+loanAmount+"\" ");
+ ret.append("loanDuration=\""+loanDuration+"\" ");
+ ret.append("email=\""+email+"\" ");
+ ret.append("creditScore=\""+creditScore+"\" />");
+
+ return(ret.toString());
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/CustomerMasterFile.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/CustomerMasterFile.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/CustomerMasterFile.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,88 @@
+package org.jboss.soa.esb.samples.trailblazer.loanbroker;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/*
+ * Utility class used to persist the customer quote requests to a serialized Hash list on the file system
+ * Key is the customer's SSN #
+ */
+
+public class CustomerMasterFile implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private static Map<String, Customer> customers;
+ private static final String TMP_DIR = System.getProperty("java.io.tmpdir","/tmp");
+ private static final File FILE = new File(TMP_DIR, "customers");
+
+ static {
+ getCustomers();
+ }
+
+ public static synchronized void writeCustomers() {
+ try {
+ ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(FILE));
+ stream.writeObject(customers);
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public static synchronized void getCustomers() {
+
+ try {
+ ObjectInputStream ois = new ObjectInputStream(new FileInputStream(FILE));
+ customers = (Map<String, Customer>)ois.readObject();
+ } catch (Exception e) {
+ customers = new HashMap<String, Customer>();
+ }
+
+ }
+
+ public static Customer getCustomer(String id) {
+ return customers.get(id);
+ }
+
+ public static void addCustomer(String id, Customer customer) {
+ customers.put(id, customer);
+ writeCustomers();
+ }
+
+
+}
Added: trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,228 @@
+package org.jboss.soa.esb.samples.trailblazer.loanbroker;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.jboss.soa.esb.samples.trailblazer.util.TrailblazerProperties;
+import org.jboss.soa.esb.samples.trailblazer.web.WebCustomer;
+import org.jboss.soa.esb.client.ServiceInvoker;
+
+/*
+ * LoanBroker is responsible for getting customer requests for loans onto the JBoss ESB
+ * Requests will come from a JSR-181 pojo web service (@org.jboss.soa.esb.samples.trailblazer.web.LoanBrokerWS)
+ * The sequence of events from the LoanBroker are:
+ * 1 - Prepare a request for the CreditAgency (transform the customer into a XML representation)
+ * 2 - Send to CreditAgency and get response (lookup the customer using the SSN (see @CustomerMasterFile)
+ * 3 - Prepare a LoanRequest for each of the banks in their unique data structures and send
+ * 4 - Collect the response(s) from the bank(s) and send an email to the customer with the quote offers
+ */
+
+public class LoanBroker {
+
+ private static Logger logger = Logger.getLogger(LoanBroker.class);
+ //used to locate our entries in the trailblazer-properties
+ private final String CREDIT_AGENCY_SERVICE_NAME = "creditagency.service.epr.name";
+ private final String CREDIT_AGENCY_SERVICE_CAT = "creditagency.service.category";
+ private final String BANK1_SERVICE_NAME = "bank1.service.epr.name";
+ private final String BANK1_SERVICE_CAT = "bank1.service.category";
+ private final String BANK2_SERVICE_NAME = "bank2.service.epr.name";
+ private final String BANK2_SERVICE_CAT = "bank2.service.category";
+ private final String NOTIFIER_SERVICE_NAME = "notifier.service.epr.name";
+ private final String NOTIFIER_SERVICE_CAT = "notifier.service.category";
+ private Properties properties = new TrailblazerProperties();
+ private ServiceInvoker serviceInvoker;
+ private ServiceInvoker bank1Invoker;
+ private ServiceInvoker bank2Invoker;
+ private ServiceInvoker notifierInvoker;
+
+ public LoanBroker() {
+ String serviceCategoryName = properties.getProperty(CREDIT_AGENCY_SERVICE_CAT);
+ String serviceName = properties.getProperty(CREDIT_AGENCY_SERVICE_NAME);
+ String bank1ServiceCategoryName = properties.getProperty(BANK1_SERVICE_CAT);
+ String bank1ServiceName = properties.getProperty(BANK1_SERVICE_NAME);
+ String bank2ServiceCategoryName = properties.getProperty(BANK2_SERVICE_CAT);
+ String bank2ServiceName = properties.getProperty(BANK2_SERVICE_NAME);
+ String notifierServiceCategoryName = properties.getProperty(NOTIFIER_SERVICE_CAT);
+ String notifierServiceName = properties.getProperty(NOTIFIER_SERVICE_NAME);
+
+ try {
+ serviceInvoker = new ServiceInvoker(serviceCategoryName, serviceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + serviceCategoryName + ":" + serviceName + "'.", e);
+ }
+
+ try {
+ bank1Invoker = new ServiceInvoker(bank1ServiceCategoryName, bank1ServiceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + bank1ServiceCategoryName + ":" + bank1ServiceName + "'.", e);
+ }
+
+ try {
+ bank2Invoker = new ServiceInvoker(bank2ServiceCategoryName, bank2ServiceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + bank2ServiceCategoryName + ":" + bank2ServiceName + "'.", e);
+ }
+
+ try {
+ notifierInvoker = new ServiceInvoker(notifierServiceCategoryName, notifierServiceName);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + notifierServiceCategoryName + ":" + notifierServiceName + "'.", e);
+ }
+ }
+
+ public void processLoanRequest(WebCustomer wCustomer) {
+
+ Customer customer = getCustomer(wCustomer);
+ //keep the customer in a file someplace for later use, if needed
+ CustomerMasterFile.addCustomer(String.valueOf(customer.ssn), customer);
+
+ //step 1 - send to credit agency for credit score if available
+
+ int score=sendToCreditAgency(customer);
+
+ //added a pause here to give the creditagency some time to reply
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ //step 2 - check if score is acceptable
+
+ if (score >= 4) {
+ //step 3a - send to Bank - async
+ System.out.println("sending to first Bank...");
+ sendToBank(bank1Invoker, customer, "b1");
+
+ System.out.println("sending to second Bank...");
+ sendToBank(bank2Invoker, customer, "b2");
+ } else {
+ //step 3b - notify customer that credit is not acceptable
+ String invalidCredit="<insufficientCredit><customerUID>"+customer.ssn+"</customerUID>" +
+ "<ref>0</ref>"+
+ "<customerEmail>"+customer.email+"</customerEmail>" +
+ "<errorCode>3</errorCode></insufficientCredit>";
+
+ Message notifyMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+ notifyMessage.getBody().add(invalidCredit);
+
+ try {
+ notifierInvoker.deliverAsync(notifyMessage);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+ }
+
+ private Customer getCustomer(WebCustomer wCustomer) {
+ Customer customer = new Customer();
+ customer.ssn = wCustomer.getSsn();
+ customer.name = wCustomer.getName();
+ customer.address = wCustomer.getAddress();
+ customer.email = wCustomer.getEmail();
+ customer.salary = wCustomer.getSalary();
+ customer.loanAmount = wCustomer.getLoanAmount();
+ customer.loanDuration = wCustomer.getLoanDuration();
+ customer.creditScore = 0;
+
+ return customer;
+ }
+
+
+ private void sendToBank(ServiceInvoker invoker, Customer customer, String ref) {
+ Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+ try {
+ //create a Quote Request that the bank expects
+ QuoteRequest quote = new QuoteRequest();
+ quote.ssn = customer.ssn;
+ quote.ref = ref;
+ quote.amount = (int) customer.loanAmount;
+ quote.creditScore = customer.creditScore;
+ quote.creditHistoryLen = 0; //not sure who added this one
+ quote.term = customer.loanDuration;
+ quote.customerEmail = customer.email;
+
+ message.getBody().add(quote.getXML());
+ invoker.deliverAsync(message);
+
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ private int sendToCreditAgency(Customer customer) {
+ Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+ Message replyMessage;
+ int score = 0;
+
+ try {
+ logger.debug("sending to credit agency");
+
+ //set the customer details inside the message
+ message.getBody().add(customer.getXML());
+
+ logger.info("Sending request to creditAgency: " + message.getBody().get());
+
+ replyMessage = serviceInvoker.deliverSync(message, 5000);
+ if (replyMessage != null) {
+ logger.info("received reply from creditAgency action: " + replyMessage.getBody().get());
+
+ String xml =(String)replyMessage.getBody().get();
+
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ java.io.InputStream xmlstr=
+ new java.io.ByteArrayInputStream(xml.getBytes());
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=builder.parse(xmlstr);
+
+ org.w3c.dom.Element tree = doc.getDocumentElement();
+
+ score = Integer.parseInt(tree.getAttribute("score"));
+
+ logger.debug("Score from XML is: "+score);
+ } else {
+ logger.debug("reply not received from credit agency - setting a value of 5");
+ score = 5;
+ }
+ } catch (Exception ex2) {
+ logger.error("exception occured: " + ex2);
+ }
+
+ return score;
+ }
+
+
+}
Added: trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanRequester.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanRequester.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanRequester.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,34 @@
+package org.jboss.soa.esb.samples.trailblazer.loanbroker;
+
+import javax.naming.InitialContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+import org.jboss.soa.esb.samples.trailblazer.web.*;
+
+/**
+ * LoanRequester is a small class that serves as a web service client.
+ */
+public class LoanRequester {
+ public LoanRequester() {
+ }
+
+ /**
+ * Grab the port and call request loan.
+ * @return customer customer bean
+ */
+ public static void request(WebCustomer customer) {
+ try {
+ InitialContext iniCtx = new InitialContext();
+ //Service service = (Service)iniCtx.lookup("java:comp/env/service/LoanBrokerService");
+ //LoanBrokerInterface port = (LoanBrokerInterface)service.getPort(LoanBrokerInterface.class);
+ Service service = Service.create(
+ new URL("http://localhost:8080/trailblazer/LoanBroker?wsdl"),
+ new QName("http://localhost/trailblazer","LoanBrokerService") );
+ LoanBrokerInterface port = (LoanBrokerInterface)service.getPort(LoanBrokerInterface.class );
+ port.RequestLoan(customer);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/QuoteRequest.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/QuoteRequest.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/QuoteRequest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,159 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.trailblazer.loanbroker;
+
+import java.io.Serializable;
+
+
+public class QuoteRequest implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+ public int ssn;
+ public String ref;
+ public int creditScore;
+ public int creditHistoryLen;
+ public int amount;
+ public int term;
+ public String customerUniqueId;
+ public String customerEmail;
+
+ /**
+ * Gets for the credit score.
+ * @return credit score
+ */
+ public int getCreditScore() {
+ return creditScore;
+ }
+ /**
+ * Sets the credit score.
+ * @param creditScore
+ */
+ public void setCreditScore(int creditScore) {
+ this.creditScore = creditScore;
+ }
+ /**
+ * Gets the credit history length (in months).
+ * @return credit history length
+ */
+ public int getCreditHistoryLen() {
+ return creditHistoryLen;
+ }
+ /**
+ * Sets the credit history length (in months).
+ * @param creditHistoryLen
+ */
+ public void setCreditHistoryLen(int historyLength) {
+ this.creditHistoryLen = historyLength;
+ }
+ /**
+ * Gets the requested loan amount (in dollar).
+ * @return the loan amount
+ */
+ public int getAmount() {
+ return amount;
+ }
+ /**
+ * Sets the loan amount.
+ * @param amount - the loan amount (in dollar).
+ */
+ public void setAmount(int loanAmount) {
+ this.amount = loanAmount;
+ }
+ /**
+ * Gets the duration of the loan, the term, (in months).
+ * @return term
+ */
+ public int getTerm() {
+ return term;
+ }
+ /**
+ * Sets the term (duration) of the loan (in months)
+ * @param term
+ */
+ public void setTerm(int loanTerm) {
+ this.term = loanTerm;
+ }
+ /**
+ * Sets the Social Security Number (SSN).
+ * @return ssn
+ */
+ public int getSsn() {
+ return ssn;
+ }
+ /**
+ * Sets the quote reference.
+ * @param ref
+ */
+ public void setRef(String ref) {
+ this.ref = ref;
+ }
+ /**
+ * Gets the quote reference.
+ * @return ref
+ */
+ public String getRef() {
+ return ref;
+ }
+ /**
+ * Sets the Social Security Number (SSN).
+ * @param ssn
+ */
+ public void setSsn(int ssn) {
+ this.ssn = ssn;
+ }
+ /**
+ * Returns a human readable string representation of this object.
+ * @return toString
+ */
+ public String toString() {
+ return this.getClass().getSimpleName() + "=["
+ + "ssn=" + ssn
+ + "ref=" + ref
+ + ", creditScore=" + creditScore
+ + ", creditHistoryLen=" + creditHistoryLen
+ + ", amount=" + amount
+ + ", term=" + term
+ + ", customerUniqueId="+ customerUniqueId + "]";
+ }
+
+ public String getXML() {
+ StringBuffer ret=new StringBuffer();
+
+ ret.append("<quoteRequest ssn=\""+ssn+"\" ");
+ ret.append("ref=\""+ref+"\" ");
+ ret.append("creditScore=\""+creditScore+"\" ");
+ ret.append("creditHistoryLen=\""+creditHistoryLen+"\" ");
+ ret.append("amount=\""+amount+"\" ");
+ ret.append("term=\""+term+"\" ");
+ ret.append("customerUID=\""+ssn+"\" ");
+ ret.append("customerEmail=\""+customerEmail+"\" />");
+
+ return(ret.toString());
+ }
+
+ public String getCustomerUniqueId() {
+ return customerUniqueId;
+ }
+ public void setCustomerUniqueId(String customerUID) {
+ this.customerUniqueId = customerUID;
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/LoanBrokerBean.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/LoanBrokerBean.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/LoanBrokerBean.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,25 @@
+package org.jboss.soa.esb.samples.trailblazer.web;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.samples.trailblazer.loanbroker.LoanBroker;
+
+ at WebService(name = "LoanBrokerInterface", targetNamespace = "http://localhost/trailblazer", serviceName = "LoanBrokerService")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public class LoanBrokerBean {
+ private static Logger logger = Logger.getLogger(LoanBrokerBean.class);
+
+ @WebMethod
+ public void RequestLoan(@WebParam(name="webCustomer_1") WebCustomer webCustomer_1)
+ {
+ logger.info("WebCustomer received: \n" + webCustomer_1);
+
+ LoanBroker broker = new LoanBroker();
+ broker.processLoanRequest(webCustomer_1);
+ }
+}
\ No newline at end of file
Added: trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/LoanBrokerInterface.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/LoanBrokerInterface.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/LoanBrokerInterface.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,17 @@
+package org.jboss.soa.esb.samples.trailblazer.web;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+ at WebService(name = "LoanBrokerInterface", targetNamespace = "http://localhost/trailblazer")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface LoanBrokerInterface {
+ @WebMethod
+ public void RequestLoan(
+ @WebParam(name = "webCustomer_1", partName = "webCustomer_1")
+ WebCustomer webCustomer_1);
+
+}
Added: trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/WebCustomer.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/WebCustomer.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/web/WebCustomer.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,249 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+/*
+ * a simple web Customer to use in the web services call and not expose the internal esb Customer object
+ */
+package org.jboss.soa.esb.samples.trailblazer.web;
+
+import java.io.Serializable;
+
+/*
+ * WebCustomer represents the data captured in the client JSP page
+ */
+
+ at SuppressWarnings("serial")
+public class WebCustomer implements Serializable
+{
+ private java.lang.String address;
+
+ private java.lang.String email;
+
+ private java.lang.String employerName;
+
+ private double loanAmount;
+
+ private int loanDuration;
+
+ private java.lang.String name;
+
+ private double salary;
+
+ private int ssn;
+
+ public WebCustomer() {
+ }
+
+ public WebCustomer(
+ java.lang.String address,
+ java.lang.String email,
+ java.lang.String employerName,
+ double loanAmount,
+ int loanDuration,
+ java.lang.String name,
+ double salary,
+ int ssn) {
+ this.address = address;
+ this.email = email;
+ this.employerName = employerName;
+ this.loanAmount = loanAmount;
+ this.loanDuration = loanDuration;
+ this.name = name;
+ this.salary = salary;
+ this.ssn = ssn;
+ }
+ public String toString() {
+ String ret = "-- WebCustomer details -- \n";
+ ret += "name: " + name + "\n";
+ ret += "address: " + address + "\n";
+ ret += "employerName: " + employerName + "\n";
+ ret += "salary: " + salary + "\n";
+ ret += "loanAmount: " + loanAmount + "\n";
+ ret += "loanDuration: " + loanDuration + "\n";
+ ret += "ssn: " + ssn + "\n";
+ ret += "email: " + email + "\n";
+ ret += "--------------------------";
+
+ return ret;
+ }
+
+ /**
+ * Gets the address value for this WebCustomer.
+ *
+ * @return address
+ */
+ public java.lang.String getAddress() {
+ return address;
+ }
+
+
+ /**
+ * Sets the address value for this WebCustomer.
+ *
+ * @param address
+ */
+ public void setAddress(java.lang.String address) {
+ this.address = address;
+ }
+
+
+ /**
+ * Gets the email value for this WebCustomer.
+ *
+ * @return email
+ */
+ public java.lang.String getEmail() {
+ return email;
+ }
+
+
+ /**
+ * Sets the email value for this WebCustomer.
+ *
+ * @param email
+ */
+ public void setEmail(java.lang.String email) {
+ this.email = email;
+ }
+
+
+ /**
+ * Gets the employerName value for this WebCustomer.
+ *
+ * @return employerName
+ */
+ public java.lang.String getEmployerName() {
+ return employerName;
+ }
+
+
+ /**
+ * Sets the employerName value for this WebCustomer.
+ *
+ * @param employerName
+ */
+ public void setEmployerName(java.lang.String employerName) {
+ this.employerName = employerName;
+ }
+
+
+ /**
+ * Gets the loanAmount value for this WebCustomer.
+ *
+ * @return loanAmount
+ */
+ public double getLoanAmount() {
+ return loanAmount;
+ }
+
+
+ /**
+ * Sets the loanAmount value for this WebCustomer.
+ *
+ * @param loanAmount
+ */
+ public void setLoanAmount(double loanAmount) {
+ this.loanAmount = loanAmount;
+ }
+
+
+ /**
+ * Gets the loanDuration value for this WebCustomer.
+ *
+ * @return loanDuration
+ */
+ public int getLoanDuration() {
+ return loanDuration;
+ }
+
+
+ /**
+ * Sets the loanDuration value for this WebCustomer.
+ *
+ * @param loanDuration
+ */
+ public void setLoanDuration(int loanDuration) {
+ this.loanDuration = loanDuration;
+ }
+
+
+ /**
+ * Gets the name value for this WebCustomer.
+ *
+ * @return name
+ */
+ public java.lang.String getName() {
+ return name;
+ }
+
+
+ /**
+ * Sets the name value for this WebCustomer.
+ *
+ * @param name
+ */
+ public void setName(java.lang.String name) {
+ this.name = name;
+ }
+
+
+ /**
+ * Gets the salary value for this WebCustomer.
+ *
+ * @return salary
+ */
+ public double getSalary() {
+ return salary;
+ }
+
+
+ /**
+ * Sets the salary value for this WebCustomer.
+ *
+ * @param salary
+ */
+ public void setSalary(double salary) {
+ this.salary = salary;
+ }
+
+
+ /**
+ * Gets the ssn value for this WebCustomer.
+ *
+ * @return ssn
+ */
+ public int getSsn() {
+ return ssn;
+ }
+
+
+ /**
+ * Sets the ssn value for this WebCustomer.
+ *
+ * @param ssn
+ */
+ public void setSsn(int ssn) {
+ this.ssn = ssn;
+ }
+
+}
Added: trunk/samples/jbossesb/trailblazer/esb/build.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/build.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/build.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,106 @@
+<project name="TRAILBLAZER" default="org.jboss.esb.samples.trailblazer.esb.compile" basedir=".">
+
+ <property name="org.jboss.soa.samples.trailblazer.esb_home" value="../../.."/>
+ <property name="org.jboss.esb.samples.trailblazer.esb.dest" value="${basedir}/build"/>
+ <property name="org.jboss.esb.samples.trailblazer.esb.classes.dir" value="${basedir}/build/classes/esb/"/>
+ <property name="org.jboss.esb.samples.trailblazer.esb.testclasses.dir" value="${basedir}/build/classes/tests/"/>
+ <property name="org.jboss.esb.samples.trailblazer.esb.src.dir" value="${basedir}/src"/>
+ <property name="org.jboss.esb.samples.trailblazer.esb.test.dir" value="${basedir}/test"/>
+ <property name="org.jboss.esb.samples.trailblazer.esb.lib.dir" value="${basedir}/lib"/>
+ <property name="org.jboss.esb.samples.trailblazer.esb.tests.report.dir" value="${basedir}/build/tests"/>
+
+ <!-- UPDATE THIS WITH YOUR JBOSS_HOME -->
+ <property name="org.jboss.soa.samples.trailblazer.jboss_home" value="/usr/local/jboss-4.0.4"/>
+
+ <property environment="env" />
+
+ <property name="org.jboss.soa.esb.lib.file" value="jbossesb-rosetta.jar"/>
+ <property name="org.jboss.soa.esb.lib.dist.dir" value="${org.jboss.soa.samples.trailblazer.esb_home}/lib"/>
+ <property name="org.jboss.soa.esb.lib.src.dir" value="../../../build/jbossesb/lib"/>
+
+ <available file="${org.jboss.soa.esb.lib.file}"
+ filepath="${org.jboss.soa.esb.lib.dist.dir}"
+ property="org.jboss.soa.esb.lib.dir"
+ value="${org.jboss.soa.esb.lib.dist.dir}"/>
+
+ <available file="${org.jboss.soa.esb.lib.file}"
+ filepath="${org.jboss.soa.esb.lib.src.dir}"
+ property="org.jboss.soa.esb.lib.dir"
+ value="${org.jboss.soa.esb.lib.src.dir}"/>
+
+
+ <!-- classpath -->
+ <path id="org.jboss.esb.samples.trailblazer.esb.classpath">
+ <fileset dir="${org.jboss.esb.samples.trailblazer.esb.lib.dir}/ext" includes="*.jar"/>
+ <fileset dir="${org.jboss.soa.esb.lib.dir}/ext" includes="*.jar"/>
+ <fileset dir="${org.jboss.soa.samples.trailblazer.jboss_home}/client" includes="jbossall-client.jar jbossws-client.jar mail.jar"/>
+ <fileset dir="${org.jboss.soa.esb.lib.dir}" includes="*.jar"/>
+ </path>
+
+ <!-- classpath for running the listener-->
+ <path id="org.jboss.esb.samples.trailblazer.esb.classpath.run">
+ <fileset dir="${org.jboss.esb.samples.trailblazer.esb.dest}/dist" includes="trailblazer-esb.jar"/>
+ <fileset dir="${org.jboss.soa.samples.trailblazer.esb_home}/lib/ext" includes="*.jar"/>
+ <fileset dir="${org.jboss.soa.esb.lib.dir}/ext" includes="*.jar"/>
+ <!-- for finding the jbossesb-properties.xml file -->
+ <fileset dir="${org.jboss.soa.samples.trailblazer.esb_home}/install/conf" includes="*.jar"/>
+ </path>
+
+ <target name="clean">
+ <delete dir="${org.jboss.esb.samples.trailblazer.esb.dest}" />
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Prepares the directory structure -->
+ <!-- =================================================================== -->
+ <target name="org.jboss.esb.samples.trailblazer.esb.prepare">
+ <mkdir dir="${org.jboss.esb.samples.trailblazer.esb.dest}"/>
+ <mkdir dir="${org.jboss.esb.samples.trailblazer.esb.dest}/dist"/>
+ <mkdir dir="${org.jboss.esb.samples.trailblazer.esb.dest}/classes/esb"/>
+ </target>
+
+ <!-- Compilation targets -->
+ <target name="org.jboss.esb.samples.trailblazer.esb.compile" depends="org.jboss.esb.samples.trailblazer.esb.prepare"
+ description="Compile all classes">
+
+ <javac
+ destdir="${org.jboss.esb.samples.trailblazer.esb.classes.dir}"
+ classpathref="org.jboss.esb.samples.trailblazer.esb.classpath"
+ debug="true"
+ >
+ <src path="${org.jboss.esb.samples.trailblazer.esb.src.dir}"/>
+ </javac>
+
+ </target>
+
+ <!-- javadocs paths -->
+ <path id="org.jboss.esb.samples.trailblazer.esb.javadocs.path">
+ <pathelement path="esb/classes"/>
+ </path>
+
+ <!-- Jar targets -->
+ <target name="org.jboss.esb.samples.trailblazer.esb.jar" depends="org.jboss.esb.samples.trailblazer.esb.compile" >
+ <echo message="Building Trailblazer ESB jar file"/>
+ <delete file="${org.jboss.esb.samples.trailblazer.esb.dest}/dist/trailblazer-esb.jar" />
+ <jar destfile="${org.jboss.esb.samples.trailblazer.esb.dest}/dist/trailblazer-esb.jar"
+ basedir="${org.jboss.esb.samples.trailblazer.esb.classes.dir}"
+ includes="**/*.class" excludes="**/web/*.class"
+ />
+ </target>
+
+ <!-- Short target names -->
+ <target name="compile" depends="org.jboss.esb.samples.trailblazer.esb.compile"/>
+ <target name="jar" depends="org.jboss.esb.samples.trailblazer.esb.jar"/>
+
+ <!-- run the listener -->
+ <target name="runESB" depends="org.jboss.esb.samples.trailblazer.esb.jar">
+ <echo>Running ESB Trailblazer listeners</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.trailblazer.util.Launcher" failonerror="true"
+ args="10 /home/dbrum/dev/jbossesb/product/samples/trailblazer2/conf/jbossesb-trailblazer.xml">
+ <classpath refid="org.jboss.esb.samples.trailblazer.esb.classpath"/>
+ <classpath refid="org.jboss.esb.samples.trailblazer.esb.classpath.run"/>
+ </java>
+ </target>
+
+
+</project>
Added: trunk/samples/jbossesb/trailblazer/esb/conf/deployment.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/conf/deployment.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/conf/deployment.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,11 @@
+<jbossesb-deployment>
+ <depends>jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-creditAgencyQueue</depends>
+ <depends>jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-creditAgencyQueue_reply</depends>
+ <depends>jboss.esb.trailblazer.destination:service=Queue,name=jms-tb-jmsBankRequestQueue</depends>
+ <depends>jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-jmsBankRequestQueue</depends>
+ <depends>jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-jmsBankResponseQueue</depends>
+ <depends>jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-jmsBankGatewayResponseQueue</depends>
+ <depends>jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-fileBankRequestQueue</depends>
+ <depends>jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-fileBankResponseQueue</depends>
+ <depends>jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-customerNotifier</depends>
+</jbossesb-deployment>
Added: trunk/samples/jbossesb/trailblazer/esb/conf/jbm-queue-service.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/conf/jbm-queue-service.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/conf/jbm-queue-service.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-creditAgencyQueue"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-creditAgencyQueue_reply"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=jms-tb-jmsBankRequestQueue"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-jmsBankRequestQueue"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-jmsBankResponseQueue"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-jmsBankGatewayResponseQueue"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-fileBankRequestQueue"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-fileBankResponseQueue"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-customerNotifier"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added: trunk/samples/jbossesb/trailblazer/esb/conf/jbmq-queue-service.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/conf/jbmq-queue-service.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/conf/jbmq-queue-service.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-creditAgencyQueue">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-creditAgencyQueue_reply">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=jms-tb-jmsBankRequestQueue">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-jmsBankRequestQueue">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-jmsBankResponseQueue">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-jmsBankGatewayResponseQueue">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-fileBankRequestQueue">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-fileBankResponseQueue">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.trailblazer.destination:service=Queue,name=esb-tb-customerNotifier">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+
+</server>
Added: trunk/samples/jbossesb/trailblazer/esb/conf/jboss-esb.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/conf/jboss-esb.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/conf/jboss-esb.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,140 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
+ parameterReloadSecs="5000">
+
+ <providers>
+ <jms-provider name="JBossMQ" connection-factory="ConnectionFactory"
+ jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-URL="localhost">
+ <jms-bus busid="creditAgencyRequest">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/esb-tb-creditAgencyQueue" selector="function='request'"/>
+ </jms-bus>
+ <jms-bus busid="jmsBankRequest">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/esb-tb-jmsBankRequestQueue"/>
+ </jms-bus>
+ <jms-bus busid="fileBankRequest">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/esb-tb-fileBankRequestQueue"/>
+ </jms-bus>
+ <jms-bus busid="jmsBankResponseGateway">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/esb-tb-jmsBankGatewayResponseQueue"/>
+ </jms-bus>
+ <jms-bus busid="jmsBankResponseListener">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/esb-tb-jmsBankResponseQueue"/>
+ </jms-bus>
+ <jms-bus busid="fileBankResponseListener">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/esb-tb-fileBankResponseQueue"/>
+ </jms-bus>
+ <jms-bus busid="customerNotifier">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/esb-tb-customerNotifier"/>
+ </jms-bus>
+ </jms-provider>
+
+ <fs-provider name="FSprovider1">
+ <fs-bus busid="fileBankChannel" >
+ <fs-message-filter
+ directory="/tmp/output"
+ input-suffix=".quote"
+ work-suffix=".esbWorking"
+ post-delete="true"
+ error-delete="true" />
+ </fs-bus>
+ </fs-provider>
+ </providers>
+ <services>
+
+ <service category="tbCreditAGency" name="creditagency" description="Credit Agency Service">
+ <listeners>
+ <jms-listener name="trailblazer-jmscreditagency"
+ busidref="creditAgencyRequest"
+ maxThreads="1"/>
+ </listeners>
+ <actions>
+ <action class="org.jboss.soa.esb.samples.trailblazer.actions.CreditCheckXMLToCSVActions"
+ process="handle" name="XMLToCSV">
+ </action>
+ <!--action name="transform-from-csv" class="org.jboss.soa.esb.actions.converters.SmooksTransformer">
+ <property name="resource-config" value="/smooks-xml2csv.xml" />
+ </action-->
+
+ <action class="org.jboss.soa.esb.samples.trailblazer.actions.CreditAgencyActions"
+ process="processCreditRequest" name="fido">
+ </action>
+ <action name="transform-from-csv" class="org.jboss.soa.esb.actions.converters.SmooksTransformer">
+ <property name="resource-config" value="/smooks-csv2xml.xml" />
+ </action>
+ <!--action class="org.jboss.soa.esb.samples.trailblazer.actions.CreditCheckCSVToXMLActions"
+ process="handle" name="CSVToXML">
+ </action-->
+ </actions>
+ </service>
+ <service category="tbBanks" name="jmsBank" description="JMS Bank Service">
+ <listeners>
+ <jms-listener name="trailblazer-jmsbankreq"
+ busidref="jmsBankRequest"
+ maxThreads="1"/>
+ </listeners>
+ <actions mep="OneWay" >
+ <action class="org.jboss.soa.esb.actions.routing.JMSRouter"
+ name="jmsBankAction" >
+ <property name="jndiName" value="queue/jms-tb-jmsBankRequestQueue" />
+ <property name="unwrap" value="true" />
+ </action>
+ </actions>
+ </service>
+ <service category="tbJmsbank" name="jmsbankreplies" description="Trailblazer JMS Bank Reply Service">
+ <listeners>
+ <jms-listener name="trailblazer-jmsbankrespgw"
+ busidref="jmsBankResponseGateway"
+ maxThreads="1"
+ is-gateway="true"/>
+ <jms-listener name="trailblazer-jmsbankreplies"
+ busidref="jmsBankResponseListener"
+ maxThreads="1"/>
+ </listeners>
+ <actions>
+ <action class="org.jboss.soa.esb.samples.trailblazer.actions.BankResponseActions"
+ process="processResponseFromJMSBank" name="pepe"/>
+ </actions>
+ </service>
+ <service category="tbBanks" name="fileBank" description="File Bank Service">
+ <listeners>
+ <jms-listener name="trailblazer-filebankreq"
+ busidref="fileBankRequest"
+ maxThreads="1"/>
+ </listeners>
+ <actions mep="OneWay" >
+ <action class="org.jboss.soa.esb.samples.trailblazer.actions.FileBankRequestActions"
+ process="processFileBankRequest" name="fileBankRequestAction" >
+ </action>
+ </actions>
+ </service>
+ <service category="tbFilebank" name="filebankreplies" description="Trailblazer File Bank Reply Service">
+ <listeners>
+ <fs-listener name="FileGateway"
+ busidref="fileBankChannel"
+ maxThreads="1"
+ is-gateway="true"
+ schedule-frequency="10" />
+ <jms-listener name="trailblazer-filebankreplies"
+ busidref="fileBankResponseListener"
+ maxThreads="1"/>
+ </listeners>
+ <actions>
+ <action class="org.jboss.soa.esb.samples.trailblazer.actions.BankResponseActions"
+ process="processResponseFromFileBank" name="filebankin"/>
+ </actions>
+ </service>
+ <service category="notifiers" name="customer" description="Customer Notification Service">
+ <listeners>
+ <jms-listener name="trailblazer-custnotifier"
+ busidref="customerNotifier"
+ maxThreads="1"/>
+ </listeners>
+ <actions mep="OneWay" >
+ <action class="org.jboss.soa.esb.samples.trailblazer.actions.NotifyCustomerActions"
+ process="notifyCustomer" name="notify"/>
+ </actions>
+ </service>
+ </services>
+
+</jbossesb>
Added: trunk/samples/jbossesb/trailblazer/esb/conf/jbossesb-properties-monitor.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/conf/jbossesb-properties-monitor.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/conf/jbossesb-properties-monitor.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., 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.
+
+ (C) 2005-2006,
+ @author JBoss Inc.
+-->
+<!-- $Id: jbossesb-unittest-properties.xml $ -->
+<!--
+ These options are described in the JBossESB manual.
+ Defaults are provided here for convenience only.
+
+ Please read through this file prior to using the system, and consider
+ updating the specified entries.
+-->
+<esb
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="jbossesb-1_0.xsd">
+ <properties name="core">
+ <property name="org.jboss.soa.esb.jndi.server.context.factory" value="org.jnp.interfaces.NamingContextFactory"/>
+ <property name="org.jboss.soa.esb.jndi.server.url" value="localhost"/>
+ <property name="org.jboss.soa.esb.persistence.connection.factory" value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
+ <property name="org.jboss.soa.esb.loadbalancer.policy" value="org.jboss.soa.esb.listeners.ha.RoundRobin"/>
+ </properties>
+ <properties name="registry">
+ <property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.registry.local.InquiryService#inquire"/>
+ <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.registry.local.PublishService#publish"/>
+ <property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
+ <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
+ <property name="org.jboss.soa.esb.registry.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.registry.password" value="password"/>
+ <!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
+ <property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/>
+ </properties>
+ <properties name="transports" depends="core">
+ <property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>
+ <property name="org.jboss.soa.esb.mail.smtp.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.mail.smtp.password" value=""/>
+ <property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
+ <property name="org.jboss.soa.esb.mail.smtp.auth" value="true"/>
+ <property name="org.jboss.soa.esb.ftp.localdir" value="/tmp"/>
+ <property name="org.jboss.soa.esb.ftp.remotedir" value="/tmp"/>
+ <property name="org.jboss.soa.esb.jms.connectionPool" value="20"/>
+ <property name="org.jboss.soa.esb.jms.sessionSleep" value="30"/>
+ </properties>
+ <properties name="connection">
+ <property name="min-pool-size" value="5"/>
+ <property name="max-pool=size" value="10"/>
+ <property name="blocking-timeout-millis" value="5000"/>
+ <property name="abandoned-connection-timeout" value="10000"/>
+ <property name="abandoned-connection-time-interval" value="30000"/>
+ </properties>
+ <properties name="dbstore">
+
+ <!-- connection manager type -->
+ <!-- <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.StandaloneConnectionManager"/> -->
+ <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.J2eeConnectionManager"/>
+
+ <!-- this property is only used if using the j2ee connection manager -->
+ <property name="org.jboss.soa.esb.persistence.db.datasource.name" value="java:/JBossESBDS"/>
+
+ <!-- standalone connection pooling settings -->
+ <property name="org.jboss.soa.esb.persistence.db.connection.url" value="jdbc:hsqldb:hsql://localhost:9001/"/>
+ <property name="org.jboss.soa.esb.persistence.db.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+ <property name="org.jboss.soa.esb.persistence.db.user" value="sa"/>
+ <property name="org.jboss.soa.esb.persistence.db.pwd" value=""/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.initial.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.min.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.max.size" value="5"/>
+ <!--table managed by pool to test for valid connections - created by pool automatically -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.test.table" value="pooltest"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis" value="5000"/>
+
+ </properties>
+
+ <properties name="filters">
+ <property name="org.jboss.soa.esb.filter.1" value="org.jboss.internal.soa.esb.message.filter.MetaDataFilter"/>
+ <property name="org.jboss.soa.esb.filter.2" value="org.jboss.internal.soa.esb.message.filter.GatewayFilter"/>
+ <property name="org.jboss.soa.esb.filter.3" value="org.pi4soa.jbossesb.monitor.MonitorFilter" />
+ </properties>
+</esb>
Added: trunk/samples/jbossesb/trailblazer/esb/conf/jbossesb-properties.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/conf/jbossesb-properties.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/conf/jbossesb-properties.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., 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.
+
+ (C) 2005-2006,
+ @author JBoss Inc.
+-->
+<!-- $Id: jbossesb-unittest-properties.xml $ -->
+<!--
+ These options are described in the JBossESB manual.
+ Defaults are provided here for convenience only.
+
+ Please read through this file prior to using the system, and consider
+ updating the specified entries.
+-->
+<esb
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="jbossesb-1_0.xsd">
+ <properties name="core">
+ <property name="org.jboss.soa.esb.jndi.server.context.factory" value="org.jnp.interfaces.NamingContextFactory"/>
+ <property name="org.jboss.soa.esb.jndi.server.url" value="localhost"/>
+ <property name="org.jboss.soa.esb.persistence.connection.factory" value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
+ <property name="org.jboss.soa.esb.loadbalancer.policy" value="org.jboss.soa.esb.listeners.ha.RoundRobin"/>
+ </properties>
+ <properties name="registry">
+ <property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.registry.local.InquiryService#inquire"/>
+ <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.registry.local.PublishService#publish"/>
+ <property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
+ <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
+ <property name="org.jboss.soa.esb.registry.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.registry.password" value="password"/>
+ <!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
+ <property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/>
+ </properties>
+ <properties name="transports" depends="core">
+ <property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>
+ <property name="org.jboss.soa.esb.mail.smtp.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.mail.smtp.password" value=""/>
+ <property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
+ <property name="org.jboss.soa.esb.mail.smtp.auth" value="true"/>
+ <property name="org.jboss.soa.esb.ftp.localdir" value="/tmp"/>
+ <property name="org.jboss.soa.esb.ftp.remotedir" value="/tmp"/>
+ <property name="org.jboss.soa.esb.jms.connectionPool" value="20"/>
+ <property name="org.jboss.soa.esb.jms.sessionSleep" value="30"/>
+ </properties>
+ <properties name="connection">
+ <property name="min-pool-size" value="5"/>
+ <property name="max-pool=size" value="10"/>
+ <property name="blocking-timeout-millis" value="5000"/>
+ <property name="abandoned-connection-timeout" value="10000"/>
+ <property name="abandoned-connection-time-interval" value="30000"/>
+ </properties>
+ <properties name="dbstore">
+
+ <!-- connection manager type -->
+ <!-- <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.StandaloneConnectionManager"/> -->
+ <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.J2eeConnectionManager"/>
+
+ <!-- this property is only used if using the j2ee connection manager -->
+ <property name="org.jboss.soa.esb.persistence.db.datasource.name" value="java:/JBossESBDS"/>
+
+ <!-- standalone connection pooling settings -->
+ <property name="org.jboss.soa.esb.persistence.db.connection.url" value="jdbc:hsqldb:hsql://localhost:9001/"/>
+ <property name="org.jboss.soa.esb.persistence.db.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+ <property name="org.jboss.soa.esb.persistence.db.user" value="sa"/>
+ <property name="org.jboss.soa.esb.persistence.db.pwd" value=""/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.initial.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.min.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.max.size" value="5"/>
+ <!--table managed by pool to test for valid connections - created by pool automatically -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.test.table" value="pooltest"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis" value="5000"/>
+
+ </properties>
+ <properties name="filters">
+ <property name="org.jboss.soa.esb.filter.1" value="org.jboss.internal.soa.esb.message.filter.MetaDataFilter"/>
+ <property name="org.jboss.soa.esb.filter.2" value="org.jboss.internal.soa.esb.message.filter.GatewayFilter"/>
+ </properties>
+</esb>
\ No newline at end of file
Added: trunk/samples/jbossesb/trailblazer/esb/conf/log4j.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/conf/log4j.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/conf/log4j.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,246 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.10 2006/04/21 17:29:20 csuconic Exp $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="./trailblazer.log"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- A size based file rolling appender
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/server.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ====================== -->
+ <!-- More Appender examples -->
+ <!-- ====================== -->
+
+ <!-- Buffer events and log them asynchronously
+ <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="SMTP"/>
+ </appender>
+ -->
+
+ <!-- EMail events to an administrator
+ <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="To" value="admin at myhost.domain.com"/>
+ <param name="From" value="nobody at myhost.domain.com"/>
+ <param name="Subject" value="JBoss Sever Errors"/>
+ <param name="SMTPHost" value="localhost"/>
+ <param name="BufferSize" value="10"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Syslog events
+ <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Facility" value="LOCAL7"/>
+ <param name="FacilityPrinting" value="true"/>
+ <param name="SyslogHost" value="localhost"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Log events to JMS (requires a topic to be created)
+ <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
+ <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
+ </appender>
+ -->
+
+ <!-- Log events through SNMP
+ <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="ImplementationClassName" value="org.apache.log4j.ext.JoeSNMPTrapSender"/>
+ <param name="ManagementHost" value="127.0.0.1"/>
+ <param name="ManagementHostTrapListenPort" value="162"/>
+ <param name="EnterpriseOID" value="1.3.6.1.4.1.24.0"/>
+ <param name="LocalIPAddress" value="127.0.0.1"/>
+ <param name="LocalTrapSendPort" value="161"/>
+ <param name="GenericTrapType" value="6"/>
+ <param name="SpecificTrapType" value="12345678"/>
+ <param name="CommunityString" value="public"/>
+ <param name="ForwardStackTraceWithTrap" value="true"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="ApplicationTrapOID" value="1.3.6.1.4.1.24.12.10.22.64"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Emit events as JMX notifications
+ <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+
+ <param name="Threshold" value="WARN"/>
+ <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
+ <category name="org.apache">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
+ <category name="org.jboss.serial">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
+ <category name="org.jgroups">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit the jacorb category to WARN as its INFO is verbose -->
+ <category name="jacorb">
+ <priority value="WARN"/>
+ </category>
+
+
+ <!-- Limit the JSR77 categories -->
+ <category name="org.jboss.management">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit Axis based webservice category -->
+ <category name="org.jboss.webservice">
+ <priority value="DEBUG"/>
+ </category>
+ <category name="org.jboss.axis">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.milyn">
+ <priority value="INFO"/>
+ </category>
+ <category name="org.milyn.delivery.SmooksXML">
+ <priority value="INFO"/>
+ </category>
+ <category name="org.milyn.delivery.serialize.Serializer">
+ <priority value="INFO"/>
+ </category>
+ <category name="org.milyn.cdr.XMLConfigDigester">
+ <priority value="INFO"/>
+ </category>
+ <category name="org.jboss.soa.esb.samples.trailblazer">
+ <priority value="INFO"/>
+ </category>
+
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+ <!-- Clustering logging -->
+ <!-- Uncomment the following to redirect the org.jgroups and
+ org.jboss.ha categories to a cluster.log file.
+
+ <appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/cluster.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ <category name="org.jgroups">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ <category name="org.jboss.ha">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ -->
+
+</log4j:configuration>
Added: trunk/samples/jbossesb/trailblazer/esb/conf/smooks-csv2xml.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/conf/smooks-csv2xml.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/conf/smooks-csv2xml.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,19 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
+ <resource-config selector="org.xml.sax.driver">
+ <resource>org.milyn.csv.CSVParser</resource>
+ <param name="fields" type="string-list">
+ ssn,score
+ </param>
+ </resource-config>
+
+ <resource-config selector="csv-set">
+ <resource type="xsl">
+ <![CDATA[
+ <creditCheckResult ssn="{csv-record/ssn}" score="{csv-record/score}" />
+ ]]>
+ </resource>
+ <param name="is-xslt-templatelet">true</param>
+ </resource-config>
+
+</smooks-resource-list>
Added: trunk/samples/jbossesb/trailblazer/esb/conf/smooks-xml2csv.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/conf/smooks-xml2csv.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/conf/smooks-xml2csv.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
+ <resource-config selector="creditCheck">
+ <resource>/xml2csv.xsl</resource>
+ <param name="is-xslt-templatelet">false</param>
+ </resource-config>
+</smooks-resource-list>
Added: trunk/samples/jbossesb/trailblazer/esb/conf/xml2csv.xsl
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/conf/xml2csv.xsl (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/conf/xml2csv.xsl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,24 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+ <xsl:output method="text" encoding="UTF-8" />
+ <xsl:variable name="delimiter">,</xsl:variable>
+ <xsl:template match="creditCheck">
+ <xsl:value-of select="@name"/>
+ <xsl:value-of select="$delimiter"/>
+ <xsl:value-of select="@ssn"/>
+ <xsl:value-of select="$delimiter"/>
+ <xsl:value-of select="@address"/>
+ <xsl:value-of select="$delimiter"/>
+ <xsl:value-of select="@employerName"/>
+ <xsl:value-of select="$delimiter"/>
+ <xsl:value-of select="@salary"/>
+ <xsl:value-of select="$delimiter"/>
+ <xsl:value-of select="@loanAmount"/>
+ <xsl:value-of select="$delimiter"/>
+ <xsl:value-of select="@loanDuration"/>
+ <xsl:value-of select="$delimiter"/>
+ <xsl:value-of select="@email"/>
+ <xsl:value-of select="$delimiter"/>
+ <xsl:value-of select="@creditScore"/>
+ </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
Added: trunk/samples/jbossesb/trailblazer/esb/lib/ext/c3p0-0.9.1-pre9.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/esb/lib/ext/c3p0-0.9.1-pre9.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/esb/lib/ext/commons-logging.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/esb/lib/ext/commons-logging.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/esb/lib/ext/hsqldb.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/esb/lib/ext/hsqldb.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/esb/lib/ext/milyn-smooks-csv-0.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/esb/lib/ext/milyn-smooks-csv-0.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/esb/lib/ext/opencsv-1.6.jar
===================================================================
(Binary files differ)
Property changes on: trunk/samples/jbossesb/trailblazer/esb/lib/ext/opencsv-1.6.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/BankResponseActions.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/BankResponseActions.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/BankResponseActions.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,80 @@
+package org.jboss.soa.esb.samples.trailblazer.actions;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.jboss.soa.esb.samples.trailblazer.util.ProcessEmail;
+
+public class BankResponseActions extends AbstractActionLifecycle {
+
+ protected ConfigTree _config;
+
+ private final String SERVICE_NAME = "customer";
+ private final String SERVICE_CAT = "notifiers";
+ private ServiceInvoker notifierInvoker;
+
+ private static Logger _logger = Logger.getLogger(BankResponseActions.class);
+
+ public BankResponseActions(ConfigTree config) {
+ _config = config;
+
+ try {
+ notifierInvoker = new ServiceInvoker(SERVICE_CAT, SERVICE_NAME);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create ServiceInvoker for '" + SERVICE_CAT + ":" + SERVICE_NAME + "'.", e);
+ }
+ }
+
+ public Message processResponseFromJMSBank(Message message) throws Exception {
+ System.out.println("Got the message from the JMS bank: " + message.getBody().get());
+
+ _logger.debug("JMS bank message received: \n" + message.getBody().get());
+
+ Message notifyMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+ notifyMessage.getBody().add(message.getBody().get());
+
+ notifierInvoker.deliverAsync(notifyMessage);
+
+ return null;
+ }
+
+ public Message processResponseFromFileBank(Message message) throws Exception {
+ String mesg=new String((byte[])message.getBody().get());
+
+ System.out.println("Got the message from the File bank: " + mesg);
+
+ _logger.debug("File bank message received: \n" + mesg);
+
+ Message notifyMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+ notifyMessage.getBody().add(mesg);
+
+ notifierInvoker.deliverAsync(notifyMessage);
+
+ return null;
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditAgencyActions.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditAgencyActions.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditAgencyActions.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,79 @@
+package org.jboss.soa.esb.samples.trailblazer.actions;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @daniel.brum at jboss.com
+ */
+
+import java.util.Random;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.jboss.soa.esb.util.Util;
+
+public class CreditAgencyActions extends AbstractActionLifecycle {
+ protected ConfigTree _config;
+
+ private static Logger _logger = Logger.getLogger(CreditAgencyActions.class);
+
+ public CreditAgencyActions(ConfigTree config) { _config = config; }
+
+ public Message noOperation(Message message) { return message; }
+
+ public Message processCreditRequest(Message message) throws Exception{
+
+ _logger.debug("message received: " + Util.serialize(message) );
+
+ String csvData = (String)message.getBody().get();
+ _logger.debug("csv data received: " + csvData);
+
+ String[] parts=csvData.split(",");
+
+ //generate a random score between 1 and 10
+ Random rand = new Random();
+ int n = 10;
+ int score = rand.nextInt(n+1);
+
+ //send back the reply
+ Message replyMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+ _logger.info("CreditAgency sending back a credit score of " + score);
+
+ // Return the unique customer ref (ssn) and the score
+ String resp=parts[1]+","+score;
+ replyMessage.getBody().add(resp);
+
+ return replyMessage;
+ }
+
+ public Message debugMessage(Message message) throws Exception{
+
+ _logger.debug("message received in processCreditRequest with message: " + Util.serialize(message));
+
+
+
+ return message;
+ }
+}
+
+
Added: trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditCheckCSVToXMLActions.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditCheckCSVToXMLActions.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditCheckCSVToXMLActions.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,66 @@
+package org.jboss.soa.esb.samples.trailblazer.actions;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @daniel.brum at jboss.com
+ */
+
+import java.util.Random;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.jboss.soa.esb.util.Util;
+
+public class CreditCheckCSVToXMLActions extends AbstractActionLifecycle {
+ protected ConfigTree _config;
+
+ private static Logger _logger = Logger.getLogger(CreditCheckCSVToXMLActions.class);
+
+ public CreditCheckCSVToXMLActions(ConfigTree config) { _config = config; }
+
+ public Message handle(Message message) throws Exception{
+
+ _logger.debug("CSV message received: " + Util.serialize(message) );
+
+ String csv=(String)message.getBody().get();
+
+ String[] parts=csv.split(",");
+
+ String xml="<creditCheckResult ssn=\""+parts[0]+
+ "\" score=\""+parts[1]+"\" />";
+
+ _logger.debug("XML data to return" + xml);
+
+ //send back the reply
+ Message replyMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+ replyMessage.getBody().add(xml);
+
+ return replyMessage;
+ }
+}
+
+
Added: trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditCheckXMLToCSVActions.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditCheckXMLToCSVActions.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/CreditCheckXMLToCSVActions.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,89 @@
+package org.jboss.soa.esb.samples.trailblazer.actions;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @daniel.brum at jboss.com
+ */
+
+import java.util.Random;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.jboss.soa.esb.util.Util;
+
+public class CreditCheckXMLToCSVActions extends AbstractActionLifecycle {
+ protected ConfigTree _config;
+
+ private static Logger _logger = Logger.getLogger(CreditCheckXMLToCSVActions.class);
+
+ public CreditCheckXMLToCSVActions(ConfigTree config) { _config = config; }
+
+ public Message handle(Message message) throws Exception{
+
+ _logger.debug("XML message received: " + Util.serialize(message) );
+
+ String xml=(String)message.getBody().get();
+ String csvData=null;
+
+ try {
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ java.io.InputStream xmlstr=
+ new java.io.ByteArrayInputStream(xml.getBytes());
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=builder.parse(xmlstr);
+
+ org.w3c.dom.Element tree = doc.getDocumentElement();
+
+ csvData = (tree.getAttribute("name")+","+
+ tree.getAttribute("ssn")+","+
+ tree.getAttribute("address")+","+
+ tree.getAttribute("employerName")+","+
+ tree.getAttribute("salary")+","+
+ tree.getAttribute("loanAmount")+","+
+ tree.getAttribute("loanDuration")+","+
+ tree.getAttribute("email")+","+
+ tree.getAttribute("creditScore"));
+
+ } catch(Exception ex) {
+ _logger.error(ex.getMessage(), ex);
+ }
+
+ _logger.debug("CSV data to return" + csvData);
+
+ //send back the reply
+ Message replyMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+ replyMessage.getBody().add(csvData);
+
+
+ return replyMessage;
+ }
+}
+
+
Added: trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/FileBankRequestActions.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/FileBankRequestActions.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/FileBankRequestActions.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,66 @@
+package org.jboss.soa.esb.samples.trailblazer.actions;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.samples.trailblazer.util.TrailblazerProperties;
+
+public class FileBankRequestActions extends AbstractActionLifecycle {
+
+ protected ConfigTree _config;
+ private Properties properties = new TrailblazerProperties();
+
+ private static final String BANK_REQUEST_DIR="file.bank.monitored.dir";
+
+ private String m_bankRequestDir=null;
+
+ private static Logger _logger = Logger.getLogger(FileBankRequestActions.class);
+
+ public FileBankRequestActions(ConfigTree config) {
+ _config = config;
+ m_bankRequestDir = properties.getProperty(BANK_REQUEST_DIR);
+ }
+
+ public Message processFileBankRequest(Message message) throws Exception {
+ System.out.println("Got the message for the File bank: " + message.getBody().get());
+
+ _logger.debug("File bank message received: \n" + message.getBody().get());
+
+ java.io.File dir=new java.io.File(m_bankRequestDir);
+
+ java.io.File f=java.io.File.createTempFile("FileBank", "tb", dir);
+
+ java.io.FileOutputStream fos=new java.io.FileOutputStream(f);
+
+ fos.write(((String)message.getBody().get()).getBytes());
+
+ fos.flush();
+ fos.close();
+
+ return null;
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/NotifyCustomerActions.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/NotifyCustomerActions.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/NotifyCustomerActions.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,63 @@
+package org.jboss.soa.esb.samples.trailblazer.actions;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.samples.trailblazer.util.ProcessEmail;
+
+public class NotifyCustomerActions extends AbstractActionLifecycle {
+
+ protected ConfigTree _config;
+
+ private static Logger _logger = Logger.getLogger(NotifyCustomerActions.class);
+
+ public NotifyCustomerActions(ConfigTree config) { _config = config; }
+
+ public Message notifyCustomer(Message message) throws Exception {
+
+ _logger.debug("message received: \n" + message.getBody().get());
+
+ //get the quote response and send it to the customer
+ ConfigTree tree = ConfigTree.fromXml((String)message.getBody().get());
+
+ String quoteID = tree.getFirstTextChild("quoteId");
+ String rate = tree.getFirstTextChild("interestRate");
+ String errorCode = tree.getFirstTextChild("errorCode");
+ String ssn = tree.getFirstTextChild("customerUID");
+ String email = tree.getFirstTextChild("customerEmail");
+
+ _logger.debug("info using for email: " + quoteID +" "+rate+" "+errorCode+" "+ssn+" "+email);
+
+
+ _logger.debug("preparing to send the quote response via email to customer");
+ ProcessEmail procEmail = new ProcessEmail(email, quoteID, rate, errorCode, ssn);
+ procEmail.sendEmail();
+
+ System.out.println("Sent email to: " +email);
+
+
+ return null;
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/HsqldbUtil.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/HsqldbUtil.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/HsqldbUtil.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.trailblazer.util;
+
+import java.sql.DriverManager;
+import java.sql.Statement;
+
+import org.apache.log4j.Logger;
+import org.hsqldb.Server;
+/**
+ * Utility to start and stop a hsql Database.
+ *
+ * @author <a href="mailto:kurt.stam at jboss.com">Kurt Stam</a>
+ *
+ */
+public class HsqldbUtil
+{
+ final private static String THREAD_NAME = "hypersonic-unittest";
+
+ private static Logger _logger = Logger.getLogger(HsqldbUtil.class);
+ /**
+ * Starts the hsql database in it's own thread.
+ * Don't forget to shut it down when you're done.
+ *
+ * @param databaseFile - i.e. build/hsqltestdb
+ * @param databaseName - i.e. jbossesb
+ * @throws Exception
+ */
+ public static void startHsqldb(final String databaseFile,
+ final String databaseName) throws Exception
+ {
+ // Start DB in new thread, or else it will block us
+ Thread serverThread = new Thread(THREAD_NAME) {
+ public void run() {
+ try {
+ // Create startup arguments
+ String[] args = new String[4];
+ args[0] = "-database.0";
+ args[1] = databaseFile;
+ args[2] = "-dbname.0";
+ args[3] = databaseName;
+
+ _logger.info("creating db from this script: " + databaseFile);
+
+ // Start server
+ Server.main(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+// log.error("Failed to start database", e);
+ }
+ };
+ serverThread.run();
+ }
+ /**
+ *
+ * @param url
+ * @param username
+ * @param password
+ * @throws Exception
+ */
+ public static void stopHsqldb(String url, String username, String password) throws Exception {
+ java.sql.Connection connection = DriverManager.getConnection(
+ url, username, password);
+ Statement statement = connection.createStatement();
+ String shutdownCommand = "SHUTDOWN COMPACT";
+ statement.executeQuery(shutdownCommand);
+ }
+
+
+}
Added: trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/ProcessEmail.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/ProcessEmail.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/ProcessEmail.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.soa.esb.samples.trailblazer.util;
+
+import java.util.Properties;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.antlr.stringtemplate.StringTemplateGroup;
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.helpers.Email;
+
+
+public class ProcessEmail {
+
+ private Logger logger = Logger.getLogger(this.getClass());
+ private String emailTo, quoteID, rate, code, ssn;
+ private Properties properties = new TrailblazerProperties();
+
+ public ProcessEmail(String email, String quoteID, String rate, String code, String ssn) {
+ this.emailTo=email;
+ this.quoteID=quoteID;
+ this.rate=rate;
+ this.code=code;
+ this.ssn=ssn;
+ logger.debug("creating email helper");
+
+ }
+
+ public void sendEmail() {
+ try {
+ if (null==emailTo) {
+ logger.error("no email found for customer, aborting send");
+ return;
+ }
+ logger.info("customer SSN " + ssn + " - sending email to: " + emailTo);
+ Email emailMessage = new Email();
+ emailMessage.setSendTo(emailTo);
+ emailMessage.setSubject("TrailBlazer Quote from Bank");
+ String emailFrom = properties.getProperty("email.from");
+ emailMessage.setFrom(emailFrom);
+// File emailTemplate = new File(LoanBrokerConstants.EMAIL_TEMPLATE);
+// String quoteMsg=FileUtil.readTextFile(emailTemplate);
+ emailMessage.setMessage(fillTemplate());
+ emailMessage.sendMessage();
+ }catch (Exception e) {
+ logger.error("error sending email - " + e);
+ e.printStackTrace();
+ }
+ }
+
+ private String fillTemplate() throws Exception{
+ String templatePath = properties.getProperty("email.template.path", "template");
+ String templateFile = properties.getProperty("email.template.file", "quote");
+
+ logger.info("loading StringTemplate from path: "+templatePath);
+ logger.info("loading StringTemplate from file: "+templateFile);
+
+ StringTemplateGroup group = new StringTemplateGroup("loan");
+ StringTemplate email = group.getInstanceOf(templatePath + "/" + templateFile);
+
+ //String email, String quoteID, String rate, String code, String ssn
+ email.setAttribute("quote", quoteID);
+ email.setAttribute("rate", rate);
+ email.setAttribute("ssn", ssn);
+ email.setAttribute("code", code);
+ email.setAttribute("email", emailTo);
+
+ return email.toString();
+
+ }
+
+ public static void main(String[] args) {
+ ProcessEmail email = new ProcessEmail("dbrum101 at gmail.com", "111", ".65", "0", "123456");
+ email.sendEmail();
+
+ }
+
+}
Added: trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TbBootStrapper.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TbBootStrapper.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TbBootStrapper.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.trailblazer.util;
+
+import java.io.File;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.Statement;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.jboss.soa.esb.persistence.manager.ConnectionManager;
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.listeners.StandAloneBootStrapper;
+import org.jboss.soa.esb.persistence.manager.ConnectionManagerFactory;
+import org.jboss.soa.esb.testutils.FileUtil;
+//import org.jboss.soa.esb.testutils.HsqldbUtil;
+import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
+
+public class TbBootStrapper extends StandAloneBootStrapper {
+
+ protected static Logger _logger = Logger.getLogger(TbBootStrapper.class);
+
+ public static void main(String[] args) throws Exception
+ {
+ Exception eT = null;
+ if (args.length < 1)
+ {
+ eT = new Exception ("No configuration file specified - Ending immediately");
+ _logger.fatal(eT);
+ throw eT;
+ } else {
+ _logger.info("Starting the trailblazer with arg=" + args[0]);
+ }
+ TbBootStrapper boot = null;
+
+ String configName = args[0];
+ long lSecondsToRun = 365 * 24 * 3600; // run for 1 year (is it enough ?)
+ if (args.length > 1)
+ try
+ {
+ lSecondsToRun = Long.parseLong(args[1]);
+ }
+ catch (Exception e)
+ {
+ _logger.fatal(e);
+ throw e;
+ }
+ try
+ {
+ boot = new TbBootStrapper(configName);
+ if (lSecondsToRun < 5)
+ lSecondsToRun = 5;
+ long lRunTo = System.currentTimeMillis()+1000*lSecondsToRun;
+
+ while (System.currentTimeMillis() < lRunTo)
+ try { Thread.sleep(1000); }
+ catch (InterruptedException e) { break; }
+ }
+ finally
+ {
+ if (null!=boot)
+ boot.requestEnd();
+ }
+ }
+
+ private TbBootStrapper() throws Exception {super(null);}
+
+ public TbBootStrapper (String configName) throws Exception
+ {
+ super(configName, null);
+ }
+
+ public TbBootStrapper (String configName, String validationFileName) throws Exception
+ {
+ super(configName, validationFileName);
+ }
+
+ /*
+ * Setup HSQLDB for the Registry and the MessageStore
+ */
+ protected void runBefore(){
+ //System.setProperty("com.arjuna.common.util.propertyservice.verbosePropertyManager", "on");
+ String baseDir="";
+ String productDir = "../../";
+ if (TestEnvironmentUtil.getUserDir("trailblazer").equals("trailblazer/")) {
+ baseDir = "product/samples/trailblazer/";
+ productDir = "product/";
+ }
+ DOMConfigurator.configure(baseDir + "log4j.xml");
+ String driver = Configuration.getStoreDriver();
+ System.out.println("Driver=" + driver);
+ if ("org.hsqldb.jdbcDriver".equals(driver)) {
+
+ //start hsqldb
+ try {
+ HsqldbUtil.startHsqldb(productDir + "build/hsqldb", "jbossesb");
+ String database = "hsqldb";
+
+ //message store db
+ String sqlDir = productDir + "install/message-store/sql/" + database + "/";
+ String sqlCreateCmd = TestEnvironmentUtil.readTextFile(new File(sqlDir + "create_database.sql"));
+ String sqlDropCmd = TestEnvironmentUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
+
+ ConnectionManager mgr = ConnectionManagerFactory.getConnectionManager();
+ Connection con = mgr.getConnection();
+
+ Statement stmnt = con.createStatement();
+ System.out.println("Dropping the message store schema if exists...");
+ stmnt.execute(sqlDropCmd);
+ System.out.println("Creating the message store schema...");
+ stmnt.execute(sqlCreateCmd);
+
+ //registry DB
+ sqlDir = productDir + "install/jUDDI-registry/sql/" + database + "/";
+ System.out.println("Dropping the registry schema if exists...");
+ sqlDropCmd = TestEnvironmentUtil.readTextFile(new File(sqlDir + "drop_database.sql")).replaceAll("\\$\\{prefix}", "");
+ stmnt.execute(sqlDropCmd);
+ System.out.println("creating the registry schema...");
+ String resource = "juddi-sql/" + database + "/create_database.sql";
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
+ sqlCreateCmd = FileUtil.readStream(is).trim().replaceAll("\\$\\{prefix}", "");
+ stmnt.execute(sqlCreateCmd);
+ System.out.println("inserting registry publishers...");
+ String sqlInsertPubCmd = TestEnvironmentUtil.readTextFile(new File(sqlDir + "import.sql")).trim().replaceAll("\\$\\{prefix}", "");
+ stmnt.execute(sqlInsertPubCmd);
+ stmnt.close();
+ con.close();
+ }catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /*
+ * Shuts down the HSQLDB instance
+ */
+ protected void runAfter()
+ {
+ try { Thread.sleep(5000); }
+ catch (InterruptedException e) {}
+
+ //shutdown message store if using hsqldb
+ if ("org.hsqldb.jdbcDriver".equals(Configuration.getStoreDriver())) {
+ try {
+ HsqldbUtil.stopHsqldb(Configuration.getStoreUrl(),
+ Configuration.getStoreUser(),Configuration.getStorePwd() );
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+
+}
Added: trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TrailblazerProperties.java
===================================================================
--- trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TrailblazerProperties.java (rev 0)
+++ trunk/samples/jbossesb/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TrailblazerProperties.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.trailblazer.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.util.ClassUtil;
+
+/**
+ * Trilablazer Properties.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class TrailblazerProperties extends Properties {
+
+ private static final long serialVersionUID = 1L;
+ public static final String CONFIG_FILE = "trailblazer.properties";
+ private static Logger logger = Logger.getLogger(TrailblazerProperties.class);
+
+ public TrailblazerProperties() {
+ InputStream config = ClassUtil.getResourceAsStream("/" + CONFIG_FILE, TrailblazerProperties.class);
+
+ if(config == null) {
+ logger.error("Failed to locate '" + CONFIG_FILE + "' in the root of the classpath.");
+ return;
+ }
+
+ try {
+ load(config);
+ } catch (IOException e) {
+ logger.error("Error reading '" + CONFIG_FILE + "'.", e);
+ } finally {
+ try {
+ config.close();
+ } catch (IOException e) {
+ logger.warn("Failed to close stream to '" + CONFIG_FILE + "'.");
+ }
+ }
+ }
+}
Added: trunk/samples/jbossesb/trailblazer/juddi.properties
===================================================================
--- trunk/samples/jbossesb/trailblazer/juddi.properties (rev 0)
+++ trunk/samples/jbossesb/trailblazer/juddi.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,70 @@
+# jUDDI Registry Properties (used by RegistryServer)
+# see http://www.juddi.org for more information
+
+# The UDDI Operator Name
+juddi.operatorName = jUDDI.org
+
+# The i18n locale default codes
+juddi.i18n.languageCode = en
+juddi.i18n.countryCode = US
+
+# The UDDI DiscoveryURL Prefix
+juddi.discoveryURL = http://localhost:8080/juddi/uddiget.jsp?
+
+# The UDDI Operator Contact Email Address
+juddi.operatorEmailAddress = admin at juddi.org
+
+# The maximum name size and maximum number
+# of name elements allows in several of the
+# FindXxxx and SaveXxxx UDDI functions.
+juddi.maxNameLength=255
+juddi.maxNameElementsAllowed=5
+
+# The maximum number of UDDI artifacts allowed
+# per publisher. A value of '-1' indicates any
+# number of artifacts is valid (These values can be
+# overridden at the individual publisher level).
+juddi.maxBusinessesPerPublisher=25
+juddi.maxServicesPerBusiness=20
+juddi.maxBindingsPerService=10
+juddi.maxTModelsPerPublisher=100
+
+# jUDDI Authentication module to use
+juddi.auth = org.apache.juddi.auth.DefaultAuthenticator
+
+# jUDDI DataStore module currently to use
+juddi.dataStore = org.apache.juddi.datastore.jdbc.JDBCDataStore
+
+# use a dataSource (if set to false a direct
+# jdbc connection will be used.
+juddi.isUseDataSource=false
+juddi.jdbcDriver=org.hsqldb.jdbcDriver
+#juddi.jdbcUrl=jdbc:hsqldb:hsql://localhost/jbossesb
+juddi.jdbcUrl=jdbc:hsqldb:hsql://localhost:9001/jbossesb
+juddi.jdbcUsername=sa
+juddi.jdbcPassword=
+# jUDDI DataSource to use
+juddi.dataSource=java:comp/env/jdbc/juddiDB
+
+# jUDDI UUIDGen implementation to use
+juddi.uuidgen = org.apache.juddi.uuidgen.DefaultUUIDGen
+
+# jUDDI Cryptor implementation to use
+juddi.cryptor = org.apache.juddi.cryptor.DefaultCryptor
+
+# jUDDI Validator to use
+juddi.validator=org.apache.juddi.validator.DefaultValidator
+
+# jUDDI Proxy Properties (used by RegistryProxy)
+juddi.proxy.adminURL = http://localhost:8080/juddi/admin
+juddi.proxy.inquiryURL = http://localhost:8080/juddi/inquiry
+juddi.proxy.publishURL = http://localhost:8080/juddi/publish
+juddi.proxy.transportClass = org.apache.juddi.proxy.AxisTransport
+juddi.proxy.securityProvider = com.sun.net.ssl.internal.ssl.Provider
+juddi.proxy.protocolHandler = com.sun.net.ssl.internal.www.protocol
+
+# JNDI settings (used by RMITransport)
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+
Added: trunk/samples/jbossesb/trailblazer/log4j.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/log4j.xml (rev 0)
+++ trunk/samples/jbossesb/trailblazer/log4j.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,300 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.10 2006/04/21 17:29:20 csuconic Exp $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="./trailblazer.log"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- A size based file rolling appender
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/server.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="DEBUG"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ====================== -->
+ <!-- More Appender examples -->
+ <!-- ====================== -->
+
+ <!-- Buffer events and log them asynchronously
+ <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="SMTP"/>
+ </appender>
+ -->
+
+ <!-- EMail events to an administrator
+ <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="To" value="admin at myhost.domain.com"/>
+ <param name="From" value="nobody at myhost.domain.com"/>
+ <param name="Subject" value="JBoss Sever Errors"/>
+ <param name="SMTPHost" value="localhost"/>
+ <param name="BufferSize" value="10"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Syslog events
+ <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Facility" value="LOCAL7"/>
+ <param name="FacilityPrinting" value="true"/>
+ <param name="SyslogHost" value="localhost"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Log events to JMS (requires a topic to be created)
+ <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
+ <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
+ </appender>
+ -->
+
+ <!-- Log events through SNMP
+ <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="ImplementationClassName" value="org.apache.log4j.ext.JoeSNMPTrapSender"/>
+ <param name="ManagementHost" value="127.0.0.1"/>
+ <param name="ManagementHostTrapListenPort" value="162"/>
+ <param name="EnterpriseOID" value="1.3.6.1.4.1.24.0"/>
+ <param name="LocalIPAddress" value="127.0.0.1"/>
+ <param name="LocalTrapSendPort" value="161"/>
+ <param name="GenericTrapType" value="6"/>
+ <param name="SpecificTrapType" value="12345678"/>
+ <param name="CommunityString" value="public"/>
+ <param name="ForwardStackTraceWithTrap" value="true"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="ApplicationTrapOID" value="1.3.6.1.4.1.24.12.10.22.64"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Emit events as JMX notifications
+ <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+
+ <param name="Threshold" value="WARN"/>
+ <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
+ <category name="org.apache">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
+ <category name="org.jboss.serial">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
+ <category name="org.jgroups">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit the jacorb category to WARN as its INFO is verbose -->
+ <category name="jacorb">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit JBoss categories
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+ -->
+
+ <!-- Limit the JSR77 categories -->
+ <category name="org.jboss.management">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit Axis based webservice category -->
+ <category name="org.jboss.webservice">
+ <priority value="DEBUG"/>
+ </category>
+ <category name="org.jboss.axis">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit JBossWS webservice category
+ <category name="org.jboss.ws">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!-- Decrease the priority threshold for the org.jboss.varia category
+ <category name="org.jboss.varia">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
+ <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <!--
+ | An example of enabling the custom TRACE level priority that is used
+ | by the JBoss internals to diagnose low level details. This example
+ | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
+ | subpackages. This will produce A LOT of logging output.
+ <category name="org.jboss.system">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ <category name="org.jboss.ejb.plugins">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <!--
+ | Logs these events to SNMP:
+ - server starts/stops
+ - cluster evolution (node death/startup)
+ - When an EJB archive is deployed (and associated verified messages)
+ - When an EAR archive is deployed
+
+ <category name="org.jboss.system.server.Server">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.MainDeployer">
+ <priority value="ERROR" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ejb.EJBDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.EARDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ -->
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+ <!-- Clustering logging -->
+ <!-- Uncomment the following to redirect the org.jgroups and
+ org.jboss.ha categories to a cluster.log file.
+
+ <appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/cluster.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ <category name="org.jgroups">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ <category name="org.jboss.ha">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ -->
+
+</log4j:configuration>
Added: trunk/samples/jbossesb/trailblazer/models/LoanRequest.scn
===================================================================
--- trunk/samples/jbossesb/trailblazer/models/LoanRequest.scn (rev 0)
+++ trunk/samples/jbossesb/trailblazer/models/LoanRequest.scn 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="Cp1252"?>
+<scn:Scenario xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:scn="http://www.pi4soa.org/scenario" name="LoanRequest" description="Valid loan request" author="gary" choreographyDescriptionURL="TrailBlazer.cdm">
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="checkCredit" value="<creditCheck name="Joe Broke" ssn="1234567890" address="1 Spenditall Str., BrokeTown 99999 DC" employerName="" salary="50000.0" loanAmount="1000.0" loanDuration="12" email="gary at pi4tech.com" creditScore="0" />" serviceType="{http://www.pi4soa.org/TrailBlazer}creditAgency" messageType="creditCheck"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.1" operationName="checkCredit" value="<creditCheck name="Joe Broke" ssn="1234567890" address="1 Spenditall Str., BrokeTown 99999 DC" employerName="" salary="50000.0" loanAmount="1000.0" loanDuration="12" email="gary at pi4tech.com" creditScore="0" />" direction="receive" serviceType="{http://www.pi4soa.org/TrailBlazer}creditAgency" messageType="creditCheck"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.1" operationName="checkCredit" isRequest="false" value="<creditCheckResult ssn="1234567890" score="4" />" serviceType="{http://www.pi4soa.org/TrailBlazer}creditAgency" messageType="creditCheckResult"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="checkCredit" isRequest="false" value="<creditCheckResult ssn="1234567890" score="4" />" direction="receive" serviceType="{http://www.pi4soa.org/TrailBlazer}creditAgency" messageType="creditCheckResult"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="requestQuote" value="<quoteRequest ssn="1234567890" creditScore="0" creditHistoryLen="0" amount="1000" term="12" ref="1" customerUID="1234567890" customerEmail="gary at scribble.org" />" serviceType="{http://www.pi4soa.org/TrailBlazer}bank" messageType="quoteRequest"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.2" operationName="requestQuote" value="<quoteRequest ssn="1234567890" creditScore="0" creditHistoryLen="0" amount="1000" term="12" ref="1" customerUID="1234567890" customerEmail="gary at scribble.org" />" direction="receive" serviceType="{http://www.pi4soa.org/TrailBlazer}bank" messageType="quoteRequest"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.2" operationName="requestQuote" isRequest="false" value="<quote>
 <interestRate>8.60</interestRate>
 <quoteId>JMSBasedBank-0</quoteId>
 <ref>1</ref>
 <errorCode>0</errorCode>
 <customerUID>1234567890</customerUID>
 <customerEmail>gary at scribble.org</customerEmail>
</quote>
" serviceType="{http://www.pi4soa.org/TrailBlazer}bank" messageType="quote"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="requestQuote" isRequest="false" value="<quote>
 <interestRate>8.60</interestRate>
 <quoteId>JMSBasedBank-0</quoteId>
 <ref>1</ref>
 <errorCode>0</errorCode>
 <customerUID>1234567890</customerUID>
 <customerEmail>gary at scribble.org</customerEmail>
</quote>
" direction="receive" serviceType="{http://www.pi4soa.org/TrailBlazer}bank" messageType="quote"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="notify" value="<quote>
 <interestRate>8.60</interestRate>
 <quoteId>JMSBasedBank-0</quoteId>
 <ref>1</ref>
 <errorCode>0</errorCode>
 <customerUID>1234567890</customerUID>
 <customerEmail>gary at scribble.org</customerEmail>
</quote>" serviceType="{http://www.pi4soa.org/TrailBlazer}notifier" messageType="quote"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.4" operationName="notify" value="<quote>
 <interestRate>8.60</interestRate>
 <quoteId>JMSBasedBank-0</quoteId>
 <ref>1</ref>
 <errorCode>0</errorCode>
 <customerUID>1234567890</customerUID>
 <customerEmail>gary at scribble.org</customerEmail>
</quote>" direction="receive" serviceType="{http://www.pi4soa.org/TrailBlazer}notifier" messageType="quote"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="requestQuote" value="<quoteRequest ssn="1234567890" creditScore="0" creditHistoryLen="0" amount="1000" term="12" ref="2" customerUID="1234567890" customerEmail="gary at scribble.org" />" serviceType="{http://www.pi4soa.org/TrailBlazer}bank" messageType="quoteRequest"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.3" operationName="requestQuote" value="<quoteRequest ssn="1234567890" creditScore="0" creditHistoryLen="0" amount="1000" term="12" ref="2" customerUID="1234567890" customerEmail="gary at scribble.org" />" direction="receive" serviceType="{http://www.pi4soa.org/TrailBlazer}bank" messageType="quoteRequest"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.3" operationName="requestQuote" isRequest="false" value="<quote>
 <interestRate>8.60</interestRate>
 <quoteId>FileBasedBank-0</quoteId>
 <ref>2</ref>
 <errorCode>0</errorCode>
 <customerUID>1234567890</customerUID>
 <customerEmail>gary at scribble.org</customerEmail>
</quote>
" serviceType="{http://www.pi4soa.org/TrailBlazer}bank" messageType="quote"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="requestQuote" isRequest="false" value="<quote>
 <interestRate>8.60</interestRate>
 <quoteId>FileBasedBank-0</quoteId>
 <ref>2</ref>
 <errorCode>0</errorCode>
 <customerUID>1234567890</customerUID>
 <customerEmail>gary at scribble.org</customerEmail>
</quote>
" direction="receive" serviceType="{http://www.pi4soa.org/TrailBlazer}bank" messageType="quote"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="notify" value="<quote>
 <interestRate>8.60</interestRate>
 <quoteId>FileBasedBank-0</quoteId>
 <ref>2</ref>
 <errorCode>0</errorCode>
 <customerUID>1234567890</customerUID>
 <customerEmail>gary at scribble.org</customerEmail>
</quote>" serviceType="{http://www.pi4soa.org/TrailBlazer}notifier" messageType="quote"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.4" operationName="notify" value="<quote>
 <interestRate>8.60</interestRate>
 <quoteId>FileBasedBank-0</quoteId>
 <ref>2</ref>
 <errorCode>0</errorCode>
 <customerUID>1234567890</customerUID>
 <customerEmail>gary at scribble.org</customerEmail>
</quote>" direction="receive" serviceType="{http://www.pi4soa.org/TrailBlazer}notifier" messageType="quote"/>
+ <messageLinks source="//@scenarioObjects.0" target="//@scenarioObjects.1"/>
+ <messageLinks source="//@scenarioObjects.2" target="//@scenarioObjects.3"/>
+ <messageLinks source="//@scenarioObjects.4" target="//@scenarioObjects.5"/>
+ <messageLinks source="//@scenarioObjects.6" target="//@scenarioObjects.7"/>
+ <messageLinks source="//@scenarioObjects.8" target="//@scenarioObjects.9"/>
+ <messageLinks source="//@scenarioObjects.10" target="//@scenarioObjects.11"/>
+ <messageLinks source="//@scenarioObjects.12" target="//@scenarioObjects.13"/>
+ <messageLinks source="//@scenarioObjects.14" target="//@scenarioObjects.15"/>
+ <participants type="LoanBrokerParticipant"/>
+ <participants type="CreditAgencyParticipant"/>
+ <participants type="BankParticipant" instance="JMSBank"/>
+ <participants type="BankParticipant" instance="FileBank"/>
+ <participants type="NotifierParticipant"/>
+</scn:Scenario>
\ No newline at end of file
Added: trunk/samples/jbossesb/trailblazer/models/TrailBlazer.cdm
===================================================================
--- trunk/samples/jbossesb/trailblazer/models/TrailBlazer.cdm (rev 0)
+++ trunk/samples/jbossesb/trailblazer/models/TrailBlazer.cdm 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<org.pi4soa.cdl:Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org.pi4soa.cdl="http:///org/pi4soa/cdl.ecore" description="The choreography description for TrailBlazer" name="TrailBlazer" author="gary" version="0.1" targetNamespace="http://www.pi4soa.org/TrailBlazer">
+ <typeDefinitions>
+ <nameSpaces description="Target Namespace for TrailBlazer" prefix="tns" uRI="http://www.pi4soa.org/TrailBlazer"/>
+ <nameSpaces description="XML Schema Namespace" prefix="xsd" uRI="http://www.w3.org/2001/XMLSchema"/>
+ <informationTypes description="This is the information type CreditCheckReq" name="CreditCheckReq" elementName="creditCheck"/>
+ <informationTypes description="This is the information type CreditCheckResp" name="CreditCheckResp" elementName="creditCheckResult"/>
+ <informationTypes description="This is the information type InsufficientCredit" name="InsufficientCredit" elementName="insufficientCredit"/>
+ <informationTypes description="This is the information type Quote" name="Quote" elementName="quote"/>
+ <informationTypes description="This is the information type QuoteRefType" name="QuoteRefType" typeName="xsd:string"/>
+ <informationTypes description="This is the information type QuoteReq" name="QuoteReq" elementName="quoteRequest"/>
+ <informationTypes description="This is the information type SSNType" name="SSNType" typeName="xsd:string"/>
+ <informationTypes description="This is the information type URIType" name="URIType" typeName="xsd:anyURI"/>
+ <tokens description="This is the token QuoteRef" name="QuoteRef" informationType="//@typeDefinitions/@informationTypes.4"/>
+ <tokens description="This is the token SSN" name="SSN" informationType="//@typeDefinitions/@informationTypes.6"/>
+ <tokens description="This is the token URI" name="URI" informationType="//@typeDefinitions/@informationTypes.7"/>
+ <tokenLocators description="This is the token locator QuoteRef4InsufficientCredit" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.2" query="//ref/text()" name="QuoteRef4InsufficientCredit"/>
+ <tokenLocators description="This is the token locator QuoteRef4Quote" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.3" query="//ref/text()" name="QuoteRef4Quote"/>
+ <tokenLocators description="This is the token locator QuoteRef4QuoteReq" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.5" query="//@ref" name="QuoteRef4QuoteReq"/>
+ <tokenLocators description="This is the token locator SSN4CreditCheckReq" token="//@typeDefinitions/@tokens.1" informationType="//@typeDefinitions/@informationTypes.0" query="//@ssn" name="SSN4CreditCheckReq"/>
+ <tokenLocators description="This is the token locator SSN4CreditCheckResp" token="//@typeDefinitions/@tokens.1" informationType="//@typeDefinitions/@informationTypes.1" query="//@ssn" name="SSN4CreditCheckResp"/>
+ <tokenLocators description="This is the token locator SSN4InsufficientCredit" token="//@typeDefinitions/@tokens.1" informationType="//@typeDefinitions/@informationTypes.2" query="//customerUID/text()" name="SSN4InsufficientCredit"/>
+ <tokenLocators description="This is the token locator SSN4Quote" token="//@typeDefinitions/@tokens.1" informationType="//@typeDefinitions/@informationTypes.3" query="//customerUID/text()" name="SSN4Quote"/>
+ <tokenLocators description="This is the token locator SSN4QuoteReq" token="//@typeDefinitions/@tokens.1" informationType="//@typeDefinitions/@informationTypes.5" query="//@ssn" name="SSN4QuoteReq"/>
+ <roleTypes description="This is the role type Bank" name="Bank">
+ <behaviors description="This is the behavior BankBehavior" name="BankBehavior" interface="bank"/>
+ </roleTypes>
+ <roleTypes description="This is the role type CreditAgency" name="CreditAgency">
+ <behaviors description="This is the behavior CreditAgencyBehavior" name="CreditAgencyBehavior" interface="creditAgency"/>
+ </roleTypes>
+ <roleTypes description="This is the role type LoanBroker" name="LoanBroker">
+ <behaviors description="This is the behavior LoanBrokerBehavior" name="LoanBrokerBehavior" interface="loanBroker"/>
+ </roleTypes>
+ <roleTypes description="This is the role type Notifier" name="Notifier">
+ <behaviors description="This is the behavior NotifierBehavior" name="NotifierBehavior" interface="notifier"/>
+ </roleTypes>
+ <relationshipTypes description="Relationship between LoanBroker and Bank" name="LoanBrokerToBankRel" firstRoleType="//@typeDefinitions/@roleTypes.2" secondRoleType="//@typeDefinitions/@roleTypes.0"/>
+ <relationshipTypes description="Relationship between LoanBroker and CreditAgency" name="LoanBrokerToCreditAgencyRel" firstRoleType="//@typeDefinitions/@roleTypes.2" secondRoleType="//@typeDefinitions/@roleTypes.1"/>
+ <relationshipTypes description="Relationship between LoanBroker and Notifier" name="LoanBrokerToNotifierRel" firstRoleType="//@typeDefinitions/@roleTypes.2" secondRoleType="//@typeDefinitions/@roleTypes.3"/>
+ <participantTypes description="This is the participant type BankParticipant" name="BankParticipant" roleTypes="//@typeDefinitions/@roleTypes.0"/>
+ <participantTypes description="This is the participant type CreditAgencyParticipant" name="CreditAgencyParticipant" roleTypes="//@typeDefinitions/@roleTypes.1"/>
+ <participantTypes description="This is the participant type LoanBrokerParticipant" name="LoanBrokerParticipant" roleTypes="//@typeDefinitions/@roleTypes.2"/>
+ <participantTypes description="This is the participant type NotifierParticipant" name="NotifierParticipant" roleTypes="//@typeDefinitions/@roleTypes.3"/>
+ <channelTypes description="This is the channel type BankChannelType" name="BankChannelType" referenceToken="//@typeDefinitions/@tokens.2" roleType="//@typeDefinitions/@roleTypes.0">
+ <identities description="SSN Id and Quote Ref" tokens="//@typeDefinitions/@tokens.1 //@typeDefinitions/@tokens.0"/>
+ <identities description="SSN Id" type="Association" tokens="//@typeDefinitions/@tokens.1"/>
+ </channelTypes>
+ <channelTypes description="This is the channel type CreditAgencyChannelType" name="CreditAgencyChannelType" referenceToken="//@typeDefinitions/@tokens.2" roleType="//@typeDefinitions/@roleTypes.1">
+ <identities description="SSN Id" tokens="//@typeDefinitions/@tokens.1"/>
+ </channelTypes>
+ <channelTypes description="This is the channel type NotifierChannelType" name="NotifierChannelType" referenceToken="//@typeDefinitions/@tokens.2" roleType="//@typeDefinitions/@roleTypes.3">
+ <identities description="SSN Id" type="Association" tokens="//@typeDefinitions/@tokens.1"/>
+ <identities description="SSN Id and Quote Ref" tokens="//@typeDefinitions/@tokens.1 //@typeDefinitions/@tokens.0"/>
+ </channelTypes>
+ </typeDefinitions>
+ <choreographies description="Choreography flow for the TrailBlazer process" name="TrailBlazerProcess" root="true">
+ <enclosedChoreographies name="RequestQuote">
+ <variableDefinitions description="Channel to facilitate interaction to Bank" name="BankChannel" type="//@typeDefinitions/@channelTypes.0" roleTypes="//@typeDefinitions/@roleTypes.0 //@typeDefinitions/@roleTypes.2"/>
+ <variableDefinitions description="Channel to facilitate interaction to Notifier" name="NotifierChannel" type="//@typeDefinitions/@channelTypes.2" roleTypes="//@typeDefinitions/@roleTypes.2 //@typeDefinitions/@roleTypes.3"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="QuoteRequest" operation="requestQuote" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction QuoteRequest" name="QuoteRequestRequestExchange" type="//@typeDefinitions/@informationTypes.5">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-jmsBankRequestQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-fileBankRequestQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction QuoteRequest" name="QuoteRequestRespondExchange" type="//@typeDefinitions/@informationTypes.3" action="Respond">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-jmsBankResponseQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-fileBankResponseQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="NotifyCustomer" operation="notify" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction NotifyCustomer" name="NotifyCustomerRequestExchange" type="//@typeDefinitions/@informationTypes.3">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-customerNotifier}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </enclosedChoreographies>
+ <variableDefinitions description="Channel to facilitate interaction to CreditAgency" name="CreditAgencyChannel" type="//@typeDefinitions/@channelTypes.1" roleTypes="//@typeDefinitions/@roleTypes.1 //@typeDefinitions/@roleTypes.2"/>
+ <variableDefinitions description="This is the variable NotifierChannel" name="NotifierChannel" type="//@typeDefinitions/@channelTypes.2" roleTypes="//@typeDefinitions/@roleTypes.2 //@typeDefinitions/@roleTypes.3"/>
+ <variableDefinitions description="This is the variable creditCheckResult" name="creditCheckResult" type="//@typeDefinitions/@informationTypes.1" roleTypes="//@typeDefinitions/@roleTypes.2"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheck" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction CreditCheck" name="CreditCheckRequestExchange" type="//@typeDefinitions/@informationTypes.0">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-creditAgencyQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheck" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheck" name="CreditCheckRespondExchange" type="//@typeDefinitions/@informationTypes.1" action="Respond" receiveVariable="//@choreographies.0/@variableDefinitions.2">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-creditAgencyQueue_reply}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Choice">
+ <activities xsi:type="org.pi4soa.cdl:Conditional" description="Sufficient credit to request quotes" name="ValidCredit" expression="cdl:getVariable('creditCheckResult','','//@score') >= 4">
+ <activities xsi:type="org.pi4soa.cdl:Parallel">
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="First quote">
+ <activities xsi:type="org.pi4soa.cdl:Perform" choreography="//@choreographies.0/@enclosedChoreographies.0"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Second quote">
+ <activities xsi:type="org.pi4soa.cdl:Perform" choreography="//@choreographies.0/@enclosedChoreographies.0"/>
+ </activities>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Insufficient credit">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="NotifyCustomer" operation="notify" channelVariable="//@choreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction NotifyCustomer" name="NotifyCustomerRequestExchange" type="//@typeDefinitions/@informationTypes.2">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-customerNotifier}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </activities>
+ </activities>
+ </choreographies>
+</org.pi4soa.cdl:Package>
Added: trunk/samples/jbossesb/trailblazer/readme.txt
===================================================================
--- trunk/samples/jbossesb/trailblazer/readme.txt (rev 0)
+++ trunk/samples/jbossesb/trailblazer/readme.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,45 @@
+
+The trailblazer is a small application that uses several of the services provided by the JBoss ESB.
+
+
+Required to run the Trailblazer:
+- ANT
+- A mail server to send email notifications
+- JBoss AS 4.2.1 or higher with EJB3 and JBossWS support. You can install the latest JBoss AS JEMS installer and select the "EJB3" install config to get the right one installed.
+- JBoss AS 4.2.1 or higher with the JBoss ESB SAR deployment (jbossesb.sar).
+- JBossESB 4.3 or higher
+
+Settings required to edit before running:
+
+File: jbossesb-properties.xml (jbossesb.sar/jbossesb-properties.xml)
+- Update the section titled "transports" and specify all of the SMTP mail server settings for your environment.
+
+File : deployment.properties (install/deployment.properties)
+- Update the JBossAS and JBossESB location settings.
+
+File : trailblazer.properties (TB_ROOT/trailblazer.properties)
+- Update the file.bank.monitored.directory and file.output.directory properties' value properly.
+ These are input and output folder needs to be specified, they are set to /tmp/input /tmp/output by default.
+
+File : jboss-esb.xml (TB_ROOT/esb/conf/jboss-esb.xml)
+- there is a "<fs-provider>..</fs-provider>" block, update the "directory" attribute value as same as file.output.directory value in trailblazer.properties file.
+
+Basic Trailblazer example running instructions:
+------------------------------------------------
+To run the Trailblazer, follow these steps:
+
+1 - run your JBoss AS - you will need to have the 4.2.1 or higher with the EJB3 support installed. This is required because the TB uses the JSR-181 pojo style web service.
+
+2 - from the TB_ROOT, execute the command to start the ESB: "ant deploy"
+* this should deploy the ESB and WAR files to your JBoss AS server/default.
+
+3 - from the TB_ROOT/banks execute the command to start the JMS Bank service: "ant runJMSBank".
+
+4 - start another window/shell, from the TB_ROOT/banks execute the command to start the File bank service: "ant runFileBank".
+
+5 - from the jsp: localhost:8080/trailblazer.
+
+That's it. Now you can submit quotes, You will see either a loan request rejected (single email)
+because the score is less than 4, or two emails (one from JMS bank and one from FileBased
+bank) with valid quotes.
+
Added: trunk/samples/jbossesb/trailblazer/template/quote.st
===================================================================
--- trunk/samples/jbossesb/trailblazer/template/quote.st (rev 0)
+++ trunk/samples/jbossesb/trailblazer/template/quote.st 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,20 @@
+JBossESB - TrailBlazer Quote Response Notification
+
+Customer SSN: $ssn$
+Customer Email: $email$
+
+-- BANK QUOTES RECEIVED --
+
+QUOTE ID: $quote$
+RATE: $rate$
+BANK CODE: $code$
+
+-- BANK CODES --
+0 - success
+1 - loan term exceeds the maximum available loan term
+2 - invalid SSN
+3 - invalid credit score
+4 - invalid credit history length
+5 - invalid loan term
+6 - invalid message
+7 - invalid customer ID
Added: trunk/samples/jbossesb/trailblazer/trailblazer.properties
===================================================================
--- trunk/samples/jbossesb/trailblazer/trailblazer.properties (rev 0)
+++ trunk/samples/jbossesb/trailblazer/trailblazer.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,30 @@
+
+# Credit Agency configs
+creditagency.service.category=tbCreditAGency
+creditagency.service.epr.name=creditagency
+
+# Bank configs
+bank1.service.category=tbBanks
+bank1.service.epr.name=jmsBank
+bank2.service.category=tbBanks
+bank2.service.epr.name=fileBank
+
+# FileBank config
+
+file.bank.monitored.dir=/tmp/input
+file.output.directory=/tmp/output
+
+#JMS Bank config
+jms.provider.url=localhost
+jms.queue.in=queue/jms-tb-jmsBankRequestQueue
+jms.queue.out=queue/esb-tb-jmsBankGatewayResponseQueue
+
+
+# Notifier configs
+notifier.service.category=notifiers
+notifier.service.epr.name=customer
+
+# Customer email notification configs
+email.from=email at jboss.com
+email.template.path=template
+email.template.file=quote
Added: trunk/samples/purchasing/.project
===================================================================
--- trunk/samples/purchasing/.project (rev 0)
+++ trunk/samples/purchasing/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>purchasing</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
Added: trunk/samples/purchasing/BuyConfirmed.xml
===================================================================
--- trunk/samples/purchasing/BuyConfirmed.xml (rev 0)
+++ trunk/samples/purchasing/BuyConfirmed.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,4 @@
+<tns:BuyConfirmed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tns="http://www.jboss.org/examples/store"
+ xsi:schemaLocation="http://www.jboss.org/examples/store store.xsd "
+ id="1" />
\ No newline at end of file
Added: trunk/samples/purchasing/BuyRequest.xml
===================================================================
--- trunk/samples/purchasing/BuyRequest.xml (rev 0)
+++ trunk/samples/purchasing/BuyRequest.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,4 @@
+<tns:BuyRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tns="http://www.jboss.org/examples/store"
+ xsi:schemaLocation="http://www.jboss.org/examples/store store.xsd "
+ id="1" />
\ No newline at end of file
Added: trunk/samples/purchasing/CreditCheckInvalid.xml
===================================================================
--- trunk/samples/purchasing/CreditCheckInvalid.xml (rev 0)
+++ trunk/samples/purchasing/CreditCheckInvalid.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,4 @@
+<tns:CreditCheckInvalid xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tns="http://www.jboss.org/examples/creditAgency"
+ xsi:schemaLocation="http://www.jboss.org/examples/creditAgency creditAgency.xsd "
+ id="1" />
\ No newline at end of file
Added: trunk/samples/purchasing/CreditCheckOk.xml
===================================================================
--- trunk/samples/purchasing/CreditCheckOk.xml (rev 0)
+++ trunk/samples/purchasing/CreditCheckOk.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,4 @@
+<tns:CreditCheckOk xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tns="http://www.jboss.org/examples/creditAgency"
+ xsi:schemaLocation="http://www.jboss.org/examples/creditAgency creditAgency.xsd "
+ id="1" />
\ No newline at end of file
Added: trunk/samples/purchasing/CreditCheckRequest.xml
===================================================================
--- trunk/samples/purchasing/CreditCheckRequest.xml (rev 0)
+++ trunk/samples/purchasing/CreditCheckRequest.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,4 @@
+<tns:CreditCheckRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tns="http://www.jboss.org/examples/creditAgency"
+ xsi:schemaLocation="http://www.jboss.org/examples/creditAgency creditAgency.xsd "
+ id="1" amount="200" />
\ No newline at end of file
Added: trunk/samples/purchasing/InvalidPurchase.scn
===================================================================
--- trunk/samples/purchasing/InvalidPurchase.scn (rev 0)
+++ trunk/samples/purchasing/InvalidPurchase.scn 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scn:Scenario xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:scn="http://www.pi4soa.org/scenario" name="InvalidPurchase" description="Invalid purchase goods" author="" choreographyDescriptionURL="PurchaseGoods.cdm">
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="buy" messageType="{http://www.jboss.org/examples/store}BuyRequest" valueURL="BuyRequest.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.1" operationName="buy" direction="receive" messageType="{http://www.jboss.org/examples/store}BuyRequest" valueURL="BuyRequest.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.1" operationName="checkCredit" messageType="{http://www.jboss.org/examples/creditAgency}CreditCheckRequest" valueURL="CreditCheckRequest.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.2" operationName="checkCredit" direction="receive" messageType="{http://www.jboss.org/examples/creditAgency}CreditCheckRequest" valueURL="CreditCheckRequest.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.2" operationName="checkCredit" faultName="{http://www.jboss.org/savara/examples}CreditCheckFailed" isRequest="false" messageType="{http://www.jboss.org/examples/creditAgency}CreditCheckInvalid" valueURL="CreditCheckInvalid.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.1" operationName="checkCredit" faultName="{http://www.jboss.org/savara/examples}CreditCheckFailed" isRequest="false" direction="receive" messageType="{http://www.jboss.org/examples/creditAgency}CreditCheckInvalid" valueURL="CreditCheckInvalid.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.1" operationName="buy" isRequest="false" messageType="{http://www.jboss.org/examples/store}BuyConfirmed" valueURL="BuyConfirmed.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="buy" isRequest="false" direction="receive" messageType="{http://www.jboss.org/examples/store}BuyConfirmed" valueURL="BuyConfirmed.xml"/>
+ <messageLinks source="//@scenarioObjects.0" target="//@scenarioObjects.1"/>
+ <messageLinks source="//@scenarioObjects.2" target="//@scenarioObjects.3"/>
+ <messageLinks source="//@scenarioObjects.4" target="//@scenarioObjects.5"/>
+ <messageLinks source="//@scenarioObjects.6" target="//@scenarioObjects.7"/>
+ <participants type="Buyer"/>
+ <participants type="sto:Store"/>
+ <participants type="ca:CreditAgency"/>
+</scn:Scenario>
Added: trunk/samples/purchasing/PurchaseGoods.cdm
===================================================================
--- trunk/samples/purchasing/PurchaseGoods.cdm (rev 0)
+++ trunk/samples/purchasing/PurchaseGoods.cdm 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<org.pi4soa.cdl:Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org.pi4soa.cdl="http:///org/pi4soa/cdl.ecore" description="The choreography description for PurchaseGoods" name="PurchaseGoods" author="gary" version="0.1" targetNamespace="http://www.jboss.org/savara/examples">
+ <typeDefinitions>
+ <nameSpaces description="Target Namespace for PurchaseGoods" prefix="tns" uRI="http://www.jboss.org/savara/examples"/>
+ <nameSpaces description="XML Schema Namespace" prefix="xsd" uRI="http://www.w3.org/2001/XMLSchema"/>
+ <nameSpaces prefix="sto" uRI="http://www.jboss.org/examples/store" schemaLocation="store.xsd"/>
+ <nameSpaces prefix="ca" uRI="http://www.jboss.org/examples/creditAgency" schemaLocation="creditAgency.xsd"/>
+ <informationTypes description="This is the information type BuyConfirmed" name="BuyConfirmed" typeName="" elementName="sto:BuyConfirmed"/>
+ <informationTypes description="This is the information type BuyFailed" name="BuyFailed" typeName="" elementName="sto:BuyFailed"/>
+ <informationTypes description="This is the information type BuyRequest" name="BuyRequest" typeName="" elementName="sto:BuyRequest"/>
+ <informationTypes description="This is the information type CreditCheckInvalid" name="CreditCheckInvalid" typeName="" elementName="ca:CreditCheckInvalid"/>
+ <informationTypes description="This is the information type CreditCheckOk" name="CreditCheckOk" typeName="" elementName="ca:CreditCheckOk"/>
+ <informationTypes description="This is the information type CreditCheckRequest" name="CreditCheckRequest" typeName="" elementName="ca:CreditCheckRequest"/>
+ <informationTypes description="This is the information type IDType" name="IDType" typeName="xsd:string"/>
+ <informationTypes description="This is the information type URITokenType" name="URITokenType" typeName="xsd:anyURI"/>
+ <tokens description="This is the token ID" name="ID" informationType="//@typeDefinitions/@informationTypes.6"/>
+ <tokens description="This is the token URIToken" name="URIToken" informationType="//@typeDefinitions/@informationTypes.7"/>
+ <tokenLocators description="This is the token locator BuyFailedIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.1" query="//@id" name="BuyFailedIDLocator"/>
+ <tokenLocators description="This is the token locator BuyRequestIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.2" query="//@id" name="BuyRequestIDLocator"/>
+ <tokenLocators description="This is the token locator BuyResponseIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.0" query="//@id" name="BuyResponseIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckInvalidIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.3" query="//@id" name="CreditCheckInvalidIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckRequestIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.5" query="//@id" name="CreditCheckRequestIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckResponseIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.4" query="//@id" name="CreditCheckResponseIDLocator"/>
+ <roleTypes description="This is the role type Buyer" name="Buyer">
+ <behaviors description="This is the behavior BuyerBehavior" name="BuyerBehavior"/>
+ </roleTypes>
+ <roleTypes description="This is the role type CreditAgency" name="CreditAgency">
+ <behaviors description="This is the behavior CreditAgencyBehavior" name="CreditAgencyBehavior" interface="ca:CreditAgencyInterface"/>
+ </roleTypes>
+ <roleTypes description="This is the role type Store" name="Store">
+ <behaviors description="This is the behavior StoreBehavior" name="StoreBehavior" interface="sto:StoreInterface"/>
+ </roleTypes>
+ <relationshipTypes description="Relationship between Buyer and Store" name="BuyerToStoreRel" firstRoleType="//@typeDefinitions/@roleTypes.0" secondRoleType="//@typeDefinitions/@roleTypes.2"/>
+ <relationshipTypes description="Relationship between Store and CreditAgency" name="StoreToCreditAgencyRel" firstRoleType="//@typeDefinitions/@roleTypes.2" secondRoleType="//@typeDefinitions/@roleTypes.1"/>
+ <participantTypes description="This is the participant type Buyer" name="Buyer" roleTypes="//@typeDefinitions/@roleTypes.0">
+ <semanticAnnotations annotation="savara.samples.Purchasing at Buyer" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type ca:CreditAgency" name="ca:CreditAgency" roleTypes="//@typeDefinitions/@roleTypes.1">
+ <semanticAnnotations annotation="savara.samples.Common at CreditAgency" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type sto:Store" name="sto:Store" roleTypes="//@typeDefinitions/@roleTypes.2">
+ <semanticAnnotations annotation="savara.samples.Purchasing at Store" name="conversationType"/>
+ </participantTypes>
+ <channelTypes description="This is the channel type CreditAgencyChannelType" name="CreditAgencyChannelType" referenceToken="//@typeDefinitions/@tokens.1" roleType="//@typeDefinitions/@roleTypes.1">
+ <identities description="ID" tokens="//@typeDefinitions/@tokens.0"/>
+ </channelTypes>
+ <channelTypes description="This is the channel type StoreChannelType" name="StoreChannelType" referenceToken="//@typeDefinitions/@tokens.1" roleType="//@typeDefinitions/@roleTypes.2">
+ <identities description="ID" tokens="//@typeDefinitions/@tokens.0"/>
+ </channelTypes>
+ </typeDefinitions>
+ <choreographies description="Choreography flow for the PurchaseGoods process" name="PurchaseGoodsProcess" root="true">
+ <variableDefinitions description="Channel to facilitate interaction to CreditAgency" name="CreditAgencyChannel" type="//@typeDefinitions/@channelTypes.0"/>
+ <variableDefinitions name="CreditCheckVar" type="//@typeDefinitions/@informationTypes.5"/>
+ <variableDefinitions description="Channel to facilitate interaction to Supplier" name="SupplierChannel" type="//@typeDefinitions/@channelTypes.1"/>
+ <variableDefinitions description="This is the variable buy" name="buy" type="//@typeDefinitions/@informationTypes.2"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="BuyRequest" operation="buy" channelVariable="//@choreographies.0/@variableDefinitions.2" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction BuyRequest" name="BuyRequestRequestExchange" type="//@typeDefinitions/@informationTypes.2">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/store}StoreService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheck" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction CreditCheck" name="CreditCheckRequestExchange" type="//@typeDefinitions/@informationTypes.5" receiveVariable="//@choreographies.0/@variableDefinitions.1">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAgencyService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Choice" description="Is credit ok?">
+ <activities xsi:type="org.pi4soa.cdl:Conditional" name="CreditValid" expression="cdl:getVariable('CreditCheckVar','','//@amount','CreditAgency') < 250">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckOk" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckOk" name="CreditCheckOkRespondExchange" type="//@typeDefinitions/@informationTypes.4" action="Respond">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAgencyService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="BuyConfirmed" operation="buy" channelVariable="//@choreographies.0/@variableDefinitions.2" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction BuyConfirmed" name="BuyConfirmedRespondExchange" type="//@typeDefinitions/@informationTypes.0" action="Respond">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/store}StoreService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Credit Invalid">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckFailed" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckFailed" name="CreditCheckFailedRespondExchange" type="//@typeDefinitions/@informationTypes.3" action="Respond" faultName="CreditCheckFailed">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAgencyService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="BuyFailed" operation="buy" channelVariable="//@choreographies.0/@variableDefinitions.2" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction BuyFailed" name="BuyFailedRespondExchange" type="//@typeDefinitions/@informationTypes.1" action="Respond" faultName="BuyFailed">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/store}StoreService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </activities>
+ </activities>
+ </choreographies>
+</org.pi4soa.cdl:Package>
Added: trunk/samples/purchasing/SuccessfulPurchase.scn
===================================================================
--- trunk/samples/purchasing/SuccessfulPurchase.scn (rev 0)
+++ trunk/samples/purchasing/SuccessfulPurchase.scn 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scn:Scenario xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:scn="http://www.pi4soa.org/scenario" name="SuccessfulPurchase" description="Successfully purchase goods" author="" choreographyDescriptionURL="PurchaseGoods.cdm">
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="buy" messageType="{http://www.jboss.org/examples/store}BuyRequest" valueURL="BuyRequest.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.1" operationName="buy" direction="receive" messageType="{http://www.jboss.org/examples/store}BuyRequest" valueURL="BuyRequest.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.1" operationName="checkCredit" messageType="{http://www.jboss.org/examples/creditAgency}CreditCheckRequest" valueURL="CreditCheckRequest.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.2" operationName="checkCredit" direction="receive" messageType="{http://www.jboss.org/examples/creditAgency}CreditCheckRequest" valueURL="CreditCheckRequest.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.2" operationName="checkCredit" isRequest="false" messageType="{http://www.jboss.org/examples/creditAgency}CreditCheckOk" valueURL="CreditCheckOk.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.1" operationName="checkCredit" isRequest="false" direction="receive" messageType="{http://www.jboss.org/examples/creditAgency}CreditCheckOk" valueURL="CreditCheckOk.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.1" operationName="buy" isRequest="false" messageType="{http://www.jboss.org/examples/store}BuyConfirmed" valueURL="BuyConfirmed.xml"/>
+ <scenarioObjects xsi:type="scn:MessageEvent" participant="//@participants.0" operationName="buy" isRequest="false" direction="receive" messageType="{http://www.jboss.org/examples/store}BuyConfirmed" valueURL="BuyConfirmed.xml"/>
+ <messageLinks source="//@scenarioObjects.0" target="//@scenarioObjects.1"/>
+ <messageLinks source="//@scenarioObjects.2" target="//@scenarioObjects.3"/>
+ <messageLinks source="//@scenarioObjects.4" target="//@scenarioObjects.5"/>
+ <messageLinks source="//@scenarioObjects.6" target="//@scenarioObjects.7"/>
+ <participants type="Buyer"/>
+ <participants type="sto:Store"/>
+ <participants type="ca:CreditAgency"/>
+</scn:Scenario>
Added: trunk/samples/purchasing/completed/creditAgency/PurchaseGoodsProcess_CreditAgency.bpel
===================================================================
--- trunk/samples/purchasing/completed/creditAgency/PurchaseGoodsProcess_CreditAgency.bpel (rev 0)
+++ trunk/samples/purchasing/completed/creditAgency/PurchaseGoodsProcess_CreditAgency.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,65 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:ca="http://www.jboss.org/examples/creditAgency" xmlns:sto="http://www.jboss.org/examples/store" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="savara.samples.Common at CreditAgency" name="PurchaseGoodsProcess_CreditAgency" targetNamespace="http://www.jboss.org/examples/creditAgency" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="http://www.jboss.org/examples/creditAgency"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgencyArtifacts.wsdl" namespace="http://www.jboss.org/examples/creditAgency"/>
+ <partnerLinks>
+ <partnerLink myRole="CreditAgencyService" name="StoreToCreditAgency" partnerLinkType="ca:StoreToCreditAgencyServiceLT"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="ca:checkCreditRequest" name="creditCheckRequestVar"/>
+ <variable messageType="ca:checkCreditResponse" name="creditCheckOkVar"/>
+ <variable messageType="ca:CreditCheckFailedFault" name="creditCheckInvalidVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_CreditCheckRequest" operation="checkCredit" partnerLink="StoreToCreditAgency" portType="ca:CreditAgencyInterface" variable="creditCheckRequestVar"/>
+ <if>
+ <bpel:condition><![CDATA[
+ $creditCheckRequestVar.content/@amount <= 500
+ ]]></bpel:condition>
+ <sequence>
+ <assign name="CopyPurchaseDetails">
+ <bpel:copy>
+ <bpel:from>
+ <bpel:literal xml:space="preserve">
+ <tns:CreditCheckOk xmlns:tns="http://www.jboss.org/examples/creditAgency"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.org/examples/creditAgency creditAgency.xsd "
+ id="" amount="" >
+ </tns:CreditCheckOk>
+ </bpel:literal>
+ </bpel:from>
+ <bpel:to variable="creditCheckOkVar" part="content"></bpel:to>
+ </bpel:copy>
+ <copy>
+ <from>$creditCheckRequestVar.content/@id</from>
+ <to>$creditCheckOkVar.content/@id</to>
+ </copy>
+ </assign>
+ <reply name="Send_CreditCheckOk" operation="checkCredit" partnerLink="StoreToCreditAgency" portType="ca:CreditAgencyInterface" variable="creditCheckOkVar"/>
+ </sequence>
+ <else>
+ <sequence>
+ <assign name="CopyPurchaseDetails">
+ <bpel:copy>
+ <bpel:from>
+ <bpel:literal xml:space="preserve">
+ <tns:CreditCheckInvalid xmlns:tns="http://www.jboss.org/examples/creditAgency"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.org/examples/creditAgency creditAgency.xsd "
+ id="" amount="" >
+ </tns:CreditCheckInvalid>
+ </bpel:literal>
+ </bpel:from>
+ <bpel:to variable="creditCheckInvalidVar" part="content"></bpel:to>
+ </bpel:copy>
+ <copy>
+ <from>$creditCheckRequestVar.content/@id</from>
+ <to>$creditCheckInvalidVar.content/@id</to>
+ </copy>
+ </assign>
+ <reply faultName="ca:CreditCheckFailed" name="Send_CreditCheckInvalid" operation="checkCredit" partnerLink="StoreToCreditAgency" portType="ca:CreditAgencyInterface" variable="creditCheckInvalidVar"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+</process>
Added: trunk/samples/purchasing/completed/creditAgency/bpel-deploy.xml
===================================================================
--- trunk/samples/purchasing/completed/creditAgency/bpel-deploy.xml (rev 0)
+++ trunk/samples/purchasing/completed/creditAgency/bpel-deploy.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03" xmlns:ns1="http://www.jboss.org/examples/creditAgency">
+ <process name="ns1:PurchaseGoodsProcess_CreditAgency">
+ <active>
+ true
+ </active>
+ <provide partnerLink="StoreToCreditAgency">
+ <service name="ns1:CreditAgencyService" port="CreditAgencyInterfacePort"/>
+ </provide>
+ </process>
+</deploy>
Added: trunk/samples/purchasing/completed/store/PurchaseGoodsProcess_Store.bpel
===================================================================
--- trunk/samples/purchasing/completed/store/PurchaseGoodsProcess_Store.bpel (rev 0)
+++ trunk/samples/purchasing/completed/store/PurchaseGoodsProcess_Store.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,94 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:ca="http://www.jboss.org/examples/creditAgency" xmlns:pur="http://www.jboss.org/examples/purchasing" xmlns:sto="http://www.jboss.org/examples/store" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="savara.samples.Purchasing at Store" name="PurchaseGoodsProcess_Store" targetNamespace="http://www.jboss.org/examples/store" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="http://www.jboss.org/examples/creditAgency"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_StoreArtifacts.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <partnerLinks>
+ <partnerLink myRole="StoreService" name="BuyerToStore" partnerLinkType="sto:BuyerToStoreServiceLT"/>
+ <partnerLink name="StoreToCreditAgency" partnerLinkType="sto:StoreToCreditAgencyLT" partnerRole="CreditAgencyRequester"/>
+ </partnerLinks>
+ <bpel:messageExchanges>
+ <bpel:messageExchange name="messageExchange"></bpel:messageExchange>
+ <bpel:messageExchange name="messageExchange1"></bpel:messageExchange>
+ </bpel:messageExchanges>
+ <variables>
+ <variable messageType="sto:buyRequest" name="buyRequestVar"/>
+ <variable messageType="ca:checkCreditRequest" name="creditCheckRequestVar"/>
+ <variable messageType="ca:checkCreditResponse" name="creditCheckOkVar"/>
+ <variable messageType="sto:buyResponse" name="buyConfirmedVar"/>
+ <variable messageType="sto:BuyFailedFault" name="buyFailedVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_BuyRequest" operation="buy" partnerLink="BuyerToStore" portType="sto:StoreInterface" variable="buyRequestVar"/>
+ <scope>
+ <faultHandlers>
+ <catch faultMessageType="ca:CreditCheckFailedFault" faultName="ca:CreditCheckFailed" faultVariable="creditCheckInvalidVar">
+ <sequence>
+ <assign name="CopyPurchaseDetails">
+ <bpel:copy>
+ <bpel:from>
+ <bpel:literal xml:space="preserve">
+ <tns:BuyFailed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tns="http://www.jboss.org/examples/store"
+ xsi:schemaLocation="http://www.jboss.org/examples/store store.xsd "
+ id="" />
+ </bpel:literal>
+ </bpel:from>
+ <bpel:to variable="buyFailedVar" part="content"></bpel:to>
+ </bpel:copy>
+ <copy>
+ <from>$creditCheckInvalidVar.content/@id</from>
+ <to>$buyFailedVar.content/@id</to>
+ </copy>
+ </assign>
+ <reply faultName="sto:BuyFailed" name="Send_BuyFailed" operation="buy" partnerLink="BuyerToStore" portType="sto:StoreInterface" variable="buyFailedVar"/>
+ </sequence>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <assign name="CopyPurchaseDetails">
+ <bpel:copy>
+ <bpel:from>
+ <bpel:literal xml:space="preserve">
+ <tns:CreditCheckRequest xmlns:tns="http://www.jboss.org/examples/creditAgency"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.org/examples/creditAgency creditAgency.xsd "
+ id="" amount="" >
+ </tns:CreditCheckRequest>
+ </bpel:literal>
+ </bpel:from>
+ <bpel:to variable="creditCheckRequestVar" part="content"></bpel:to>
+ </bpel:copy>
+ <copy>
+ <from>$buyRequestVar.content/@id</from>
+ <to>$creditCheckRequestVar.content/@id</to>
+ </copy>
+ <copy>
+ <from>$buyRequestVar.content/@amount</from>
+ <to>$creditCheckRequestVar.content/@amount</to>
+ </copy>
+ </assign>
+
+ <invoke inputVariable="creditCheckRequestVar" name="Send_CreditCheckRequest" operation="checkCredit" outputVariable="creditCheckOkVar" partnerLink="StoreToCreditAgency" portType="ca:CreditAgencyInterface"/>
+
+ <assign name="CopyPurchaseDetails">
+ <bpel:copy>
+ <bpel:from>
+ <bpel:literal xml:space="preserve">
+ <tns:BuyConfirmed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tns="http://www.jboss.org/examples/store"
+ xsi:schemaLocation="http://www.jboss.org/examples/store store.xsd "
+ id="" />
+ </bpel:literal>
+ </bpel:from>
+ <bpel:to variable="buyConfirmedVar" part="content"></bpel:to>
+ </bpel:copy>
+ <copy>
+ <from>$creditCheckOkVar.content/@id</from>
+ <to>$buyConfirmedVar.content/@id</to>
+ </copy>
+ </assign>
+ <reply name="Send_BuyConfirmed" operation="buy" partnerLink="BuyerToStore" portType="sto:StoreInterface" variable="buyConfirmedVar"/>
+ </sequence>
+ </scope>
+ </sequence>
+</process>
Added: trunk/samples/purchasing/completed/store/bpel-deploy.xml
===================================================================
--- trunk/samples/purchasing/completed/store/bpel-deploy.xml (rev 0)
+++ trunk/samples/purchasing/completed/store/bpel-deploy.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03" xmlns:ns1="http://www.jboss.org/examples/store"
+ xmlns:ns2="http://www.jboss.org/examples/creditAgency">
+ <process name="ns1:PurchaseGoodsProcess_Store">
+ <active>
+ true
+ </active>
+ <provide partnerLink="BuyerToStore">
+ <service name="ns1:StoreService" port="StoreInterfacePort"/>
+ </provide>
+ <invoke partnerLink="StoreToCreditAgency">
+ <service name="ns2:CreditAgencyService" port="CreditAgencyInterfacePort"/>
+ </invoke>
+ </process>
+</deploy>
Added: trunk/samples/purchasing/creditAgency.xsd
===================================================================
--- trunk/samples/purchasing/creditAgency.xsd (rev 0)
+++ trunk/samples/purchasing/creditAgency.xsd 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.jboss.org/examples/creditAgency" xmlns:tns="http://www.jboss.org/examples/creditAgency" elementFormDefault="qualified">
+
+ <element name="CreditCheckRequest" type="tns:CreditCheckType"></element>
+ <element name="CreditCheckOk" type="tns:CreditCheckType"></element>
+ <element name="CreditCheckInvalid" type="tns:CreditCheckType"></element>
+
+ <complexType name="CreditCheckType">
+ <attribute name="id" type="string"></attribute>
+ <attribute name="amount" type="integer"></attribute>
+ </complexType>
+</schema>
\ No newline at end of file
Added: trunk/samples/purchasing/purchasing.tap
===================================================================
--- trunk/samples/purchasing/purchasing.tap (rev 0)
+++ trunk/samples/purchasing/purchasing.tap 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.savara.org/ta/project" xmlns:xsi="http://www.w3.org/2001/XMLSchema"
+ xsi:schemaLocation="http://www.savara.org/ta/project tap.xsd"
+ name="Purchasing" version="1.0.0">
+
+ <phase name="requirements">
+ <resource id="SuccessfulPurchase.scn">
+ <uri type="eclipse" context="purchasing" locator="/SuccessfulPurchase.scn" />
+ </resource>
+ <resource id="InvalidPurchase.scn">
+ <uri type="eclipse" context="purchasing" locator="/InvalidPurchase.scn" />
+ </resource>
+ </phase>
+
+ <phase name="architecture">
+ <resource id="PurchaseGoods.cdm">
+ <uri type="eclipse" context="purchasing" locator="/PurchaseGoods.cdm" />
+ <relationship type="depends" ref="SuccessfulPurchase.scn" />
+ <relationship type="depends" ref="InvalidPurchase.scn" />
+ </resource>
+ </phase>
+
+ <phase name="implementation">
+ <resource id="PurchaseGoodsProcess_Store.bpel">
+ <uri type="eclipse" context="PurchaseGoodsProcess-Store" locator="/bpelContent/PurchaseGoodsProcess_Store.bpel" />
+ <relationship type="depends" ref="PurchaseGoods.cdm" >
+ <description>Link from the BPEL process to the 'Store' participant within the choreography</description>
+ <link type="role" to="Store" />
+ </relationship>
+ </resource>
+ <resource id="PurchaseGoodsProcess_CreditAgency.bpel">
+ <uri type="eclipse" context="PurchaseGoodsProcess-CreditAgency" locator="/bpelContent/PurchaseGoodsProcess_CreditAgency.bpel" />
+ <relationship type="depends" ref="PurchaseGoods.cdm" >
+ <description>Link from the BPEL process to the 'CreditAgency' participant within the choreography</description>
+ <link type="role" to="CreditAgency" />
+ </relationship>
+ </resource>
+ </phase>
+</project>
\ No newline at end of file
Added: trunk/samples/purchasing/store.xsd
===================================================================
--- trunk/samples/purchasing/store.xsd (rev 0)
+++ trunk/samples/purchasing/store.xsd 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.jboss.org/examples/store" xmlns:tns="http://www.jboss.org/examples/store" elementFormDefault="qualified">
+
+ <element name="BuyRequest" type="tns:StoreType"></element>
+ <element name="BuyConfirmed" type="tns:StoreType"></element>
+ <element name="BuyFailed" type="tns:StoreType"></element>
+
+ <complexType name="StoreType">
+ <attribute name="id" type="string"></attribute>
+ <attribute name="amount" type="integer"></attribute>
+ </complexType>
+</schema>
\ No newline at end of file
Added: trunk/tools/features/org.jboss.savara.tools.feature/Copyright.txt
===================================================================
--- trunk/tools/features/org.jboss.savara.tools.feature/Copyright.txt (rev 0)
+++ trunk/tools/features/org.jboss.savara.tools.feature/Copyright.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/tools/features/org.jboss.savara.tools.feature/build.properties
===================================================================
--- trunk/tools/features/org.jboss.savara.tools.feature/build.properties (rev 0)
+++ trunk/tools/features/org.jboss.savara.tools.feature/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,6 @@
+bin.includes = feature.xml,\
+ Copyright.txt
+src.includes = pom.xml,\
+ Copyright.txt,\
+ build.properties,\
+ feature.xml
Added: trunk/tools/features/org.jboss.savara.tools.feature/feature.xml
===================================================================
--- trunk/tools/features/org.jboss.savara.tools.feature/feature.xml (rev 0)
+++ trunk/tools/features/org.jboss.savara.tools.feature/feature.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.jboss.savara.tools.feature"
+ label="JBoss SAVARA Tools Feature"
+ version="1.2.0.qualifier"
+ provider-name="www.jboss.org">
+
+ <description>
+ The JBoss Tools for Savara.
+ </description>
+
+ <copyright>
+ /*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+ </copyright>
+
+ <license url="http://www.gnu.org/licenses/lgpl-2.1.html">
+ GNU LESSER GENERAL PUBLIC LICENSE
+
+Version 2.1, February 1999
+
+Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
+
+This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
+
+When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
+
+To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
+
+For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
+
+We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
+
+To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
+
+Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
+
+Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
+
+When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
+
+We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
+
+For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
+
+In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
+
+Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
+
+The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
+
+A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
+
+The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
+
+"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
+
+1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+ * a) The modified work must itself be a software library.
+ * b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
+ * c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
+ * d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
+
+Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
+
+This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
+
+4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
+
+If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
+
+5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
+
+However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
+
+When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
+
+If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
+
+Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
+
+6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
+
+You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
+
+ * a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
+ * b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
+ * c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
+ * d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
+ * e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
+
+For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
+
+7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
+
+ * a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
+ * b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
+
+8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
+
+10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
+
+11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
+
+14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ </license>
+
+ <includes
+ id="org.savara.tools.feature"
+ version="0.0.0"/>
+
+</feature>
Added: trunk/tools/features/org.jboss.savara.tools.feature/pom.xml
===================================================================
--- trunk/tools/features/org.jboss.savara.tools.feature/pom.xml (rev 0)
+++ trunk/tools/features/org.jboss.savara.tools.feature/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,74 @@
+<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.tools</groupId>
+ <artifactId>org.jboss.savara.tools.feature</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-feature</packaging>
+ <name>Savara::Tools::Features::JBossSavaraTools</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>features</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <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.contract.model</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.bpel</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.comparator</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.scribble.conversation.projector</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.scribble.conversation.export.text</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.scribble.conversation.validation</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>org.savara.tools.bpel</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>org.savara.tools.wsdl</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
+
Added: trunk/tools/features/org.savara.tools.feature/Copyright.txt
===================================================================
--- trunk/tools/features/org.savara.tools.feature/Copyright.txt (rev 0)
+++ trunk/tools/features/org.savara.tools.feature/Copyright.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/tools/features/org.savara.tools.feature/build.properties
===================================================================
--- trunk/tools/features/org.savara.tools.feature/build.properties (rev 0)
+++ trunk/tools/features/org.savara.tools.feature/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,6 @@
+bin.includes = feature.xml,\
+ Copyright.txt
+src.includes = pom.xml,\
+ Copyright.txt,\
+ build.properties,\
+ feature.xml
Added: trunk/tools/features/org.savara.tools.feature/feature.xml
===================================================================
--- trunk/tools/features/org.savara.tools.feature/feature.xml (rev 0)
+++ trunk/tools/features/org.savara.tools.feature/feature.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,294 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.savara.tools.feature"
+ label="SAVARA Tools Feature"
+ version="1.2.0.qualifier"
+ provider-name="www.savara.org">
+
+ <description>
+ The Tools for Savara.
+ </description>
+
+ <copyright>
+ /*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+ </copyright>
+
+ <license url="http://www.gnu.org/licenses/lgpl-2.1.html">
+ GNU LESSER GENERAL PUBLIC LICENSE
+
+Version 2.1, February 1999
+
+Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
+
+This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
+
+When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
+
+To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
+
+For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
+
+We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
+
+To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
+
+Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
+
+Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
+
+When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
+
+We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
+
+For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
+
+In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
+
+Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
+
+The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
+
+A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
+
+The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
+
+"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
+
+1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+ * a) The modified work must itself be a software library.
+ * b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
+ * c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
+ * d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
+
+Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
+
+This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
+
+4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
+
+If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
+
+5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
+
+However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
+
+When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
+
+If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
+
+Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
+
+6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
+
+You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
+
+ * a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
+ * b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
+ * c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
+ * d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
+ * e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
+
+For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
+
+7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
+
+ * a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
+ * b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
+
+8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
+
+10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
+
+11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
+
+14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ </license>
+
+ <requires>
+ <import feature="org.scribble.protocol.feature"/>
+ <import feature="org.pi4soa.core.feature"/>
+ </requires>
+
+ <plugin
+ id="org.savara.contract.model"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.protocol.contract"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.core"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.tools.bpel"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.bpel"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.tools.validator"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.tools.wsdl"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.wsdl"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.tools.bpmn"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.tools.monitor"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.pi4soa.cdm"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.tap.eclipse"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.tap.model"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.savara.tap.validation"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.scribble.conformance"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.scribble.conversation.comparator"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
Added: trunk/tools/features/org.savara.tools.feature/pom.xml
===================================================================
--- trunk/tools/features/org.savara.tools.feature/pom.xml (rev 0)
+++ trunk/tools/features/org.savara.tools.feature/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,74 @@
+<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.tools</groupId>
+ <artifactId>org.savara.tools.feature</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-feature</packaging>
+ <name>Savara::Tools::Features::SavaraTools</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>features</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <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.contract.model</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.bpel</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.comparator</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.scribble.conversation.projector</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.scribble.conversation.export.text</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.scribble.conversation.validation</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>org.savara.tools.bpel</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>org.savara.tools.wsdl</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
+
Added: trunk/tools/features/org.scribble.protocol.feature/LICENSE.txt
===================================================================
--- trunk/tools/features/org.scribble.protocol.feature/LICENSE.txt (rev 0)
+++ trunk/tools/features/org.scribble.protocol.feature/LICENSE.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/tools/features/org.scribble.protocol.feature/build.properties
===================================================================
--- trunk/tools/features/org.scribble.protocol.feature/build.properties (rev 0)
+++ trunk/tools/features/org.scribble.protocol.feature/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,6 @@
+bin.includes = feature.xml,\
+ Copyright.txt
+src.includes = pom.xml,\
+ Copyright.txt,\
+ build.properties,\
+ feature.xml
Added: trunk/tools/features/org.scribble.protocol.feature/feature.xml
===================================================================
--- trunk/tools/features/org.scribble.protocol.feature/feature.xml (rev 0)
+++ trunk/tools/features/org.scribble.protocol.feature/feature.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,272 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.scribble.protocol.feature"
+ label="Scribble Protocol Feature"
+ version="1.2.0.qualifier"
+ provider-name="www.jboss.org">
+
+ <description>
+ Scribble Protocol Features.
+ </description>
+
+ <copyright>
+ *
+ * Copyright 2010 www.scribble.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ </copyright>
+
+ <license url="http://www.apache.org/licenses/LICENSE-2.0">
+ 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
+ </license>
+
+ <plugin
+ id="org.scribble.conversation.export.text"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.scribble.conversation.model"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.scribble.conversation.parser"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.scribble.conversation.projector"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.scribble.conversation.validation"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.scribble.core"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.scribble.eclipse"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.scribble.expression.xpath"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.scribble.lang.model"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
Added: trunk/tools/features/org.scribble.protocol.feature/pom.xml
===================================================================
--- trunk/tools/features/org.scribble.protocol.feature/pom.xml (rev 0)
+++ trunk/tools/features/org.scribble.protocol.feature/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,59 @@
+<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.tools</groupId>
+ <artifactId>org.scribble.protocol.feature</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-feature</packaging>
+ <name>Savara::Tools::Features::ScribbleProtocol</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>features</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.conversation.projector</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.scribble.conversation.validation</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.scribble.conversation.export.text</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.scribble.lang.model</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
+
Added: trunk/tools/features/pom.xml
===================================================================
--- trunk/tools/features/pom.xml (rev 0)
+++ trunk/tools/features/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,23 @@
+<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.tools</groupId>
+ <artifactId>features</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Savara::Tools::Features</name>
+
+ <parent>
+ <groupId>org.savara</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <modules>
+ <module>org.scribble.protocol.feature</module>
+ <module>org.savara.tools.feature</module>
+ <module>org.jboss.savara.tools.feature</module>
+ </modules>
+</project>
+
+
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/.classpath
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/.classpath (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/.project
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/.project (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.pi4soa.cdm</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/tools/plugins/org.savara.pi4soa.cdm/Copyright.txt
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/Copyright.txt (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/Copyright.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/tools/plugins/org.savara.pi4soa.cdm/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA pi4soa CDM
+Bundle-SymbolicName: org.savara.pi4soa.cdm
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.pi4soa.cdm.osgi.Activator
+Bundle-Vendor: www.savara.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.pi4soa.cdl,
+ org.pi4soa.common,
+ 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.conversation.parser;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.ui;resolution:=optional,
+ org.eclipse.core.resources;resolution:=optional,
+ org.eclipse.core.runtime;resolution:=optional,
+ org.pi4soa.designer;resolution:=optional,
+ org.eclipse.ui.views.properties.tabbed;resolution:=optional,
+ org.scribble.expression.xpath,
+ org.scribble.eclipse;bundle-version="[1.0.0,2.0.0)";resolution:=optional,
+ org.savara.contract.model
+Scribble-Extensions: org.savara.pi4soa.cdm.parser.CDMTokenizer,
+ org.savara.pi4soa.cdm.parser.CDMModelParserRule,
+ org.savara.pi4soa.cdm.model.CDMNotation,
+ org.savara.pi4soa.cdm.model.SCNNotation,
+ org.savara.pi4soa.cdm.validation.TypeReferenceValidationRule,
+ org.savara.pi4soa.cdm.editor.CDMEditorManager,
+ org.savara.pi4soa.cdm.editor.SCNEditorManager
+Export-Package: org.savara.pi4soa.cdm.model,
+ org.savara.pi4soa.cdm.parser
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/build.properties
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/build.properties (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,4 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/pom.xml
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/pom.xml (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,69 @@
+<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.tools</groupId>
+ <artifactId>org.savara.pi4soa.cdm</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::Pi4SOACDM</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</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>
+ </dependencies>
+
+<!--
+ <dependencies>
+ <dependency>
+ <groupId></groupId>
+ <artifactId></artifactId>
+ <version></version>
+ </dependency>
+ </dependencies>
+-->
+
+</project>
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/CDMDefinitions.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/CDMDefinitions.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/CDMDefinitions.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 17 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm;
+
+/**
+ * This class provides common definitions used in the Scribble
+ * transformation of the CDM file.
+ */
+public class CDMDefinitions {
+
+ public static final String CDM_NOTATION="cdm";
+
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/editor/CDMEditorManager.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/editor/CDMEditorManager.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/editor/CDMEditorManager.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,114 @@
+/*
+ * 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.savara.pi4soa.cdm.editor;
+
+import org.eclipse.emf.ecore.EValidator;
+import org.savara.pi4soa.cdm.model.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.editor.*;
+
+/**
+ * This is the CDM designer's implementation of the EditorManager
+ * interface.
+ */
+ at RegistryInfo(extension=EditorManager.class,notation=CDMNotation.NOTATION_CODE) //preference=10,
+public class CDMEditorManager extends AbstractEditorManager {
+
+ /**
+ * 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) {
+ String uri=null;
+ org.eclipse.core.resources.IFile file=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.getFile(mref);
+
+ if (file == null || file.exists() == false) {
+ file = org.scribble.eclipse.model.admin.OSGIModelRepository.getGlobalFile(mref);
+ }
+
+ if (file != null && file.exists()) {
+ uri = file.getFullPath().toPortableString();
+ }
+
+ if (uri != null) {
+ org.eclipse.ui.IWorkbenchPage page=
+ org.eclipse.ui.PlatformUI.getWorkbench().
+ getActiveWorkbenchWindow().getActivePage();
+
+ org.eclipse.core.resources.IResource res=
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(uri);
+
+ if (res instanceof org.eclipse.core.resources.IFile) {
+ org.eclipse.ui.part.FileEditorInput input=
+ new org.eclipse.ui.part.FileEditorInput(
+ (org.eclipse.core.resources.IFile)res);
+
+ try {
+ org.eclipse.ui.IEditorPart part=page.openEditor(input,
+ "org.pi4soa.designer.Pi4SOADesignerID");
+
+ if (part instanceof org.pi4soa.designer.editor.ChoreographyDescriptionEditor) {
+ org.pi4soa.designer.editor.ChoreographyDescriptionEditor editor=
+ (org.pi4soa.designer.editor.ChoreographyDescriptionEditor)part;
+
+ /* Other approach using marker - can be used if editor does not
+ * provide alternative way to focus on component.
+ org.eclipse.core.resources.IMarker marker=res.createMarker(EValidator.MARKER);
+ marker.setAttribute(EValidator.URI_ATTRIBUTE, ref.getComponentURI());
+ editor.gotoMarker(marker);
+ marker.delete();
+ */
+
+ editor.showComponent(sref.getComponentURI());
+ }
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * This method enriches the set of properties required
+ * by the editor, using the properties associated with
+ * the model issue.
+ *
+ * @param issue The model issue
+ */
+ @Override
+ public void enrich(ModelIssue issue) {
+
+ if (issue.getModelObject() != null) {
+ // Set the EMF URI attribute
+ issue.getProperties().put(EValidator.URI_ATTRIBUTE,
+ issue.getModelObject().getSource().getComponentURI());
+ }
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/editor/SCNEditorManager.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/editor/SCNEditorManager.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/editor/SCNEditorManager.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,114 @@
+/*
+ * 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.savara.pi4soa.cdm.editor;
+
+import org.eclipse.emf.ecore.EValidator;
+import org.savara.pi4soa.cdm.model.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.editor.*;
+
+/**
+ * This is the CDM designer's implementation of the EditorManager
+ * interface.
+ */
+ at RegistryInfo(extension=EditorManager.class,notation=SCNNotation.NOTATION_CODE) //preference=10,
+public class SCNEditorManager extends AbstractEditorManager {
+
+ /**
+ * 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) {
+ String uri=null;
+ org.eclipse.core.resources.IFile file=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.getFile(mref);
+
+ if (file == null || file.exists() == false) {
+ file = org.scribble.eclipse.model.admin.OSGIModelRepository.getGlobalFile(mref);
+ }
+
+ if (file != null && file.exists()) {
+ uri = file.getFullPath().toPortableString();
+ }
+
+ if (uri != null) {
+ org.eclipse.ui.IWorkbenchPage page=
+ org.eclipse.ui.PlatformUI.getWorkbench().
+ getActiveWorkbenchWindow().getActivePage();
+
+ org.eclipse.core.resources.IResource res=
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(uri);
+
+ if (res instanceof org.eclipse.core.resources.IFile) {
+ org.eclipse.ui.part.FileEditorInput input=
+ new org.eclipse.ui.part.FileEditorInput(
+ (org.eclipse.core.resources.IFile)res);
+
+ try {
+ org.eclipse.ui.IEditorPart part=page.openEditor(input,
+ "org.pi4soa.scenario.designer.Pi4SOAScenarioDesignerID");
+
+ if (part instanceof org.pi4soa.designer.editor.ChoreographyDescriptionEditor) {
+ org.pi4soa.designer.editor.ChoreographyDescriptionEditor editor=
+ (org.pi4soa.designer.editor.ChoreographyDescriptionEditor)part;
+
+ /* Other approach using marker - can be used if editor does not
+ * provide alternative way to focus on component.
+ org.eclipse.core.resources.IMarker marker=res.createMarker(EValidator.MARKER);
+ marker.setAttribute(EValidator.URI_ATTRIBUTE, ref.getComponentURI());
+ editor.gotoMarker(marker);
+ marker.delete();
+ */
+
+ editor.showComponent(sref.getComponentURI());
+ }
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * This method enriches the set of properties required
+ * by the editor, using the properties associated with
+ * the model issue.
+ *
+ * @param issue The model issue
+ */
+ @Override
+ public void enrich(ModelIssue issue) {
+
+ if (issue.getModelObject() != null) {
+ // Set the EMF URI attribute
+ issue.getProperties().put(EValidator.URI_ATTRIBUTE,
+ issue.getModelObject().getSource().getComponentURI());
+ }
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/model/CDMNotation.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/model/CDMNotation.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/model/CDMNotation.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,67 @@
+/*
+ * 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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.model;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Notation;
+
+/**
+ * This class represents the CDM notation implementation.
+ */
+ at RegistryInfo(extension=org.scribble.model.Notation.class)
+public class CDMNotation extends org.scribble.model.AbstractNotation {
+
+ public static final String NOTATION_CODE="cdm";
+
+ /**
+ * This is the constructor for the CDM notation.
+ */
+ public CDMNotation() {
+ super(NOTATION_CODE, "CDM", 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
+ */
+ 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/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/model/SCNNotation.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/model/SCNNotation.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/model/SCNNotation.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,67 @@
+/*
+ * 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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.model;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Notation;
+
+/**
+ * This class represents the SCN notation implementation.
+ */
+ at RegistryInfo(extension=org.scribble.model.Notation.class)
+public class SCNNotation extends org.scribble.model.AbstractNotation {
+
+ public static final String NOTATION_CODE="scn";
+
+ /**
+ * This is the constructor for the CDM notation.
+ */
+ public SCNNotation() {
+ super(NOTATION_CODE, "SCN", 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
+ */
+ 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/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/osgi/Activator.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,22 @@
+package org.savara.pi4soa.cdm.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/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/CDMModelParserRule.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/CDMModelParserRule.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/CDMModelParserRule.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,133 @@
+/*
+ * 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:
+ * 6 May 2009 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.savara.pi4soa.cdm.model.CDMNotation;
+import org.savara.pi4soa.cdm.parser.rules.ConverterContext;
+import org.savara.pi4soa.cdm.parser.rules.ConverterRule;
+import org.savara.pi4soa.cdm.parser.rules.ConverterRuleFactory;
+import org.savara.pi4soa.cdm.parser.rules.DefaultConverterContext;
+import org.scribble.conversation.model.ConversationModel;
+import org.scribble.extensions.RegistryFactory;
+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 CDM notation.
+ *
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=CDMNotation.NOTATION_CODE)
+public class CDMModelParserRule extends org.scribble.conversation.parser.ConversationModelParserRule {
+
+ /**
+ * The default constructor.
+ */
+ public CDMModelParserRule() {
+ //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) {
+ ConversationModel ret=null;
+
+ Token t=context.nextToken();
+
+ if (t != null && t.getObject() instanceof org.pi4soa.cdl.Package) {
+ try {
+ org.pi4soa.cdl.Package cdlpack=
+ (org.pi4soa.cdl.Package)t.getObject();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(ConversationModel.class,
+ cdlpack);
+
+ if (rule != null) {
+ ConverterContext cctxt=
+ new DefaultConverterContext(context.getSource());
+
+ ret = (ConversationModel)rule.convert(cctxt,
+ ConversationModel.class, cdlpack);
+ }
+
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to load model", e);
+ }
+
+ if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+
+ 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.getSource(), ret, formatter);
+
+ String str=new String(os.toByteArray());
+
+ System.out.println("EXPORTED CDM TEXT:");
+ System.out.println(str);
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser");
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/CDMTokenizer.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/CDMTokenizer.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/CDMTokenizer.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 6 May 2009 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser;
+
+import org.savara.pi4soa.cdm.model.CDMNotation;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.parser.*;
+
+/**
+ * This is the CDM based implementation of the tokenizer
+ * interface.
+ */
+ at RegistryInfo(extension=Tokenizer.class,notation=CDMNotation.NOTATION_CODE)
+public class CDMTokenizer extends DefaultTokenizer {
+
+ /**
+ * The default constructor.
+ */
+ public CDMTokenizer() {
+ }
+
+ /**
+ * 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>();
+
+ org.pi4soa.cdl.Package cdlpack=
+ org.pi4soa.cdl.CDLManager.load(is);
+
+ if (cdlpack != null) {
+ Token t=new Token(cdlpack);
+ ret.add(t);
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,134 @@
+/*
+ * 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 Jun 2009 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.pi4soa.cdl.util.PackageUtil;
+import org.pi4soa.common.xml.XMLUtils;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class AssignConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Assign);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.model.Block ret=
+ new org.scribble.model.Block();
+ org.pi4soa.cdl.Assign cdl=(org.pi4soa.cdl.Assign)cdlType;
+ java.util.List<Raise> exceptions=new java.util.Vector<Raise>();
+
+ for (int i=0; i < cdl.getCopyDetails().size(); i++) {
+ org.pi4soa.cdl.CopyDetails details=cdl.getCopyDetails().get(i);
+
+ Assignment assign=new Assignment();
+
+ assign.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(details));
+
+ // Set role
+ Role role=new Role();
+
+ if (cdl.getParticipant() != null) {
+ role.setName(cdl.getParticipant().getName());
+ } else if (cdl.getRoleType() != null) {
+ org.pi4soa.cdl.ParticipantType ptype=
+ PackageUtil.getParticipantForRoleType(cdl.getRoleType());
+
+ if (ptype != null) {
+ role.setName(ptype.getName());
+ }
+ }
+
+ assign.getRoles().add(role);
+
+ // Set variable
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(details.getTargetVariable().getName());
+
+ assign.setVariable(var);
+
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ if (details.getSourceExpression() != null) {
+ expr.setQuery(details.getSourceExpression());
+ } else if (details.getSourceVariable() != null) {
+ expr.setQuery("cdl:getVariable('"+details.getSourceVariable().getName()+"','','')");
+ }
+
+ assign.setExpression(expr);
+
+ ret.getContents().add(assign);
+
+ if (details.getCauseException() != null &&
+ details.getCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+
+ Role raiseRole=new Role();
+ raiseRole.setName(role.getName());
+ raise.getRoles().add(raiseRole);
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(details.getCauseException()));
+ raise.setType(tref);
+
+ exceptions.add(raise);
+ }
+ }
+
+ if (exceptions.size() > 0) {
+ ret.getContents().addAll(exceptions);
+ }
+
+ if (ret.getContents().size() > 1) {
+ return(ret);
+ } else if (ret.getContents().size() == 1) {
+ return(ret.getContents().get(0));
+ } else {
+ return(null);
+ }
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,781 @@
+/*
+ * 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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.Interaction;
+import org.pi4soa.cdl.interfaces.InterfaceDefinition;
+import org.pi4soa.cdl.interfaces.InterfaceVisitor;
+import org.pi4soa.cdl.interfaces.MessageDefinition;
+import org.pi4soa.cdl.interfaces.OperationDefinition;
+import org.pi4soa.cdl.interfaces.RoleTypeDefinition;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.pi4soa.cdl.util.PackageUtil;
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.XMLUtils;
+import org.savara.contract.model.*;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.*;
+
+public class ConversationConverterRuleImpl implements ConverterRule {
+
+ private static final String CONVERSATION_TYPE = "conversationType";
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == Conversation.class &&
+ cdlType instanceof Choreography);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ Conversation ret=new Conversation();
+ Choreography choreo=(Choreography)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(choreo));
+
+ context.pushScope();
+
+ LocatedName modelName=new LocatedName();
+ modelName.setName(choreo.getName());
+
+ ret.setLocatedName(modelName);
+
+ // Define roles
+ defineRoles(context, choreo, ret);
+
+ // Check if root, then need to project other sibling choreos
+ if (choreo.getRoot() == Boolean.TRUE) {
+
+ java.util.Iterator<Choreography> citer=
+ choreo.getPackage().getChoreographies().iterator();
+
+ while (citer.hasNext()) {
+ Choreography subchoreo=citer.next();
+
+ if (subchoreo != choreo) {
+ Conversation subconv=(Conversation)
+ convert(context, Conversation.class, subchoreo);
+
+ ret.getBlock().getContents().add(subconv);
+
+ context.addConversation(subconv);
+ }
+
+ for (int i=0; i < subchoreo.getFinalizers().size(); i++) {
+ FinalizerHandler finalizer=subchoreo.getFinalizers().get(i);
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ Conversation.class, finalizer);
+
+ if (rule != null) {
+
+ Conversation subconv=(Conversation)
+ rule.convert(context, Conversation.class, finalizer);
+
+ ret.getBlock().getContents().add(subconv);
+
+ context.addConversation(subconv);
+ }
+ }
+ }
+ }
+
+ // Process any sub-choreographies
+ java.util.Iterator<Choreography> citer=
+ choreo.getEnclosedChoreographies().iterator();
+
+ while (citer.hasNext()) {
+ Choreography subchoreo=citer.next();
+
+ Conversation subconv=(Conversation)
+ convert(context, Conversation.class, subchoreo);
+
+ ret.getBlock().getContents().add(subconv);
+
+ context.addConversation(subconv);
+
+ for (int i=0; i < subchoreo.getFinalizers().size(); i++) {
+ FinalizerHandler finalizer=subchoreo.getFinalizers().get(i);
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ Conversation.class, finalizer);
+
+ if (rule != null) {
+
+ subconv = (Conversation)
+ rule.convert(context, Conversation.class, finalizer);
+
+ ret.getBlock().getContents().add(subconv);
+
+ context.addConversation(subconv);
+ }
+ }
+ }
+
+ // Convert variables
+ convertVariables(context, choreo, ret.getBlock());
+
+ // Define identities
+ convertIdentities(context, choreo, ret);
+
+ // Check if exception handlers have been defined
+ // and/or completion condition
+ if (NamesUtil.isSet(choreo.getCompletionCondition()) ||
+ (choreo.getExceptionHandler() != null &&
+ choreo.getExceptionHandler().getExceptionWorkUnits().size() > 0)) {
+
+ TryEscape te=new TryEscape();
+ ret.getBlock().getContents().add(te);
+
+ // Process all of the activities within the
+ // choreography
+ convertActivities(context, choreo.getActivities(),
+ te.getBlock());
+
+ for (int i=0; choreo.getExceptionHandler() != null &&
+ i < choreo.getExceptionHandler().
+ getExceptionWorkUnits().size(); i++) {
+ ExceptionWorkUnit ewu=choreo.getExceptionHandler().
+ getExceptionWorkUnits().get(i);
+
+ CatchBlock catchPath=new CatchBlock();
+
+ if (NamesUtil.isSet(ewu.getExceptionType())) {
+ TypeReference ref=new TypeReference();
+ ref.setLocalpart(XMLUtils.getLocalname(ewu.getExceptionType()));
+ ref.setNamespace(CDLTypeUtil.getNamespace(
+ ewu.getExceptionType(), choreo));
+
+ catchPath.setType(ref);
+ }
+
+ te.getEscapeBlocks().add(catchPath);
+
+ convertActivities(context, ewu.getActivities(),
+ catchPath);
+ }
+
+ if (NamesUtil.isSet(choreo.getCompletionCondition())) {
+ InterruptBlock interrupt=new InterruptBlock();
+
+ te.getEscapeBlocks().add(interrupt);
+
+ // Set expression from completion condition
+ // using xpath
+ XPathExpression exp=new XPathExpression();
+
+ exp.setQuery(choreo.getCompletionCondition());
+
+ interrupt.setExpression(exp);
+
+ // No activities
+ }
+ } else {
+
+ // Process all of the activities within the
+ // choreography
+ convertActivities(context, choreo.getActivities(), ret.getBlock());
+ }
+
+ // Transfer sub-conversations to end of block
+ if (ret.getBlock().getContents().size() > 0) {
+ org.scribble.model.Activity lastAct=
+ ret.getBlock().getContents().get(ret.getBlock().getContents().size()-1);
+ int pos=0;
+ while (ret.getBlock().getContents().get(pos) != lastAct) {
+ if (ret.getBlock().getContents().get(pos) instanceof Conversation) {
+ Conversation c=(Conversation)ret.getBlock().getContents().get(pos);
+
+ ret.getBlock().getContents().remove(pos);
+ ret.getBlock().getContents().add(c);
+
+ context.removeConversation(c);
+ } else {
+ pos++;
+ }
+ }
+ }
+
+ context.popScope();
+
+ return(ret);
+ }
+
+
+ protected void defineRoles(ConverterContext context,
+ final Choreography choreo, Conversation conv) {
+
+ org.pi4soa.cdl.interfaces.InterfaceDeriver intfDeriver=
+ org.pi4soa.cdl.interfaces.InterfaceFactory.getInterfaceDeriver();
+
+ final java.util.List<ParticipantType> partTypes=new java.util.Vector<ParticipantType>();
+ final java.util.List<Participant> partInstances=new java.util.Vector<Participant>();
+
+ choreo.visit(new DefaultCDLVisitor() {
+
+ public void interaction(Interaction interaction) {
+
+ if (interaction.getEnclosingChoreography() != choreo) {
+ return;
+ }
+
+ if (interaction.getFromParticipant() != null) {
+ if (partInstances.contains(interaction.getFromParticipant()) == false) {
+ partInstances.add(interaction.getFromParticipant());
+ }
+ } else {
+ ParticipantType ptype=
+ org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+ interaction.getFromRoleType());
+
+ if (ptype != null &&
+ partTypes.contains(ptype) == false) {
+ partTypes.add(ptype);
+ }
+ }
+
+ if (interaction.getToParticipant() != null) {
+ if (partInstances.contains(interaction.getToParticipant()) == false) {
+ partInstances.add(interaction.getToParticipant());
+ }
+ } else {
+ ParticipantType ptype=
+ org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+ interaction.getToRoleType());
+
+ if (ptype != null &&
+ partTypes.contains(ptype) == false) {
+ partTypes.add(ptype);
+ }
+ }
+ }
+ });
+
+ // Define roles
+ java.util.Iterator<Participant> piter=partInstances.iterator();
+
+ RoleList roleList=null;
+
+ while (piter.hasNext()) {
+ Role role=new Role();
+ Participant pinst=piter.next();
+ role.setName(pinst.getName());
+
+ if (roleList == null) {
+ roleList = new RoleList();
+ conv.getBlock().getContents().add(roleList);
+ }
+
+ roleList.getRoles().add(role);
+
+ context.setState(role.getName(), role);
+
+ registerRole(context, choreo, conv, roleList, role, pinst);
+
+ // Setup interfaces
+ for (int i=0; i < pinst.getRoleTypes().size(); i++) {
+ Contract contract=null;
+
+ if (role.getAnnotations().containsKey(Contract.class.getName())) {
+ contract = (Contract)role.getAnnotations().get(
+ Contract.class.getName());
+ } else {
+ contract = new Contract();
+
+ java.util.List<?> ptypes=
+ PackageUtil.getParticipantsForRoleTypes(choreo.getPackage(),
+ pinst.getRoleTypes());
+
+ if (ptypes.size() == 1) {
+ ParticipantType pt=(ParticipantType)ptypes.get(0);
+
+ contract.setName(XMLUtils.getLocalname(pt.getName()));
+ contract.setNamespace(CDLTypeUtil.getNamespace(pt.getName(), pt));
+ } else {
+
+ logger.warning("Could not find single participant type for participant instance '"+
+ pinst.getName()+"'");
+ contract.setName(XMLUtils.getLocalname(pinst.getName()));
+ contract.setNamespace(CDLTypeUtil.getNamespace(pinst.getName(), pinst));
+ }
+
+ // Setup namespace to prefix mappings
+ java.util.List<NameSpace> nspaces=pinst.getPackage().getTypeDefinitions().getNameSpaces();
+
+ for (int j=0; j < nspaces.size(); j++) {
+ org.savara.contract.model.Namespace ns=
+ new org.savara.contract.model.Namespace();
+
+ ns.setPrefix(nspaces.get(j).getPrefix());
+ ns.setURI(nspaces.get(j).getURI());
+ ns.setSchemaLocation(nspaces.get(j).getSchemaLocation());
+
+ contract.getNamespaces().add(ns);
+ }
+
+ role.getAnnotations().put(Contract.class.getName(),
+ contract);
+ }
+
+ setupInterfaces((org.pi4soa.cdl.RoleType)pinst.getRoleTypes().get(i),
+ contract, intfDeriver);
+ }
+ }
+
+ java.util.Iterator<ParticipantType> ptiter=partTypes.iterator();
+
+ if (choreo.getRoot() != Boolean.TRUE) {
+ roleList = null;
+ } else {
+ ptiter = choreo.getPackage().getTypeDefinitions().getParticipantTypes().iterator();
+ }
+
+ while (ptiter.hasNext()) {
+ Role role=new Role();
+ ParticipantType ptype=ptiter.next();
+ role.setName(XMLUtils.getLocalname(ptype.getName()));
+
+ if (roleList == null) {
+ roleList = new RoleList();
+
+ roleList.setOpen(choreo.getRoot() != Boolean.TRUE);
+
+ conv.getBlock().getContents().add(roleList);
+ }
+
+ roleList.getRoles().add(role);
+
+ context.setState(role.getName(), role);
+
+ if (choreo.getRoot() == Boolean.TRUE) {
+ registerRole(context, choreo, conv, roleList, role, ptype);
+
+ // Setup interfaces
+ for (int i=0; i < ptype.getRoleTypes().size(); i++) {
+ Contract contract=null;
+
+ if (role.getAnnotations().containsKey(Contract.class.getName())) {
+ contract = (Contract)role.getAnnotations().get(
+ Contract.class.getName());
+ } else {
+ contract = new Contract();
+
+ contract.setName(XMLUtils.getLocalname(ptype.getName()));
+ contract.setNamespace(CDLTypeUtil.getNamespace(ptype.getName(), ptype, true));
+
+ // Setup namespace to prefix mappings
+ java.util.List<NameSpace> nspaces=ptype.getPackage().getTypeDefinitions().getNameSpaces();
+
+ for (int j=0; j < nspaces.size(); j++) {
+ org.savara.contract.model.Namespace ns=
+ new org.savara.contract.model.Namespace();
+
+ ns.setPrefix(nspaces.get(j).getPrefix());
+ ns.setURI(nspaces.get(j).getURI());
+ ns.setSchemaLocation(nspaces.get(j).getSchemaLocation());
+
+ contract.getNamespaces().add(ns);
+ }
+
+ role.getAnnotations().put(Contract.class.getName(),
+ contract);
+ }
+
+ setupInterfaces((org.pi4soa.cdl.RoleType)ptype.getRoleTypes().get(i),
+ contract, intfDeriver);
+ }
+ }
+ }
+ }
+
+ protected void setupInterfaces(org.pi4soa.cdl.RoleType roleType, Contract contract,
+ org.pi4soa.cdl.interfaces.InterfaceDeriver intfDeriver) {
+
+ org.pi4soa.cdl.interfaces.RoleTypeDefinition rtd=
+ intfDeriver.getRoleTypeDefinition(roleType);
+
+ InterfaceVisitorImpl iv=new InterfaceVisitorImpl(contract);
+
+ rtd.visit(iv);
+ }
+
+ protected void convertVariables(ConverterContext context,
+ Choreography choreo, Block block) {
+
+ java.util.List<org.pi4soa.cdl.Variable> vars=
+ choreo.getVariableDefinitions();
+
+ for (int i=0; i < vars.size(); i++) {
+ org.pi4soa.cdl.Variable var=(org.pi4soa.cdl.Variable)vars.get(i);
+
+ if (var.getType() instanceof InformationType) {
+ java.util.List<RoleType> roleTypes=var.getRoleTypes();
+
+ if (roleTypes.size() == 0) {
+ roleTypes = choreo.getPackage().getTypeDefinitions().getRoleTypes();
+ }
+
+ VariableList vlist=new VariableList();
+ TypeReference ref=new TypeReference();
+
+ String qname=((InformationType)var.getType()).getElementName();
+
+ if (NamesUtil.isSet(qname)==false) {
+ qname=((InformationType)var.getType()).getTypeName();
+ }
+
+ ref.setNamespace(CDLTypeUtil.getNamespace(qname, var));
+ ref.setLocalpart(XMLUtils.getLocalname(qname));
+
+ vlist.setType(ref);
+
+ /* TODO: See if variables should be located?
+ for (int j=0; j < roleTypes.size(); j++) {
+ org.scribble.conversation.model.Variable newVar=
+ new org.scribble.conversation.model.Variable();
+
+ newVar.setName(var.getName());
+ }
+ */
+
+ org.scribble.conversation.model.Variable newVar=
+ new org.scribble.conversation.model.Variable();
+
+ newVar.setName(var.getName());
+
+ vlist.getVariables().add(newVar);
+
+ block.getContents().add(vlist);
+
+ } else if (var.getType() instanceof ChannelType) {
+
+ // TODO: Only convert if channel is explicitly defined
+
+
+ }
+ }
+ }
+
+ protected void convertActivities(ConverterContext context,
+ java.util.List<org.pi4soa.cdl.Activity> acts, Block block) {
+
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ acts.iterator();
+
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+
+ if (activity instanceof Block) {
+ block.getContents().addAll(((Block)activity).getContents());
+ } else {
+ block.getContents().add(activity);
+ }
+ }
+ }
+ }
+ }
+
+ protected void convertIdentities(ConverterContext context,
+ Choreography choreo, Conversation conv) {
+
+ // Define identities
+ java.util.List<org.pi4soa.cdl.Variable> vars=
+ choreo.getVariableDefinitions();
+ java.util.List<org.scribble.conversation.model.Identity> ids=
+ new java.util.Vector<org.scribble.conversation.model.Identity>();
+
+ for (int i=0; i < vars.size(); i++) {
+ if (vars.get(i).getType() instanceof org.pi4soa.cdl.ChannelType) {
+ org.pi4soa.cdl.ChannelType ctype=
+ (org.pi4soa.cdl.ChannelType)vars.get(i).getType();
+
+ java.util.Iterator<org.pi4soa.cdl.Identity> cids=
+ ctype.getIdentities().iterator();
+
+ while (cids.hasNext()) {
+ org.pi4soa.cdl.Identity cid=cids.next();
+ org.scribble.conversation.model.Identity id=
+ new org.scribble.conversation.model.Identity();
+
+ if (cid.getType() == KeyType.ASSOCIATION) {
+ id.setIdentityType(IdentityType.Association);
+ } else if (cid.getType() == KeyType.DERIVED) {
+ id.setIdentityType(IdentityType.Derived);
+ } else {
+ id.setIdentityType(IdentityType.Primary);
+ }
+
+ for (int j=0; j < cid.getTokens().size(); j++) {
+ id.getNames().add(cid.getTokens().get(j).getName());
+ }
+
+ if (ids.contains(id) == false) {
+ ids.add(id);
+ }
+ }
+ }
+ }
+
+ conv.getIdentities().addAll(ids);
+ }
+
+ private void registerRole(ConverterContext context,
+ Choreography choreo,
+ Conversation conv, RoleList roleList,
+ Role role, CDLType cdlType) {
+
+ if (cdlType.getSemanticAnnotations().size() > 0) {
+ java.util.Iterator<SemanticAnnotation> iter=
+ cdlType.getSemanticAnnotations().iterator();
+
+ while (iter.hasNext()) {
+ SemanticAnnotation annotation=iter.next();
+
+ if (annotation.getName() != null &&
+ annotation.getName().equals(CONVERSATION_TYPE)) {
+ String convType=annotation.getAnnotation();
+
+ if (convType != null) {
+ int index=convType.indexOf('@');
+
+ if (index != -1) {
+ ConformanceReference ref=
+ new ConformanceReference(ConversationNotation.NOTATION_CODE);
+
+ ref.setLocatedRole(convType.substring(index+1));
+
+ String mainpart=convType.substring(0, index);
+
+ index = mainpart.lastIndexOf(".");
+
+ String namespace="";
+ String localpart=mainpart;
+
+ if (index != -1) {
+ namespace=mainpart.substring(0, index);
+ localpart=mainpart.substring(index+1);
+ }
+
+ String[] elems=localpart.split("\\$");
+ if (elems.length > 1) {
+ localpart = elems[0];
+
+ for (int i=1; i < elems.length; i++) {
+ ref.getSubDefinitionPath().addPathElement(elems[i]);
+ }
+ }
+
+ ref.setNamespace(namespace);
+ ref.setLocalpart(localpart);
+
+ ref.setFullyQualified(true);
+
+ conv.getConformsTo().add(ref);
+
+ ModelReference sref=context.getSource();
+
+ // If not the root choreography, then
+ // identify the sub definition path
+ // in the source reference
+ if (choreo.getRoot() != Boolean.TRUE) {
+ sref = new ModelReference(sref);
+ Choreography sub=choreo;
+
+ while (sub != null && sub.getRoot() != Boolean.TRUE) {
+ sref.getSubDefinitionPath().addPathElement(0, sub.getName());
+
+ sub = sub.getParent().getEnclosingChoreography();
+ }
+ }
+
+ // Establish 'conforms to' dependency
+ // between source (which could be a
+ // sub definition) and the identified
+ // conversation type
+
+ // GPB: TO REMOVE dm.recordDependency(sref, ref,
+ // DependencyType.ConformsTo);
+
+ } else {
+ logger.warning("Conversation type '"+
+ convType+"' does not " +
+ "contain '@' located role separator");
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+
+ public static class InterfaceVisitorImpl implements InterfaceVisitor,
+ java.io.Serializable {
+
+ private static final long serialVersionUID = 4068744630125720449L;
+
+ private org.savara.contract.model.Contract m_contract=null;
+ private org.savara.contract.model.Interface m_currentInterface=null;
+ private org.savara.contract.model.MessageExchangePattern m_currentMEP=null;
+
+ public InterfaceVisitorImpl(Contract contract) {
+ m_contract = contract;
+ }
+
+ public Contract getContract() {
+ return(m_contract);
+ }
+
+ public void interfaceEnd(InterfaceDefinition defn) {
+ m_currentInterface = null;
+ }
+
+ public void interfaceStart(InterfaceDefinition defn) {
+ m_currentInterface = new org.savara.contract.model.Interface();
+
+ m_currentInterface.setNamespace(defn.getNamespace());
+
+ if (defn.getInterfaceName() != null &&
+ defn.getInterfaceName().trim().length() > 0) {
+ m_currentInterface.setName(defn.getInterfaceName());
+ } else {
+ m_currentInterface.setName(defn.getBehaviorName());
+ }
+
+ m_contract.getInterfaces().add(m_currentInterface);
+ }
+
+ public void message(MessageDefinition defn) {
+
+ if (defn.getClassification() == MessageDefinition.INPUT) {
+ m_currentMEP.getTypes().add(createType(defn));
+
+ } else if (m_currentMEP instanceof RequestResponseMEP) {
+ RequestResponseMEP mep=(RequestResponseMEP)m_currentMEP;
+
+ if (defn.getClassification() == MessageDefinition.OUTPUT) {
+ mep.getResponseTypes().add(createType(defn));
+
+ } else if (defn.getClassification() == MessageDefinition.OUTFAULT) {
+ FaultDetails fault=new FaultDetails();
+
+ fault.setName(defn.getFaultName());
+ fault.setNamespace(defn.getFaultNamespace());
+
+ fault.getTypes().add(createType(defn));
+
+ mep.getFaultDetails().add(fault);
+ }
+ }
+ }
+
+ protected Type createType(MessageDefinition defn) {
+ Type ret=new Type();
+ TypeDefinition td=new TypeDefinition();
+ ret.getTypeDefinitions().add(td);
+
+ if (defn.getElement() != null && defn.getElement().trim().length() > 0) {
+ td.setName(defn.getElement());
+
+ if (defn.getElementNamespace() != null) {
+ td.setNamespace(defn.getElementNamespace());
+ }
+
+ td.setTypeSystem(TypeDefinition.XSD_ELEMENT);
+
+ } else if (defn.getType() != null && defn.getType().trim().length() > 0) {
+ td.setName(defn.getType());
+
+ if (defn.getTypeNamespace() != null) {
+ td.setNamespace(defn.getTypeNamespace());
+ }
+
+ td.setTypeSystem(TypeDefinition.XSD_TYPE);
+ }
+
+ ret.setName(td.getName());
+
+ return(ret);
+ }
+
+ public void operationEnd(OperationDefinition defn) {
+ m_currentMEP = null;
+ }
+
+ public void operationStart(OperationDefinition defn) {
+ if (defn.getMessages().size() == 1 &&
+ ((MessageDefinition)defn.getMessages().get(0)).getClassification()
+ == MessageDefinition.INPUT) {
+ m_currentMEP = new OneWayRequestMEP();
+ } else {
+ m_currentMEP = new RequestResponseMEP();
+ }
+
+ m_currentMEP.setOperation(defn.getOperationName());
+
+ m_currentInterface.getMessageExchangePatterns().add(m_currentMEP);
+ }
+
+ public void roleTypeEnd(RoleTypeDefinition defn) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void roleTypeStart(RoleTypeDefinition defn) {
+ // TODO Auto-generated method stub
+
+ }
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,698 @@
+/*
+ * 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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.Interaction;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.XPathExpression;
+import org.pi4soa.cdl.util.*;
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.NameSpaceUtil;
+import org.pi4soa.common.xml.XMLUtils;
+
+public class ConversationInteractionConverterRuleImpl implements ConverterRule {
+
+ private static final String INTERFACE_NAME = "interfaceName";
+ 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 determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Interaction);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.model.Block ret=new org.scribble.model.Block();
+ org.pi4soa.cdl.Interaction cdl=
+ (org.pi4soa.cdl.Interaction)cdlType;
+ Role fromRole=null;
+ Role toRole=null;
+
+ if (cdl.getFromParticipant() != null) {
+ fromRole = (Role)
+ context.getState(XMLUtils.getLocalname(cdl.getFromParticipant().getName()));
+
+ if (fromRole == null) {
+ logger.severe("Failed to get 'from' role '"+XMLUtils.getLocalname(cdl.getFromParticipant().getName())+"'");
+ }
+ } else if (cdl.getFromRoleType() != null) {
+ ParticipantType ptype=
+ PackageUtil.getParticipantForRoleType(cdl.getFromRoleType());
+
+ fromRole = (Role)
+ context.getState(XMLUtils.getLocalname(ptype.getName()));
+
+ if (fromRole == null) {
+ logger.severe("Failed to get 'from' role '"+XMLUtils.getLocalname(ptype.getName())+"'");
+ }
+ }
+
+ if (cdl.getToParticipant() != null) {
+ toRole = (Role)
+ context.getState(XMLUtils.getLocalname(cdl.getToParticipant().getName()));
+
+ if (toRole == null) {
+ logger.severe("Failed to get 'to' role '"+XMLUtils.getLocalname(cdl.getFromParticipant().getName())+"'");
+ }
+ } else if (cdl.getToRoleType() != null) {
+ ParticipantType ptype=
+ PackageUtil.getParticipantForRoleType(cdl.getToRoleType());
+
+ toRole = (Role)
+ context.getState(XMLUtils.getLocalname(ptype.getName()));
+
+ if (toRole == null) {
+ logger.severe("Failed to get 'to' role '"+XMLUtils.getLocalname(ptype.getName())+"'");
+ }
+ }
+
+ // Determine if interaction may result in
+ // a timeout
+ Block block=ret;
+
+ if (NamesUtil.isSet(cdl.getTimeToComplete())) {
+ TryEscape te=new TryEscape();
+
+ ret.getContents().add(te);
+
+ block = te.getBlock();
+
+ InterruptBlock interrupt=new InterruptBlock();
+
+ te.getEscapeBlocks().add(interrupt);
+
+ // Set expression from 'time to complete'
+ // using xpath
+ XPathExpression exp=new XPathExpression();
+
+ exp.setQuery("cdl:hasDurationPassed('"+
+ cdl.getTimeToComplete()+"')");
+
+ interrupt.setExpression(exp);
+
+ // Perform assignments associated with timeout
+ for (int i=0; i < cdl.getRecordDetails().size(); i++) {
+ org.pi4soa.cdl.RecordDetails rd=
+ cdl.getRecordDetails().get(i);
+
+ if (rd.getWhen() == WhenType.TIMEOUT) {
+
+ // TODO: Record variable - but which role??? May need to
+ // be part of the following conditions, so depends on
+ // whether the record details are in the from/to timeout record details
+
+ if (cdl.getTimeoutFromRoleTypeRecordDetails().contains(rd)) {
+
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(fromRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ interrupt.getContents().add(raise);
+ }
+ }
+
+ if (cdl.getTimeoutToRoleTypeRecordDetails().contains(rd)) {
+
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(toRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ interrupt.getContents().add(raise);
+ }
+ }
+ }
+ }
+ }
+
+ java.util.Iterator<ExchangeDetails> iter=
+ cdl.getExchangeDetails().iterator();
+ java.util.List<ConditionalBlock> cbs=
+ new java.util.Vector<ConditionalBlock>();
+
+ while (iter.hasNext()) {
+ ExchangeDetails details=iter.next();
+ ConditionalBlock cb=new ConditionalBlock();
+
+ // Convert 'before' send and receive record details
+ for (int i=0; i < details.getSendRecordDetails().size(); i++) {
+ RecordDetails rd=details.getSendRecordDetails().get(i);
+
+ if (rd.getWhen() == WhenType.BEFORE) {
+ String fromRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+ fromRole.getName():toRole.getName());
+
+ // Define record expression
+ Assignment assign=new Assignment();
+
+ assign.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(rd));
+
+ // Set role
+ Role role=new Role(fromRoleName);
+
+ assign.getRoles().add(role);
+
+ // Set variable
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(rd.getTargetVariable().getName());
+
+ assign.setVariable(var);
+
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ if (rd.getSourceExpression() != null) {
+ expr.setQuery(rd.getSourceExpression());
+ } else if (rd.getSourceVariable() != null) {
+ expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+ }
+
+ assign.setExpression(expr);
+
+ cb.getContents().add(assign);
+
+ // Check for cause exception
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(fromRoleName));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ }
+ }
+
+ for (int i=0; i < details.getReceiveRecordDetails().size(); i++) {
+ RecordDetails rd=details.getReceiveRecordDetails().get(i);
+
+ if (rd.getWhen() == WhenType.BEFORE) {
+ String toRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+ toRole.getName():fromRole.getName());
+
+ // Define record expression
+ Assignment assign=new Assignment();
+
+ assign.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(rd));
+
+ // Set role
+ Role role=new Role(toRoleName);
+
+ assign.getRoles().add(role);
+
+ // Set variable
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(rd.getTargetVariable().getName());
+
+ assign.setVariable(var);
+
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ if (rd.getSourceExpression() != null) {
+ expr.setQuery(rd.getSourceExpression());
+ } else if (rd.getSourceVariable() != null) {
+ expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+ }
+
+ assign.setExpression(expr);
+
+ cb.getContents().add(assign);
+
+ // Check for cause exception
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(toRoleName));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ }
+ }
+
+ // Convert the interaction
+ ConversationInteraction interaction=
+ new ConversationInteraction();
+
+ interaction.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(details));
+
+ // Check if interaction's channel has been explicitly defined
+ Object ch=context.getState(cdl.getChannelVariable().getName());
+
+ if (ch instanceof Channel) {
+ interaction.setChannel((Channel)ch);
+ }
+
+ // Define message signature
+ MessageSignature ms=new MessageSignature();
+ ms.setOperation(cdl.getOperation());
+
+ if (NamesUtil.isSet(details.getFaultName())) {
+ ms.getAnnotations().put(FAULT_NAME,
+ details.getFaultName());
+ }
+
+ interaction.setMessageSignature(ms);
+
+ // Define interaction message type
+ if (details.getType() instanceof InformationType) {
+ InformationType itype=(InformationType)details.getType();
+
+ TypeReference ref=ConverterUtil.getTypeReference(itype);
+
+ ms.getTypes().add(ref);
+
+ if (NamesUtil.isSet(itype.getTypeName())) {
+ String ns=CDLTypeUtil.getNamespace(itype.getTypeName(),
+ cdl);
+ String lp=XMLUtils.getLocalname(itype.getTypeName());
+
+ if (lp != null) {
+ ms.getAnnotations().put(MESSAGE_TYPE_LOCALPART,
+ lp);
+ }
+ if (ns != null) {
+ ms.getAnnotations().put(MESSAGE_TYPE_NAMESPACE,
+ ns);
+ }
+ } else if (NamesUtil.isSet(itype.getElementName())) {
+ String ns=CDLTypeUtil.getNamespace(itype.getElementName(),
+ cdl);
+ String lp=XMLUtils.getLocalname(itype.getElementName());
+
+ if (lp != null) {
+ ms.getAnnotations().put(MESSAGE_TYPE_LOCALPART,
+ lp);
+ }
+ if (ns != null) {
+ ms.getAnnotations().put(MESSAGE_TYPE_NAMESPACE,
+ ns);
+ }
+ }
+ }
+
+ cb.getContents().add(interaction);
+
+ // Set interface name
+ if (cdl.getToRoleType() != null) {
+ // TODO: Deal with interfaces that have multiple behaviours
+ interaction.getAnnotations().put(INTERFACE_NAME,
+ getInterfaceName(cdl));
+ }
+
+ if (details.getAction() == ExchangeActionType.REQUEST) {
+ interaction.setFromRole(fromRole);
+ interaction.setToRole(toRole);
+
+ if (details.getSendVariable() != null) {
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(details.getSendVariable().getName());
+ interaction.setFromVariable(var);
+ }
+
+ if (details.getReceiveVariable() != null) {
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(details.getReceiveVariable().getName());
+ interaction.setToVariable(var);
+ }
+
+ // Check if request has response/fault exchanges
+ java.util.List<ExchangeDetails> resps=
+ InteractionUtil.getResponseExchangeDetails(details);
+
+ if (resps != null && resps.size() > 0) {
+ interaction.setRequestLabel(getLabel(details));
+ }
+
+ // Check if fault thrown
+ if (details.getSendCauseException() != null &&
+ details.getSendCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(fromRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(details.getSendCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+
+ if (details.getReceiveCauseException() != null &&
+ details.getReceiveCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(toRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(details.getReceiveCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ } else {
+ interaction.setFromRole(toRole);
+ interaction.setToRole(fromRole);
+
+ if (details.getReceiveVariable() != null) {
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(details.getReceiveVariable().getName());
+ interaction.setFromVariable(var);
+ }
+
+ if (details.getSendVariable() != null) {
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(details.getSendVariable().getName());
+ interaction.setToVariable(var);
+ }
+
+ if (details.getAction() == ExchangeActionType.RESPOND) {
+ interaction.setReplyToLabel(getLabel(details));
+ }
+
+ // Check if fault thrown
+ if (details.getSendCauseException() != null &&
+ details.getSendCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(toRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(details.getSendCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+
+ if (details.getReceiveCauseException() != null &&
+ details.getReceiveCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(fromRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(details.getReceiveCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ }
+
+ // Convert 'after' send and receive record details
+ for (int i=0; i < details.getSendRecordDetails().size(); i++) {
+ RecordDetails rd=details.getSendRecordDetails().get(i);
+
+ if (rd.getWhen() == WhenType.AFTER) {
+ String fromRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+ fromRole.getName():toRole.getName());
+
+ // Define record expression
+ Assignment assign=new Assignment();
+
+ assign.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(rd));
+
+ // Set role
+ Role role=new Role(fromRoleName);
+
+ assign.getRoles().add(role);
+
+ // Set variable
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(rd.getTargetVariable().getName());
+
+ assign.setVariable(var);
+
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ if (rd.getSourceExpression() != null) {
+ expr.setQuery(rd.getSourceExpression());
+ } else if (rd.getSourceVariable() != null) {
+ expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+ }
+
+ assign.setExpression(expr);
+
+ cb.getContents().add(assign);
+
+ // Check for cause exception
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(fromRoleName));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ }
+ }
+
+ for (int i=0; i < details.getReceiveRecordDetails().size(); i++) {
+ RecordDetails rd=details.getReceiveRecordDetails().get(i);
+
+ if (rd.getWhen() == WhenType.AFTER) {
+ String toRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+ toRole.getName():fromRole.getName());
+
+ // Define record expression
+ Assignment assign=new Assignment();
+
+ assign.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(rd));
+
+ // Set role
+ Role role=new Role(toRoleName);
+
+ assign.getRoles().add(role);
+
+ // Set variable
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(rd.getTargetVariable().getName());
+
+ assign.setVariable(var);
+
+ // If target variable is a channel, then make explicit
+ if (rd.getTargetVariable().getType() instanceof ChannelType) {
+ Object state=context.getState(rd.getTargetVariable().getName());
+
+ if (state == null) {
+ Channel newch=new Channel();
+ newch.setName(rd.getTargetVariable().getName());
+
+ context.setState(newch.getName(), newch);
+
+ //
+ }
+ }
+
+ // Convert source expression
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ if (rd.getSourceExpression() != null) {
+ expr.setQuery(rd.getSourceExpression());
+ } else if (rd.getSourceVariable() != null) {
+ expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+ }
+
+ assign.setExpression(expr);
+
+ cb.getContents().add(assign);
+
+ // Check for cause exception
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(toRoleName));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ }
+ }
+
+ cbs.add(cb);
+ }
+
+ if (cbs.size() > 2) {
+ block.getContents().addAll(cbs.remove(0).getContents());
+
+ If choice=new If();
+
+ choice.getRoles().add(new Role(toRole.getName()));
+
+ for (int i=0; i < cbs.size(); i++) {
+ ConditionalBlock cb=cbs.get(i);
+
+ choice.getConditionalBlocks().add(cb);
+ }
+
+ block.getContents().add(choice);
+ } else {
+ for (int i=0; i < cbs.size(); i++) {
+ ConditionalBlock cb=cbs.get(i);
+ block.getContents().addAll(cb.getContents());
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method creates a label appropriate for the request
+ * response correlation associated with the supplied exchange.
+ *
+ * @param details The exchange
+ * @return The label
+ */
+ protected String getLabel(ExchangeDetails details) {
+ String ret=null;
+
+ if (details.getInteraction() != null) {
+ ret = details.getInteraction().getOperation();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the interface name associated with the
+ * supplied role type.
+ *
+ * @param interaction The interaction
+ * @return The interface name
+ */
+ protected String getInterfaceName(org.pi4soa.cdl.Interaction interaction) {
+ String ret=null;
+
+ if (interaction != null) {
+ String intfName=getInterface(interaction);
+
+ String ns=CDLTypeUtil.getNamespace(intfName, interaction, true);
+ String lp=XMLUtils.getLocalname(intfName);
+
+ ret = NameSpaceUtil.getFullyQualifiedName(ns, lp);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the interaction's interface.
+ *
+ * @param interaction The interaction
+ * @return The interface
+ */
+ public static String getInterface(Interaction interaction) {
+ String ret=null;
+
+ if (interaction != null &&
+ interaction.getChannelVariable() != null &&
+ interaction.getChannelVariable().getType() instanceof
+ ChannelType) {
+ ChannelType ctype=(ChannelType)
+ interaction.getChannelVariable().getType();
+
+ if (ctype.getBehavior() != null) {
+ ret = ctype.getBehavior().getInterface();
+
+ if (NamesUtil.isSet(ret)==false) {
+ ret = ctype.getBehavior().getName();
+ }
+ } else if (ctype.getRoleType() != null) {
+
+ // Attempt to find default behavior
+ org.pi4soa.cdl.Behavior behavior=
+ ctype.getRoleType().getBehavior(null);
+
+ if (behavior != null) {
+ ret = behavior.getInterface();
+
+ if (NamesUtil.isSet(ret)==false) {
+ ret = behavior.getName();
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,177 @@
+/*
+ * 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:
+ * 31 Jul 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class ConversationModelConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == ConversationModel.class &&
+ cdlType instanceof org.pi4soa.cdl.Package);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ ConversationModel ret=new ConversationModel();
+ org.pi4soa.cdl.Package cdlpack=(org.pi4soa.cdl.Package)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdlpack));
+
+ ret.setNamespace(getNamespace(cdlpack));
+
+ // Convert token locators
+ java.util.Iterator<TokenLocator> locators=
+ cdlpack.getTypeDefinitions().getTokenLocators().iterator();
+
+ while (locators.hasNext()) {
+ TokenLocator locator=locators.next();
+
+ IdentityLocator idLocator=new IdentityLocator();
+ idLocator.setLocator(locator.getToken().getName(),
+ locator.getQuery());
+
+ TypeReference typeRef=ConverterUtil.getTypeReference(locator.getInformationType());
+ idLocator.setType(typeRef);
+
+ ret.getIdentityLocators().add(idLocator);
+ }
+
+ // Convert root choreography
+ java.util.Iterator<org.pi4soa.cdl.Choreography> iter=
+ cdlpack.getChoreographies().iterator();
+ org.pi4soa.cdl.Choreography choreo=null;
+
+ while (choreo == null && iter.hasNext()) {
+ choreo = iter.next();
+
+ if (choreo.getRoot() != Boolean.TRUE) {
+ choreo = null;
+ }
+ }
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(Conversation.class,
+ choreo);
+
+ if (rule != null) {
+ ret.setConversation((Conversation)rule.convert(context,
+ Conversation.class, choreo));
+ } else {
+ logger.severe("Failed to find conversation conversion rule");
+ }
+
+ // Clear the inner definition for any Compose activities
+ // The inner definitions are temporarily established to
+ // help internal analysis, e.g. to determine initiator
+ // roles
+ for (int i=0; i < context.getComposeActivities().size(); i++) {
+ // Save parent
+ Definition defn=context.getComposeActivities().get(i).getInlineDefinition();
+ ModelObject parent=defn.getParent();
+
+ context.getComposeActivities().get(i).setInlineDefinition(null);
+
+ // Re-establish parent
+ defn.setParent(parent);
+ }
+
+ return(ret);
+ }
+
+
+ /**
+ * This method generates a namespace associated with
+ * the supplied CDL package.
+ *
+ * @param cdlpack The choreography package
+ * @return The namespace
+ */
+ protected static org.scribble.model.Namespace getNamespace(
+ org.pi4soa.cdl.Package cdlpack) {
+ org.scribble.model.Namespace ret=new org.scribble.model.Namespace();
+
+ String ns=cdlpack.getTargetNamespace()+"/"+cdlpack.getName();
+
+ if (ns.startsWith("http://")) {
+ ns = ns.substring(7);
+ }
+
+ if (ns.startsWith("www.")) {
+ ns = ns.substring(4);
+ }
+
+ java.util.StringTokenizer st=new java.util.StringTokenizer(ns, "/");
+ boolean f_first=true;
+ String namespace=null;
+
+ while (st.hasMoreTokens()) {
+ String token=st.nextToken();
+
+ if (f_first) {
+ java.util.StringTokenizer innerst=
+ new java.util.StringTokenizer(token, ".");
+ while (innerst.hasMoreTokens()) {
+ if (namespace == null) {
+ namespace = innerst.nextToken();
+ } else {
+ namespace = innerst.nextToken()+"."+namespace;
+ }
+ }
+
+ f_first = false;
+ } else {
+ namespace += "."+token;
+ }
+ }
+
+ if (namespace != null) {
+ ret.setName(namespace.toLowerCase());
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterContext.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterContext.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterContext.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,113 @@
+/*
+ * 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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public interface ConverterContext {
+
+ /**
+ * This method returns the source model reference.
+ *
+ * @return The source model reference
+ */
+ public ModelReference getSource();
+
+ /**
+ * This method returns the declaration associated
+ * with the supplied name.
+ *
+ * @param name The name
+ * @return The declaration, or null if not found
+ */
+ public Object getState(String name);
+
+ /**
+ * This method sets the declaration associated with
+ * the supplied name.
+ *
+ * @param name The name
+ * @param decl The declaration
+ */
+ public void setState(String name, Object decl);
+
+ /**
+ * This method pushes the scope, to clear the current
+ * state associated with a parent scope.
+ */
+ public void pushScope();
+
+ /**
+ * This method pops the scope associated with a parent
+ * conversation.
+ *
+ */
+ public void popScope();
+
+ /**
+ * This method pushes the current state onto a stack,
+ * to create a local scope where further roles or
+ * variables may be declared.
+ */
+ public void pushState();
+
+ /**
+ * This method pops a previous state from the stack
+ * to clear any local declarations made within a
+ * local scope as part of a conversation definition.
+ */
+ public void popState();
+
+ /**
+ * This method adds a conversation to the context,
+ * for use when processing activities within its
+ * scope.
+ *
+ * @param conv The conversation
+ */
+ public void addConversation(Conversation conv);
+
+ /**
+ * This method removes the conversation from the
+ * context.
+ *
+ * @param conv The conversation
+ */
+ public void removeConversation(Conversation conv);
+
+ /**
+ * This method retrieves the conversation associated
+ * with the supplied model reference.
+ *
+ * @param ref The model reference
+ * @return The conversation
+ */
+ public Conversation getConversation(ModelReference ref);
+
+ /**
+ * This method returns the list of Compose activities
+ * within the model.
+ *
+ * @return The list of compose activities
+ */
+ public java.util.List<Compose> getComposeActivities();
+
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterRule.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterRule.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterRule.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,52 @@
+/*
+ * 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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+/**
+ * This interface represents a CDM to Scribble conversation
+ * rule.
+ */
+public interface ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ org.pi4soa.cdl.CDLType cdlType);
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public org.scribble.model.ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, org.pi4soa.cdl.CDLType cdlType);
+
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,63 @@
+/*
+ * 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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+/**
+ * This class represents a factory for converter rules.
+ */
+public class ConverterRuleFactory {
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converter rule, or null if not found
+ */
+ public static ConverterRule getConverter(Class<?> scribbleType,
+ org.pi4soa.cdl.CDLType cdlType) {
+ ConverterRule ret=null;
+
+ for (int i=0; ret == null && i < m_rules.length; i++) {
+ if (m_rules[i].isSupported(scribbleType, cdlType)) {
+ ret = m_rules[i];
+ }
+ }
+
+ return(ret);
+ }
+
+ private static ConverterRule[] m_rules={
+ new ConversationModelConverterRuleImpl(),
+ new ConversationConverterRuleImpl(),
+ new ParallelConverterRuleImpl(),
+ new IfOrWhenConverterRuleImpl(),
+ new IfConverterRuleImpl(),
+ new WhenConverterRuleImpl(),
+ new WhileConverterRuleImpl(),
+ new ConversationInteractionConverterRuleImpl(),
+ new FinalizeConverterRuleImpl(),
+ new FinalizerHandlerConverterRuleImpl(),
+ new AssignConverterRuleImpl(),
+ new SequenceConverterRuleImpl(),
+ new PerformConverterRuleImpl()
+ };
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,63 @@
+/*
+ * 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:
+ * 31 Jul 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import org.scribble.model.*;
+
+/**
+ * This class defines some converter utility functions.
+ */
+public class ConverterUtil {
+
+ /**
+ * This method converts the supplied information type into a
+ * type reference.
+ *
+ * @param infoType The information type
+ * @return The type reference
+ */
+ public static TypeReference getTypeReference(org.pi4soa.cdl.InformationType infoType) {
+ TypeReference ret=new TypeReference();
+
+ // TODO: Establish 'implements' dependency between
+ // XML type and an abstract type derived from the
+ // XML namespace and localpart.
+
+ org.pi4soa.common.xml.XMLPrefixResolver resolver=
+ org.pi4soa.cdl.util.CDLTypeUtil.getPrefixResolver(infoType.getPackage());
+ String typeName=null;
+
+ // TODO: Need to have general way to convert
+ // namespace scoped type into a type reference
+
+ if (org.pi4soa.common.util.NamesUtil.isSet(infoType.getTypeName())) {
+ typeName = infoType.getTypeName();
+ } else if (org.pi4soa.common.util.NamesUtil.isSet(infoType.getElementName())) {
+ typeName = infoType.getElementName();
+ }
+
+ if (typeName != null) {
+ ret.setLocalpart(org.pi4soa.common.xml.XMLUtils.getLocalname(typeName));
+ ret.setNamespace(org.pi4soa.common.xml.XMLUtils.getNamespace(typeName, resolver, null));
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,184 @@
+/*
+ * 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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+import org.scribble.util.Scope;
+
+import org.scribble.conversation.model.Compose;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.model.*;
+
+/**
+ * The default implementation of the converter context.
+ */
+public class DefaultConverterContext implements ConverterContext {
+
+ /**
+ * Default constructor.
+ */
+ public DefaultConverterContext() {
+ }
+
+ /**
+ * This is the constructor for the converter context, initialized
+ * with the source reference.
+ *
+ * @param ref The source model reference
+ */
+ public DefaultConverterContext(ModelReference ref) {
+ m_source = ref;
+ }
+
+ /**
+ * This method returns the source model reference.
+ *
+ * @return The source model reference
+ */
+ public ModelReference getSource() {
+ return(m_source);
+ }
+
+ /**
+ * This method returns the declaration associated
+ * with the supplied name.
+ *
+ * @param name The name
+ * @return The declaration, or null if not found
+ */
+ public Object getState(String name) {
+ return(m_scope.getState(name));
+ }
+
+ /**
+ * This method sets the declaration associated with
+ * the supplied name.
+ *
+ * @param name The name
+ * @param decl The declaration
+ */
+ public void setState(String name, Object decl) {
+ m_scope.setState(name, decl);
+ }
+
+ /**
+ * 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 adds a conversation to the context,
+ * for use when processing activities within its
+ * scope.
+ *
+ * @param conv The conversation
+ */
+ public void addConversation(Conversation conv) {
+ m_conversations.add(conv);
+ }
+
+ /**
+ * This method removes the conversation from the
+ * context.
+ *
+ * @param conv The conversation
+ */
+ public void removeConversation(Conversation conv) {
+ m_conversations.remove(conv);
+ }
+
+ /**
+ * This method retrieves the conversation associated
+ * with the supplied model reference.
+ *
+ * @param ref The model reference
+ * @return The conversation
+ */
+ public Conversation getConversation(ModelReference ref) {
+ Conversation ret=null;
+
+ for (int i=0; ret == null && i < m_conversations.size(); i++) {
+ Conversation subconv=(Conversation)
+ m_conversations.get(i);
+
+ if (subconv.getLocatedName() != null &&
+ subconv.getLocatedName().getName() != null &&
+ ref.getAlias().equals(
+ subconv.getLocatedName().getName()) &&
+ ((ref.getLocatedRole() == null &&
+ subconv.getLocatedName().getRole() == null) ||
+ ((ref.getLocatedRole() != null &&
+ subconv.getLocatedName().getRole() != null &&
+ ref.getLocatedRole().equals(
+ subconv.getLocatedName().getRole().getName()))))) {
+
+ ret = subconv;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of Compose activities
+ * within the model.
+ *
+ * @return The list of compose activities
+ */
+ public java.util.List<Compose> getComposeActivities() {
+ return(m_composeActivities);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+
+ private ModelReference m_source=null;
+ private Scope m_scope=new Scope();
+ private java.util.List<Scope> m_scopeStack=new java.util.Vector<Scope>();
+ private java.util.List<Compose> m_composeActivities=new java.util.Vector<Compose>();
+ private java.util.List<Conversation> m_conversations=new java.util.Vector<Conversation>();
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,95 @@
+/*
+ * 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 Jun 2009 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class FinalizeConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Finalize);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.Run ret=
+ new org.scribble.conversation.model.Run();
+ org.pi4soa.cdl.Finalize cdl=(org.pi4soa.cdl.Finalize)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ ConversationReference ref=new ConversationReference();
+ ref.setLocalpart(cdl.getChoreography().getName()+"_"+cdl.getFinalizer().getName());
+ ref.setInner(true);
+
+ ret.setReference(ref);
+
+ // Find conversation related to reference, and use
+ // as inner definition initially - to help with
+ // subsequent processing (e.g. locating initiator
+ // roles). The inner definition will be cleared when
+ // the model is fully converted.
+ Conversation conv=context.getConversation(ref);
+
+ if (conv != null) {
+ ret.setInlineDefinition(conv);
+ context.getComposeActivities().add(ret);
+
+ // Bind roles
+ java.util.List<Role> roles=conv.getRoles();
+
+ for (int i=0; i < roles.size(); i++) {
+ Role role=roles.get(i);
+
+ Object decl=context.getState(role.getName());
+
+ if (decl instanceof Declaration) {
+ ret.getBindings().add(new DeclarationBinding((Declaration)decl, role.getName()));
+ }
+ }
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,316 @@
+/*
+ * 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 Jun 2009 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.Interaction;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.XMLUtils;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.*;
+
+public class FinalizerHandlerConverterRuleImpl implements ConverterRule {
+
+ private static final String CONVERSATION_TYPE = "conversationType";
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == Conversation.class &&
+ cdlType instanceof FinalizerHandler);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ Conversation ret=new Conversation();
+ FinalizerHandler choreo=(FinalizerHandler)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(choreo));
+
+ context.pushScope();
+
+ LocatedName modelName=new LocatedName();
+ modelName.setName(choreo.getEnclosingChoreography().getName()+"_"+choreo.getName());
+
+ ret.setLocatedName(modelName);
+
+ // Define roles
+ defineRoles(context, choreo, ret);
+
+ // Convert variables
+ convertVariables(context, choreo, ret.getBlock());
+
+ // Define identities
+ convertIdentities(context, choreo, ret);
+
+ // Process all of the activities within the
+ // choreography
+ convertActivities(context, choreo.getActivities(), ret.getBlock());
+
+ context.popScope();
+
+ return(ret);
+ }
+
+
+ protected void defineRoles(ConverterContext context,
+ final FinalizerHandler choreo, Conversation conv) {
+
+ final java.util.List<ParticipantType> partTypes=new java.util.Vector<ParticipantType>();
+ final java.util.List<Participant> partInstances=new java.util.Vector<Participant>();
+
+ choreo.visit(new DefaultCDLVisitor() {
+
+ public void interaction(Interaction interaction) {
+
+ if (interaction.getEnclosingChoreography() != choreo.getEnclosingChoreography()) {
+ return;
+ }
+
+ if (interaction.getFromParticipant() != null) {
+ if (partInstances.contains(interaction.getFromParticipant()) == false) {
+ partInstances.add(interaction.getFromParticipant());
+ }
+ } else {
+ ParticipantType ptype=
+ org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+ interaction.getFromRoleType());
+
+ if (ptype != null &&
+ partTypes.contains(ptype) == false) {
+ partTypes.add(ptype);
+ }
+ }
+
+ if (interaction.getToParticipant() != null) {
+ if (partInstances.contains(interaction.getToParticipant()) == false) {
+ partInstances.add(interaction.getToParticipant());
+ }
+ } else {
+ ParticipantType ptype=
+ org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+ interaction.getToRoleType());
+
+ if (ptype != null &&
+ partTypes.contains(ptype) == false) {
+ partTypes.add(ptype);
+ }
+ }
+ }
+ });
+
+ // Define roles
+ java.util.Iterator<Participant> piter=partInstances.iterator();
+
+ RoleList roleList=null;
+
+ while (piter.hasNext()) {
+ Role role=new Role();
+ Participant pinst=piter.next();
+ role.setName(pinst.getName());
+
+ if (roleList == null) {
+ roleList = new RoleList();
+ conv.getBlock().getContents().add(roleList);
+ }
+
+ roleList.getRoles().add(role);
+
+ context.setState(role.getName(), role);
+ }
+
+ java.util.Iterator<ParticipantType> ptiter=partTypes.iterator();
+
+ /*
+ if (choreo.getRoot() != Boolean.TRUE) {
+ roleList = null;
+ } else {
+ ptiter = choreo.getPackage().getTypeDefinitions().getParticipantTypes().iterator();
+ }
+ */
+
+ while (ptiter.hasNext()) {
+ Role role=new Role();
+ ParticipantType ptype=ptiter.next();
+ role.setName(ptype.getName());
+
+ if (roleList == null) {
+ roleList = new RoleList();
+
+ roleList.setOpen(choreo.getEnclosingChoreography().getRoot() != Boolean.TRUE);
+
+ conv.getBlock().getContents().add(roleList);
+ }
+
+ roleList.getRoles().add(role);
+
+ context.setState(role.getName(), role);
+ }
+ }
+
+ protected void convertVariables(ConverterContext context,
+ FinalizerHandler choreo, Block block) {
+
+ java.util.List<org.pi4soa.cdl.Variable> vars=
+ choreo.getEnclosingChoreography().getVariableDefinitions();
+
+ for (int i=0; i < vars.size(); i++) {
+ org.pi4soa.cdl.Variable var=(org.pi4soa.cdl.Variable)vars.get(i);
+
+ if (var.getType() instanceof InformationType) {
+ java.util.List<RoleType> roleTypes=var.getRoleTypes();
+
+ if (roleTypes.size() == 0) {
+ roleTypes = choreo.getPackage().getTypeDefinitions().getRoleTypes();
+ }
+
+ VariableList vlist=new VariableList();
+ TypeReference ref=new TypeReference();
+
+ String qname=((InformationType)var.getType()).getElementName();
+
+ if (NamesUtil.isSet(qname)==false) {
+ qname=((InformationType)var.getType()).getTypeName();
+ }
+
+ ref.setNamespace(CDLTypeUtil.getNamespace(qname, var));
+ ref.setLocalpart(XMLUtils.getLocalname(qname));
+
+ vlist.setType(ref);
+
+ /* TODO: See if variables should be located?
+ for (int j=0; j < roleTypes.size(); j++) {
+ org.scribble.conversation.model.Variable newVar=
+ new org.scribble.conversation.model.Variable();
+
+ newVar.setName(var.getName());
+ }
+ */
+
+ org.scribble.conversation.model.Variable newVar=
+ new org.scribble.conversation.model.Variable();
+
+ newVar.setName(var.getName());
+
+ vlist.getVariables().add(newVar);
+
+ block.getContents().add(vlist);
+ }
+ }
+ }
+
+ protected void convertActivities(ConverterContext context,
+ java.util.List<org.pi4soa.cdl.Activity> acts, Block block) {
+
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ acts.iterator();
+
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+
+ if (activity instanceof Block) {
+ block.getContents().addAll(((Block)activity).getContents());
+ } else {
+ block.getContents().add(activity);
+ }
+ }
+ }
+ }
+ }
+
+ protected void convertIdentities(ConverterContext context,
+ FinalizerHandler choreo, Conversation conv) {
+
+ // Define identities
+ java.util.List<org.pi4soa.cdl.Variable> vars=
+ choreo.getEnclosingChoreography().getVariableDefinitions();
+ java.util.List<org.scribble.conversation.model.Identity> ids=
+ new java.util.Vector<org.scribble.conversation.model.Identity>();
+
+ for (int i=0; i < vars.size(); i++) {
+ if (vars.get(i).getType() instanceof org.pi4soa.cdl.ChannelType) {
+ org.pi4soa.cdl.ChannelType ctype=
+ (org.pi4soa.cdl.ChannelType)vars.get(i).getType();
+
+ java.util.Iterator<org.pi4soa.cdl.Identity> cids=
+ ctype.getIdentities().iterator();
+
+ while (cids.hasNext()) {
+ org.pi4soa.cdl.Identity cid=cids.next();
+ org.scribble.conversation.model.Identity id=
+ new org.scribble.conversation.model.Identity();
+
+ if (cid.getType() == KeyType.ASSOCIATION) {
+ id.setIdentityType(IdentityType.Association);
+ } else if (cid.getType() == KeyType.DERIVED) {
+ id.setIdentityType(IdentityType.Derived);
+ } else {
+ id.setIdentityType(IdentityType.Primary);
+ }
+
+ for (int j=0; j < cid.getTokens().size(); j++) {
+ id.getNames().add(cid.getTokens().get(j).getName());
+ }
+
+ if (ids.contains(id) == false) {
+ ids.add(id);
+ }
+ }
+ }
+ }
+
+ conv.getIdentities().addAll(ids);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.XPathExpression;
+
+public class IfConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Conditional);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.If ret=
+ new org.scribble.conversation.model.If();
+ org.pi4soa.cdl.Conditional cdl=(org.pi4soa.cdl.Conditional)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ ConditionalBlock block=new ConditionalBlock();
+ ret.getConditionalBlocks().add(block);
+
+ context.pushState();
+
+ // Set the expression if defined in the 'conditional'
+ if (cdl.getExpression() != null) {
+ XPathExpression exp=new XPathExpression();
+
+ exp.setQuery(cdl.getExpression());
+
+ block.setExpression(exp);
+ }
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof Block) {
+ block.getContents().addAll(((Block)activity).getContents());
+ } else {
+ block.getContents().add(activity);
+ }
+ }
+ }
+ }
+
+ // Get initiator role(s) for first activity in body and
+ // associated with If
+ ret.getRoles().addAll(block.getInitiatorRoles());
+
+ context.popState();
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class IfOrWhenConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Choice);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.model.Activity ret=null;
+ org.pi4soa.cdl.Choice cdl=(org.pi4soa.cdl.Choice)cdlType;
+ java.util.List<ConditionalBlock> blocks=new java.util.Vector<ConditionalBlock>();
+ boolean f_when=false;
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+
+ context.pushState();
+
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof If) {
+ blocks.addAll(((If)activity).getConditionalBlocks());
+ } else if (activity instanceof
+ org.scribble.conversation.model.When) {
+ blocks.addAll(((org.scribble.conversation.model.When)activity).getConditionalBlocks());
+ f_when = true;
+ } else {
+ ConditionalBlock block=new ConditionalBlock();
+
+ if (activity instanceof Block) {
+ block.getContents().addAll(((Block)activity).getContents());
+ } else {
+ block.getContents().add(activity);
+ }
+
+ blocks.add(block);
+ }
+ }
+
+ context.popState();
+ }
+ }
+
+ // Build up initiator role list
+ java.util.List<Role> roles=null;
+
+ for (int i=0; i < blocks.size(); i++) {
+ Block b=blocks.get(i);
+
+ java.util.List<Role> blockRoles=
+ b.getInitiatorRoles();
+
+ if (blockRoles != null) {
+ if (roles == null) {
+ roles = blockRoles;
+ } else {
+ for (int j=0; j < blockRoles.size(); j++) {
+ if (roles.contains(blockRoles.get(j)) == false) {
+ roles.add(blockRoles.get(j));
+ }
+ }
+ }
+ }
+ }
+
+ if (f_when) {
+ ret = new org.scribble.conversation.model.When();
+ ((org.scribble.conversation.model.When)ret).
+ getConditionalBlocks().addAll(blocks);
+
+ if (roles != null) {
+ ((org.scribble.conversation.model.When)ret).
+ getRoles().addAll(roles);
+ }
+ } else {
+ ret = new org.scribble.conversation.model.If();
+ ((org.scribble.conversation.model.If)ret).
+ getConditionalBlocks().addAll(blocks);
+
+ if (roles != null) {
+ ((org.scribble.conversation.model.If)ret).
+ getRoles().addAll(roles);
+ }
+ }
+
+ if (ret != null) {
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+
+public class ParallelConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Parallel);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.Parallel ret=
+ new org.scribble.conversation.model.Parallel();
+ org.pi4soa.cdl.Parallel cdl=(org.pi4soa.cdl.Parallel)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+
+ context.pushState();
+
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof Block) {
+ ret.getBlocks().add((Block)activity);
+ } else {
+ Block block=new Block();
+ block.getContents().add(activity);
+ ret.getBlocks().add(block);
+ }
+ }
+
+ context.popState();
+ }
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,127 @@
+/*
+ * 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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class PerformConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Perform);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.Compose ret=null;
+ org.pi4soa.cdl.Perform cdl=(org.pi4soa.cdl.Perform)cdlType;
+
+ if (cdl.getWaitForCompletion() == Boolean.TRUE) {
+ ret = new org.scribble.conversation.model.Run();
+ } else {
+ ret = new org.scribble.conversation.model.Spawn();
+ }
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ ConversationReference ref=new ConversationReference();
+ ref.setLocalpart(cdl.getChoreography().getName());
+ ref.setInner(true);
+
+ ret.setReference(ref);
+
+ // Find conversation related to reference, and use
+ // as inner definition initially - to help with
+ // subsequent processing (e.g. locating initiator
+ // roles). The inner definition will be cleared when
+ // the model is fully converted.
+ Conversation conv=context.getConversation(ref);
+
+ if (conv != null) {
+ ret.setInlineDefinition(conv);
+ context.getComposeActivities().add(ret);
+
+ // Bind roles
+ java.util.List<Role> roles=conv.getRoles();
+
+ for (int i=0; i < roles.size(); i++) {
+ Role role=roles.get(i);
+
+ Object decl=context.getState(role.getName());
+
+ if (decl instanceof Declaration) {
+ ret.getBindings().add(new DeclarationBinding((Declaration)decl, role.getName()));
+ }
+ }
+ }
+
+ // Convert binding parameters
+ java.util.List<BindDetails> bds=cdl.getBindDetails();
+
+ for (int i=0; i < bds.size(); i++) {
+
+ // Only convert if a variable, not a channel
+ // TODO: Need to also convert explicit channels
+ if (bds.get(i).getThisVariable() instanceof org.pi4soa.cdl.Variable) {
+ DeclarationBinding db=new DeclarationBinding();
+
+ Object state=context.getState(bds.get(i).getThisVariable().getName());
+
+ if (state instanceof Declaration) {
+ db.setDeclaration((Declaration)state);
+ db.setBoundName(bds.get(i).getFreeVariable().getName());
+
+ ret.getBindings().add(db);
+ } else {
+ logger.finer("State not found for '"+bds.get(i).getThisVariable().getName()+"'");
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,94 @@
+/*
+ * 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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+
+public class SequenceConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Sequence);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.model.Block ret=
+ new org.scribble.model.Block();
+ org.pi4soa.cdl.Sequence cdl=(org.pi4soa.cdl.Sequence)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ context.pushState();
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof Block) {
+ ret.getContents().addAll(
+ ((Block)activity).getContents());
+ } else {
+ ret.getContents().add(activity);
+ }
+ }
+ }
+ }
+
+ context.popState();
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.XPathExpression;
+
+public class WhenConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.When);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.When ret=
+ new org.scribble.conversation.model.When();
+ org.pi4soa.cdl.When cdl=(org.pi4soa.cdl.When)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ ConditionalBlock block=new ConditionalBlock();
+ ret.getConditionalBlocks().add(block);
+
+ context.pushState();
+
+ // Set the expression if defined in the 'when'
+ if (cdl.getExpression() != null) {
+ XPathExpression exp=new XPathExpression();
+
+ exp.setQuery(cdl.getExpression());
+
+ block.setExpression(exp);
+ }
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof Block) {
+ block.getContents().addAll(((Block)activity).getContents());
+ } else {
+ block.getContents().add(activity);
+ }
+ }
+ }
+ }
+
+ // Get initiator role(s) for first activity in body and
+ // associated with When
+ ret.getRoles().addAll(block.getInitiatorRoles());
+
+ context.popState();
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,108 @@
+/*
+ * 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 Jun 2008 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.expression.xpath.model.XPathExpression;
+import org.scribble.model.*;
+
+public class WhileConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.While);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.While ret=
+ new org.scribble.conversation.model.While();
+ org.pi4soa.cdl.While cdl=(org.pi4soa.cdl.While)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ context.pushState();
+
+ // Set the expression if defined in the 'while'
+ if (cdl.getExpression() != null &&
+ cdl.getExpression().trim().length() > 0) {
+ XPathExpression exp=new XPathExpression();
+
+ exp.setQuery(cdl.getExpression());
+
+ ret.getBlock().setExpression(exp);
+ }
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof Block) {
+ ret.getBlock().getContents().addAll(((Block)activity).getContents());
+ } else {
+ ret.getBlock().getContents().add(activity);
+ }
+ }
+ }
+ }
+
+ // Get initiator role(s) for first activity in body and
+ // associated with While
+ ret.getRoles().addAll(ret.getBlock().getInitiatorRoles());
+
+ context.popState();
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java
===================================================================
--- trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java (rev 0)
+++ trunk/tools/plugins/org.savara.pi4soa.cdm/src/java/org/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 2 Nov 2007 : Initial version created by gary
+ */
+package org.savara.pi4soa.cdm.validation;
+
+import org.savara.pi4soa.cdm.model.CDMNotation;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.validation.*;
+
+/**
+ * This class implements the validation rule for the
+ * type reference. This rule overrides the type
+ * reference validation in the core scribble plugin.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=CDMNotation.NOTATION_CODE)
+public class TypeReferenceValidationRule extends org.scribble.validation.TypeReferenceValidationRule {
+
+ /**
+ * 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) {
+ // Ignore type references - these will be represented
+ // as XML type or elements
+
+ // TODO: Eventually may want to validate if the XML
+ // schemas are located in the project
+ }
+}
Added: trunk/tools/plugins/org.savara.protocol.contract/.classpath
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/.classpath (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/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/tools/plugins/org.savara.protocol.contract/.project
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/.project (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.protocol.contract</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/tools/plugins/org.savara.protocol.contract/Copyright.txt
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/Copyright.txt (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/Copyright.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/tools/plugins/org.savara.protocol.contract/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA Protocol Contract Plugin
+Bundle-SymbolicName: org.savara.protocol.contract
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.protocol.contract.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)",
+ org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)",
+ org.savara.contract.model
+Export-Package: org.savara.protocol.contract,
+ org.savara.protocol.contract.impl;x-friends:="org.savara.protocol.contract.tests"
Added: trunk/tools/plugins/org.savara.protocol.contract/build.properties
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/build.properties (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,4 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/tools/plugins/org.savara.protocol.contract/pom.xml
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/pom.xml (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.tools</groupId>
+ <artifactId>org.savara.protocol.contract</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ProtocolContract</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</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>
+ </dependencies>
+ </project>
Added: trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/ContractGenerator.java
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/ContractGenerator.java (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/ContractGenerator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.protocol.contract;
+
+import org.savara.contract.model.Contract;
+import org.scribble.conversation.model.Conversation;
+
+/**
+ * This interface represents the capability that generates a contract
+ * from a protocol associated with a particular interacting role.
+ *
+ */
+public interface ContractGenerator {
+
+ /**
+ * This method generates a contract associated with a supplied located
+ * protocol.
+ *
+ * @param cm The protocol
+ * @return The contract
+ */
+ public Contract generate(Conversation cm) throws IllegalArgumentException;
+
+}
Added: trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/ContractGeneratorFactory.java
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/ContractGeneratorFactory.java (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/ContractGeneratorFactory.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,38 @@
+/*
+ * 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.protocol.contract;
+
+import org.savara.protocol.contract.impl.ContractGeneratorImpl;
+
+/**
+ * This class provides access to a contract generator.
+ *
+ */
+public class ContractGeneratorFactory {
+
+ /**
+ * This method returns an instance of the ContractGenerator
+ * interface.
+ *
+ * @return The contract generator
+ */
+ public static ContractGenerator getContractGenerator() {
+ return(new ContractGeneratorImpl());
+ }
+
+}
Added: trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/Messages.properties
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/Messages.properties (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/Messages.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,20 @@
+#/*
+# * 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.
+# */
+
+SAVARAPC-00001=Protocol must be supplied
+SAVARAPC-00002=Contract generation requires a protocol that represents the local behaviour associated with a particular role
Added: trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/impl/ContractGeneratorImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/impl/ContractGeneratorImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/impl/ContractGeneratorImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.protocol.contract.impl;
+
+import java.text.MessageFormat;
+
+import org.savara.contract.model.Contract;
+import org.savara.protocol.contract.ContractGenerator;
+import org.scribble.conversation.model.Conversation;
+
+/**
+ * This class generates a contract from a protocol defining the behaviour of
+ * multiple interacting roles.
+ *
+ */
+public class ContractGeneratorImpl implements ContractGenerator {
+
+ /**
+ * This method generates a contract associated with a supplied located
+ * protocol.
+ *
+ * @param cm The protocol
+ * @return The contract
+ */
+ public Contract generate(Conversation cm) throws IllegalArgumentException {
+
+ // Check parameters
+ if (cm == null) {
+ throw new IllegalArgumentException(MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.savara.protocol.contract.Messages").
+ getString("SAVARAPC-00001"), (Object)null));
+
+ } else if (cm.getLocatedName() == null || cm.getLocatedName().getRole() == null) {
+ throw new IllegalArgumentException(MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.savara.protocol.contract.Messages").
+ getString("SAVARAPC-00002"), (Object)null));
+ }
+
+ ContractIntrospector introspector=new ContractIntrospector(cm);
+
+ introspector.process();
+
+ return(introspector.getContract());
+ }
+
+}
Added: trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/impl/ContractIntrospector.java
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/impl/ContractIntrospector.java (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/impl/ContractIntrospector.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,248 @@
+/*
+ * 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.protocol.contract.impl;
+
+import java.text.MessageFormat;
+import java.util.logging.Logger;
+
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.Interface;
+import org.savara.contract.model.MessageExchangePattern;
+import org.savara.contract.model.OneWayRequestMEP;
+import org.savara.contract.model.RequestResponseMEP;
+import org.savara.contract.model.Type;
+import org.savara.contract.model.TypeDefinition;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.conversation.model.Run;
+import org.scribble.model.ModelObject;
+import org.scribble.model.Role;
+import org.scribble.model.TypeReference;
+
+/**
+ * This class examines a protocol to determine the contract that represents
+ * the static functional interface to the role's behaviour.
+ *
+ */
+public class ContractIntrospector implements org.scribble.model.Visitor {
+
+ private Contract m_contract=new Contract();
+ private java.util.Set<Conversation> m_processedProtocols=null;
+ private Role m_role=null;
+ private Conversation m_protocol=null;
+
+ private static Logger logger = Logger.getLogger(ContractIntrospector.class.getName());
+
+ /**
+ * Constructor for the contract introspector.
+ *
+ * @param protocol The protocol to introspect
+ */
+ public ContractIntrospector(Conversation protocol) {
+ this(protocol, null, null);
+ }
+
+ /**
+ * Constructor for the contract introspector.
+ *
+ * @param protocol The protocol being introspected
+ * @param contract The optional contract being derived
+ * @param processed The optional set of protocols currently processed
+ */
+ public ContractIntrospector(Conversation protocol, Contract contract,
+ java.util.Set<Conversation> processed) {
+ m_contract = contract;
+
+ if (m_contract == null) {
+ m_contract = new Contract();
+ }
+
+ if (processed != null) {
+ m_processedProtocols = processed;
+ } else {
+ m_processedProtocols = new java.util.HashSet<Conversation>();
+ }
+
+ m_protocol = protocol;
+
+ if (protocol != null) {
+ m_role = protocol.getLocatedName().getRole();
+ }
+ }
+
+ /**
+ * This method returns the contract being derived.
+ *
+ * @return The contract
+ */
+ public Contract getContract() {
+ return(m_contract);
+ }
+
+ /**
+ * This method returns the interface.
+ *
+ * @return The interface
+ */
+ public Interface getInterface() {
+ Interface ret=getContract().getInterface(m_role.getName());
+
+ if (ret == null) {
+ // Create interface for the role
+ ret = new Interface();
+ ret.setName(m_role.getName());
+
+ getContract().getInterfaces().add(ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the set of processed protocols.
+ *
+ * @return The processed protocols
+ */
+ public java.util.Set<Conversation> getProcessedProtocols() {
+ return(m_processedProtocols);
+ }
+
+ /**
+ * This method introspects the supplied protocol to derive information
+ * that can be used to define the functional contract for the role
+ * associated with the protocol.
+ *
+ * @param conv The located protocol
+ */
+ public void process() throws IllegalStateException {
+
+ if (m_protocol == null) {
+ throw new IllegalStateException(MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.savara.protocol.contract.Messages").
+ getString("SAVARAPC-00001"), (Object)null));
+ }
+
+ m_protocol.visit(this);
+ }
+
+ public boolean visit(ModelObject obj) {
+ boolean f_visitChildren=true;
+
+ if (obj.getClass() == Conversation.class) {
+
+ // Only visit children if same protocol that is being visited
+ f_visitChildren = (obj == m_protocol);
+
+ } else if (obj.getClass() == Run.class) {
+ Run run=(Run)obj;
+
+ Conversation toProtocol=run.getDefinition();
+
+ // Check if protocol already processed to avoid stack overflow
+ if (m_processedProtocols.contains(toProtocol) == false) {
+ m_processedProtocols.add(toProtocol);
+
+ ContractIntrospector ci=new ContractIntrospector(toProtocol,
+ getContract(), getProcessedProtocols());
+
+ ci.process();
+ } else {
+ logger.fine("Invoked definition not found for "+run.getReference());
+ }
+ } else if (obj.getClass() == ConversationInteraction.class) {
+ visitInteraction((ConversationInteraction)obj);
+ }
+
+ return(f_visitChildren);
+ }
+
+ /**
+ * This method introspects the supplied interaction to generate Message Exchange
+ * Patterns on the contract interface.
+ *
+ * @param interaction The interaction
+ */
+ public void visitInteraction(ConversationInteraction interaction) {
+
+ // Check if the interacton is being received
+ if (interaction.getFromRole() != null &&
+ interaction.getFromRole().equals(m_role) == false) {
+
+ // Received by the role, but need to check if its replyTo
+ // has been set, indicating it is receiving a response
+ if (interaction.getReplyToLabel() == null ||
+ interaction.getReplyToLabel().trim().length() == 0) {
+
+ // Receiving a request - so record this in the contract
+ Interface intf=getInterface();
+
+ if (interaction.getMessageSignature().getOperation() != null) {
+
+ // Check if message exchange pattern exists for operation
+ MessageExchangePattern mep=intf.getMessageExchangePatternForOperation(
+ interaction.getMessageSignature().getOperation());
+
+ if (mep == null) {
+ // Create new MEP
+ if (interaction.getRequestLabel() != null) {
+ mep = new RequestResponseMEP();
+ } else {
+ mep = new OneWayRequestMEP();
+ }
+
+ mep.setOperation(interaction.getMessageSignature().getOperation());
+
+ for (int i=0; i < interaction.getMessageSignature().getTypes().size(); i++) {
+ mep.getTypes().add(convertType(interaction.getMessageSignature().getTypes().get(i)));
+ }
+
+ intf.getMessageExchangePatterns().add(mep);
+ }
+ }
+
+ } else {
+
+ }
+ }
+ }
+
+ /**
+ * This method converts a protocol type reference into a contract model type.
+ *
+ * @param tref The protocol type reference
+ * @return The type
+ */
+ public Type convertType(TypeReference tref) {
+ Type ret=new Type();
+
+ TypeDefinition td=new TypeDefinition();
+ td.setName(tref.getLocalpart());
+ td.setNamespace(tref.getNamespace());
+ //td.setTypeSystem(typeSystem);
+
+ ret.getTypeDefinitions().add(td);
+ ret.setName(td.getName());
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/osgi/Activator.java (rev 0)
+++ trunk/tools/plugins/org.savara.protocol.contract/src/java/org/savara/protocol/contract/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.protocol.contract.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/tools/plugins/org.savara.tap.eclipse/.classpath
===================================================================
--- trunk/tools/plugins/org.savara.tap.eclipse/.classpath (rev 0)
+++ trunk/tools/plugins/org.savara.tap.eclipse/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <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="src" path="src/java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/plugins/org.savara.tap.eclipse/.project
===================================================================
--- trunk/tools/plugins/org.savara.tap.eclipse/.project (rev 0)
+++ trunk/tools/plugins/org.savara.tap.eclipse/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.tap.eclipse</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/tools/plugins/org.savara.tap.eclipse/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.savara.tap.eclipse/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.savara.tap.eclipse/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA TAP Eclipse integration
+Bundle-SymbolicName: org.savara.tap.eclipse; singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.tap.eclipse.Activator
+Bundle-Vendor: www.savara.org
+Service-Component: OSGI-INF/eclipse-resource-loader.xml
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.savara.tap.model,
+ org.savara.tap.validation,
+ org.scribble.eclipse;bundle-version="[1.1.0,2.0.0)",
+ org.scribble.core;bundle-version="[1.1.0,2.0.0)"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
Added: trunk/tools/plugins/org.savara.tap.eclipse/OSGI-INF/eclipse-resource-loader.xml
===================================================================
--- trunk/tools/plugins/org.savara.tap.eclipse/OSGI-INF/eclipse-resource-loader.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tap.eclipse/OSGI-INF/eclipse-resource-loader.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<component name="eclipse-resource-loader">
+ <implementation class="org.savara.tap.eclipse.EclipseResourceLoader"/>
+ <service>
+ <provide interface="org.savara.tap.model.admin.ResourceLoader"/>
+ </service>
+</component>
Added: trunk/tools/plugins/org.savara.tap.eclipse/build.properties
===================================================================
--- trunk/tools/plugins/org.savara.tap.eclipse/build.properties (rev 0)
+++ trunk/tools/plugins/org.savara.tap.eclipse/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,16 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ OSGI-INF/,\
+ build.properties,\
+ pom.xml
+src.includes = .project,\
+ .classpath,\
+ META-INF/,\
+ OSGI-INF/,\
+ build.properties,\
+ plugin.xml,\
+ pom.xml,\
+ src/
Added: trunk/tools/plugins/org.savara.tap.eclipse/plugin.xml
===================================================================
--- trunk/tools/plugins/org.savara.tap.eclipse/plugin.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tap.eclipse/plugin.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IFile"
+ id="org.savara.tap.eclipse.contribution1"
+ nameFilter="*.tap" >
+ <menu
+ label="Savara"
+ path="additions"
+ id="org.savara.tools.menu">
+ <separator
+ name="group1">
+ </separator>
+ </menu>
+ <action
+ label="Validate"
+ class="org.savara.tap.eclipse.actions.ValidateAction"
+ menubarPath="org.savara.tools.menu/group1"
+ enablesFor="1"
+ id="org.savara.tap.validation.ValidateAction">
+ </action>
+ </objectContribution>
+ </extension>
+
+</plugin>
Added: trunk/tools/plugins/org.savara.tap.eclipse/pom.xml
===================================================================
--- trunk/tools/plugins/org.savara.tap.eclipse/pom.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tap.eclipse/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,24 @@
+<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.tools</groupId>
+ <artifactId>org.savara.tap.eclipse</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ToolsTAPEclipse</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</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>
+ </dependencies>
+
+</project>
Added: trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/Activator.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/Activator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,61 @@
+package org.savara.tap.eclipse;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.savara.tap.eclipse"; //$NON-NLS-1$
+
+ // 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 {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
Added: trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/EclipseResourceLoader.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/EclipseResourceLoader.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/EclipseResourceLoader.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,290 @@
+/*
+ * 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.tap.eclipse;
+
+import java.io.InputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Path;
+import org.savara.tap.model.Resource;
+import org.savara.tap.model.URI;
+import org.savara.tap.model.admin.ResourceLoader;
+import org.scribble.eclipse.model.admin.OSGIModelListener;
+import org.scribble.eclipse.model.admin.OSGIModelRepository;
+import org.scribble.model.ModelReference;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class providers the Eclipse resource loader implementation.
+ *
+ */
+public class EclipseResourceLoader implements ResourceLoader {
+
+ private static Logger logger = Logger.getLogger(EclipseResourceLoader.class.getName());
+
+ /**
+ * This method determines whether the resource loader can
+ * retrieve the contents associated with the supplied resource.
+ *
+ * @param resource The resource
+ * @return Whether the contents can be retrieved
+ */
+ public boolean isSupported(Resource resource) {
+ boolean ret=false;
+
+ for (URI uri : resource.getUri()) {
+ if (uri.getType().equalsIgnoreCase("eclipse")) {
+ ret = true;
+ break;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines if the supplied resource exists.
+ *
+ * @param resource The resource
+ * @return Whether the resource exists
+ */
+ public boolean exists(Resource resource) {
+ IFile res=getFile(resource);
+ return(res == null ? false : res.exists());
+ }
+
+ /**
+ * This method retrieves the contents associated with the
+ * supplied resource.
+ *
+ * @param resource The resource
+ * @return The contents, or null if not found
+ */
+ public InputStream getContents(Resource resource) {
+ java.io.InputStream ret=null;
+ IFile res=getFile(resource);
+
+ if (res != null) {
+ try {
+ ret = res.getContents();
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to get contents for resource '"+res+"'", e);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method retrieves the URI associated with the
+ * supplied resource.
+ *
+ * @param resource The resource
+ * @return The URI, or null if not found
+ */
+ public java.net.URI getURI(Resource resource) {
+ IFile res=getFile(resource);
+ java.net.URI ret=null;
+
+ if (res != null) {
+ ret = res.getRawLocationURI();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method retrieves the contents associated with the
+ * supplied URI. If the URI is a relative path, then the resource will
+ * be located relative to the supplied model reference.
+ *
+ * @param ref The model reference
+ * @param uri The URI
+ * @return The contents, or null if not found
+ */
+ public java.io.InputStream getContents(ModelReference ref, String uri) {
+ java.io.InputStream ret=null;
+
+ if (uri != null) {
+
+ if (uri.startsWith("http:")) {
+ // TODO: Implement
+
+ } else {
+ // Try to locate as relative path from supplied model reference
+ IFile file=OSGIModelRepository.getFile(ref);
+
+ // Find folder
+ IFolder folder = (IFolder)file.getParent();
+
+ IFile refFile=folder.getFile(new Path(uri));
+
+ if (refFile != null) {
+ try {
+ ret = refFile.getContents();
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to load content from referenced resource '"+uri+"'", e);
+ }
+ } else if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Unable to locate resource '"+uri+"'");
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method retrieves the URI associated with the
+ * supplied URI string. If the supplied URI is a relative path,
+ * then the resource will be located relative to the supplied
+ * model reference.
+ *
+ * @param ref The model reference
+ * @param uri The URI
+ * @return The resolved URI, or null if not found
+ */
+ public java.net.URI getURI(ModelReference ref, String uri) {
+ java.net.URI ret=null;
+
+ if (uri != null) {
+
+ if (uri.startsWith("http:")) {
+ try {
+ ret = new java.net.URI(uri);
+ } catch(Exception e) {
+ logger.log(Level.SEVERE, "Invalid URI '"+uri+"'", e);
+ }
+ } else {
+ // Try to locate as relative path from supplied model reference
+ IFile file=OSGIModelRepository.getFile(ref);
+
+ // Find folder
+ IFolder folder = (IFolder)file.getParent();
+
+ IFile refFile=folder.getFile(new Path(uri));
+
+ if (refFile != null) {
+ ret = refFile.getRawLocationURI();
+ } else if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Unable to locate resource '"+uri+"'");
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method retrieves the contents associated with the
+ * supplied resource.
+ *
+ * @param resource The resource
+ * @return The contents, or null if not found
+ */
+ protected IFile getFile(Resource resource) {
+ String projectName=null;
+ String location=null;
+ IFile ret=null;
+
+ for (URI uri : resource.getUri()) {
+ if (uri.getType().equalsIgnoreCase("eclipse")) {
+ projectName = uri.getContext();
+ location = uri.getLocator();
+ break;
+ }
+ }
+
+ if (projectName != null) {
+ IProject project=org.eclipse.core.resources.ResourcesPlugin.getWorkspace().
+ getRoot().getProject(projectName);
+
+ if (project == null) {
+ logger.severe("Eclipse context (project) '"+projectName+
+ "' does not exist for resource: "+resource.getId());
+ } else if (location == null) {
+ logger.severe("Eclipse locator has not been defined for resource: "+resource.getId());
+ } else {
+ ret = project.getFile(new Path(location));
+
+ if (ret == null) {
+ logger.severe("Eclipse locator '"+location+"' for project '"+projectName+
+ "' does not exist for resource: "+resource.getId());
+ }
+ }
+ } else {
+ logger.severe("Unable to determine Eclipse context (project) for resource: "+
+ resource.getId());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns a model listener associated with the supplied resource.
+ *
+ * @param res The resource
+ * @return The model listener associated with the resource
+ */
+ public ModelListener getResourceModelListener(Resource res) {
+ IFile file=getFile(res);
+ ModelListener ret=null;
+
+ if (file != null) {
+ ret = new OSGIModelListener(file);
+ } else {
+ logger.severe("Failed to get model listener for resource '"+res+"'");
+
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method frees a model listener associated with the supplied resource.
+ *
+ * @param res The resource
+ * @param l The model listener associated with the resource
+ */
+ public void freeResourceModelListener(Resource res, ModelListener l) {
+ if (l instanceof OSGIModelListener) {
+ ((OSGIModelListener)l).finished();
+ }
+ }
+
+ /**
+ * This method returns the model reference associated with the supplied resource.
+ *
+ * @param resource The resource
+ * @return The model reference
+ */
+ public ModelReference getModelReference(Resource resource) {
+ return(OSGIModelRepository.createReference(getFile(resource)));
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/actions/ValidateAction.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/actions/ValidateAction.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.eclipse/src/java/org/savara/tap/eclipse/actions/ValidateAction.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,154 @@
+package org.savara.tap.eclipse.actions;
+
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.savara.tap.model.Project;
+import org.savara.tap.model.admin.TAPModelUtil;
+import org.savara.tap.validation.TAPValidator;
+import org.scribble.eclipse.model.admin.OSGIModelListener;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+public class ValidateAction implements IObjectActionDelegate {
+
+ private static Logger logger = Logger.getLogger(ValidateAction.class.getName());
+
+ private ISelection m_selection=null;
+ private IWorkbenchPart m_targetPart=null;
+ private static TAPValidator m_validator=TAPValidator.getInstance();
+
+ public ValidateAction() {
+ }
+
+ /**
+ * This method returns the validator.
+ *
+ * @return The validator
+ */
+ public static TAPValidator getValidator() {
+ return(m_validator);
+ }
+
+ /**
+ * This method implements the action's run method.
+ *
+ * @param action The action
+ */
+ public void run(IAction action) {
+
+ if (m_selection instanceof StructuredSelection) {
+ StructuredSelection sel=(StructuredSelection)m_selection;
+
+ IResource res=(IResource)sel.getFirstElement();
+
+ // Obtain the TAP model from the resource
+ if (res instanceof IFile) {
+ Project project=null;
+ OSGIModelListener l=new OSGIModelListener(res);
+ java.io.InputStream is=null;
+
+ try {
+ is = ((IFile)res).getContents();
+
+ // Check the XML document is valid
+ if (TAPValidator.getInstance().isValidTAPDocument(is, l)) {
+
+ is.close();
+
+ // Re-acquire contents to deserialize into project object model
+ is = ((IFile)res).getContents();
+
+ project = TAPModelUtil.deserialize(is);
+
+ is.close();
+
+ if (project != null) {
+ m_validator.validate(project, l);
+ }
+ }
+ } catch(Exception e) {
+ if (is != null) {
+ try {
+ is.close();
+ } catch(Exception ex) {
+ }
+ }
+
+ e.printStackTrace();
+
+ error(e.getMessage());
+ }
+
+ l.finished();
+ }
+ }
+ }
+
+ /**
+ * This method is used to report an error.
+ *
+ * @param mesg The error message
+ */
+ public void error(String mesg) {
+
+ logger.severe("Error occurred: "+mesg);
+
+ MessageBox mbox=new MessageBox(m_targetPart.getSite().getShell(),
+ SWT.ICON_ERROR|SWT.OK);
+
+ if (mesg == null) {
+ mesg = "Null pointer exception has occurred";
+ }
+
+ mbox.setMessage(mesg);
+ mbox.open();
+ }
+
+ /**
+ * This method indicates that the selection has changed.
+ *
+ * @param action The action
+ * @param selection The selection
+ */
+ public void selectionChanged(IAction action,
+ ISelection selection) {
+ m_selection = selection;
+ }
+
+ /**
+ * This method sets the currently active workbench part.
+ *
+ * @param action The action
+ * @param targetPart The active workbench part
+ */
+ public void setActivePart(IAction action,
+ IWorkbenchPart targetPart) {
+ m_targetPart = targetPart;
+ }
+}
Added: trunk/tools/plugins/org.savara.tap.model/.classpath
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/.classpath (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <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="src" path="src/java"/>
+ <classpathentry kind="var" path="M2_REPO/javax/xml/jaxb-impl/2.1/jaxb-impl-2.1.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/plugins/org.savara.tap.model/.project
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/.project (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.tap.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/tools/plugins/org.savara.tap.model/Copyright.txt
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/Copyright.txt (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/Copyright.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,17 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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/tools/plugins/org.savara.tap.model/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA TAP Model
+Bundle-SymbolicName: org.savara.tap.model
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.tap.model.osgi.Activator
+Bundle-Vendor: www.savara.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0"
+Export-Package: org.savara.tap.model,
+ org.savara.tap.model.admin
+Require-Bundle: org.scribble.core;bundle-version="[1.1.0,2.0.0)"
Added: trunk/tools/plugins/org.savara.tap.model/build.properties
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/build.properties (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,15 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ schema/,\
+ Copyright.txt
+src.includes = schema/,\
+ pom.xml,\
+ src/,\
+ Copyright.txt,\
+ META-INF/,\
+ build.properties,\
+ .classpath,\
+ .project,\
+ .settings/
Added: trunk/tools/plugins/org.savara.tap.model/pom.xml
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/pom.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,40 @@
+<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.tools</groupId>
+ <artifactId>org.savara.tap.model</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ToolsTAPModel</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</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>javax.xml</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>${jaxb.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>${jaxb.version}</version>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>javax.xml</groupId>
+ <artifactId>jaxb-xjc</artifactId>
+ <version>${jaxb.version}</version>
+ </dependency>
+ -->
+ </dependencies>
+</project>
Added: trunk/tools/plugins/org.savara.tap.model/schema/tap.xsd
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/schema/tap.xsd (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/schema/tap.xsd 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema targetNamespace="http://www.savara.org/ta/project" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.savara.org/ta/project">
+
+
+ <complexType name="Project">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="phase" type="tns:Phase"
+ maxOccurs="unbounded" minOccurs="0">
+ </element>
+ </sequence>
+ <attribute name="name" type="string" use="required"></attribute>
+ <attribute name="version" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Phase">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="resource" type="tns:Resource" maxOccurs="unbounded" minOccurs="0"></element>
+ </sequence>
+ <attribute name="name" type="string" use="required"></attribute>
+
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Resource">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="uri" type="tns:URI"
+ maxOccurs="unbounded" minOccurs="0">
+ </element>
+ <element name="relationship" type="tns:Relationship" maxOccurs="unbounded" minOccurs="0"></element>
+ </sequence>
+ <attribute name="id" type="ID" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Relationship">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="link" type="tns:Link"
+ maxOccurs="unbounded" minOccurs="0">
+ </element>
+ </sequence>
+ <attribute name="ref" type="IDREF" use="required"></attribute>
+ <attribute name="type" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Link">
+ <complexContent>
+ <extension base="tns:Root">
+ <attribute name="from" type="string"></attribute>
+
+ <attribute name="to" type="string"></attribute>
+
+ <attribute name="type" type="string" use="required"></attribute>
+
+ </extension>
+ </complexContent>
+ </complexType>
+
+
+ <complexType name="Root">
+ <sequence>
+ <element name="description" type="string" maxOccurs="1"
+ minOccurs="0">
+ </element>
+ <any namespace="##other" processContents="lax" maxOccurs="100"
+ minOccurs="0" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="URI">
+ <complexContent>
+ <extension base="tns:Root">
+ <attribute name="type" type="string" use="required"></attribute>
+ <attribute name="context" type="string" use="required"></attribute>
+ <attribute name="locator" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="project" type="tns:Project"></element>
+</schema>
Added: trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Link.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Link.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Link.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,122 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2010.09.14 at 02:07:43 PM BST
+//
+
+
+package org.savara.tap.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for Link complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="Link">
+ * <complexContent>
+ * <extension base="{http://www.savara.org/ta/project}Root">
+ * <attribute name="from" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="to" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="type" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <anyAttribute processContents='lax' namespace='##other'/>
+ * </extension>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "Link")
+public class Link
+ extends Root
+{
+
+ @XmlAttribute
+ protected String from;
+ @XmlAttribute
+ protected String to;
+ @XmlAttribute(required = true)
+ protected String type;
+
+ /**
+ * Gets the value of the from property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getFrom() {
+ return from;
+ }
+
+ /**
+ * Sets the value of the from property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setFrom(String value) {
+ this.from = value;
+ }
+
+ /**
+ * Gets the value of the to property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getTo() {
+ return to;
+ }
+
+ /**
+ * Sets the value of the to property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setTo(String value) {
+ this.to = value;
+ }
+
+ /**
+ * Gets the value of the type property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the value of the type property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setType(String value) {
+ this.type = value;
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/ObjectFactory.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/ObjectFactory.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/ObjectFactory.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,108 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2010.09.14 at 02:07:43 PM BST
+//
+
+
+package org.savara.tap.model;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.savara.tap.model package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+ at XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _Project_QNAME = new QName("http://www.savara.org/ta/project", "project");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.savara.tap.model
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link Resource }
+ *
+ */
+ public Resource createResource() {
+ return new Resource();
+ }
+
+ /**
+ * Create an instance of {@link Phase }
+ *
+ */
+ public Phase createPhase() {
+ return new Phase();
+ }
+
+ /**
+ * Create an instance of {@link URI }
+ *
+ */
+ public URI createURI() {
+ return new URI();
+ }
+
+ /**
+ * Create an instance of {@link Link }
+ *
+ */
+ public Link createLink() {
+ return new Link();
+ }
+
+ /**
+ * Create an instance of {@link Root }
+ *
+ */
+ public Root createRoot() {
+ return new Root();
+ }
+
+ /**
+ * Create an instance of {@link Relationship }
+ *
+ */
+ public Relationship createRelationship() {
+ return new Relationship();
+ }
+
+ /**
+ * Create an instance of {@link Project }
+ *
+ */
+ public Project createProject() {
+ return new Project();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link Project }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.savara.org/ta/project", name = "project")
+ public JAXBElement<Project> createProject(Project value) {
+ return new JAXBElement<Project>(_Project_QNAME, Project.class, null, value);
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Phase.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Phase.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Phase.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,105 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2010.09.14 at 02:07:43 PM BST
+//
+
+
+package org.savara.tap.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for Phase complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="Phase">
+ * <complexContent>
+ * <extension base="{http://www.savara.org/ta/project}Root">
+ * <sequence>
+ * <element name="resource" type="{http://www.savara.org/ta/project}Resource" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <anyAttribute processContents='lax' namespace='##other'/>
+ * </extension>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "Phase", propOrder = {
+ "resource"
+})
+public class Phase
+ extends Root
+{
+
+ protected List<Resource> resource;
+ @XmlAttribute(required = true)
+ protected String name;
+
+ /**
+ * Gets the value of the resource property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the resource property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getResource().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Resource }
+ *
+ *
+ */
+ public List<Resource> getResource() {
+ if (resource == null) {
+ resource = new ArrayList<Resource>();
+ }
+ return this.resource;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Project.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Project.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Project.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,132 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2010.09.14 at 02:07:43 PM BST
+//
+
+
+package org.savara.tap.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for Project complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="Project">
+ * <complexContent>
+ * <extension base="{http://www.savara.org/ta/project}Root">
+ * <sequence>
+ * <element name="phase" type="{http://www.savara.org/ta/project}Phase" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <anyAttribute processContents='lax' namespace='##other'/>
+ * </extension>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "Project", propOrder = {
+ "phase"
+})
+public class Project
+ extends Root
+{
+
+ protected List<Phase> phase;
+ @XmlAttribute(required = true)
+ protected String name;
+ @XmlAttribute(required = true)
+ protected String version;
+
+ /**
+ * Gets the value of the phase property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the phase property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getPhase().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Phase }
+ *
+ *
+ */
+ public List<Phase> getPhase() {
+ if (phase == null) {
+ phase = new ArrayList<Phase>();
+ }
+ return this.phase;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ /**
+ * Gets the value of the version property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Sets the value of the version property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setVersion(String value) {
+ this.version = value;
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Relationship.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Relationship.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Relationship.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,136 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2010.09.14 at 02:07:43 PM BST
+//
+
+
+package org.savara.tap.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlIDREF;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for Relationship complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="Relationship">
+ * <complexContent>
+ * <extension base="{http://www.savara.org/ta/project}Root">
+ * <sequence>
+ * <element name="link" type="{http://www.savara.org/ta/project}Link" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="ref" use="required" type="{http://www.w3.org/2001/XMLSchema}IDREF" />
+ * <attribute name="type" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <anyAttribute processContents='lax' namespace='##other'/>
+ * </extension>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "Relationship", propOrder = {
+ "link"
+})
+public class Relationship
+ extends Root
+{
+
+ protected List<Link> link;
+ @XmlAttribute(required = true)
+ @XmlIDREF
+ @XmlSchemaType(name = "IDREF")
+ protected Object ref;
+ @XmlAttribute(required = true)
+ protected String type;
+
+ /**
+ * Gets the value of the link property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the link property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getLink().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Link }
+ *
+ *
+ */
+ public List<Link> getLink() {
+ if (link == null) {
+ link = new ArrayList<Link>();
+ }
+ return this.link;
+ }
+
+ /**
+ * Gets the value of the ref property.
+ *
+ * @return
+ * possible object is
+ * {@link Object }
+ *
+ */
+ public Object getRef() {
+ return ref;
+ }
+
+ /**
+ * Sets the value of the ref property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Object }
+ *
+ */
+ public void setRef(Object value) {
+ this.ref = value;
+ }
+
+ /**
+ * Gets the value of the type property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the value of the type property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setType(String value) {
+ this.type = value;
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Resource.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Resource.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Resource.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,144 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2010.09.14 at 02:07:43 PM BST
+//
+
+
+package org.savara.tap.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for Resource complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="Resource">
+ * <complexContent>
+ * <extension base="{http://www.savara.org/ta/project}Root">
+ * <sequence>
+ * <element name="uri" type="{http://www.savara.org/ta/project}URI" maxOccurs="unbounded" minOccurs="0"/>
+ * <element name="relationship" type="{http://www.savara.org/ta/project}Relationship" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * <anyAttribute processContents='lax' namespace='##other'/>
+ * </extension>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "Resource", propOrder = {
+ "uri",
+ "relationship"
+})
+public class Resource
+ extends Root
+{
+
+ protected List<URI> uri;
+ protected List<Relationship> relationship;
+ @XmlAttribute(required = true)
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the uri property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getUri().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link URI }
+ *
+ *
+ */
+ public List<URI> getUri() {
+ if (uri == null) {
+ uri = new ArrayList<URI>();
+ }
+ return this.uri;
+ }
+
+ /**
+ * Gets the value of the relationship property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the relationship property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getRelationship().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Relationship }
+ *
+ *
+ */
+ public List<Relationship> getRelationship() {
+ if (relationship == null) {
+ relationship = new ArrayList<Relationship>();
+ }
+ return this.relationship;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Root.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Root.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/Root.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,139 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2010.09.14 at 02:07:43 PM BST
+//
+
+
+package org.savara.tap.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyAttribute;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.namespace.QName;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for Root complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="Root">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <any processContents='lax' namespace='##other' maxOccurs="100" minOccurs="0"/>
+ * </sequence>
+ * <anyAttribute processContents='lax' namespace='##other'/>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "Root", propOrder = {
+ "description",
+ "any"
+})
+ at XmlSeeAlso({
+ Project.class,
+ Resource.class,
+ Link.class,
+ Relationship.class,
+ Phase.class,
+ URI.class
+})
+public class Root {
+
+ protected String description;
+ @XmlAnyElement(lax = true)
+ protected List<Object> any;
+ @XmlAnyAttribute
+ private Map<QName, String> otherAttributes = new HashMap<QName, String>();
+
+ /**
+ * Gets the value of the description property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Sets the value of the description property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setDescription(String value) {
+ this.description = value;
+ }
+
+ /**
+ * Gets the value of the any property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the any property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getAny().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Object }
+ * {@link Element }
+ *
+ *
+ */
+ public List<Object> getAny() {
+ if (any == null) {
+ any = new ArrayList<Object>();
+ }
+ return this.any;
+ }
+
+ /**
+ * Gets a map that contains attributes that aren't bound to any typed property on this class.
+ *
+ * <p>
+ * the map is keyed by the name of the attribute and
+ * the value is the string value of the attribute.
+ *
+ * the map returned by this method is live, and you can add new attribute
+ * by updating the map directly. Because of this design, there's no setter.
+ *
+ *
+ * @return
+ * always non-null
+ */
+ public Map<QName, String> getOtherAttributes() {
+ return otherAttributes;
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/URI.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/URI.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/URI.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,122 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2010.09.14 at 02:07:43 PM BST
+//
+
+
+package org.savara.tap.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for URI complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="URI">
+ * <complexContent>
+ * <extension base="{http://www.savara.org/ta/project}Root">
+ * <attribute name="type" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="context" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="locator" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <anyAttribute processContents='lax' namespace='##other'/>
+ * </extension>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "URI")
+public class URI
+ extends Root
+{
+
+ @XmlAttribute(required = true)
+ protected String type;
+ @XmlAttribute(required = true)
+ protected String context;
+ @XmlAttribute(required = true)
+ protected String locator;
+
+ /**
+ * Gets the value of the type property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the value of the type property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setType(String value) {
+ this.type = value;
+ }
+
+ /**
+ * Gets the value of the context property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getContext() {
+ return context;
+ }
+
+ /**
+ * Sets the value of the context property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setContext(String value) {
+ this.context = value;
+ }
+
+ /**
+ * Gets the value of the locator property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getLocator() {
+ return locator;
+ }
+
+ /**
+ * Sets the value of the locator property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setLocator(String value) {
+ this.locator = value;
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/admin/ResourceLoader.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/admin/ResourceLoader.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/admin/ResourceLoader.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,112 @@
+/*
+ * 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.tap.model.admin;
+
+import org.savara.tap.model.Resource;
+import org.scribble.model.ModelReference;
+import org.scribble.model.admin.ModelListener;
+
+public interface ResourceLoader {
+
+ /**
+ * This method determines whether the resource loader can
+ * retrieve the contents associated with the supplied resource.
+ *
+ * @param resource The resource
+ * @return Whether the contents can be retrieved
+ */
+ public boolean isSupported(Resource resource);
+
+ /**
+ * This method determines if the supplied resource exists.
+ *
+ * @param resource The resource
+ * @return Whether the resource exists
+ */
+ public boolean exists(Resource resource);
+
+ /**
+ * This method retrieves the contents associated with the
+ * supplied resource.
+ *
+ * @param resource The resource
+ * @return The contents, or null if not found
+ */
+ public java.io.InputStream getContents(Resource resource);
+
+ /**
+ * This method retrieves the URI associated with the
+ * supplied resource.
+ *
+ * @param resource The resource
+ * @return The URI, or null if not found
+ */
+ public java.net.URI getURI(Resource resource);
+
+ /**
+ * This method retrieves the contents associated with the
+ * supplied URI. If the URI is a relative path, then the resource will
+ * be located relative to the supplied model reference.
+ *
+ * @param ref The model reference
+ * @param uri The URI
+ * @return The contents, or null if not found
+ */
+ public java.io.InputStream getContents(ModelReference ref, String uri);
+
+ /**
+ * This method retrieves the URI associated with the
+ * supplied URI string. If the supplied URI is a relative path,
+ * then the resource will be located relative to the supplied
+ * model reference.
+ *
+ * @param ref The model reference
+ * @param uri The URI
+ * @return The resolved URI, or null if not found
+ */
+ public java.net.URI getURI(ModelReference ref, String uri);
+
+ /**
+ * This method returns a model listener associated with the supplied resource.
+ *
+ * @param res The resource
+ * @return The model listener associated with the resource
+ */
+ public ModelListener getResourceModelListener(Resource res);
+
+ /**
+ * This method frees a model listener associated with the supplied resource.
+ *
+ * @param res The resource
+ * @param l The model listener associated with the resource
+ */
+ public void freeResourceModelListener(Resource res, ModelListener l);
+
+ /**
+ * This method returns the model reference associated with the supplied resource.
+ *
+ * @param resource The resource
+ * @return The model reference
+ */
+ public ModelReference getModelReference(Resource resource);
+
+}
Added: trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/admin/TAPModelUtil.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/admin/TAPModelUtil.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/admin/TAPModelUtil.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,94 @@
+/*
+ * 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.tap.model.admin;
+
+import java.io.IOException;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.savara.tap.model.ObjectFactory;
+import org.savara.tap.model.Project;
+
+/**
+ * This class contains utility methods associated with the Testable Architecture Project (TAP)
+ * model.
+ *
+ */
+public class TAPModelUtil {
+
+ /**
+ * This method deserializes a TAP project model from an XML document provided in
+ * the supplied input stream.
+ *
+ * @param is The input stream containing the XML document
+ * @return The TAP project
+ * @throws IOException Failed to deserialize the project
+ */
+ public static Project deserialize(java.io.InputStream is) throws IOException {
+ Project ret=null;
+
+ try {
+ JAXBContext context = JAXBContext.newInstance("org.savara.tap.model");
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+
+ //note: setting schema to null will turn validator off
+ //unmarshaller.setSchema(null);
+ Object xmlObject = unmarshaller.unmarshal(is);
+
+ if (xmlObject instanceof JAXBElement) {
+ ret = (Project)((JAXBElement<?>)xmlObject).getValue();
+ }
+
+ } catch(Exception e) {
+ throw new IOException("Failed to deserialize 'testable architecture project'", e);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method serializes a TAP project model into an XML representation, stored
+ * in the supplied output stream.
+ *
+ * @param project The project to be serialized
+ * @param os The output stream on which to record the serialized project
+ * @throws IOException Failed to serialize the project
+ */
+ public static void serialize(Project project, java.io.OutputStream os) throws IOException {
+
+ try {
+ org.savara.tap.model.ObjectFactory factory=
+ new org.savara.tap.model.ObjectFactory();
+
+ JAXBContext context = JAXBContext.newInstance(Project.class);
+ Marshaller marshaller = context.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+
+ marshaller.marshal(factory.createProject(project), os);
+ } catch(Exception e) {
+ throw new IOException("Failed to serialize 'testable architecture project'", e);
+ }
+ }
+}
Added: trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/osgi/Activator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.tap.model.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/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/package-info.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/package-info.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.model/src/java/org/savara/tap/model/package-info.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,9 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2010.09.14 at 02:07:43 PM BST
+//
+
+ at javax.xml.bind.annotation.XmlSchema(namespace = "http://www.savara.org/ta/project", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package org.savara.tap.model;
Added: trunk/tools/plugins/org.savara.tap.validation/.classpath
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/.classpath (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <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="src" path="src/java"/>
+ <classpathentry kind="src" path="src/resources"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/plugins/org.savara.tap.validation/.project
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/.project (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.tap.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/tools/plugins/org.savara.tap.validation/Copyright.txt
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/Copyright.txt (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/Copyright.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,17 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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/tools/plugins/org.savara.tap.validation/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA TAP Validation
+Bundle-SymbolicName: org.savara.tap.validation;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.tap.validation.osgi.Activator
+Bundle-Vendor: www.savara.org
+Service-Component: OSGI-INF/bpel-cdm-relationship-validator.xml,
+ OSGI-INF/cdm-scenario-relationship-validator.xml
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.savara.tap.model,
+ org.scribble.core;bundle-version="[1.1.0,2.0.0)",
+ org.scribble.eclipse;bundle-version="[1.1.0,2.0.0)",
+ org.pi4soa.scenario,
+ org.pi4soa.cdl
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.savara.tap.validation
Added: trunk/tools/plugins/org.savara.tap.validation/OSGI-INF/bpel-cdm-relationship-validator.xml
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/OSGI-INF/bpel-cdm-relationship-validator.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/OSGI-INF/bpel-cdm-relationship-validator.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<component name="bpel-cdm-relationship-validator">
+ <implementation class="org.savara.tap.validation.ws.BPELCDMRelationshipValidator"/>
+ <service>
+ <provide interface="org.savara.tap.validation.RelationshipValidator"/>
+ </service>
+</component>
Added: trunk/tools/plugins/org.savara.tap.validation/OSGI-INF/cdm-scenario-relationship-validator.xml
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/OSGI-INF/cdm-scenario-relationship-validator.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/OSGI-INF/cdm-scenario-relationship-validator.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<component name="cdm-scenario-relationship-validator">
+ <implementation class="org.savara.tap.validation.cdl.CDMScenarioRelationshipValidator"/>
+ <service>
+ <provide interface="org.savara.tap.validation.RelationshipValidator"/>
+ </service>
+</component>
Added: trunk/tools/plugins/org.savara.tap.validation/build.properties
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/build.properties (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,18 @@
+source.. = src/java/,\
+ src/resources/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ build.properties,\
+ OSGI-INF/,\
+ Copyright.txt
+src.includes = .classpath,\
+ .project,\
+ Copyright.txt,\
+ META-INF/,\
+ OSGI-INF/,\
+ plugin.xml,\
+ pom.xml,\
+ build.properties,\
+ src/
Added: trunk/tools/plugins/org.savara.tap.validation/plugin.xml
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/plugin.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/plugin.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+<!--
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ id="org.savara.tap.validation.contribution1"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.tap">
+ <menu
+ id="org.savara.tools.menu"
+ label="Savara"
+ path="additions">
+ <separator name="group1"/>
+ </menu>
+ <action
+ label="Validate"
+ class="org.savara.tap.validation.action.ValidateAction"
+ menubarPath="org.savara.tools.menu/group1"
+ enablesFor="1"
+ id="org.savara.tap.validation.ValidateAction">
+ </action>
+ </objectContribution>
+ </extension>
+-->
+
+ <extension
+ point="org.eclipse.ui.startup">
+ <startup
+ class="org.savara.tap.validation.osgi.Activator">
+ </startup>
+ </extension>
+
+</plugin>
Added: trunk/tools/plugins/org.savara.tap.validation/pom.xml
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/pom.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,24 @@
+<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.tools</groupId>
+ <artifactId>org.savara.tap.validation</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ToolsTAPValidation</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</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>
+ </dependencies>
+
+</project>
Added: trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/Messages.properties
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/Messages.properties (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/Messages.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,20 @@
+#/*
+# * 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.
+# */
+
+SAVARATAPV-00001=Unable to load resource type for resource with id "{0}"
+SAVARATAPV-00002=Unable to locate resource with id "{0}"
Added: trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/RelationshipValidator.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/RelationshipValidator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/RelationshipValidator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,61 @@
+/*
+ * 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.tap.validation;
+
+import org.savara.tap.model.Relationship;
+import org.savara.tap.model.Resource;
+import org.savara.tap.model.admin.ResourceLoader;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface provides validation for relationships defined within a Testable
+ * Architecture Project (TAP) model.
+ *
+ */
+public interface RelationshipValidator {
+
+ /**
+ * This method determines whether the validator supports the
+ * supplied resource and relationship types.
+ *
+ * @param rel The relationship details
+ * @param fromResource The 'from' resource to be validated
+ * @param toResource The 'to' resource to be validated
+ * @return Whether the validator supports the resource types
+ */
+ public boolean isSupported(Relationship rel, Resource fromResource, Resource toResource);
+
+ /**
+ * This method validates the supplied resources and relationship,
+ * and reports any issues to the supplied model listener.
+ *
+ * @param rel The relationship details
+ * @param fromResource The 'from' resource to be validated
+ * @param fromRL The 'from' resource loader
+ * @param toResource The 'to' resource to be validated
+ * @param toRL The 'to' resource loader
+ * @param l The model listener
+ */
+ public void validate(Relationship rel, Resource fromResource, ResourceLoader fromRL,
+ Resource toResource, ResourceLoader toRL, ModelListener l);
+
+}
Added: trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/ResourceValidator.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/ResourceValidator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/ResourceValidator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,53 @@
+/*
+ * 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.tap.validation;
+
+import org.savara.tap.model.Resource;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface provides validation for resources within a Testable
+ * Architecture Project (TAP) model.
+ *
+ */
+public interface ResourceValidator {
+
+ /**
+ * This method determines whether the validator supports the
+ * supplied resource type.
+ *
+ * @param resource The resource to be validated
+ * @return Whether the validator supports the resource type
+ */
+ public boolean isSupported(Resource resource);
+
+ /**
+ * This method validates the supplied resource and reports
+ * any issues to the supplied model listener.
+ *
+ * @param resource The resource
+ * @param is The resource input stream
+ * @param l The model listener
+ */
+ public void validate(Resource resource, java.io.InputStream is, ModelListener l);
+
+}
Added: trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/TAPValidator.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/TAPValidator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/TAPValidator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,360 @@
+/*
+ * 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.tap.validation;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import org.savara.tap.model.Phase;
+import org.savara.tap.model.Project;
+import org.savara.tap.model.Relationship;
+import org.savara.tap.model.Resource;
+import org.savara.tap.model.admin.ResourceLoader;
+import org.scribble.model.ModelReference;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.resolutions.ShowReferencedDescription;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+/**
+ * This class provides the validation control mechanism for a TAP
+ * project file.
+ *
+ */
+public class TAPValidator {
+
+ private static Logger logger = Logger.getLogger(TAPValidator.class.getName());
+
+ private static java.util.List<ResourceLoader> m_resourceLoaders=
+ new java.util.Vector<ResourceLoader>();
+ private static java.util.List<ResourceValidator> m_resourceValidators=
+ new java.util.Vector<ResourceValidator>();
+ private static java.util.List<RelationshipValidator> m_relationshipValidators=
+ new java.util.Vector<RelationshipValidator>();
+
+ private static TAPValidator m_instance=new TAPValidator();
+
+ protected TAPValidator() {
+ }
+
+ public static TAPValidator getInstance() {
+ return(m_instance);
+ }
+
+ /**
+ * This method adds a resource loader.
+ *
+ * @param rl The resource loader
+ */
+ public void addResourceLoader(ResourceLoader rl) {
+ m_resourceLoaders.add(rl);
+ }
+
+ /**
+ * This method removes a resource loader.
+ *
+ * @param rl The resource loader
+ */
+ public void removeResourceLoader(ResourceLoader rl) {
+ m_resourceLoaders.remove(rl);
+ }
+
+ /**
+ * This method adds a resource validator.
+ *
+ * @param rv The resource validator
+ */
+ public void addResourceValidator(ResourceValidator rv) {
+ m_resourceValidators.add(rv);
+ }
+
+ /**
+ * This method removes a resource validator.
+ *
+ * @param rv The resource validator
+ */
+ public void removeResourceValidator(ResourceValidator rv) {
+ m_resourceValidators.remove(rv);
+ }
+
+ /**
+ * This method adds a relationship validator.
+ *
+ * @param rv The relationship validator
+ */
+ public void addRelationshipValidator(RelationshipValidator rv) {
+ m_relationshipValidators.add(rv);
+ }
+
+ /**
+ * This method removes a relationship validator.
+ *
+ * @param rv The relationship validator
+ */
+ public void removeRelationshipValidator(RelationshipValidator rv) {
+ m_relationshipValidators.remove(rv);
+ }
+
+ /**
+ * This method validates a TAP project.
+ *
+ * @param project The TAP project
+ * @param l The model listener
+ */
+ public void validate(Project project, ModelListener l) {
+
+ // Load and validate the individual resources
+ for (Phase phase : project.getPhase()) {
+ for (Resource resource : phase.getResource()) {
+ ModelListener ml=getResourceModelListener(resource);
+
+ // Validate resource
+ for (ResourceValidator rv : m_resourceValidators) {
+ if (rv.isSupported(resource)) {
+ // Obtain input stream for resource
+ ResourceLoader rl=getResourceLoader(resource);
+ java.io.InputStream is=rl.getContents(resource);
+
+ if (is != null) {
+ rv.validate(resource, is, ml);
+
+ try {
+ is.close();
+ } catch(Exception e) {
+ logger.log(Level.SEVERE, "Failed to close resource '"+
+ resource.getId()+"' input stream", e);
+ }
+ } else {
+ // TODO: Log error - resource validator supports resource
+ // but cannot be loaded (or possibly a warning)?
+ }
+ break;
+ }
+ }
+
+ for (Relationship rel : resource.getRelationship()) {
+ Resource toResource=(Resource)rel.getRef();
+
+ if (toResource !=null) {
+ // Obtain input stream for resource
+ ResourceLoader fromRL=getResourceLoader(resource);
+ ResourceLoader toRL=getResourceLoader(toResource);
+
+ if (fromRL == null) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00001"), resource.getId())));
+ } else if (toRL == null) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00001"), toResource.getId())));
+ } else if (!fromRL.exists(resource)) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00002"), resource.getId())));
+ } else if (!toRL.exists(toResource)) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00002"), toResource.getId())));
+ } else {
+ ModelReference ref=toRL.getModelReference(toResource);
+
+ ModelListener proxyml=new InnerModelListener(ref, ml);
+
+ for (RelationshipValidator rv : m_relationshipValidators) {
+
+ if (rv.isSupported(rel, resource, toResource)) {
+ rv.validate(rel, resource, fromRL, toResource, toRL, proxyml);
+
+ break;
+ }
+ }
+ }
+ } else {
+ logger.severe("Linked resource with id '"+rel.getRef()+
+ "' not found for resource '"+resource.getId()+"'");
+ }
+ }
+
+ freeResourceModelListener(resource, ml);
+ }
+ }
+ }
+
+ /**
+ * This method can be used to determine whether the supplied input stream
+ * contains a valid TAP document.
+ *
+ * @param is The TAP content
+ * @param l
+ * @return
+ */
+ public boolean isValidTAPDocument(java.io.InputStream is, ModelListener l) {
+ boolean ret=false;
+
+ try {
+
+ // Parse an XML document into a DOM tree.
+ DocumentBuilderFactory f=DocumentBuilderFactory.newInstance();
+ f.setNamespaceAware(true);
+
+ DocumentBuilder parser=f.newDocumentBuilder();
+
+ Document document = parser.parse(is);
+
+ // Create a SchemaFactory capable of understanding WXS schemas.
+ SchemaFactory factory =
+ SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+
+ // Load a WXS schema, represented by a Schema instance.
+ java.io.InputStream schemais=TAPValidator.class.getResourceAsStream("/tap.xsd");
+
+ Source schemaFile = new StreamSource(schemais);
+ Schema schema = factory.newSchema(schemaFile);
+
+ schemais.close();
+
+ // Create a Validator object, which can be used to validate
+ // an instance document.
+ Validator validator = schema.newValidator();
+
+ // Validate the DOM tree.
+ validator.validate(new DOMSource(document));
+
+ ret = true;
+
+ } catch (ParserConfigurationException e) {
+ l.error(new ModelIssue(null, "Failed to parse TAP document: "+e.getMessage()));
+ } catch (SAXException e) {
+ l.error(new ModelIssue(null, "Invalid TAP document: "+e.getMessage()));
+ } catch (IOException e) {
+ l.error(new ModelIssue(null, "Failed to load TAP document: "+e.getMessage()));
+ }
+
+ return(ret);
+ }
+
+ protected ResourceLoader getResourceLoader(Resource resource) {
+ ResourceLoader ret=null;
+
+ try {
+ for (ResourceLoader rl : m_resourceLoaders) {
+ if (rl.isSupported(resource)) {
+ ret = rl;
+
+ if (ret != null) {
+ break;
+ }
+ }
+ }
+ } catch(Exception e) {
+ logger.log(Level.SEVERE, "Failed to get resource loader for resource '"+
+ resource.getId()+"'", e);
+ }
+
+ return(ret);
+ }
+
+ protected ModelListener getResourceModelListener(Resource resource) {
+ ModelListener ret=null;
+
+ for (ResourceLoader rl : m_resourceLoaders) {
+ if (rl.isSupported(resource)) {
+ ret = rl.getResourceModelListener(resource);
+
+ if (ret != null) {
+ break;
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ protected void freeResourceModelListener(Resource resource, ModelListener l) {
+
+ for (ResourceLoader rl : m_resourceLoaders) {
+ if (rl.isSupported(resource)) {
+ rl.freeResourceModelListener(resource, l);
+ break;
+ }
+ }
+ }
+
+ public class InnerModelListener implements ModelListener {
+
+ private ModelListener m_listener=null;
+ private ModelReference m_reference=null;
+
+ public InnerModelListener(ModelReference ref, ModelListener l) {
+ m_reference = ref;
+ m_listener = l;
+ }
+
+ public void error(ModelIssue issue) {
+
+ ShowReferencedDescription res=new ShowReferencedDescription();
+ res.setModel(m_reference);
+
+ if (issue.getModelObject() != null) {
+ res.setSourceReference(issue.getModelObject().getSource());
+ }
+
+ issue.getResolutions().add(res);
+
+ m_listener.error(issue);
+ }
+
+ public void warning(ModelIssue issue) {
+ ShowReferencedDescription res=new ShowReferencedDescription();
+ res.setModel(m_reference);
+ res.setSourceReference(issue.getModelObject().getSource());
+
+ issue.getResolutions().add(res);
+
+ m_listener.warning(issue);
+ }
+ }
+}
Added: trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/cdl/CDMScenarioRelationshipValidator.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/cdl/CDMScenarioRelationshipValidator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/cdl/CDMScenarioRelationshipValidator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,114 @@
+/*
+ * 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.tap.validation.cdl;
+
+import org.pi4soa.cdl.CDLManager;
+import org.savara.tap.model.Relationship;
+import org.savara.tap.model.Resource;
+import org.savara.tap.model.admin.ResourceLoader;
+import org.savara.tap.validation.RelationshipValidator;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+public class CDMScenarioRelationshipValidator implements RelationshipValidator {
+
+ /**
+ * This method determines whether the validator supports the
+ * supplied resource and relationship types.
+ *
+ * @param rel The relationship details
+ * @param fromResource The 'from' resource to be validated
+ * @param toResource The 'to' resource to be validated
+ * @return Whether the validator supports the resource types
+ */
+ public boolean isSupported(Relationship rel, Resource fromResource, Resource toResource) {
+ boolean ret=false;
+
+ if (fromResource.getId().endsWith(".cdm") && toResource.getId().endsWith(".scn")) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method validates the supplied resources and relationship,
+ * and reports any issues to the supplied model listener.
+ *
+ * @param rel The relationship details
+ * @param fromResource The 'from' resource to be validated
+ * @param fromRL The 'from' resource loader
+ * @param toResource The 'to' resource to be validated
+ * @param toRL The 'to' resource loader
+ * @param l The model listener
+ */
+ public void validate(Relationship rel, Resource fromResource, final ResourceLoader fromRL,
+ Resource toResource, final ResourceLoader toRL, ModelListener l) {
+ java.net.URI cdmURI=fromRL.getURI(fromResource);
+ java.net.URI scnURI=toRL.getURI(toResource);
+
+ Simulator simulator=new Simulator(scnURI.getPath(), cdmURI.getPath());
+
+ simulator.run();
+
+ if (simulator.isFailed()) {
+ l.error(new ModelIssue(null, "Choreography does not satisfy scenario with id '"+
+ toResource.getId()+"'"));
+ }
+ }
+
+ public class Simulator extends org.pi4soa.scenario.simulation.ScenarioSimulator {
+
+ private String m_cdmPath=null;
+ private boolean m_failed=false;
+
+ public Simulator(String scenarioPath, String cdmPath) {
+ super(scenarioPath, null);
+
+ m_cdmPath = cdmPath;
+ }
+
+ @Override
+ protected org.pi4soa.cdl.Package loadCDL(String cdlurl,
+ String scenarioFile) {
+ // Ignore the parameters and use the TAP configured file
+ org.pi4soa.cdl.Package ret=null;
+
+ try {
+ ret = CDLManager.load(m_cdmPath);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return(ret);
+ }
+
+ @Override
+ protected void failed(String id, String text) {
+ m_failed = true;
+ }
+
+ public boolean isFailed() {
+ return(m_failed);
+ }
+ }
+}
Added: trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/osgi/Activator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,106 @@
+package org.savara.tap.validation.osgi;
+
+import java.util.logging.Logger;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.savara.tap.model.admin.ResourceLoader;
+import org.savara.tap.validation.RelationshipValidator;
+import org.savara.tap.validation.ResourceValidator;
+import org.savara.tap.validation.TAPValidator;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin implements org.eclipse.ui.IStartup {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.savara.tap.validation"; //$NON-NLS-1$
+
+ private static Logger logger=Logger.getLogger(Activator.class.getName());
+
+ // 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 {
+ super.start(context);
+ plugin = this;
+
+ // Get resource loaders
+ ServiceReference[] srefs=context.getServiceReferences(ResourceLoader.class.getName(), null);
+
+ if (srefs != null) {
+ for (ServiceReference sr : srefs) {
+ ResourceLoader rl=(ResourceLoader)context.getService(sr);
+
+ if (rl != null) {
+ TAPValidator.getInstance().addResourceLoader(rl);
+ } else {
+ logger.severe("ResourceLoader does not exist for service ref: "+sr);
+ }
+ }
+ }
+
+ // Get resource validators
+ srefs = context.getServiceReferences(ResourceValidator.class.getName(), null);
+
+ if (srefs != null) {
+ for (ServiceReference sr : srefs) {
+ ResourceValidator rv=(ResourceValidator)context.getService(sr);
+
+ if (rv != null) {
+ TAPValidator.getInstance().addResourceValidator(rv);
+ } else {
+ logger.severe("ResourceValidator does not exist for service ref: "+sr);
+ }
+ }
+ }
+
+ // Get relationship validators
+ srefs = context.getServiceReferences(RelationshipValidator.class.getName(), null);
+
+ if (srefs != null) {
+ for (ServiceReference sr : srefs) {
+ RelationshipValidator rv=(RelationshipValidator)context.getService(sr);
+
+ if (rv != null) {
+ TAPValidator.getInstance().addRelationshipValidator(rv);
+ } else {
+ logger.severe("RelationshipValidator does not exist for service ref: "+sr);
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public void earlyStartup() {
+ }
+}
Added: trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/ws/BPELCDMRelationshipValidator.java
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/ws/BPELCDMRelationshipValidator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/src/java/org/savara/tap/validation/ws/BPELCDMRelationshipValidator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,175 @@
+/*
+ * 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.tap.validation.ws;
+
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+
+import org.savara.tap.model.Link;
+import org.savara.tap.model.Relationship;
+import org.savara.tap.model.Resource;
+import org.savara.tap.model.admin.ResourceLoader;
+import org.savara.tap.validation.RelationshipValidator;
+import org.scribble.model.Model;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Role;
+import org.scribble.model.admin.Context;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+public class BPELCDMRelationshipValidator implements RelationshipValidator {
+
+ /**
+ * This method determines whether the validator supports the
+ * supplied resource and relationship types.
+ *
+ * @param rel The relationship details
+ * @param fromResource The 'from' resource to be validated
+ * @param toResource The 'to' resource to be validated
+ * @return Whether the validator supports the resource types
+ */
+ public boolean isSupported(Relationship rel, Resource fromResource, Resource toResource) {
+ boolean ret=false;
+
+ // NOTE: When more than one choreography model is available, we may need to just find
+ // a way to identify whether a parser exists to convert the 'toResource' into a
+ // global protocol model
+ if (fromResource.getId().endsWith(".bpel") && toResource.getId().endsWith(".cdm")) {
+
+ // Check that a link exists with type 'role' and a 'to' field containing the target
+ // role (or participant in CDL case)
+ for (Link link : rel.getLink()) {
+ if (link.getType().equals("role") && link.getTo() != null) {
+ ret = true;
+ break;
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method validates the supplied resources and relationship,
+ * and reports any issues to the supplied model listener.
+ *
+ * @param rel The relationship details
+ * @param fromResource The 'from' resource to be validated
+ * @param fromRL The 'from' resource loader
+ * @param toResource The 'to' resource to be validated
+ * @param toRL The 'to' resource loader
+ * @param l The model listener
+ */
+ public void validate(Relationship rel, Resource fromResource, final ResourceLoader fromRL,
+ Resource toResource, final ResourceLoader toRL, ModelListener l) {
+ String roleName=null;
+
+ // Get the 'to' role associated with the link
+ for (Link link : rel.getLink()) {
+ if (link.getType().equals("role") && link.getTo() != null) {
+ roleName = link.getTo();
+ break;
+ }
+ }
+
+ if (roleName == null) {
+ ModelIssue issue=new ModelIssue();
+ issue.setMessage("Role not defined on relationship link");
+ l.error(issue);
+ } else {
+ org.scribble.parser.Parser p=new org.scribble.parser.DefaultParser();
+
+ org.scribble.model.ModelReference fromRef=fromRL.getModelReference(fromResource);
+ //new org.scribble.model.ModelReference("bpel");
+
+ java.io.InputStream fromIS=fromRL.getContents(fromResource);
+
+ org.scribble.model.Model fromModel=p.parse(fromRef, fromIS, l,
+ new ResourceLoaderContext(fromRL));
+
+ if (fromModel == null) {
+ ModelIssue issue=new ModelIssue();
+ issue.setMessage("Failed to parse '"+fromResource.getId()+"'");
+ l.error(issue);
+ } else {
+
+ org.scribble.model.ModelReference toRef=toRL.getModelReference(toResource);
+ //new org.scribble.model.ModelReference("cdm");
+
+ java.io.InputStream toIS=fromRL.getContents(toResource);
+
+ org.scribble.model.Model toModel=p.parse(toRef, toIS, l,
+ new ResourceLoaderContext(toRL));
+
+ if (toModel == null) {
+ ModelIssue issue=new ModelIssue();
+ issue.setMessage("Failed to parse related resource '"+toResource.getId()+
+ "' for resource '"+fromResource.getId()+"'");
+ l.error(issue);
+
+ } else {
+ org.scribble.projector.Projector projector=new org.scribble.projector.DefaultProjector();
+
+ Role role=new Role(roleName);
+
+ org.scribble.model.Model toLocalModel=projector.project(toRef, toModel, role, l);
+
+ if (toLocalModel == null) {
+ ModelIssue issue=new ModelIssue();
+ issue.setMessage("Failed to project related resource '"+toResource.getId()+
+ "', role '"+roleName+"', for resource '"+fromResource.getId()+"'");
+ l.error(issue);
+ } else {
+ org.scribble.comparator.Comparator comparator=new org.scribble.comparator.DefaultComparator();
+
+ if (comparator.compare((Model)fromModel, fromRef, (Model)toLocalModel, toRef, l)) {
+ //System.out.println("COMPARE OK");
+ } else {
+ //System.out.println("COMPARE NOT OK");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public class ResourceLoaderContext implements Context {
+
+ private ResourceLoader m_resourceLoader=null;
+
+ public ResourceLoaderContext(ResourceLoader rl) {
+ m_resourceLoader = rl;
+ }
+
+ @Override
+ public InputStream getResource(ModelReference ref, String uri) {
+ return(m_resourceLoader.getContents(ref, uri));
+ }
+
+ @Override
+ public java.net.URI getResourceURI(ModelReference ref, String uri) {
+ return(m_resourceLoader.getURI(ref, uri));
+ }
+
+ }
+}
Added: trunk/tools/plugins/org.savara.tap.validation/src/resources/tap.xsd
===================================================================
--- trunk/tools/plugins/org.savara.tap.validation/src/resources/tap.xsd (rev 0)
+++ trunk/tools/plugins/org.savara.tap.validation/src/resources/tap.xsd 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema targetNamespace="http://www.savara.org/ta/project" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.savara.org/ta/project">
+
+
+ <complexType name="Project">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="phase" type="tns:Phase"
+ maxOccurs="unbounded" minOccurs="0">
+ </element>
+ </sequence>
+ <attribute name="name" type="string" use="required"></attribute>
+ <attribute name="version" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Phase">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="resource" type="tns:Resource" maxOccurs="unbounded" minOccurs="0"></element>
+ </sequence>
+ <attribute name="name" type="string" use="required"></attribute>
+
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Resource">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="uri" type="tns:URI"
+ maxOccurs="unbounded" minOccurs="0">
+ </element>
+ <element name="relationship" type="tns:Relationship" maxOccurs="unbounded" minOccurs="0"></element>
+ </sequence>
+ <attribute name="id" type="ID" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Relationship">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="link" type="tns:Link"
+ maxOccurs="unbounded" minOccurs="0">
+ </element>
+ </sequence>
+ <attribute name="ref" type="IDREF" use="required"></attribute>
+ <attribute name="type" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Link">
+ <complexContent>
+ <extension base="tns:Root">
+ <attribute name="from" type="string"></attribute>
+
+ <attribute name="to" type="string"></attribute>
+
+ <attribute name="type" type="string" use="required"></attribute>
+
+ </extension>
+ </complexContent>
+ </complexType>
+
+
+ <complexType name="Root">
+ <sequence>
+ <element name="description" type="string" maxOccurs="1"
+ minOccurs="0">
+ </element>
+ <any namespace="##other" processContents="lax" maxOccurs="100"
+ minOccurs="0" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="URI">
+ <complexContent>
+ <extension base="tns:Root">
+ <attribute name="type" type="string" use="required"></attribute>
+ <attribute name="context" type="string" use="required"></attribute>
+ <attribute name="locator" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="project" type="tns:Project"></element>
+</schema>
Added: trunk/tools/plugins/org.savara.tools.bpel/.classpath
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/.classpath (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/plugins/org.savara.tools.bpel/.project
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/.project (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.tools.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/tools/plugins/org.savara.tools.bpel/Copyright.txt
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/Copyright.txt (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/Copyright.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/tools/plugins/org.savara.tools.bpel/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA Tools BPEL Plug-in
+Bundle-SymbolicName: org.savara.tools.bpel;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.tools.bpel.osgi.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ 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.eclipse.core.resources,
+ org.scribble.eclipse;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jdt.core,
+ org.junit,
+ 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.tools.wsdl,
+ org.eclipse.ui.ide,
+ org.eclipse.jst.common.frameworks,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.wst.common.project.facet.core,
+ org.savara.wsdl,
+ org.savara.bpel,
+ org.savara.core
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: www.savara.org
+Scribble-Extensions: org.savara.tools.bpel.editor.BPELEditorManager
Added: trunk/tools/plugins/org.savara.tools.bpel/build.properties
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/build.properties (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,13 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ Copyright.txt
+src.includes = src/,\
+ plugin.xml,\
+ build.properties,\
+ META-INF/,\
+ Copyright.txt,\
+ .project,\
+ .classpath
Added: trunk/tools/plugins/org.savara.tools.bpel/plugin.xml
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/plugin.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/plugin.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ id="org.jboss.tools.overlord.cdl.bpel.object.contribution"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.cdm">
+ <menu
+ id="org.savara.tools.menu"
+ label="Savara"
+ path="additions">
+ <separator name="group1"/>
+ </menu>
+ <menu
+ id="generate.menu"
+ label="Generate"
+ path="org.savara.tools.menu/additions">
+ <separator name="group2"/>
+ </menu>
+ <action
+ label="WS-BPEL"
+ class="org.savara.tools.bpel.actions.GenerateAction"
+ menubarPath="org.savara.tools.menu/generate.menu/group2"
+ enablesFor="1"
+ id="org.savara.tools.bpel.actions.GenerateAction">
+ </action>
+ </objectContribution>
+ </extension>
+
+</plugin>
Added: trunk/tools/plugins/org.savara.tools.bpel/pom.xml
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/pom.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.tools</groupId>
+ <artifactId>org.savara.tools.bpel</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ToolsBPEL</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <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.expression.xpath</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.savara.contract.model</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.bpel</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
Added: trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/actions/GenerateAction.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/actions/GenerateAction.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/actions/GenerateAction.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,115 @@
+/*
+ * 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.bpel.actions;
+
+import org.apache.commons.logging.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import org.savara.tools.bpel.dialogs.*;
+import org.scribble.eclipse.util.*;
+
+
+/**
+ * This class implements the action to generate the choreography
+ * as a BPEL process.
+ */
+public class GenerateAction implements IObjectActionDelegate {
+
+ private static final String CANNOT_GENERATE = "Choreography has errors, so cannot generate";
+
+ public GenerateAction() {
+ }
+
+ /**
+ * This method implements the action's run method.
+ *
+ * @param action The action
+ */
+ public void run(IAction action) {
+ if (m_selection instanceof StructuredSelection) {
+ StructuredSelection sel=(StructuredSelection)m_selection;
+
+ IResource res=(IResource)sel.getFirstElement();
+
+ if (res instanceof IFile) {
+
+ if (ResourceUtil.hasErrors(res) == false) {
+ GenerateDialog dialog=
+ new GenerateDialog(m_targetPart.getSite().getShell(),
+ (IFile)res);
+
+ try {
+ dialog.open();
+ } catch(Throwable e) {
+ logger.error("Failed to open generate dialog", e);
+ }
+ } else {
+ warn(CANNOT_GENERATE);
+ }
+ }
+ }
+ }
+
+ /**
+ * This method indicates that the selection has changed.
+ *
+ * @param action The action
+ * @param selection The selection
+ */
+ public void selectionChanged(IAction action,
+ ISelection selection) {
+ m_selection = selection;
+ }
+
+ /**
+ * This method sets the currently active workbench part.
+ *
+ * @param action The action
+ * @param targetPart The active workbench part
+ */
+ public void setActivePart(IAction action,
+ IWorkbenchPart targetPart) {
+ m_targetPart = targetPart;
+ }
+
+ /**
+ * This method is used to report a warning.
+ *
+ * @param mesg The warning message
+ */
+ public void warn(String mesg) {
+
+ MessageBox mbox=new MessageBox(m_targetPart.getSite().getShell(),
+ SWT.ICON_WARNING|SWT.OK);
+ mbox.setMessage(mesg);
+ mbox.open();
+ }
+
+ private static Log logger = LogFactory.getLog(GenerateAction.class);
+
+ private ISelection m_selection=null;
+ private IWorkbenchPart m_targetPart=null;
+}
Added: trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/dialogs/GenerateDialog.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/dialogs/GenerateDialog.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/dialogs/GenerateDialog.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,344 @@
+/*
+ * 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.bpel.dialogs;
+
+import org.apache.commons.logging.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+import org.savara.tools.bpel.generator.*;
+import org.scribble.conversation.model.ConversationModel;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.model.admin.ModelRepository;
+
+/**
+ * This class provides the dialog for generating BPEL
+ * artefacts.
+ */
+public class GenerateDialog extends org.eclipse.jface.dialogs.Dialog {
+
+ /**
+ * This is the constructor for the generate dialog.
+ *
+ * @param shell The shell
+ */
+ public GenerateDialog(Shell shell, IFile file) {
+ super(shell);
+
+ m_file = file;
+
+ initialize(m_file);
+ }
+
+ /**
+ * This method initializes the conversation model associated
+ * with the supplied file resource.
+ *
+ * @param res The file
+ */
+ protected void initialize(IFile res) {
+ ModelReference ref=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.createReference(res);
+
+ if (ref != null) {
+ ModelRepository mrep=(ModelRepository)
+ RegistryFactory.getRegistry().getExtension(
+ ModelRepository.class, null);
+
+ if (mrep != null) {
+ Model model=mrep.getModel(ref,
+ new DefaultModelListener());
+
+ if (model instanceof ConversationModel) {
+ m_conversationModel = (ConversationModel)model;
+
+ m_localModelRefs = m_conversationModel.getLocalModels(ref);
+ }
+ }
+ }
+
+ if (m_conversationModel == null) {
+ error("Unable to load model used to generate " +
+ "the BPEL artefacts", null);
+ }
+ }
+
+ /**
+ * This method creates the dialog details.
+ *
+ * @param parent The parent control
+ * @return The control containing the dialog components
+ */
+ protected Control createDialogArea(Composite parent) {
+
+ Composite composite=(Composite)super.createDialogArea(parent);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+
+ GridData gd=null;
+
+ Group group=new Group(composite, SWT.H_SCROLL|SWT.V_SCROLL);
+
+ gd=new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.horizontalSpan = 1;
+ gd.widthHint = 530;
+ gd.grabExcessHorizontalSpace = true;
+ group.setLayoutData(gd);
+
+ layout = new GridLayout();
+ layout.numColumns = 4;
+ group.setLayout(layout);
+
+ // Labels
+ Label label=new Label(group, SWT.NONE);
+ label.setText("Service Role");
+
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.widthHint = 150;
+ label.setLayoutData(gd);
+
+ label = new Label(group, SWT.NONE);
+ label.setText("Project Name");
+
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.widthHint = 300;
+ label.setLayoutData(gd);
+
+ if (m_conversationModel != null) {
+
+ for (int i=0; i < m_localModelRefs.size(); i++) {
+
+ Button button=new Button(group, SWT.CHECK);
+ button.setText(m_localModelRefs.get(i).getLocatedRole());
+ button.setSelection(true);
+
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.widthHint = 150;
+ button.setLayoutData(gd);
+
+ m_roleButtons.add(button);
+
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ checkStatus();
+ }
+ });
+
+ Text projectName=new Text(group, SWT.NONE);
+
+ String prjName=m_localModelRefs.get(i).getLocatedRole();
+
+ if (m_conversationModel.getModelName() != null) {
+ prjName = m_conversationModel.getModelName().getName()+"-"+prjName;
+ }
+
+ projectName.setText(prjName);
+
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.widthHint = 300;
+ projectName.setLayoutData(gd);
+
+ m_projectNames.add(projectName);
+
+ projectName.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ checkStatus();
+ }
+ });
+
+ }
+ }
+
+ Button button=new Button(group, SWT.NONE);
+ button.setText("Check All");
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 100;
+ button.setLayoutData(gd);
+
+ button.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ for (int i=0; i < m_roleButtons.size(); i++) {
+ m_roleButtons.get(i).setSelection(true);
+ }
+ checkStatus();
+ }
+ });
+
+ button=new Button(group, SWT.NONE);
+ button.setText("Clear All");
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 100;
+ button.setLayoutData(gd);
+
+ button.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ for (int i=0; i < m_roleButtons.size(); i++) {
+ m_roleButtons.get(i).setSelection(false);
+ }
+ checkStatus();
+ }
+ });
+
+ return(composite);
+ }
+
+ @Override
+ protected Control createButtonBar(Composite parent) {
+ Control ret=super.createButtonBar(parent);
+
+ checkStatus();
+
+ return(ret);
+ }
+
+ protected void checkStatus() {
+ int selected=0;
+ boolean f_error=false;
+
+ for (int i=0; i < m_roleButtons.size(); i++) {
+ if (m_roleButtons.get(i).getSelection()) {
+ selected++;
+
+ m_projectNames.get(i).setEnabled(true);
+
+ // Check project name
+ String projectName=m_projectNames.get(i).getText();
+
+ if (isProjectNameValid(projectName) == false) {
+ f_error = true;
+
+ m_projectNames.get(i).setBackground(
+ Display.getCurrent().getSystemColor(SWT.COLOR_RED));
+ } else {
+ m_projectNames.get(i).setBackground(
+ Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+ }
+ } else {
+ m_projectNames.get(i).setEnabled(false);
+ m_projectNames.get(i).setBackground(
+ Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+ }
+ }
+
+ if (f_error || selected == 0) {
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ } else {
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+ }
+ }
+
+ protected boolean isProjectNameValid(String name) {
+ boolean ret=true;
+
+ if (name == null || name.trim().length() == 0) {
+ ret = false;
+ } else if (m_file.getWorkspace().getRoot().getProject(name).exists()) {
+ ret = false;
+ } else {
+ for (int i=0; ret && i < name.length(); i++) {
+ if (i == 0) {
+ ret = Character.isJavaIdentifierStart(name.charAt(i));
+ } else if ("-.".indexOf(name.charAt(i)) != -1) {
+ ret = true;
+ } else {
+ ret = Character.isJavaIdentifierPart(name.charAt(i));
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * The ok button has been pressed.
+ */
+ public void okPressed() {
+
+ try {
+ Generator generator=new Generator(m_file);
+
+ for (int i=0; i < m_localModelRefs.size(); i++) {
+
+ if (m_roleButtons.get(i).getSelection()) {
+ generator.generateRole(m_localModelRefs.get(i),
+ m_projectNames.get(i).getText(), m_file);
+ }
+ }
+
+ super.okPressed();
+ } catch(Exception e) {
+ error("Failed to generate BPEL artefacts", e);
+ }
+ }
+
+ /**
+ * This method is used to report an error.
+ *
+ * @param mesg The error message
+ * @param ex The exception
+ */
+ public void error(String mesg, Exception ex) {
+
+ org.savara.tools.bpel.osgi.Activator.logError(mesg, ex);
+
+ MessageBox mbox=new MessageBox(getShell(),
+ SWT.ICON_ERROR|SWT.OK);
+ mbox.setMessage(mesg);
+ mbox.open();
+
+ logger.error(mesg, ex);
+ }
+
+ private static Log logger = LogFactory.getLog(GenerateDialog.class);
+
+ private IFile m_file=null;
+ private ConversationModel m_conversationModel=null;
+ private java.util.List<ModelReference> m_localModelRefs=null;
+ private java.util.List<Button> m_roleButtons=new java.util.Vector<Button>();
+ private java.util.List<Text> m_projectNames=new java.util.Vector<Text>();
+}
Added: trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/editor/BPELEditorManager.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/editor/BPELEditorManager.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/editor/BPELEditorManager.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.tools.bpel.editor;
+
+//import org.eclipse.emf.ecore.EValidator;
+import org.savara.bpel.model.BPELNotation;
+import org.savara.bpel.model.component.BPELElement;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.editor.*;
+
+/**
+ * This is the BPEL editor implementation of the EditorManager
+ * interface.
+ */
+ at RegistryInfo(extension=EditorManager.class,notation=BPELNotation.NOTATION_CODE)
+public class BPELEditorManager extends AbstractEditorManager {
+
+ /**
+ * 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) {
+ String uri=null;
+ org.eclipse.core.resources.IFile file=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.getFile(mref);
+
+ if (file == null || file.exists() == false) {
+ file = org.scribble.eclipse.model.admin.OSGIModelRepository.getGlobalFile(mref);
+ }
+
+ if (file != null && file.exists()) {
+ uri = file.getFullPath().toPortableString();
+ }
+
+ if (uri != null) {
+ org.eclipse.ui.IWorkbenchPage page=
+ org.eclipse.ui.PlatformUI.getWorkbench().
+ getActiveWorkbenchWindow().getActivePage();
+
+ org.eclipse.core.resources.IResource res=
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(uri);
+
+ if (res instanceof org.eclipse.core.resources.IFile) {
+ org.eclipse.ui.part.FileEditorInput input=
+ new org.eclipse.ui.part.FileEditorInput(
+ (org.eclipse.core.resources.IFile)res);
+
+ try {
+// org.eclipse.ui.IEditorPart part=page.openEditor(input,
+// "org.eclipse.stp.bpmn.diagram.part.BpmnDiagramEditorID");
+
+// if (part instanceof org.eclipse.stp.bpmn.diagram.part.BpmnDiagramEditor) {
+// org.eclipse.stp.bpmn.diagram.part.BpmnDiagramEditor editor=
+// (org.eclipse.stp.bpmn.diagram.part.BpmnDiagramEditor)part;
+
+ System.out.println("FOCUS ON: "+sref.getComponentURI());
+ //editor.showComponent(sref.getComponentURI());
+// }
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * This method enriches the set of properties required
+ * by the editor, using the properties associated with
+ * the model issue.
+ *
+ * @param issue The model issue
+ */
+ @Override
+ public void enrich(ModelIssue issue) {
+
+ if (issue != null && issue.getModelObject() != null) {
+ String uri=issue.getModelObject().getSource().getComponentURI();
+
+ issue.getProperties().put("address.model", uri);
+ }
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,865 @@
+/*
+ * 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.bpel.generator;
+
+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.apache.commons.logging.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.component.PartnerLink;
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.Interface;
+import org.savara.contract.model.Namespace;
+import org.savara.util.XMLUtils;
+import org.savara.wsdl.generator.WSDLGeneratorFactory;
+import org.savara.wsdl.generator.soap.SOAPDocLitWSDLBinding;
+import 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;
+import org.scribble.model.change.ModelGenerator;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jst.common.project.facet.WtpUtils;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+
+/**
+ * This class provides the mechanism for generating JBossESB
+ * service artefacts.
+ */
+public class Generator {
+
+ private static final String SCHEMA_LOCATION_ATTR = "schemaLocation";
+
+ private static final String INCLUDE_ELEMENT = "include";
+
+ private static final String XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
+
+ private static final String WSDL_IMPORT = "wsdl:import";
+
+ private static final String BPEL_DEPLOY_DESCRIPTOR_FILENAME = "bpel-deploy.xml";
+
+ private static final String XMLNS_PREFIX = "xmlns:";
+
+ private static final String SERVICE_LABEL = "service";
+
+ private static final String PROVIDE_LABEL = "provide";
+
+ private static final String PARTNER_LINK_LABEL = "partnerLink";
+
+ private static final String INVOKE_LABEL = "invoke";
+
+ private static final String ACTIVE_LABEL = "active";
+
+ private static final String PROCESS_LABEL = "process";
+
+ private static final String DEPLOY_LABEL = "deploy";
+
+ private static final String APACHE_ODE_NAMESPACE = "http://www.apache.org/ode/schemas/dd/2007/03";
+
+ private static final String PORT_TYPE_LABEL = "portType";
+
+ private static final String TARGET_NAMESPACE_LABEL = "targetNamespace";
+
+ private static final String PLNK_ROLE = "plnk:role";
+
+ private static final String NAME_LABEL = "name";
+
+ private static final String PLNK_PARTNER_LINK_TYPE = "plnk:partnerLinkType";
+
+ private static final String WSDL_DEFINITIONS = "wsdl:definitions";
+
+ private static final String WSDL_NS = "http://schemas.xmlsoap.org/wsdl/";
+
+ private static final String PLNKTYPE_NS = "http://docs.oasis-open.org/wsbpel/2.0/plnktype";
+
+ private static final String XMLNS_WSDL = "xmlns:wsdl";
+
+ private static final String XMLNS_PLNK = "xmlns:plnk";
+
+ private static final String BPEL_PATH = "bpelContent";
+
+ /**
+ * This is the constructor for the generator.
+ *
+ */
+ public Generator(IFile file) {
+ m_file = file;
+
+ initialize(m_file);
+ }
+
+ /**
+ * This method initializes the conversation model associated
+ * with the supplied file resource.
+ *
+ * @param res The file
+ */
+ protected void initialize(IFile res) {
+
+ // Initialize the model
+ ModelReference ref=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.createReference(res);
+
+ if (ref != null) {
+ ModelRepository mrep=(ModelRepository)
+ RegistryFactory.getRegistry().getExtension(
+ ModelRepository.class, null);
+
+ if (mrep != null) {
+ Model model=mrep.getModel(ref,
+ new DefaultModelListener());
+
+ if (model instanceof ConversationModel) {
+ m_conversationModel = (ConversationModel)model;
+
+ m_localModelRefs = m_conversationModel.getLocalModels(ref);
+ }
+ }
+ }
+
+ if (m_conversationModel == null) {
+ logger.error("Unable to load model used to generate " +
+ "the ESB artefacts");
+ }
+ }
+
+ /**
+ * This method returns the local model references that
+ * can be generated.
+ *
+ * @return The local model references
+ */
+ public java.util.List<ModelReference> getLocalModels() {
+ return(m_localModelRefs);
+ }
+
+ /**
+ * This method generates the project associated with the
+ * supplied role (and optional sub-definition path) contained
+ * in the local model reference.
+ *
+ * @param localModelRef The local model reference
+ * @param projectName The project name
+ * @param cdmResource The original choreography file
+ * @throws Exception Failed to generate role
+ */
+ public void generateRole(ModelReference localModelRef, String projectName, IFile cdmResource)
+ throws Exception {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Generate local model '"+localModelRef+"' for: "+
+ m_conversationModel);
+ }
+
+ // Project to role
+ org.scribble.projector.Projector projector=
+ (org.scribble.projector.Projector)
+ RegistryFactory.getRegistry().getExtension(
+ org.scribble.projector.Projector.class, null);
+
+ if (projector != null) {
+ Role role=new Role(localModelRef.getLocatedRole());
+
+ // Transfer contract details (if defined) from local model
+ // reference to role
+ if (localModelRef.getAnnotations().containsKey(org.savara.contract.model.Contract.class.getName())) {
+ role.getAnnotations().put(org.savara.contract.model.Contract.class.getName(),
+ localModelRef.getAnnotations().get(org.savara.contract.model.Contract.class.getName()));
+ }
+
+ ModelReference srcRef=
+ new ModelReference(ConversationNotation.NOTATION_CODE);
+
+ Model localModel=projector.project(srcRef, m_conversationModel,
+ localModelRef.getSubDefinitionPath(), role,
+ new DefaultModelListener());
+
+ if (localModel instanceof ConversationModel &&
+ ((ConversationModel)localModel).getConversation() != null) {
+ ConversationModel lcm=(ConversationModel)localModel;
+
+ ModelReference targetRef=
+ new ModelReference(BPELNotation.NOTATION_CODE);
+
+ DefaultBPELLanguageModel target=
+ new DefaultBPELLanguageModel(targetRef);
+
+ ModelGenerator generator=(ModelGenerator)
+ RegistryFactory.getRegistry().getExtension(
+ ModelGenerator.class, null);
+
+ if (generator != null) {
+ generator.generate(targetRef, role, target,
+ lcm);
+
+ generateRoleProject(projectName, role,
+ target.getBPELProcess(), lcm, target, cdmResource);
+ } else {
+ logger.error("Unable to find model generator");
+ }
+ }
+ }
+ }
+
+ protected void generateRoleProject(String projectName, Role role,
+ org.savara.bpel.model.component.Process bpelProcess, ConversationModel localcm,
+ BPELLanguageModel model, IFile cdmResource) throws Exception {
+
+ final IProject proj=createProject(projectName);
+
+ if (proj != null && bpelProcess != null) {
+
+ // Store BPEL configuration
+ IPath bpelPath=proj.getFullPath().append(
+ new Path(BPEL_PATH)).
+ append(localcm.getModelName().getName()+"_"+
+ localcm.getModelName().getRole().getName()+".bpel");
+
+ IFile bpelFile=proj.getProject().getWorkspace().getRoot().getFile(bpelPath);
+ createFolder(bpelFile);
+
+ bpelFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ String bpelText=XMLUtils.toText(bpelProcess.getDOMElement());
+
+ if (bpelText != null) {
+ bpelFile.setContents(new java.io.ByteArrayInputStream(
+ bpelText.getBytes()), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+
+ // Write the WSDL files
+ generateWSDL(role, proj, localcm, cdmResource);
+
+ java.util.List<Role> roles=localcm.getConversation().getRoles();
+
+ for (int i=0; i < roles.size(); i++) {
+ generateWSDL(roles.get(i), proj, localcm, cdmResource);
+ }
+
+ // Generate WSDL with partner link types
+ generatePartnerLinkTypes(role, proj, localcm, bpelProcess);
+
+ // Generate BPEL deployment descriptor
+ generateBPELDeploy(role, proj, localcm, bpelProcess);
+ }
+ }
+
+ protected void generateWSDL(Role role, IProject proj, ConversationModel localcm,
+ IFile cdmResource) throws Exception {
+
+ if (role.getAnnotations().containsKey(Contract.class.getName())) {
+ javax.wsdl.xml.WSDLWriter writer=
+ javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
+ org.savara.wsdl.generator.WSDLGenerator generator=
+ WSDLGeneratorFactory.getWSDLGenerator();
+ Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
+
+ // Generate BPEL folder
+ IPath bpelFolderPath=proj.getFullPath().append(
+ new Path(BPEL_PATH));
+
+ IFolder wsdlFolder=proj.getProject().getWorkspace().getRoot().getFolder(bpelFolderPath);
+
+ createFolder(wsdlFolder);
+
+ // Generate definition
+ java.util.List<javax.wsdl.Definition> defns=generator.generate(contract,
+ new SOAPDocLitWSDLBinding());
+
+ // Check if contract has atleast one message exchange pattern
+ boolean f_hasMEP=false;
+
+ java.util.Iterator<Interface> iter=contract.getInterfaces().iterator();
+
+ while (f_hasMEP == false && iter.hasNext()) {
+ Interface intf=iter.next();
+ f_hasMEP = (intf.getMessageExchangePatterns().size() > 0);
+ }
+
+ for (int i=defns.size()-1; i >= 0; i--) {
+ javax.wsdl.Definition defn=defns.get(i);
+
+ // Check if definition has a port type
+ if (defn.getPortTypes().size() > 0 || defn.getMessages().size() > 0
+ || (f_hasMEP && defn.getServices().size() > 0)) {
+ String num="";
+ if (i > 0) {
+ num += i;
+ }
+
+ String filename=getWSDLFileName(role, localcm.getModelName().getName(), num);
+ byte[] b=null;
+
+ if (i > 0) {
+ javax.wsdl.Import imp=defns.get(0).createImport();
+
+ imp.setDefinition(defn);
+ imp.setNamespaceURI(defn.getTargetNamespace());
+ imp.setLocationURI(filename);
+
+ defns.get(0).addImport(imp);
+
+ java.io.ByteArrayOutputStream baos=new java.io.ByteArrayOutputStream();
+
+ writer.writeWSDL(defn, baos);
+
+ b = baos.toByteArray();
+
+ baos.close();
+
+ } else {
+ org.w3c.dom.Document doc=writer.getDocument(defn);
+
+ importSchemas(cdmResource, contract, bpelFolderPath,
+ doc);
+
+ // Create bytearray from DOM
+ java.io.ByteArrayOutputStream xmlstr=
+ new java.io.ByteArrayOutputStream();
+
+ DOMSource source=new DOMSource();
+ source.setNode(doc);
+
+ StreamResult result=new StreamResult(xmlstr);
+
+ Transformer trans=
+ TransformerFactory.newInstance().newTransformer();
+ trans.transform(source, result);
+
+ xmlstr.close();
+
+ b = XMLUtils.format(new String(xmlstr.toByteArray())).getBytes();
+ }
+
+ IPath wsdlPath=bpelFolderPath.append(filename);
+
+ IFile wsdlFile=proj.getProject().getWorkspace().getRoot().getFile(wsdlPath);
+
+ createFolder(wsdlFile);
+
+ if (wsdlFile.exists() == false) {
+ wsdlFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+
+ wsdlFile.setContents(new java.io.ByteArrayInputStream(b), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+ }
+ }
+ }
+
+ protected void importSchemas(IFile cdmResource, Contract contract,
+ IPath bpelFolderPath, org.w3c.dom.Document doc) throws Exception {
+
+ // NOTE: Unfortunate workaround due to issue with WSDLWriter not
+ // generating output for extensible elements created to represent
+ // the xsd:schema/xsd:import elements. So instead had to obtain
+ // the DOM document and insert the relevant elements.
+
+ if (contract.getNamespaces().size() > 0) {
+ org.w3c.dom.Element defnElem=doc.getDocumentElement();
+
+ // Added types node
+ org.w3c.dom.Element types=doc.createElementNS("http://schemas.xmlsoap.org/wsdl/",
+ "types");
+
+ org.w3c.dom.Element schema=doc.createElementNS("http://www.w3.org/2001/XMLSchema",
+ "schema");
+
+ types.appendChild(schema);
+
+ // Generate imports for specified message schema
+ for (Namespace ns : contract.getNamespaces()) {
+
+ if (ns.getSchemaLocation() != null &&
+ ns.getSchemaLocation().trim().length() > 0) {
+
+ java.util.StringTokenizer st=new java.util.StringTokenizer(ns.getSchemaLocation());
+
+ while (st.hasMoreTokens()) {
+ String location=st.nextToken();
+ IFile file=cdmResource.getParent().getFile(new Path(location));
+
+ org.w3c.dom.Element imp=doc.createElementNS("http://www.w3.org/2001/XMLSchema",
+ "import");
+
+ imp.setAttribute("namespace", ns.getURI());
+
+ if (file.exists()) {
+ imp.setAttribute("schemaLocation", file.getProjectRelativePath().toPortableString());
+
+ // Copy schema file into generated BPEL project
+ IPath artifactPath=bpelFolderPath.append(file.getProjectRelativePath());
+
+ IFile artifactFile=cdmResource.getProject().getWorkspace().getRoot().getFile(artifactPath);
+
+ copySchema(file, artifactFile, bpelFolderPath);
+ } else {
+ imp.setAttribute("schemaLocation", location);
+ }
+
+ schema.appendChild(imp);
+ }
+ }
+ }
+
+ defnElem.insertBefore(types, defnElem.getFirstChild());
+ }
+ }
+
+ protected void copySchema(IFile srcXSDFile, IFile targetXSDFile, IPath bpelFolderPath) throws Exception {
+
+ if (targetXSDFile.exists() == false) {
+ createFolder(targetXSDFile.getParent());
+
+ targetXSDFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+
+ targetXSDFile.setContents(srcXSDFile.getContents(), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ // Check XSD for further 'include' statements
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=builder.parse(srcXSDFile.getContents());
+
+ org.w3c.dom.NodeList nl=doc.getElementsByTagNameNS(XML_SCHEMA, INCLUDE_ELEMENT);
+
+ for (int i=0; i < nl.getLength(); i++) {
+ org.w3c.dom.Node includeNode=nl.item(i);
+
+ if (includeNode instanceof org.w3c.dom.Element) {
+ String schemaLocation=((org.w3c.dom.Element)includeNode).getAttribute(SCHEMA_LOCATION_ATTR);
+
+ // Check if a relative path
+ IFile file=srcXSDFile.getParent().getFile(new Path(schemaLocation));
+
+ if (file.exists()) {
+
+ IPath artifactPath=bpelFolderPath.append(file.getProjectRelativePath());
+
+ IFile artifactFile=file.getProject().getWorkspace().getRoot().getFile(artifactPath);
+
+ copySchema(file, artifactFile, bpelFolderPath);
+ }
+ }
+ }
+ }
+
+ protected void generatePartnerLinkTypes(Role role, IProject proj, ConversationModel localcm,
+ org.savara.bpel.model.component.Process bpelProcess) throws Exception {
+
+ org.w3c.dom.Document doc=javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();;
+
+ org.w3c.dom.Element defn=doc.createElement(WSDL_DEFINITIONS);
+ doc.appendChild(defn);
+
+ defn.setAttribute(XMLNS_PLNK, PLNKTYPE_NS);
+ defn.setAttribute(XMLNS_WSDL, WSDL_NS);
+
+ defn.setAttribute(TARGET_NAMESPACE_LABEL, bpelProcess.getTargetNamespace());
+
+ // Add import to associated wsdl
+ String wsdlName=getWSDLFileName(role, localcm.getModelName().getName(), "");
+
+ org.w3c.dom.Element imp=doc.createElement(WSDL_IMPORT);
+
+ imp.setAttribute("namespace", bpelProcess.getTargetNamespace());
+ imp.setAttribute("location", wsdlName);
+
+ defn.appendChild(imp);
+
+ // Add imports for associated roles
+ java.util.ListIterator<Role> roles=localcm.getConversation().getRoles().listIterator();
+
+ while (roles.hasNext()) {
+ Role r=roles.next();
+
+ if (r != null && r.getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)r.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) {
+ wsdlName = getWSDLFileName(r, localcm.getModelName().getName(), "");
+
+ imp = doc.createElement(WSDL_IMPORT);
+
+ imp.setAttribute("namespace", contract.getNamespace());
+ imp.setAttribute("location", wsdlName);
+
+ defn.appendChild(imp);
+ }
+ }
+ }
+
+ // Create partner link types
+ java.util.Map<String, String> nsMap=new java.util.HashMap<String, String>();
+
+ for (PartnerLink pl : bpelProcess.getPartnerLinks()) {
+ org.w3c.dom.Element plt=doc.createElement(PLNK_PARTNER_LINK_TYPE);
+
+ plt.setAttribute(NAME_LABEL, XMLUtils.getLocalname(pl.getPartnerLinkType()));
+
+ if (pl.getPartnerRole() != null && pl.getPartnerRole().trim().length() > 0) {
+ org.w3c.dom.Element plRole=doc.createElement(PLNK_ROLE);
+
+ plt.appendChild(plRole);
+
+ plRole.setAttribute(NAME_LABEL, pl.getPartnerRole());
+
+ Role useRole=null;
+
+ for (int i=0; useRole == null &&
+ i < localcm.getConversation().getRoles().size(); i++) {
+ if (pl.getPartnerRole().startsWith(localcm.getConversation().getRoles().get(i).getName())) {
+ useRole = localcm.getConversation().getRoles().get(i);
+ }
+ }
+
+ if (useRole != null &&
+ useRole.getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)useRole.getAnnotations().get(Contract.class.getName());
+ Interface intf=null;
+
+ if (pl.getMyRole() != null) {
+ intf = contract.getInterface(pl.getMyRole());
+ }
+
+ if (intf == null && contract.getInterfaces().size() > 0) {
+ intf = contract.getInterfaces().iterator().next();
+ }
+
+ if (intf != null) {
+ String prefix=null;
+ String portType=intf.getName();
+
+ if (intf.getNamespace() != null) {
+ prefix = XMLUtils.getPrefix(intf.getNamespace(), nsMap);
+
+ portType = prefix+":"+portType;
+ }
+
+ plRole.setAttribute(PORT_TYPE_LABEL, portType);
+ }
+ }
+ }
+
+ if (pl.getMyRole() != null && pl.getMyRole().trim().length() > 0) {
+ org.w3c.dom.Element plRole=doc.createElement(PLNK_ROLE);
+
+ plt.appendChild(plRole);
+
+ plRole.setAttribute(NAME_LABEL, pl.getMyRole());
+
+ if (role.getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
+ Interface intf=null;
+
+ if (pl.getMyRole() != null) {
+ intf = contract.getInterface(pl.getMyRole());
+ }
+
+ if (intf == null && contract.getInterfaces().size() > 0) {
+ intf = contract.getInterfaces().iterator().next();
+ }
+
+ if (intf != null) {
+ String prefix=null;
+ String portType=intf.getName();
+
+ if (intf.getNamespace() != null) {
+ prefix = XMLUtils.getPrefix(intf.getNamespace(), nsMap);
+
+ portType = prefix+":"+portType;
+ }
+
+ plRole.setAttribute(PORT_TYPE_LABEL, portType);
+ }
+ }
+ }
+
+ defn.appendChild(plt);
+ }
+
+ // Create remaining namespace/prefix mappings
+ java.util.Iterator<String> iter=nsMap.keySet().iterator();
+ while (iter.hasNext()) {
+ String ns=iter.next();
+ String prefix=nsMap.get(ns);
+
+ defn.setAttribute(XMLNS_PREFIX+prefix, ns);
+ }
+
+ // Write partner link types to file
+ String filename=getWSDLFileName(role, localcm.getModelName().getName(), "Artifacts");
+
+ IPath wsdlPath=proj.getFullPath().append(
+ new Path(BPEL_PATH)).
+ append(filename);
+
+ IFile wsdlFile=proj.getProject().getWorkspace().getRoot().getFile(wsdlPath);
+
+ createFolder(wsdlFile);
+
+ wsdlFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ java.io.ByteArrayOutputStream xmlstr=
+ new java.io.ByteArrayOutputStream();
+
+ DOMSource source=new DOMSource();
+ source.setNode(doc);
+
+ StreamResult result=new StreamResult(xmlstr);
+
+ Transformer trans=
+ TransformerFactory.newInstance().newTransformer();
+ trans.transform(source, result);
+
+ xmlstr.close();
+
+ String xml=XMLUtils.format(new String(xmlstr.toByteArray()));
+
+ wsdlFile.setContents(new java.io.ByteArrayInputStream(xml.getBytes()), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+
+
+ protected void generateBPELDeploy(Role role, IProject proj, ConversationModel localcm,
+ org.savara.bpel.model.component.Process bpelProcess) throws Exception {
+
+ org.w3c.dom.Document doc=javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();;
+
+ org.w3c.dom.Element defn=doc.createElementNS(APACHE_ODE_NAMESPACE,
+ DEPLOY_LABEL);
+ doc.appendChild(defn);
+
+ java.util.Map<String, String> nsMap=new java.util.HashMap<String, String>();
+
+ // Create process element
+ org.w3c.dom.Element proc=doc.createElement(PROCESS_LABEL);
+ defn.appendChild(proc);
+
+ String name=bpelProcess.getName();
+
+ if (bpelProcess.getTargetNamespace() != null) {
+ String prefix=XMLUtils.getPrefix(bpelProcess.getTargetNamespace(), nsMap);
+
+ name = prefix+":"+name;
+ }
+
+ proc.setAttribute(NAME_LABEL, name);
+
+ org.w3c.dom.Element active=doc.createElement(ACTIVE_LABEL);
+ proc.appendChild(active);
+
+ org.w3c.dom.Text activeText=doc.createTextNode(Boolean.TRUE.toString());
+ active.appendChild(activeText);
+
+ // TODO: Need more info - possibly Contract should have interfaces based on
+ // the relationship between two roles, as this may provide the necessary
+ // information - but this requires the ability to have multiple interfaces
+ // per role, which some other parts of the BPEL generation would currently
+ // not handle.
+
+ // Work through partner links for now
+ for (PartnerLink pl : bpelProcess.getPartnerLinks()) {
+ if (pl.getPartnerRole() != null && pl.getPartnerRole().trim().length() > 0) {
+ org.w3c.dom.Element invoke=doc.createElement(INVOKE_LABEL);
+
+ invoke.setAttribute(PARTNER_LINK_LABEL, XMLUtils.getLocalname(pl.getName()));
+
+ org.w3c.dom.Element service=doc.createElement(SERVICE_LABEL);
+
+ invoke.appendChild(service);
+
+ proc.appendChild(invoke);
+ }
+
+ if (pl.getMyRole() != null && pl.getMyRole().trim().length() > 0) {
+ org.w3c.dom.Element provide=doc.createElement(PROVIDE_LABEL);
+
+ provide.setAttribute(PARTNER_LINK_LABEL, XMLUtils.getLocalname(pl.getName()));
+
+ org.w3c.dom.Element service=doc.createElement(SERVICE_LABEL);
+
+ provide.appendChild(service);
+
+ proc.appendChild(provide);
+ }
+ }
+
+ // Create remaining namespace/prefix mappings
+ java.util.Iterator<String> iter=nsMap.keySet().iterator();
+ while (iter.hasNext()) {
+ String ns=iter.next();
+ String prefix=nsMap.get(ns);
+
+ defn.setAttribute(XMLNS_PREFIX+prefix, ns);
+ }
+
+ // Write partner link types to file
+ IPath wsdlPath=proj.getFullPath().append(
+ new Path(BPEL_PATH)).
+ append(BPEL_DEPLOY_DESCRIPTOR_FILENAME);
+
+ IFile wsdlFile=proj.getProject().getWorkspace().getRoot().getFile(wsdlPath);
+
+ createFolder(wsdlFile);
+
+ wsdlFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ java.io.ByteArrayOutputStream xmlstr=
+ new java.io.ByteArrayOutputStream();
+
+ DOMSource source=new DOMSource();
+ source.setNode(doc);
+
+ StreamResult result=new StreamResult(xmlstr);
+
+ Transformer trans=
+ TransformerFactory.newInstance().newTransformer();
+ trans.transform(source, result);
+
+ xmlstr.close();
+
+ String xml=XMLUtils.format(new String(xmlstr.toByteArray()));
+
+ wsdlFile.setContents(new java.io.ByteArrayInputStream(xml.getBytes()), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+
+ /**
+ * 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");
+ }
+
+ protected IProject createProject(String projectName)
+ throws Exception {
+
+ // Create project
+ IProject project=m_file.getWorkspace().getRoot().getProject(projectName);
+ project.create(new org.eclipse.core.runtime.NullProgressMonitor());
+
+ // Open the project
+ project.open(new org.eclipse.core.runtime.NullProgressMonitor());
+
+ // Add wtp natures
+ WtpUtils.addNatures(project);
+
+ // Add required project facets
+ IProjectFacet bpelFacet =
+ ProjectFacetsManager.getProjectFacet("jbt.bpel.facet.core");
+ IProjectFacetVersion ipfv = bpelFacet.getVersion("2.0");
+ IFacetedProject ifp = ProjectFacetsManager.create(project, true, null);
+ ifp.installProjectFacet(ipfv, null,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ // Update the project description
+ IProjectDescription description = project.getDescription();
+
+ // Setup project reference to CDM project
+ IProject[] projects=new IProject[1];
+ projects[0] = m_file.getProject();
+ description.setReferencedProjects(projects);
+
+ // Set the description
+ project.setDescription(description,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ return(project);
+ }
+
+ /**
+ * This method checks whether the folder exists,
+ * and if not attempts to create it.
+ *
+ * @param res The current resource
+ */
+ public static void createFolder(IResource res) {
+ if (res instanceof IFolder) {
+ IFolder folder=(IFolder)res;
+
+ if (folder.exists() == false) {
+ createFolder(folder.getParent());
+
+ try {
+ folder.create(true, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ } else if (res.getParent() != null) {
+ createFolder(res.getParent());
+ }
+ }
+
+ /*
+ public BuildSystem getBuildSystem() {
+ return(m_buildSystem);
+ }
+ */
+
+ private static Log logger = LogFactory.getLog(Generator.class);
+
+ private IFile m_file=null;
+ private java.util.List<ModelReference> m_localModelRefs=null;
+ private ConversationModel m_conversationModel=null;
+ //private BuildSystem m_buildSystem=null;
+}
Added: trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/GeneratorException.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/GeneratorException.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/GeneratorException.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.tools.bpel.generator;
+
+public class GeneratorException extends Exception {
+
+ private static final long serialVersionUID = -2263049447116467663L;
+
+ /**
+ * This constructor initializes the generator exception
+ * with a message and the underlying exception that
+ * caused the problem.
+ *
+ * @param mesg The message
+ * @param t The cause
+ */
+ public GeneratorException(String mesg, Throwable t) {
+ super(mesg, t);
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/GeneratorUtil.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/GeneratorUtil.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/GeneratorUtil.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.tools.bpel.generator;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+
+/**
+ * This class provides general utility functions for
+ * use when generating artefacts.
+ */
+public class GeneratorUtil {
+
+ /**
+ * This method checks whether the parent folder exists,
+ * and if not attempts to create it.
+ *
+ * @param res The current resource
+ */
+ public static void createParentFolder(IResource res) {
+
+ if (res.getParent() instanceof IFolder) {
+ IFolder parent=(IFolder)res.getParent();
+
+ if (parent.exists() == false) {
+ createParentFolder(parent);
+
+ try {
+ parent.create(true, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/template/Ant.template
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/template/Ant.template (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/template/Ant.template 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,44 @@
+<project name="%PROJECT%" basedir="." default="deploy" >
+ <property name="build.dir" value="${basedir}/target" />
+ <property name="classes" value="${build.dir}/classes" />
+ <property name="lib" value="src/lib" />
+ <property name="src" value="src/java" />
+ <property name="conf" value="src/conf" />
+
+ <path id="compile-classpath">
+ <fileset dir="${lib}" includes="*.jar" />
+ </path>
+
+ <target name="init" depends="clean">
+ <mkdir dir="${build.dir}" />
+ </target>
+
+ <target name="clean">
+ <delete dir="${build.dir}" />
+ </target>
+
+ <target name="compile" depends="init">
+ <mkdir dir="${classes}" />
+ <javac srcdir="${src}" destdir="${classes}" debug="true" deprecation="true">
+ <classpath refid="compile-classpath" />
+ </javac>
+ <copy todir="${classes}">
+ <fileset dir="${conf}" includes="**/*.xml"/>
+ </copy>
+ </target>
+
+ <target name="esbjar" depends="compile">
+ <jar destfile="${build.dir}/${ant.project.name}.esb">
+ <fileset dir="${classes}" />
+ <fileset dir="${build.dir}" includes="*.jar,*.war"/>
+ <fileset dir="${classes}" includes="deployment.xml"/>
+ <fileset dir="${classes}" includes="META-INF/**" />
+ <fileset dir="${lib}" includes="*.jar"/>
+ </jar>
+ </target>
+
+ <target name="deploy" depends="esbjar">
+ <copy todir="${org.jboss.esb.server.deploy.dir}"
+ file="${build.dir}/${ant.project.name}.esb"/>
+ </target>
+</project>
Added: trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/template/Maven.template
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/template/Maven.template (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/template/Maven.template 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.jboss.soa.overlord.cdl.project</groupId>
+ <artifactId>%PROJECT%</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jboss-esb</packaging>
+ <name>%PROJECT%</name>
+ <url>http://www.jboss.org/overlord</url>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.overlord.cdl</groupId>
+ <artifactId>runtime-jbossesb</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>%PROJECT%</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jboss-packaging-maven-plugin</artifactId>
+ <version>2.0-20080130.110241-9</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots/>
+ <id>jboss-plugin-snapshots</id>
+ <name>JBoss Snapshot Plugin Repository</name>
+ <url>http://snapshots.repository.codehaus.org</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+
+</project>
Added: trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/osgi/Activator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,73 @@
+package org.savara.tools.bpel.osgi;
+
+import org.apache.commons.logging.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.savara.tools.bpel";
+
+ // 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 {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * This method logs an error against the plugin.
+ *
+ * @param mesg The error message
+ * @param t The optional exception
+ */
+ public static void logError(String mesg, Throwable t) {
+
+ if (getDefault() != null) {
+ Status status=new Status(IStatus.ERROR,
+ PLUGIN_ID, 0, mesg, t);
+
+ getDefault().getLog().log(status);
+ }
+
+ logger.error("LOG ERROR: "+mesg+
+ (t == null ? "" : ": "+t), t);
+ }
+
+ private static Log logger = LogFactory.getLog(Activator.class);
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/.classpath
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/.classpath (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/plugins/org.savara.tools.bpmn/.project
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/.project (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.tools.bpmn</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/tools/plugins/org.savara.tools.bpmn/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA Tools BPMN Plug-in
+Bundle-SymbolicName: org.savara.tools.bpmn;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.tools.bpmn.eclipse.Activator
+Bundle-Vendor: www.savara.org
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.pi4soa.service,
+ org.pi4soa.cdl,
+ org.eclipse.stp.bpmn,
+ org.eclipse.gmf.runtime.notation,
+ org.eclipse.core.resources,
+ org.pi4soa.common
+Eclipse-LazyStart: true
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added: trunk/tools/plugins/org.savara.tools.bpmn/build.properties
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/build.properties (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,5 @@
+source.. = src/java/
+output.. = classes/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: trunk/tools/plugins/org.savara.tools.bpmn/plugin.xml
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/plugin.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/plugin.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.exportWizards">
+ <wizard
+ class="org.savara.tools.bpmn.eclipse.ExportBPMNWizard"
+ name="BPMN"
+ id="org.savara.tools.bpmn.exportbpmnwizard"/>
+ </extension>
+
+</plugin>
Added: trunk/tools/plugins/org.savara.tools.bpmn/pom.xml
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/pom.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,16 @@
+<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.tools</groupId>
+ <artifactId>org.savara.tools.bpmn</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ToolsBPMN</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+</project>
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/Activator.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/Activator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,50 @@
+package org.savara.tools.bpmn.eclipse;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.savara.tools.bpmn";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/ExportBPMNWizard.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/ExportBPMNWizard.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/ExportBPMNWizard.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 1, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.eclipse;
+
+import java.io.File;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.CDLDefinitions;
+import org.pi4soa.cdl.ParticipantType;
+import org.pi4soa.common.resource.FileSystemArtifactManager;
+import org.pi4soa.common.resource.eclipse.ResourceUtil;
+import org.pi4soa.service.ServiceDefinitions;
+import org.pi4soa.service.behavior.ServiceDescription;
+import org.pi4soa.service.behavior.projection.BehaviorProjection;
+import org.savara.tools.bpmn.generation.BPMNGenerator;
+import org.savara.tools.bpmn.generation.DefaultBPMNConfiguration;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.core.resources.*;
+
+
+/**
+ * This class implements the Eclipse ExportWizrd for exporting
+ * a CDL object model to a BPMN representation.
+ */
+public class ExportBPMNWizard extends Wizard implements IExportWizard {
+
+ /**
+ * This method is invoked when the 'finish' button is
+ * pressed on the export wizard.
+ */
+ public boolean performFinish() {
+ boolean ret=true;
+
+ // Export CDL's service endpoint projections to folder
+ if (m_cdlFile != null) {
+
+ // Load the CDL object model
+ try {
+ org.pi4soa.cdl.Package cdlpack=
+ org.pi4soa.cdl.eclipse.Activator.getPackage(m_cdlFile);
+
+ BPMNGenerator generator=new BPMNGenerator();
+
+ generator.generate(cdlpack, null,
+ m_selectionPage.getFolderName(),
+ new DefaultBPMNConfiguration());
+
+ } catch(Exception e) {
+
+ // Record error message on wizard page
+ m_selectionPage.setErrorMessage("Failed to export Choreography to BPMN: "+e);
+
+ logger.log(Level.SEVERE,
+ "Failed to export Choreography to BPMN", e);
+ ret = false;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method is used to initialize the export wizard.
+ *
+ * @param workbench The workbench
+ * @param selection The selected item(s)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ String errMesg=null;
+
+ // Create the selection page
+ m_selectionPage = new FolderSelectionPage(PAGE_NAME,
+ "Select a folder as the destination for "+
+ "the exported BPMN");
+
+ // Check that a single CDL file has been selected
+ if (selection != null) {
+
+ // Check element is a file
+ if (selection.getFirstElement() instanceof IFile) {
+
+ m_cdlFile = (IFile)selection.getFirstElement();
+
+ // Check the file extension is valid
+ if (m_cdlFile.getFileExtension().equals(
+ CDLDefinitions.CDL_FILE_EXTENSION)) {
+
+ // Make sure there are no markers associated
+ // with the resource
+ if (ResourceUtil.hasErrors(m_cdlFile)) {
+ errMesg = RESOURCE_ERROR;
+ }
+ } else {
+ errMesg = RESOURCE_NOT_CDL_ERROR;
+ }
+ } else {
+ errMesg = RESOURCE_NOT_FILE_ERROR;
+ }
+ } else {
+ errMesg = RESOURCE_NOT_SELECTED_ERROR;
+ }
+
+ // Check if an error should be reported
+ if (errMesg != null) {
+ m_selectionPage.setErrorMessage(errMesg);
+ }
+ }
+
+ /**
+ * This method configures the pages associated with
+ * the CDL export wizard.
+ */
+ public void addPages() {
+ addPage(m_selectionPage);
+ }
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.bpmn.eclipse");
+ private IFile m_cdlFile=null;
+ private FolderSelectionPage m_selectionPage=null;
+
+ private static final String BEHAVIOR_EXTENSION = ServiceDefinitions.SERVICE_ENDPOINT_FILE_EXTENSION;
+
+ private static String PAGE_NAME="Export BPMN";
+ private static String RESOURCE_NOT_SELECTED_ERROR="A resource has not been selected";
+ private static String RESOURCE_NOT_FILE_ERROR="The selected resource is not a file";
+ private static String RESOURCE_NOT_CDL_ERROR="The selected file is not a valid CDL object model";
+ private static String RESOURCE_ERROR="Invalid CDL cannot be exported as BPMN";
+}
\ No newline at end of file
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/FolderSelectionPage.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/FolderSelectionPage.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/eclipse/FolderSelectionPage.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 1, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.eclipse;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This class represents the wizard page for selecting
+ * a folder.
+ */
+class FolderSelectionPage extends org.eclipse.jface.wizard.WizardPage {
+
+ /**
+ * Constructor for the folder selection page.
+ *
+ * @param pageName The page name
+ * @param description The description
+ */
+ public FolderSelectionPage(String pageName,
+ String description) {
+ super(pageName);
+ setTitle(pageName);
+ setDescription(description);
+ setPageComplete(false);
+ }
+
+ /**
+ * Create the control for the selection page.
+ *
+ * @param parent The parent component
+ */
+ public void createControl(Composite parent) {
+
+ // Identify the shell
+ m_shell = parent.getShell();
+
+ // Create the composite component
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL));
+
+ // Create the text field for entering the
+ // path to the folder
+ m_text = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ m_text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Ensure there is no error before setting up the
+ // text listener
+ if (getErrorMessage() == null) {
+ m_text.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ String errMesg=null;
+
+ try {
+ // Setup file associated with entered
+ // name
+ java.io.File file=
+ new java.io.File(m_text.getText());
+
+ // Check that the folder exists
+ if (file.exists() == false) {
+ errMesg = "The folder does not exist";
+ } else if (file.isDirectory() == false) {
+ errMesg = "A folder should be selected";
+ }
+ } catch(Exception e2) {
+ // Ignore
+ }
+
+ // Check if error has been found
+ if (errMesg != null) {
+ setErrorMessage(errMesg);
+ setPageComplete(false);
+ } else {
+ setErrorMessage(null);
+ setPageComplete(true);
+ }
+ }
+ });
+ }
+
+ // Create a 'browse' button
+ m_button=new Button(composite, 0);
+
+ m_button.setText("Browse");
+ m_button.setToolTipText("Browse file system to locate destination folder");
+
+ m_button.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
+ public void widgetSelected(SelectionEvent evt) {
+ DirectoryDialog dialog=new DirectoryDialog(m_shell);
+
+ String filename=dialog.open();
+
+ if (filename != null) {
+
+ filename = preProcessFilename(filename);
+ m_text.setText(filename);
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent evt) {
+ }
+ });
+
+ if (getErrorMessage() != null) {
+ m_button.setEnabled(false);
+ m_text.setEnabled(false);
+ m_text.setEditable(false);
+ }
+
+ setControl(composite);
+ }
+
+ /**
+ * This method preprocesses the filename before it is
+ * used.
+ *
+ * @param filename The original filename
+ * @return The pre-processed filename
+ */
+ protected String preProcessFilename(String filename) {
+ return(filename);
+ }
+
+ /**
+ * This method returns the folder path that has been
+ * entered by the user.
+ *
+ * @return The folder name
+ */
+ public String getFolderName() {
+ if (m_text == null) {
+ return(null);
+ }
+ return(m_text.getText());
+ }
+
+ private Text m_text=null;
+ private Shell m_shell=null;
+ private Button m_button=null;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNConfiguration.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNConfiguration.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNConfiguration.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation;
+
+/**
+ * This interface represents the configuration information used
+ * by the BPMN projection to determine what model components and
+ * features should be included.
+ *
+ */
+public interface BPMNConfiguration {
+
+ /**
+ * This method returns the UML export format to be used. The list
+ * of valid export formats is available using the
+ * #UMLGenerator.getExportFormats() method.
+ *
+ * @return The export format, or null if the default is being used.
+ */
+ public String getExportFormat();
+
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNGenerationException.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNGenerationException.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNGenerationException.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation;
+
+/**
+ * This class represents a BPMN generation exception.
+ *
+ */
+public class BPMNGenerationException extends Exception {
+
+ private static final long serialVersionUID = -8580109779260853013L;
+
+ /**
+ * This constructor initializes the UML generation exception
+ * with a message.
+ *
+ * @param mesg The message
+ */
+ public BPMNGenerationException(String mesg) {
+ super(mesg);
+ }
+
+ /**
+ * This constructor initializes the UML generation exception
+ * with a message and associated exception.
+ *
+ * @param mesg The message
+ * @param t The associated exception
+ */
+ public BPMNGenerationException(String mesg, Throwable t) {
+ super(mesg, t);
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNGenerator.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNGenerator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNGenerator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,945 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.CDLManager;
+import org.pi4soa.service.behavior.ActivityType;
+import org.pi4soa.service.behavior.Assign;
+import org.pi4soa.service.behavior.AtomicUnit;
+import org.pi4soa.service.behavior.BehaviorDescription;
+import org.pi4soa.service.behavior.BehaviorVisitor;
+import org.pi4soa.service.behavior.Choice;
+import org.pi4soa.service.behavior.CompletionHandler;
+import org.pi4soa.service.behavior.Conditional;
+import org.pi4soa.service.behavior.ExceptionHandler;
+import org.pi4soa.service.behavior.Finalize;
+import org.pi4soa.service.behavior.Parallel;
+import org.pi4soa.service.behavior.Perform;
+import org.pi4soa.service.behavior.RaiseException;
+import org.pi4soa.service.behavior.Receive;
+import org.pi4soa.service.behavior.RepetitionType;
+import org.pi4soa.service.behavior.Send;
+import org.pi4soa.service.behavior.Sequence;
+import org.pi4soa.service.behavior.ServiceDescription;
+import org.pi4soa.service.behavior.StructuralType;
+import org.pi4soa.service.behavior.TimedUnit;
+import org.pi4soa.service.behavior.Unobservable;
+import org.pi4soa.service.behavior.VariableDeclaration;
+import org.pi4soa.service.behavior.When;
+import org.pi4soa.service.behavior.While;
+import org.pi4soa.service.behavior.projection.BehaviorProjection;
+import org.pi4soa.service.session.internal.LookaheadElement;
+import org.pi4soa.service.session.internal.Predicate;
+import org.savara.tools.bpmn.generation.components.*;
+
+/**
+ * This class provides the functionality for converting a
+ * choreography description into a BPMN representation.
+ *
+ */
+public class BPMNGenerator {
+
+ public static void main(String[] args) {
+
+ // Check for optional parameters
+ int pos=0;
+ int num=args.length;
+ String[] participant=null;
+
+ for (; pos < num && args[pos].charAt(0) == '-'; pos++) {
+ String option=args[pos].substring(1);
+ if (option.equals("p")) {
+ if (participant != null) {
+ System.err.println("Cannot specify participant more than once");
+ System.exit(1);
+ } else if (pos+1 >= num) {
+ System.err.println("Participant not defined");
+ System.exit(1);
+ } else {
+ pos++;
+ participant = new String[]{args[pos]};
+ }
+ } else {
+ System.err.println("Unknown option "+args[pos]);
+ System.err.println(USAGE_MESSAGE);
+ System.exit(1);
+ }
+ }
+
+ // Check parameters
+ if (num - pos != 2) {
+ System.err.println(USAGE_MESSAGE);
+ System.exit(1);
+ }
+
+ String choreographyFile=args[pos];
+ String outputFolder=args[pos+1];
+ org.pi4soa.cdl.Package choreography=null;
+
+ // Load the choreography
+ try {
+ choreography = CDLManager.load(choreographyFile);
+
+ } catch(Exception e) {
+ System.err.println("Failed to load choreography: "+e);
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ try {
+ BPMNGenerator generator=new BPMNGenerator();
+
+ generator.generate(choreography, participant, outputFolder,
+ new DefaultBPMNConfiguration());
+
+ } catch(Exception e) {
+ System.err.println("Failed to generate UML: "+e);
+ e.printStackTrace();
+ System.exit(3);
+ }
+ }
+
+ /**
+ * This is the constructor for the UML generator.
+ *
+ */
+ public BPMNGenerator() {
+ }
+
+ /**
+ * This method generates the UML representation for the
+ * supplied choreography. If the optional participant
+ * is specified, then only the UML representation for
+ * that participant will be generated, otherwise all
+ * participants associated with the choreography will be
+ * generated.
+ *
+ * @param choreography The choreography
+ * @param participants The optional participant names
+ * @param folder The folder where the model/diagrams will
+ * be stored
+ * @param config The UML configuration
+ * @exception BPMNGenerationException Failed to generate
+ */
+ public void generate(org.pi4soa.cdl.Package choreography,
+ String[] participants, String folder,
+ BPMNConfiguration config) throws BPMNGenerationException {
+
+ if (participants == null) {
+ java.util.List pTypes=
+ choreography.getTypeDefinitions().getParticipantTypes();
+
+ participants = new String[pTypes.size()];
+
+ for (int i=0; i < pTypes.size(); i++) {
+ participants[i] = ((org.pi4soa.cdl.ParticipantType)pTypes.
+ get(i)).getName();
+ }
+ }
+
+ // Create the model
+ org.savara.tools.bpmn.generation.BPMNModelFactory model=null;
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation=null;
+
+ try {
+ model = new org.savara.tools.bpmn.generation.stp.STPBPMNModelFactoryImpl();
+ notation = new org.savara.tools.bpmn.generation.gmf.GMFBPMNNotationFactoryImpl();
+
+ generateModel(model, notation, choreography, config, folder);
+
+ } catch(Exception e) {
+ throw new BPMNGenerationException("Failed to generate UML model", e);
+ }
+
+ /*
+ if (diagrams.size() > 0) {
+ Object diagram=diagrams.get(0);
+
+ try {
+
+ // Output the UML2 model to the supplied stream
+ final org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl xmi =
+ new org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl();
+ xmi.getContents().add(diagram);
+
+ xmi.doSave(ostream, xmi.getDefaultLoadOptions());
+
+ ostream.close();
+
+ } catch(Exception e) {
+ throw new BPMNGenerationException("Failed to convert to XMI", e);
+ }
+ }
+ */
+ // Just need to store as EMF based file
+ /*
+ try {
+ java.io.ByteArrayOutputStream bs=new java.io.ByteArrayOutputStream();
+
+ // Output the UML2 model to the supplied stream
+ final org.eclipse.emf.ecore.xmi.impl.EMOFResourceImpl xmi =
+ new org.eclipse.emf.ecore.xmi.impl.EMOFResourceImpl();
+ xmi.getContents().add(model);
+
+ xmi.doSave(bs, xmi.getDefaultLoadOptions());
+
+ bs.close();
+
+ UMLExportFormatter formatter=getExportFormatter(config.getExportFormat());
+ if (formatter != null) {
+ formatter.export(bs, ostream);
+ } else {
+ throw new UMLException("Unable to find UML export formatter for '"+
+ config.getExportFormat()+"'");
+ }
+
+ } catch(UMLException UMLex) {
+ throw UMLex;
+
+ } catch(Exception e) {
+ throw new UMLException("Failed to convert to XMI", e);
+ }
+ */
+ }
+
+ /**
+ * This method generates the model information associated
+ * with the supplied choreography description.
+ *
+ * @param model The model
+ * @param cdlpack The choreography description
+ * @param config The MDA configuration
+ * @return The list of diagrams
+ * @throws BPMNGenerationException Failed to generate model
+ */
+ public void generateModel(BPMNModelFactory model,
+ BPMNNotationFactory notation, org.pi4soa.cdl.Package cdlpack,
+ BPMNConfiguration config, String folder) throws BPMNGenerationException {
+ try {
+ java.util.List participants=cdlpack.getTypeDefinitions().getParticipantTypes();
+
+ BPMNModelVisitor visitor=
+ new BPMNModelVisitor(org.pi4soa.common.xml.XMLUtils.getLocalname(
+ cdlpack.getName()),
+ model, notation, folder);
+
+ for (int i=0; i < participants.size(); i++) {
+ org.pi4soa.cdl.ParticipantType partType=
+ (org.pi4soa.cdl.ParticipantType)
+ cdlpack.getTypeDefinitions().getParticipantTypes().get(i);
+
+ org.pi4soa.service.behavior.ServiceDescription sdesc=
+ BehaviorProjection.projectServiceDescription(cdlpack,
+ partType, null);
+
+ visitor.setParticipant(partType.getName());
+
+ sdesc.visit(visitor);
+ }
+
+ visitor.completeModels();
+
+ } catch(Exception e) {
+ throw new BPMNGenerationException("Failed to generate BPMN model", e);
+ }
+ }
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.bpmn.generation");
+
+ private static final String USAGE_MESSAGE = "Usage: BPMNGenerator [-p Participant] " +
+ "ChoreographyFile OutputFolder";
+
+ // NOTE: Currently uses the Activity Model constructs
+ public class BPMNModelVisitor implements BehaviorVisitor {
+
+ /**
+ * The constructor the BPMN model visitor.
+ *
+ */
+ public BPMNModelVisitor(String choreoName,
+ BPMNModelFactory model, BPMNNotationFactory notation,
+ String folder) {
+ m_choreoName = choreoName;
+ m_modelFactory = model;
+ m_notationFactory = notation;
+ m_folder = folder;
+ }
+
+ /**
+ * This method sets the name associated with the participant
+ * being projected.
+ *
+ * @param participant The participant
+ */
+ public void setParticipant(String participant) {
+ m_participant = participant;
+ }
+
+ /**
+ * This method visits the abstract activity. This will be
+ * performed after performing the specific visit method
+ * for the real type, but before performing the visit
+ * on any other activities that may be contained within
+ * this activity type.
+ *
+ * @param elem The activity type
+ */
+ public void activityType(ActivityType elem) {
+
+ }
+
+ /**
+ * This method visits the assign activity.
+ *
+ * @param elem The assign
+ */
+ public void assign(Assign elem) {
+
+ BPMNActivity umls=getBPMNActivity();
+ if (umls != null) {
+ new SimpleActivity(elem,
+ umls, m_modelFactory, m_notationFactory);
+ }
+ }
+
+ /**
+ * This method starts visiting the atomic unit element.
+ *
+ * @param elem The atomic unit
+ */
+ public void atomicUnitStart(AtomicUnit elem) {
+
+ }
+
+ /**
+ * This method ends visiting the atomic unit element.
+ *
+ * @param elem The atomic unit
+ */
+ public void atomicUnitEnd(AtomicUnit elem) {
+
+ }
+
+ /**
+ * This method starts visiting the behavior description element.
+ *
+ * @param elem The behavior description
+ */
+ public void behaviorDescriptionStart(BehaviorDescription elem) {
+
+ try {
+ BPMNDiagram diagram=getBPMNModel(elem, m_folder);
+
+ String participant=m_participant;
+
+ if (org.pi4soa.common.util.NamesUtil.isSet(elem.getParticipant())) {
+ participant += " ["+elem.getParticipant()+"]";
+ }
+
+ BPMNPool pool=diagram.createPool(participant);
+
+ //diagram.initialize(elem);
+
+ pushBPMNActivity(pool);
+ } catch(Exception e) {
+ logger.severe("Failed to get state machine " +
+ "for behavior '"+elem+"': "+e);
+ }
+ }
+
+ /**
+ * This method ends visiting the behavior description element.
+ *
+ * @param elem The behavior description
+ */
+ public void behaviorDescriptionEnd(BehaviorDescription elem) {
+
+ BPMNActivity umls=getBPMNActivity();
+
+ if (umls != null) {
+ umls.childrenComplete();
+ }
+
+ popUMLActivity();
+ }
+
+ /**
+ * This method starts visiting the choice element.
+ *
+ * @param elem The choice
+ */
+ public void choiceStart(Choice elem) {
+
+ try {
+ pushBPMNActivity(new ChoiceActivity(elem,
+ getBPMNActivity(), m_modelFactory, m_notationFactory));
+
+ } catch(Exception e) {
+ logger.severe("Failed to create choice state: "+e);
+ }
+ }
+
+ /**
+ * This method ends visiting the choice element.
+ *
+ * @param elem The choice
+ */
+ public void choiceEnd(Choice elem) {
+
+ popUMLActivity();
+ }
+
+ /**
+ * This method starts visiting the completion handler element.
+ *
+ * @param elem The completion handler
+ */
+ public void completionHandlerStart(CompletionHandler elem) {
+
+ /*
+ try {
+ BPMNActivity bdstate=getBPMNModel(elem, m_folder);
+
+ pushBPMNActivity(bdstate);
+ } catch(Exception e) {
+ logger.severe("Failed to get state machine for " +
+ "completion handler '"+elem+"': "+e);
+ }
+ */
+ }
+
+ /**
+ * This method ends visiting the completion handler element.
+ *
+ * @param elem The completion handler
+ */
+ public void completionHandlerEnd(CompletionHandler elem) {
+
+ /*
+ BPMNActivity umls=getBPMNActivity();
+
+ if (umls != null) {
+ umls.childrenComplete();
+ }
+
+ popUMLActivity();
+ */
+ }
+
+ /**
+ * This method starts visiting the conditional element.
+ *
+ * @param elem The conditional
+ */
+ public void conditionalStart(Conditional elem) {
+
+ try {
+ pushBPMNActivity(new ConditionalActivity(elem,
+ getBPMNActivity(), m_modelFactory, m_notationFactory));
+
+ pushBPMNActivity(new SequenceActivity(elem,
+ getBPMNActivity(), m_modelFactory, m_notationFactory));
+
+ } catch(Exception e) {
+ logger.severe("Failed to create conditional state: "+e);
+ }
+ }
+
+ /**
+ * This method ends visiting the conditional element.
+ *
+ * @param elem The conditional
+ */
+ public void conditionalEnd(Conditional elem) {
+
+ popUMLActivity();
+ popUMLActivity();
+ }
+
+ /**
+ * This method starts visiting the exception handler element.
+ *
+ * @param elem The exception handler
+ */
+ public void exceptionHandlerStart(ExceptionHandler elem) {
+
+ /*
+ try {
+ BPMNActivity bdstate=getBPMNModel(elem);
+
+ pushBPMNActivity(bdstate);
+ } catch(Exception e) {
+ logger.severe("Failed to get state machine for " +
+ "exception handler '"+elem+"': "+e);
+ }
+ */
+ }
+
+ /**
+ * This method ends visiting the exception handler element.
+ *
+ * @param elem The exception handler
+ */
+ public void exceptionHandlerEnd(ExceptionHandler elem) {
+
+ /*
+ BPMNActivity umls=getBPMNActivity();
+
+ if (umls != null) {
+ umls.childrenComplete();
+ }
+
+ popUMLActivity();
+ */
+ }
+
+ /**
+ * This method visits the finalize activity.
+ *
+ * @param elem The finalize
+ */
+ public void finalize(Finalize elem) {
+
+ BPMNActivity umls=getBPMNActivity();
+ if (umls != null) {
+ SimpleActivity state=new SimpleActivity(elem,
+ umls, m_modelFactory, m_notationFactory);
+
+ /*
+ try {
+ StateMachineState subMachine=
+ getStateMachineState(elem.getCompletionHandler());
+ state.setSubStateMachine(subMachine);
+ } catch(Exception e) {
+ logger.severe("Failed to get state machine: "+e);
+ }
+ */
+ }
+ }
+
+ /**
+ * This method starts visiting the parallel element.
+ *
+ * @param elem The parallel
+ */
+ public void parallelStart(Parallel elem) {
+
+ try {
+ pushBPMNActivity(new ParallelActivity(elem,
+ getBPMNActivity(), m_modelFactory, m_notationFactory));
+
+ } catch(Exception e) {
+ logger.severe("Failed to create parallel state: "+e);
+ }
+ }
+
+ /**
+ * This method ends visiting the parallel element.
+ *
+ * @param elem The parallel
+ */
+ public void parallelEnd(Parallel elem) {
+
+ popUMLActivity();
+ }
+
+ /**
+ * This method visits the perform activity.
+ *
+ * @param elem The perform
+ */
+ public void perform(Perform elem) {
+
+ BPMNActivity umls=getBPMNActivity();
+ if (umls != null) {
+ PerformActivity state=new PerformActivity(elem,
+ umls, m_modelFactory, m_notationFactory);
+
+ if (elem instanceof LookaheadElement) {
+ LookaheadElement lookahead=(LookaheadElement)elem;
+ boolean f_send=false;
+ boolean f_receive=false;
+
+ java.util.Iterator iter=lookahead.getPreConditions().iterator();
+ while (iter.hasNext()) {
+ Predicate pred=(Predicate)iter.next();
+
+ if (pred.isMessagePredicate()) {
+
+ if (pred.isReceiveLookaheadPredicate()) {
+ f_receive = true;
+ } else {
+ f_send = true;
+ }
+ }
+ }
+
+ if (f_send && !f_receive) {
+ umls.getBPMNDiagram().registerInitiatingPerform(elem, state);
+ } else if (!f_send && f_receive) {
+ umls.getBPMNDiagram().registerInitiatedPerform(elem, state);
+ }
+ }
+ }
+ }
+
+ /**
+ * This method visits the raise exception activity.
+ *
+ * @param elem The raise exception
+ */
+ public void raiseException(RaiseException elem) {
+
+ BPMNActivity umls=getBPMNActivity();
+ if (umls != null) {
+ new SimpleActivity(elem, umls, m_modelFactory, m_notationFactory);
+ }
+ }
+
+ /**
+ * This method visits the receive activity.
+ *
+ * @param elem The receive
+ */
+ public void receive(Receive elem) {
+
+ BPMNActivity umls=getBPMNActivity();
+ if (umls != null) {
+ ReceiveActivity sa=
+ new ReceiveActivity(elem, umls, m_modelFactory, m_notationFactory);
+
+ // Register the receive to enable links to be established
+ // with an appropriate send
+ BPMNDiagram amodel=umls.getBPMNDiagram();
+ amodel.registerReceiveActivity(elem, sa);
+ }
+ }
+
+ /**
+ * This method starts visiting the repetition type abstract element.
+ *
+ * @param elem The repetition type
+ */
+ public void repetitionTypeStart(RepetitionType elem) {
+
+ }
+
+ /**
+ * This method ends visiting the repetition type abstract element.
+ *
+ * @param elem The repetition type
+ */
+ public void repetitionTypeEnd(RepetitionType elem) {
+
+ }
+
+ /**
+ * This method visits the send activity.
+ *
+ * @param elem The send
+ */
+ public void send(Send elem) {
+
+ BPMNActivity umls=getBPMNActivity();
+ if (umls != null) {
+ SimpleActivity sa=
+ new SimpleActivity(elem, umls, m_modelFactory, m_notationFactory);
+
+ // Register the send to enable links to be established
+ // with an appropriate receive
+ BPMNDiagram amodel=umls.getBPMNDiagram();
+ amodel.registerSendActivity(elem, sa);
+ }
+ }
+
+ /**
+ * This method starts visiting the sequence element.
+ *
+ * @param elem The sequence
+ */
+ public void sequenceStart(Sequence elem) {
+
+ try {
+ pushBPMNActivity(new SequenceActivity(elem,
+ getBPMNActivity(), m_modelFactory, m_notationFactory));
+
+ } catch(Exception e) {
+ logger.severe("Failed to create sequence state: "+e);
+ }
+ }
+
+ /**
+ * This method ends visiting the sequence element.
+ *
+ * @param elem The sequence
+ */
+ public void sequenceEnd(Sequence elem) {
+
+ popUMLActivity();
+ }
+
+ /**
+ * This method starts visiting the service description element.
+ *
+ * @param elem The service description
+ */
+ public void serviceDescriptionStart(ServiceDescription elem) {
+
+ }
+
+ /**
+ * This method ends visiting the service description element.
+ *
+ * @param elem The service description
+ */
+ public void serviceDescriptionEnd(ServiceDescription elem) {
+
+ }
+
+ /**
+ * This method starts visiting the structural type abstract element.
+ *
+ * @param elem The structural type
+ */
+ public void structuralTypeStart(StructuralType elem) {
+
+ }
+
+ /**
+ * This method ends visiting the structural type abstract element.
+ *
+ * @param elem The structural type
+ */
+ public void structuralTypeEnd(StructuralType elem) {
+
+ /*
+ BPMNActivity umls=getBPMNActivity();
+
+ if (umls != null) {
+ umls.childrenComplete();
+ }
+ */
+ }
+
+ /**
+ * This method starts visiting the timed unit element.
+ *
+ * @param elem The timed unit
+ */
+ public void timedUnitStart(TimedUnit elem) {
+
+ }
+
+ /**
+ * This method ends visiting the timed unit element.
+ *
+ * @param elem The timed unit
+ */
+ public void timedUnitEnd(TimedUnit elem) {
+
+ }
+
+ /**
+ * This method visits the unobservable activity.
+ *
+ * @param elem The unobservable
+ */
+ public void unobservable(Unobservable elem) {
+
+ BPMNActivity umls=getBPMNActivity();
+ if (umls != null) {
+ new SimpleActivity(elem, umls, m_modelFactory, m_notationFactory);
+ }
+ }
+
+ /**
+ * This method visits the variable declaration activity.
+ *
+ * @param elem The variable declaration
+ */
+ public void variableDeclaration(VariableDeclaration elem) {
+
+ }
+
+ /**
+ * This method starts visiting the when element.
+ *
+ * @param elem The when
+ */
+ public void whenStart(When elem) {
+
+ try {
+ pushBPMNActivity(new WhenActivity(elem,
+ getBPMNActivity(), m_modelFactory, m_notationFactory));
+
+ pushBPMNActivity(new SequenceActivity(elem,
+ getBPMNActivity(), m_modelFactory, m_notationFactory));
+ } catch(Exception e) {
+ logger.severe("Failed to create when Activity: "+e);
+ }
+ }
+
+ /**
+ * This method ends visiting the when element.
+ *
+ * @param elem The when
+ */
+ public void whenEnd(When elem) {
+
+ popUMLActivity();
+ popUMLActivity();
+ }
+
+ /**
+ * This method starts visiting the while element.
+ *
+ * @param elem The while
+ */
+ public void whileStart(While elem) {
+
+ try {
+ pushBPMNActivity(new WhileActivity(elem,
+ getBPMNActivity(), m_modelFactory, m_notationFactory));
+
+ pushBPMNActivity(new SequenceActivity(elem,
+ getBPMNActivity(), m_modelFactory, m_notationFactory));
+
+ } catch(Exception e) {
+ logger.severe("Failed to create while Activity: "+e);
+ }
+ }
+
+ /**
+ * This method ends visiting the while element.
+ *
+ * @param elem The while
+ */
+ public void whileEnd(While elem) {
+
+ popUMLActivity();
+
+ popUMLActivity();
+ }
+
+ /**
+ * This method returns a Activity machine Activity for the supplied
+ * behavior type. If one already exists, then it will be
+ * returned, otherwise one will be created.
+ *
+ * @param elem The behavior type
+ * @return The Activity machine state
+ */
+ protected BPMNDiagram getBPMNModel(
+ BehaviorDescription elem, String folder) throws BPMNGenerationException {
+ String name=BPMNDiagram.getName(elem);
+
+ BPMNDiagram ret=(BPMNDiagram)
+ m_activityModels.get(name);
+
+ if (ret == null) {
+ ret = new BPMNDiagram(m_choreoName, name,
+ null, m_modelFactory, m_notationFactory, folder);
+
+ m_activityModels.put(name, ret);
+ }
+
+ // Create activity partition for service
+ /*
+ org.eclipse.uml2.uml.ActivityPartition partition =
+ (org.eclipse.uml2.uml.ActivityPartition)
+ ret.getTopLevelActivity().createGroup(
+ UMLPackage.eINSTANCE.getActivityPartition());
+ partition.setName(org.pi4soa.common.xml.XMLUtils.getLocalname(
+ elem.getServiceDescription().getName()));
+ ret.setCurrentPartition(partition);
+ */
+
+ return(ret);
+ }
+
+ /**
+ * This method pushes the supplied UML activity
+ * onto a stack.
+ *
+ * @param sms The activity
+ */
+ protected void pushBPMNActivity(BPMNActivity umls) {
+ m_umlActivityStack.insertElementAt(umls, 0);
+ }
+
+ /**
+ * This method returns the UML activity found at the
+ * top of the stack.
+ *
+ * @return The activity
+ */
+ protected BPMNActivity getBPMNActivity() {
+ BPMNActivity ret=null;
+
+ if (m_umlActivityStack.size() > 0) {
+ ret = (BPMNActivity)m_umlActivityStack.get(0);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the UML activity from the
+ * top of the stack.
+ *
+ */
+ protected void popUMLActivity() {
+ BPMNActivity umls=getBPMNActivity();
+
+ if (umls != null) {
+ umls.childrenComplete();
+ }
+
+ if (m_umlActivityStack.size() > 0) {
+ m_umlActivityStack.remove(0);
+ }
+ }
+
+ /**
+ * This method completes the construction of the activity
+ * models.
+ *
+ */
+ public void completeModels() throws BPMNGenerationException {
+ java.util.Enumeration iter=m_activityModels.elements();
+
+ while (iter.hasMoreElements()) {
+ BPMNDiagram amodel=(BPMNDiagram)iter.nextElement();
+
+ amodel.completeModel();
+ }
+ }
+
+ private BPMNModelFactory m_modelFactory=null;
+ private BPMNNotationFactory m_notationFactory=null;
+ private String m_folder=null;
+ private String m_choreoName=null;
+ private String m_participant=null;
+ private java.util.Vector m_umlActivityStack=new java.util.Vector();
+ private java.util.Hashtable m_activityModels=new java.util.Hashtable();
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNModelFactory.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNModelFactory.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNModelFactory.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2005-6 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR 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 Jan 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation;
+
+import org.pi4soa.service.behavior.ActivityType;
+
+public interface BPMNModelFactory {
+
+ public String getFileExtension();
+
+ public void saveModel(String fileName, Object diagram)
+ throws BPMNGenerationException;
+
+ public Object createDiagram();
+
+ public Object createPool(Object diagram, String name);
+
+ public Object createInitialNode(Object container);
+
+ public Object createSimpleTask(Object container, ActivityType activity);
+
+ public Object createDataBasedXORGateway(Object container);
+
+ public Object createEventBasedXORGateway(Object container);
+
+ public Object createANDGateway(Object container);
+
+ public Object createFinalNode(Object container);
+
+ public Object createControlLink(Object container,
+ Object fromNode, Object toNode,
+ String conditionalExpression);
+
+ public Object createMessageLink(Object container,
+ Object fromNode, Object toNode,
+ org.pi4soa.service.behavior.Receive receive);
+
+ public Object setLinkExpression(Object link, String expression);
+
+ public boolean isDecision(Object node);
+
+ /**
+ * This method determines if the supplied node is a join. This
+ * is true, if the node is a data or event based gateway,
+ * and as incoming edges. This is based on the fact that only
+ * a join gateway, at the point this method is invoked, would
+ * have incoming links, otherwise any other gateway would be
+ * assumed to be the initial gateway in a conditional grouping
+ * construct.
+ *
+ * @param node
+ * @return Whether the node is a join
+ */
+ public boolean isJoin(Object node);
+
+ public boolean isTerminal(Object node);
+
+ public void setLabel(Object entity, String label);
+
+ public Object getSource(Object link);
+
+ public void setSource(Object link, Object node);
+
+ public Object getTarget(Object link);
+
+ public void setTarget(Object link, Object node);
+
+ public java.util.List getInboundControlLinks(Object node);
+
+ public java.util.List getOutboundControlLinks(Object node);
+
+ public java.util.List getInboundMessageLinks(Object node);
+
+ public java.util.List getOutboundMessageLinks(Object node);
+
+ public void delete(Object entity);
+
+ public boolean isDeleted(Object entity);
+
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNNotationFactory.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNNotationFactory.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/BPMNNotationFactory.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2005-6 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR 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 Jan 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation;
+
+
+public interface BPMNNotationFactory {
+
+ public String getFileExtension();
+
+ public void saveNotation(String modelFileName, Object diagramModel,
+ String notationFileName, Object diagramNotation)
+ throws BPMNGenerationException;
+
+ public Object createDiagram(BPMNModelFactory factory,
+ Object diagramModel, int x, int y, int width, int height);
+
+ public Object createPool(BPMNModelFactory factory,
+ Object poolModel, Object diagramNotation,
+ int x, int y, int width, int height);
+
+ public Object createTask(BPMNModelFactory factory,
+ Object taskModel, Object parentNotation,
+ int x, int y, int width, int height);
+
+ public Object createJunction(BPMNModelFactory factory,
+ Object junctionModel, Object parentNotation,
+ int x, int y, int width, int height);
+
+ public Object createMessageLink(BPMNModelFactory factory,
+ Object linkModel, Object diagramNotation);
+
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/DefaultBPMNConfiguration.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/DefaultBPMNConfiguration.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/DefaultBPMNConfiguration.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation;
+
+/**
+ * This class provides the default implementation for the
+ * BPMN configuration interface.
+ *
+ */
+public class DefaultBPMNConfiguration implements BPMNConfiguration {
+
+ /**
+ * This is the default constructor.
+ *
+ */
+ public DefaultBPMNConfiguration() {
+ }
+
+ /**
+ * This method returns the UML export format to be used. The list
+ * of valid export formats is available using the
+ * #UMLGenerator.getExportFormats() method.
+ *
+ * @return The export format, or null if the default is being used.
+ */
+ public String getExportFormat() {
+ return(m_exportFormat);
+ }
+
+ /**
+ * This method sets the export format.
+ *
+ * @param format The export format
+ */
+ public void setExportFormat(String format) {
+ m_exportFormat = format;
+ }
+
+ private String m_exportFormat=null;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/AbstractBPMNActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/AbstractBPMNActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/AbstractBPMNActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,317 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+public abstract class AbstractBPMNActivity implements BPMNActivity {
+
+ /**
+ * This is the constructor for the default BPMN activity.
+ *
+ * @param parent The parent
+ */
+ public AbstractBPMNActivity(BPMNActivity parent,
+ org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation) {
+ m_parent = parent;
+ m_modelFactory = model;
+ m_notationFactory = notation;
+
+ if (parent instanceof AbstractBPMNActivity) {
+ ((AbstractBPMNActivity)parent).addChildState(this);
+ }
+ }
+
+ /**
+ * This method returns the parent BPMN activity.
+ *
+ * @return The parent
+ */
+ public BPMNActivity getParent() {
+ return(m_parent);
+ }
+
+ /**
+ * This method returns the container associated with the
+ * activity.
+ *
+ * @return The container
+ */
+ public Object getContainer() {
+ return(m_parent.getContainer());
+ }
+
+ /**
+ * This method returns the model.
+ *
+ * @return The model
+ */
+ protected org.savara.tools.bpmn.generation.BPMNModelFactory getModelFactory() {
+ return(m_modelFactory);
+ }
+
+ /**
+ * This method returns the notation factory.
+ *
+ * @return The notation factory
+ */
+ protected org.savara.tools.bpmn.generation.BPMNNotationFactory getNotationFactory() {
+ return(m_notationFactory);
+ }
+
+ /**
+ * This method adds a child BPMN state.
+ *
+ * @param child The child BPMN state
+ */
+ protected void addChildState(BPMNActivity child) {
+ m_childStates.add(child);
+ }
+
+ /**
+ * This method returns the list of child states.
+ *
+ * @return The child states
+ */
+ protected java.util.Vector getChildStates() {
+ return(m_childStates);
+ }
+
+ /**
+ * This method indicates that the BPMN state for the
+ * child nodes is complete.
+ *
+ */
+ public void childrenComplete() {
+ }
+
+ /**
+ * This method returns the containing BPMN diagram.
+ *
+ * @return The BPMN diagram
+ */
+ public BPMNDiagram getBPMNDiagram() {
+ BPMNDiagram ret=null;
+
+ if (m_parent != null) {
+ ret = m_parent.getBPMNDiagram();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the BPMN Activity Model.
+ *
+ * @return The activity model
+ */
+ /*
+ public Activity getTopLevelActivity() {
+ Activity ret=null;
+
+ if (m_parent != null) {
+ ret = m_parent.getTopLevelActivity();
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the BPMN Activity Partition.
+ *
+ * @return The activity model
+ */
+ /*
+ public ActivityPartition getActivityPartition() {
+ ActivityPartition ret=null;
+
+ if (m_parent != null) {
+ ret = m_parent.getActivityPartition();
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method causes a transition to be established from
+ * the supplied BPMN state to the current state, applying
+ * any relevant information (such as event triggers
+ * or conditios) to the transition as appropriate.
+ *
+ * @param fromNode The source node
+ * @param expression The optional conditional expression
+ * @return The edge
+ */
+ public Object transitionFrom(BPMNActivity fromNode,
+ String conditionalExpression) {
+ Object ret=getModelFactory().createControlLink(getContainer(),
+ fromNode.getEndNode(),
+ getStartNode(), conditionalExpression);
+
+ /*
+ Activity activity=getTopLevelActivity();
+ ActivityEdge ret=(ActivityEdge)
+ activity.createEdge(null, UMLPackage.eINSTANCE.getControlFlow());
+ ret.getInPartitions().add(getActivityPartition());
+
+ ret.setSource(fromNode.getEndNode());
+ ret.setTarget(getStartNode());
+ */
+
+ return(ret);
+ }
+
+ /**
+ * This method joins a list of sequential child BPMN states with transitions.
+ *
+ * @param children The list of child BPMN states
+ */
+ public void transitionSequentialNodes() {
+ int width=0;
+ int height=0;
+
+ if (getChildStates().size() > 0) {
+ BPMNActivity v1=(BPMNActivity)getChildStates().get(0);
+ width += v1.getWidth();
+ height = v1.getHeight();
+ }
+
+ for (int i=1; i < getChildStates().size(); i++) {
+ BPMNActivity v1=(BPMNActivity)getChildStates().get(i-1);
+ BPMNActivity v2=(BPMNActivity)getChildStates().get(i);
+
+ width += v2.getWidth();
+
+ width += HORIZONTAL_GAP; // Gap
+
+ if (height < v2.getHeight()) {
+ height = v2.getHeight();
+ }
+
+ Object endNode=v1.getEndNode();
+
+ if (v1.canDeleteEndNode() &&
+ (getModelFactory().isJoin(endNode) || // instanceof org.eclipse.uml2.uml.MergeNode ||
+ getModelFactory().isTerminal(endNode))) { // instanceof org.eclipse.uml2.uml.FlowFinalNode) {
+
+ // Move the incoming transitions from the junction
+ // to the next state
+ java.util.List list=getModelFactory().getInboundControlLinks(endNode);
+ for (int j=list.size()-1; j >= 0; j--) {
+ Object transition=list.get(j);
+
+ getModelFactory().setTarget(transition, v2.getStartNode());
+ //transition.setTarget(v2.getStartNode());
+ }
+
+ // Remove Junction
+ getModelFactory().delete(endNode);
+
+ } else {
+ v2.transitionFrom(v1, null);
+ }
+ }
+
+ //height += VERTICAL_GAP; // Gap
+
+ setWidth(width);
+ setHeight(height);
+//System.out.println("THIS: children="+m_childStates.size()+
+// " this="+this+" width="+width+" height="+height);
+ }
+
+ public int getX() {
+ return(m_x);
+ }
+
+ public void setX(int x) {
+//System.out.println("SETX: this="+this+" x="+x);
+ m_x = x;
+ }
+
+ public int getY() {
+ return(m_y);
+ }
+
+ public void setY(int y) {
+//System.out.println("SETY: this="+this+" y="+y);
+ m_y = y;
+ }
+
+ public int getWidth() {
+ return(m_width);
+ }
+
+ public void setWidth(int width) {
+ m_width = width;
+ }
+
+ public int getHeight() {
+ return(m_height);
+ }
+
+ public void setHeight(int height) {
+ m_height = height;
+ }
+
+ public void adjustWidth(int width) {
+ float percentChange=width/getWidth();
+
+ //setWidth(width);
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ int cur=act.getWidth();
+ int newWidth=(int)((float)cur * percentChange);
+
+ act.adjustWidth(newWidth);
+
+ int change=act.getWidth()-cur;
+
+ setWidth(getWidth()+change);
+ }
+ }
+
+ public void calculatePosition(int x, int y) {
+ setX(x);
+ setY(y);
+ }
+
+ public void draw(Object parent) {
+ }
+
+ public boolean canDeleteEndNode() {
+ return(true);
+ }
+
+ public static final int VERTICAL_GAP = 40;
+ public static final int HORIZONTAL_GAP = 50;
+
+ private BPMNActivity m_parent=null;
+ private org.savara.tools.bpmn.generation.BPMNModelFactory m_modelFactory=null;
+ private org.savara.tools.bpmn.generation.BPMNNotationFactory m_notationFactory=null;
+ private java.util.Vector m_childStates=new java.util.Vector();
+ private int m_x=0;
+ private int m_y=0;
+ private int m_width=0;
+ private int m_height=0;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+/**
+ * This interface represents the generic capabilities of a state
+ * managing component in the CDL to BPMN transformation.
+ *
+ */
+public interface BPMNActivity {
+
+ /**
+ * This method returns the parent BPMN activity.
+ *
+ * @return The parent
+ */
+ public BPMNActivity getParent();
+
+ /**
+ * This method returns the container object associated
+ * with this activity.
+ *
+ * @return The container
+ */
+ public Object getContainer();
+
+ /**
+ * This method indicates that the BPMN state for the
+ * child nodes is complete.
+ *
+ */
+ public void childrenComplete();
+
+ /**
+ * This method returns the BPMN top level Activity.
+ *
+ * @return The top level activity
+ */
+ //public Activity getTopLevelActivity();
+
+ /**
+ * This method returns the containing ActivityModel.
+ *
+ * @return The activity model
+ */
+ public BPMNDiagram getBPMNDiagram();
+
+ /**
+ * This method returns the BPMN Activity Partition.
+ *
+ * @return The activity model
+ */
+ //public ActivityPartition getActivityPartition();
+
+ /**
+ * This method returns the start node for the activites
+ * represented by this UML activity implementation.
+ *
+ * @return The starting node
+ */
+ public Object getStartNode();
+
+ /**
+ * This method returns the end node for the activities
+ * represented by this BPMN activity implementation.
+ *
+ * @return The ending node
+ */
+ public Object getEndNode();
+
+ /**
+ * This method returns the start state.
+ *
+ * @return The start state
+ */
+ public BPMNActivity getStartState();
+
+ /**
+ * This method returns the end state.
+ *
+ * @return The end state
+ */
+ public BPMNActivity getEndState();
+
+ /**
+ * This method causes a transition to be established from
+ * the supplied BPMN state to the current state, applying
+ * any relevant information (such as event triggers
+ * or conditios) to the transition as appropriate.
+ *
+ * @param fromNode The source node
+ * @param expression The optional conditional expression
+ * @return The edge
+ */
+ public Object transitionFrom(BPMNActivity fromNode, String expression);
+
+ public int getX();
+
+ public void setX(int x);
+
+ public int getY();
+
+ public void setY(int y);
+
+ public int getWidth();
+
+ public void setWidth(int width);
+
+ public int getHeight();
+
+ public void setHeight(int height);
+
+ public void adjustWidth(int width);
+
+ public void calculatePosition(int x, int y);
+
+ public void draw(Object parent);
+
+ public boolean canDeleteEndNode();
+
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNDiagram.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNDiagram.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNDiagram.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,465 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.service.behavior.BehaviorDescription;
+import org.pi4soa.service.behavior.BehaviorType;
+import org.pi4soa.service.behavior.CompletionHandler;
+import org.pi4soa.service.behavior.ExceptionHandler;
+import org.savara.tools.bpmn.generation.BPMNGenerationException;
+
+/**
+ * This class represents the state information associated with
+ * the construction of a BPMN Activity model.
+ *
+ */
+public class BPMNDiagram extends AbstractBPMNActivity {
+
+ /**
+ * This is the constructor for the activity model.
+ *
+ * @param choreoName The choreography name
+ * @param diagramName The diagram name
+ * @param parent The parent activity
+ * @param model The model factory
+ * @param folder The output folder
+ * @exception BPMNGenerationException Failed to construct activity model
+ */
+ public BPMNDiagram(String choreoName, String diagramName,
+ BPMNActivity parent,
+ org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation,
+ String folder) throws BPMNGenerationException {
+ super(parent, model, notation);
+
+ m_name = choreoName+"_"+diagramName;
+
+ m_diagram = model.createDiagram();
+ m_folder = folder;
+ }
+
+ /**
+ * This method returns the container associated with the
+ * activity.
+ *
+ * @return The container
+ */
+ public Object getContainer() {
+ return(m_container);
+ }
+
+ /**
+ * This method sets the container associated with the
+ * BPMN model.
+ *
+ * @param container The container
+ */
+ public BPMNPool createPool(String participant) {
+ BPMNPool ret=new BPMNPool(m_diagram, participant,
+ this, getModelFactory(), getNotationFactory());
+
+ if (m_pools.containsKey(participant)) {
+ m_duplicatePools.add(ret);
+ } else {
+ m_pools.put(participant, ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the state machine name to be used for the
+ * supplied behavior type.
+ *
+ * @param elem The behavior type
+ * @return The name
+ */
+ public static String getName(BehaviorType elem) {
+ String ret=elem.getName();
+
+ if (elem instanceof BehaviorDescription) {
+ ret = ((BehaviorDescription)elem).getName();
+
+ if (org.pi4soa.common.util.NamesUtil.isSet(
+ ((BehaviorDescription)elem).getParticipant()) &&
+ ret.endsWith("_"+((BehaviorDescription)elem).getParticipant())) {
+
+ ret = ret.substring(0, ret.length()-
+ ((BehaviorDescription)elem).getParticipant().length()-1);
+ }
+
+ } else if (elem instanceof CompletionHandler) {
+ ret = getName(((CompletionHandler)elem).
+ getEnclosingBehaviorDescription())+"["+
+ ret+"]";
+
+ } else if (elem instanceof ExceptionHandler) {
+ String excType=((ExceptionHandler)elem).getExceptionType();
+ if (NamesUtil.isSet(excType) == false) {
+ excType = "default";
+ }
+
+ ret = getName(((ExceptionHandler)elem).
+ getEnclosingBehaviorDescription())+"[exception="+
+ excType+"]";
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the supplied behavior type
+ * should result in a root entry/exit point from the
+ * state machine.
+ *
+ * @param elem The behavior type
+ * @return Whether it is a root
+ */
+ protected boolean isRoot(BehaviorType elem) {
+ boolean ret=false;
+
+ if (elem instanceof BehaviorDescription &&
+ ((BehaviorDescription)elem).isRoot()) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the containing ActivityModel.
+ *
+ * @return The activity model
+ */
+ public BPMNDiagram getBPMNDiagram() {
+ return(this);
+ }
+
+ /**
+ * This method returns the start node for the activites
+ * represented by this BPMN activity implementation.
+ *
+ * @return The starting node
+ */
+ public Object getStartNode() {
+ //return(m_initialState.getStartNode());
+ return(null);
+ }
+
+ /**
+ * This method returns the end node for the activities
+ * represented by this BPMN activity implementation.
+ *
+ * @return The ending node
+ */
+ public Object getEndNode() {
+ //return(m_finalState.getEndNode());
+ return(null);
+ }
+
+ /**
+ * This method returns the start state.
+ *
+ * @return The start state
+ */
+ public BPMNActivity getStartState() {
+ return(null);
+ }
+
+ /**
+ * This method returns the end state.
+ *
+ * @return The end state
+ */
+ public BPMNActivity getEndState() {
+ return(null);
+ }
+
+ /**
+ * This method registers a send activity against the BPMN representation.
+ *
+ * @param send The send activity
+ * @param activity The BPMN representation
+ */
+ public void registerSendActivity(org.pi4soa.service.behavior.Send send,
+ BPMNActivity activity) {
+ if (isPoolDuplicate(activity) == false) {
+ m_sendActivities.put(send, activity);
+ }
+ }
+
+ /**
+ * This method registers a receive activity against the BPMN representation.
+ *
+ * @param recv The receive activity
+ * @param activity The BPMN representation
+ */
+ public void registerReceiveActivity(org.pi4soa.service.behavior.Receive recv,
+ BPMNActivity activity) {
+ if (isPoolDuplicate(activity) == false) {
+ m_receiveActivities.put(recv.getGlobalDescriptionURI(), activity);
+ }
+ }
+
+ /**
+ * This method registers an initiating perform activity
+ * against the BPMN representation.
+ *
+ * @param perform The perform activity
+ * @param activity The BPMN representation
+ */
+ public void registerInitiatingPerform(org.pi4soa.service.behavior.Perform perform,
+ BPMNActivity activity) {
+ m_initiatingPerforms.put(perform.getGlobalDescriptionURI(), activity);
+ }
+
+ /**
+ * This method registers an initiated perform activity
+ * against the BPMN representation.
+ *
+ * @param perform The perform activity
+ * @param activity The BPMN representation
+ */
+ public void registerInitiatedPerform(org.pi4soa.service.behavior.Perform perform,
+ BPMNActivity activity) {
+ m_initiatedPerforms.put(perform.getGlobalDescriptionURI(), activity);
+ }
+
+ /**
+ * This method determines if the supplied activity is
+ * associated with a duplicate pool that will be deleted.
+ *
+ * @param activity The activity
+ * @return Whether the activity is associated with a
+ * duplicate pool
+ */
+ protected boolean isPoolDuplicate(BPMNActivity activity) {
+ boolean ret=false;
+
+ while (activity != null && (activity instanceof BPMNPool)
+ == false) {
+ activity = activity.getParent();
+ }
+
+ if (activity != null) {
+ ret = m_duplicatePools.contains(activity);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method completes the generation of the model.
+ *
+ */
+ public void completeModel() throws BPMNGenerationException {
+ java.util.Enumeration iter=m_sendActivities.keys();
+ java.util.Vector messageLinks=new java.util.Vector();
+
+ while (iter.hasMoreElements()) {
+ org.pi4soa.service.behavior.Send send=
+ (org.pi4soa.service.behavior.Send)iter.nextElement();
+
+ BPMNActivity sendActivity=(BPMNActivity)
+ m_sendActivities.get(send);
+ ReceiveActivity receiveActivity=(ReceiveActivity)
+ m_receiveActivities.get(send.getGlobalDescriptionURI());
+
+ if (sendActivity != null && receiveActivity != null) {
+
+ if (m_sendReceiveAsControlLink) {
+
+ if (m_controlFromSendOnly) {
+ // Break links to the receive node, as control will
+ // be from the sending participant
+ receiveActivity.breakLinks();
+ }
+
+ // Create control flow between the activities
+ /*
+ Activity activity=getTopLevelActivity();
+ ActivityEdge ret=(ActivityEdge)
+ activity.createEdge(null, UMLPackage.eINSTANCE.getControlFlow());
+
+ ret.setSource(sendActivity.getEndNode());
+ ret.setTarget(receiveActivity.getStartNode());
+
+ ret.setName(send.getOperationName());
+ */
+ messageLinks.add(getModelFactory().
+ createMessageLink(m_diagram,
+ sendActivity.getEndNode(),
+ receiveActivity.getStartNode(),
+ receiveActivity.getReceive()));
+
+ // Check if the receive and send activities have a link to the
+ // same node, in which case remove the link from the send
+ checkForRedundantTargetLinks(sendActivity, receiveActivity);
+ }
+ }
+ }
+
+ // Process initiating and initiated performs
+ /* GPB: COMMENT OUT PERFORM LINKS FOR NOW
+ iter = m_initiatingPerforms.keys();
+
+ while (iter.hasMoreElements()) {
+ String key=(String)iter.nextElement();
+
+ PerformActivity initiatingPerform=(PerformActivity)
+ m_initiatingPerforms.get(key);
+ PerformActivity initiatedPerform=(PerformActivity)
+ m_initiatedPerforms.get(key);
+
+ if (initiatingPerform != null && initiatedPerform != null) {
+
+ if (m_performedAsControlLink) {
+
+ if (m_controlFromInitiatingPerformOnly) {
+ // Break links to the receive node, as control will
+ // be from the initiating participant
+ initiatedPerform.breakLinks();
+ }
+
+ // Create control flow between the activities
+ Activity activity=getTopLevelActivity();
+
+ ActivityEdge ret=(ActivityEdge)
+ activity.createEdge(null, UMLPackage.eINSTANCE.getControlFlow());
+
+ ret.setSource(initiatingPerform.getEndNode());
+ ret.setTarget(initiatedPerform.getStartNode());
+
+ // Check if the initiating and initiated performs have a link to the
+ // same node, in which case remove the link from the initiating/
+ checkForRedundantTargetLinks(initiatingPerform, initiatedPerform);
+
+ }
+
+ if (m_performedAsDependencyLink) {
+ initiatingPerform.getEndNode().createDependency(
+ initiatedPerform.getStartNode());
+ }
+ }
+ }
+ */
+
+ // Delete duplicate pools
+ for (int i=0; i < m_duplicatePools.size(); i++) {
+ BPMNPool pool=(BPMNPool)m_duplicatePools.get(i);
+ getModelFactory().delete(pool.getContainer());
+ getChildStates().remove(pool);
+ }
+
+ // Draw diagram
+ int cury=0;
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNPool pool=(BPMNPool)getChildStates().get(i);
+
+ pool.calculatePosition(0, cury);
+
+ cury += (pool.getHeight()+100);
+ }
+
+ getModelFactory().saveModel(m_folder+
+ java.io.File.separator+m_name+"."+
+ getModelFactory().getFileExtension(), m_diagram);
+
+ // Construct notation
+ Object diagramNotation=getNotationFactory().createDiagram(getModelFactory(), m_diagram,
+ getX(), getY(), getWidth(), getHeight());
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNPool pool=(BPMNPool)getChildStates().get(i);
+
+ pool.draw(diagramNotation);
+ }
+
+ /* GPB: 25/4/08
+ * Don't generate message links, as diagram infers them
+ * anyway - and in the latest version the link positions
+ * the label incorrectly. If using the default message
+ * link is an issue, then need to investigate how to
+ * get label positioned correctly.
+ for (int i=0; i < messageLinks.size(); i++) {
+ Object mesglink=messageLinks.get(i);
+
+ getNotationFactory().createMessageLink(getModelFactory(),
+ mesglink, diagramNotation);
+ }
+ */
+
+ getNotationFactory().saveNotation(m_folder+
+ java.io.File.separator+m_name+"."+
+ getModelFactory().getFileExtension(), m_diagram,
+ m_folder+java.io.File.separator+m_name+"."+
+ getNotationFactory().getFileExtension(), diagramNotation);
+ }
+
+ protected void checkForRedundantTargetLinks(BPMNActivity source, BPMNActivity target) {
+
+ // Check if the target and source activities have a link to the
+ // same node, in which case remove the link from the source
+ java.util.List outgoing1=getModelFactory().getOutboundControlLinks(target.getStartNode());
+
+ for (int i=0; i < outgoing1.size(); i++) {
+ Object ae1=outgoing1.get(i);
+
+ java.util.List outgoing2=getModelFactory().getOutboundControlLinks(source.getStartNode());
+ boolean f_found=false;
+
+ for (int j=0; f_found==false && j < outgoing2.size(); j++){
+ Object ae2=outgoing2.get(j);
+
+ if (getModelFactory().getTarget(ae1) ==
+ getModelFactory().getTarget(ae2)) {
+ f_found = true;
+
+ getModelFactory().delete(ae2);
+ }
+ }
+ }
+ }
+
+ //private boolean m_completed=false;
+ private String m_name=null;
+ private Object m_diagram=null;
+ private String m_folder=null;
+ private Object m_container=null;
+ //private java.util.Hashtable m_pools=new java.util.Hashtable();
+ //private BPMNActivity m_initialState=null;
+ //private BPMNActivity m_finalState=null;
+ private java.util.Hashtable m_sendActivities=new java.util.Hashtable();
+ private java.util.Hashtable m_receiveActivities=new java.util.Hashtable();
+ private java.util.Hashtable m_initiatingPerforms=new java.util.Hashtable();
+ private java.util.Hashtable m_initiatedPerforms=new java.util.Hashtable();
+
+ private java.util.Hashtable m_pools=new java.util.Hashtable();
+ private java.util.Vector m_duplicatePools=new java.util.Vector();
+
+ private boolean m_sendReceiveAsControlLink=true;
+ private boolean m_controlFromSendOnly=false;
+
+ //private boolean m_performedAsControlLink=true;
+ //private boolean m_performedAsDependencyLink=false;
+ //private boolean m_controlFromInitiatingPerformOnly=false;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNPool.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNPool.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/BPMNPool.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2005-6 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR 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 Jan 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+import org.pi4soa.service.behavior.BehaviorDescription;
+import org.pi4soa.service.behavior.Choice;
+import org.savara.tools.bpmn.generation.BPMNGenerationException;
+
+public class BPMNPool extends AbstractBPMNActivity {
+
+ /**
+ * This constructor initializes the pool state.
+ *
+ * @param diagram The diagram
+ * @param name The pool name
+ * @param parent The parent BPMN state
+ * @param model The BPMN model
+ */
+ public BPMNPool(Object diagram, String name,
+ BPMNActivity parent,
+ org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation) {
+ super(parent, model, notation);
+
+ initialize(diagram, name);
+ }
+
+ /**
+ * This method performs the initialization of the
+ * activity model.
+ *
+ * @param diagram The diagram
+ * @param name The pool name
+ */
+ public void initialize(Object diagram, String name) {
+
+ m_pool = getModelFactory().createPool(diagram, name);
+
+ /*
+ m_activityModel = (org.eclipse.uml2.uml.Activity)
+ servicePackage.createPackagedElement(null,
+ UMLPackage.eINSTANCE.getActivity());
+
+ m_activityModel.setName(getName(elem));
+ */
+
+ // Create initial state
+ /*
+ org.eclipse.uml2.uml.InitialNode initialState=
+ (org.eclipse.uml2.uml.InitialNode)
+ m_activityModel.createNode(null, UMLPackage.eINSTANCE.getInitialNode());
+
+ m_initialState = new SimpleActivity(initialState, this);
+ */
+ m_initialState = new JunctionActivity(getModelFactory().createInitialNode(getContainer()),
+ this, getModelFactory(), getNotationFactory());
+
+ // Create final state
+ /*
+ org.eclipse.uml2.uml.FlowFinalNode finalState=
+ (org.eclipse.uml2.uml.FlowFinalNode)
+ m_activityModel.createNode(null, UMLPackage.eINSTANCE.getFlowFinalNode());
+
+ m_finalState = new SimpleActivity(finalState, this);
+ */
+ m_finalState = new JunctionActivity(getModelFactory().createFinalNode(getContainer()),
+ this, getModelFactory(), getNotationFactory());
+
+ }
+
+ /**
+ * This method returns the container associated with the
+ * activity.
+ *
+ * @return The container
+ */
+ public Object getContainer() {
+ return(m_pool);
+ }
+
+ public Object getStartNode() {
+ return(m_initialState.getStartNode());
+ }
+
+ public Object getEndNode() {
+ return(m_finalState.getEndNode());
+ }
+
+ /**
+ * This method returns the start state.
+ *
+ * @return The start state
+ */
+ public BPMNActivity getStartState() {
+ return(m_initialState);
+ }
+
+ /**
+ * This method returns the end state.
+ *
+ * @return The end state
+ */
+ public BPMNActivity getEndState() {
+ return(m_finalState);
+ }
+
+ /**
+ * This method indicates that the BPMN state for the
+ * child nodes is complete.
+ *
+ */
+ public void childrenComplete() {
+
+ if (m_completed == false) {
+
+ // Move the final state to the end of the list
+ if (getChildStates().remove(m_finalState)) {
+ getChildStates().add(m_finalState);
+ }
+
+ // Join the child state vertex with transitions
+ transitionSequentialNodes();
+
+ // Add padding
+ setHeight(getHeight()+(VERTICAL_GAP*2));
+
+ m_completed = true;
+ }
+ }
+
+ public void calculatePosition(int x, int y) {
+ int curx=0;
+ int midy=(getHeight()/2);
+
+ setX(x);
+ setY(y+VERTICAL_GAP);
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.calculatePosition(curx, midy-(act.getHeight()/2));
+
+ curx += (act.getWidth()+HORIZONTAL_GAP);
+ }
+ }
+
+ public void draw(Object parent) {
+
+ // Construct notation
+ Object notation=getNotationFactory().createPool(getModelFactory(), m_pool,
+ parent, getX(), getY(), getWidth(), getHeight());
+
+ //m_initialState.draw(notation);
+ //m_finalState.draw(notation);
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.draw(notation);
+ }
+ }
+
+ private boolean m_completed=false;
+ private Object m_pool=null;
+ private BPMNActivity m_initialState=null;
+ private BPMNActivity m_finalState=null;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ChoiceActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ChoiceActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ChoiceActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,320 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+import org.pi4soa.service.behavior.Choice;
+import org.savara.tools.bpmn.generation.*;
+
+/**
+ * This class represents a selection of states within a
+ * BPMN state machine.
+ *
+ */
+public class ChoiceActivity extends AbstractBPMNActivity {
+
+ /**
+ * This constructor initializes the choice state.
+ *
+ * @param choice The choice
+ * @param parent The parent BPMN state
+ * @param model The BPMN model
+ */
+ public ChoiceActivity(Choice choice, BPMNActivity parent,
+ org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation)
+ throws BPMNGenerationException {
+ super(parent, model, notation);
+
+ initialize(choice);
+ }
+
+ /**
+ * This method performs the initialization of the
+ * choice state.
+ *
+ * @param elem The choice
+ * @throws BPMNGenerationException Failed to initialize
+ */
+ protected void initialize(Choice elem) throws BPMNGenerationException {
+
+ // Get region
+ //Activity region=getTopLevelActivity();
+
+ // Determine if choice is event based, or data based
+ boolean dataBased=true;
+
+ java.util.List children=elem.getActivityTypes();
+ for (int i=0; i < children.size(); i++) {
+ org.pi4soa.service.behavior.ActivityType act=
+ (org.pi4soa.service.behavior.ActivityType)children.get(i);
+
+ if (act instanceof org.pi4soa.service.behavior.StructuralType) {
+ org.pi4soa.service.behavior.StructuralType st=
+ (org.pi4soa.service.behavior.StructuralType)act;
+
+ if ((st.isConditionalGroupingConstruct() == false ||
+ (st.isConditionalGroupingConstruct() &&
+ st.isConditionObservable() == false)) &&
+ st.isPredicateExtensionRequired() == false) {
+ dataBased = false;
+ }
+
+ /*
+ String expr=null;
+
+ if (st instanceof org.pi4soa.service.behavior.Conditional) {
+ expr = ((org.pi4soa.service.behavior.Conditional)st).getExpression();
+ } else if (st instanceof org.pi4soa.service.behavior.While) {
+ expr = ((org.pi4soa.service.behavior.While)st).getExpression();
+ } else if (st instanceof org.pi4soa.service.behavior.When) {
+ expr = ((org.pi4soa.service.behavior.When)st).getExpression();
+ }
+
+ if (expr != null && expr.trim().length() == 0) {
+ expr = "";
+ }
+
+ m_expressions.add(expr);
+ */
+ }
+ }
+
+ // If not data-based, then clear list of expressions
+ /*
+ if (dataBased == false) {
+ m_expressions.clear();
+ }
+ */
+
+ // Create choice state
+ Object choiceState=null;
+
+ if (dataBased) {
+ choiceState=getModelFactory().createDataBasedXORGateway(getContainer());
+ } else {
+ choiceState=getModelFactory().createEventBasedXORGateway(getContainer());
+ }
+
+ //region.createNode(null, UMLPackage.eINSTANCE.getDecisionNode());
+ //choiceState.getInPartitions().add(getActivityPartition());
+
+ m_choiceState = new JunctionActivity(choiceState, this,
+ getModelFactory(), getNotationFactory());
+
+ // Create junction state
+ Object junctionState=null;
+
+ if (dataBased) {
+ junctionState=getModelFactory().createDataBasedXORGateway(getContainer());
+ } else {
+ junctionState=getModelFactory().createEventBasedXORGateway(getContainer());
+ }
+
+ //region.createNode(null, UMLPackage.eINSTANCE.getMergeNode());
+ //junctionState.getInPartitions().add(getActivityPartition());
+
+ m_junctionState = new JunctionActivity(junctionState, this,
+ getModelFactory(), getNotationFactory());
+ }
+
+ /**
+ * This method indicates that the BPMN state for the
+ * child nodes is complete.
+ *
+ */
+ public void childrenComplete() {
+
+ if (m_completed == false) {
+ int width=m_choiceState.getWidth()+m_junctionState.getWidth()+
+ (2 * HORIZONTAL_GAP);
+ int height=0;
+
+ // Move the junction state to the end of the list
+ if (getChildStates().remove(m_junctionState)) {
+ getChildStates().add(m_junctionState);
+ }
+
+ // Join the child state vertex with transitions
+ int maxwidth=0;
+
+ for (int i=1; i < getChildStates().size()-1; i++) {
+ BPMNActivity umls=(BPMNActivity)getChildStates().get(i);
+
+ height += umls.getHeight();
+
+ if (i != 1) {
+ height += VERTICAL_GAP;
+ }
+
+ if (umls.getWidth() > maxwidth) {
+ maxwidth = umls.getWidth();
+ }
+
+ /*
+ String expr=null;
+
+ if (m_expressions.size() > 0) {
+ expr = (String)m_expressions.get(i-1);
+
+ if (expr != null && expr.length() == 0) {
+ expr = null;
+ }
+ }
+ */
+
+ umls.transitionFrom(m_choiceState, null);
+
+ // Check if state is a junction
+ Object endNode=umls.getEndNode();
+
+ /*
+ if (umls.getEndState().canDeleteEndNode() &&
+ (getModelFactory().isJoin(endNode) || // instanceof org.eclipse.uml2.uml.MergeNode ||
+ getModelFactory().isTerminal(endNode))) { // instanceof org.eclipse.uml2.uml.FlowFinalNode) {
+
+ // Move the incoming transitions from the junction
+ // to the next state
+ java.util.List list=getModelFactory().getInboundControlLinks(endNode);
+ for (int j=list.size()-1; j >= 0; j--) {
+ Object transition=list.get(j);
+
+ getModelFactory().setTarget(transition, m_junctionState.getStartNode());
+ //transition.setTarget(m_junctionState.getStartNode());
+ }
+
+ // Remove the junction
+ //endNode.destroy();
+ getModelFactory().delete(endNode);
+ } else {
+ */
+ m_junctionState.transitionFrom(umls, null);
+ //}
+ }
+
+ width += maxwidth;
+
+ if (height < m_choiceState.getHeight()) {
+ height = m_choiceState.getHeight();
+ }
+
+ if (height < m_junctionState.getHeight()) {
+ height = m_junctionState.getHeight();
+ }
+
+ setWidth(width);
+ setHeight(height);
+
+ adjustWidth(width);
+
+ m_completed = true;
+ }
+ }
+
+ public void calculatePosition(int x, int y) {
+ int cury=y;
+ int midx=x+(getWidth()/2);
+ int midy=y+(getHeight()/2);
+
+ setX(x);
+ setY(y);
+
+ for (int i=1; i < getChildStates().size()-1; i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.calculatePosition(midx-(act.getWidth()/2), cury);
+ //midy-(act.getHeight()/2));
+
+ cury += (act.getHeight()+VERTICAL_GAP);
+ }
+
+ m_choiceState.calculatePosition(x, midy-(m_choiceState.getHeight()/2));
+ m_junctionState.calculatePosition(x+getWidth()-
+ m_junctionState.getWidth(),
+ midy-(m_junctionState.getHeight()/2));
+ }
+
+ /**
+ * This method returns the start node for the activites
+ * represented by this BPMN activity implementation.
+ *
+ * @return The starting node
+ */
+ public Object getStartNode() {
+ return(m_choiceState.getStartNode());
+ }
+
+ /**
+ * This method returns the end node for the activities
+ * represented by this BPMN activity implementation.
+ *
+ * @return The ending node
+ */
+ public Object getEndNode() {
+ return(m_junctionState.getEndNode());
+ }
+
+ /**
+ * This method returns the start state.
+ *
+ * @return The start state
+ */
+ public BPMNActivity getStartState() {
+ return(m_choiceState);
+ }
+
+ /**
+ * This method returns the end state.
+ *
+ * @return The end state
+ */
+ public BPMNActivity getEndState() {
+ return(m_junctionState);
+ }
+
+ public void adjustWidth(int width) {
+
+ int extrawidth=m_choiceState.getWidth()+m_junctionState.getWidth()+
+ (2 * HORIZONTAL_GAP);
+
+ setWidth(width);
+
+ // Adjust child widths
+ for (int i=1; i < getChildStates().size()-1; i++) {
+ BPMNActivity umls=(BPMNActivity)getChildStates().get(i);
+
+ umls.adjustWidth(width-extrawidth);
+ }
+ }
+
+ public void draw(Object parent) {
+
+ // Construct notation
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.draw(parent);
+ }
+ }
+
+ private boolean m_completed=false;
+ private BPMNActivity m_choiceState=null;
+ private BPMNActivity m_junctionState=null;
+ //private java.util.Vector m_expressions=new java.util.Vector();
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ConditionalActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ConditionalActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ConditionalActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,362 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+import org.pi4soa.service.behavior.Choice;
+import org.pi4soa.service.behavior.Conditional;
+import org.savara.tools.bpmn.generation.BPMNGenerationException;
+
+/**
+ * This class represents a conditional decision within a
+ * BPMN state machine.
+ *
+ */
+public class ConditionalActivity extends AbstractBPMNActivity {
+
+ /**
+ * This constructor initializes the conditional state.
+ *
+ * @param conditional The conditional
+ * @param parent The parent BPMN state
+ * @param model The BPMN model
+ */
+ public ConditionalActivity(Conditional conditional,
+ BPMNActivity parent,
+ org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation)
+ throws BPMNGenerationException {
+ super(parent, model, notation);
+
+ initialize(conditional);
+ }
+
+ /**
+ * This method performs the initialization of the
+ * conditional state.
+ *
+ * @param elem The conditional
+ * @throws BPMNGenerationException Failed to initialize
+ */
+ protected void initialize(Conditional elem) throws BPMNGenerationException {
+ m_choiceElement = (elem.getParent() instanceof Choice);
+
+ // TODO: condition expression causes problem when used as
+ // name
+ m_conditionalDescription = elem.getName();
+
+ if (org.pi4soa.common.util.NamesUtil.isSet(elem.getExpression())) {
+ m_conditionalExpression = elem.getExpression();
+ }
+
+ if (isChoiceElement() == false) {
+
+ // Get region
+ /*
+ Activity region=getTopLevelActivity();
+
+ // Create choice state
+ ActivityNode choiceState = region.createNode(null,
+ UMLPackage.eINSTANCE.getDecisionNode());
+ choiceState.getInPartitions().add(getActivityPartition());
+ */
+ Object choiceState=getModelFactory().createDataBasedXORGateway(getContainer());
+
+ m_choiceState = new JunctionActivity(choiceState, this,
+ getModelFactory(), getNotationFactory());
+
+ // Create junction state
+ /*
+ ActivityNode junctionState = region.createNode(null,
+ UMLPackage.eINSTANCE.getMergeNode());
+ junctionState.getInPartitions().add(getActivityPartition());
+ */
+ Object junctionState=getModelFactory().createDataBasedXORGateway(getContainer());
+
+ m_junctionState = new JunctionActivity(junctionState, this,
+ getModelFactory(), getNotationFactory());
+ }
+ }
+
+ /**
+ * This method determines whether the conditional is a
+ * choice element.
+ *
+ * @return Whether a choice element
+ */
+ protected boolean isChoiceElement() {
+ return(m_choiceElement);
+ }
+
+ /**
+ * This method indicates that the UML state for the
+ * child nodes is complete.
+ *
+ */
+ public void childrenComplete() {
+
+ if (m_completed == false) {
+
+ if (isChoiceElement() == false) {
+
+ // Move the junction state to the end of the list
+ if (getChildStates().remove(m_junctionState)) {
+ getChildStates().add(m_junctionState);
+ }
+ }
+
+ // Join the child state vertex with transitions
+ transitionSequentialNodes();
+
+ if (isChoiceElement() == false) {
+
+ // Place the condition on the outgoing transition
+ // from the choice state, before adding the alternate
+ // 'false' path
+ java.util.List list=getModelFactory().getOutboundControlLinks(m_choiceState.getEndNode());
+
+ if (list.size() > 0) {
+ Object outgoing=list.get(0);
+
+ /*
+ org.eclipse.uml2.uml.OpaqueExpression expr=
+ (org.eclipse.uml2.uml.OpaqueExpression)
+ outgoing.createGuard("expression", null,
+ UMLPackage.eINSTANCE.getOpaqueExpression());
+ */
+
+ if (m_conditionalExpression != null) {
+ //expr.getBodies().add(m_conditionalExpression);
+ getModelFactory().setLinkExpression(outgoing,
+ m_conditionalExpression);
+ } else {
+ //expr.getBodies().add("<non-observable>");
+ getModelFactory().setLinkExpression(outgoing,
+ "<non-observable>");
+ }
+ }
+
+ // Have direct transition from choice to junction
+ // to represent the 'false' path
+ Object transition=
+ m_junctionState.transitionFrom(m_choiceState,
+ "false()");
+ //transition.setName("false");
+
+ /*
+ org.eclipse.uml2.uml.OpaqueExpression expr=
+ (org.eclipse.uml2.uml.OpaqueExpression)
+ transition.createGuard("expression", null,
+ UMLPackage.eINSTANCE.getOpaqueExpression());
+
+ expr.getBodies().add("false()");
+ */
+ }
+
+ if (isChoiceElement() == false) {
+ int width=0;
+ int height=0;
+
+ // Calculate extra width
+ /*
+ width = m_junctionState.getWidth()+
+ (HORIZONTAL_GAP*2)+
+ m_choiceState.getWidth();
+ */
+
+ height = m_choiceState.getHeight();
+
+ if (height < m_junctionState.getHeight()) {
+ height = m_junctionState.getHeight();
+ }
+
+ height += (VERTICAL_GAP*2);
+
+ setWidth(getWidth()+width);
+ setHeight(getHeight()+height);
+ }
+
+ m_completed = true;
+ }
+ }
+
+ /**
+ * This method causes a transition to be established from
+ * the supplied BPMN state to the current state, applying
+ * any relevant information (such as event triggers
+ * or conditions) to the transition as appropriate.
+ *
+ * @param fromVertex The source vertex
+ * @return The transition
+ */
+ public Object transitionFrom(BPMNActivity fromVertex,
+ String conditionalExpression) {
+ Object ret=null;
+
+ if (isChoiceElement()) {
+ String expr=m_conditionalExpression;
+
+ if (expr == null) {
+ expr = "<non-observable>";
+ }
+
+ ret = super.transitionFrom(fromVertex, expr);
+ } else {
+ ret = super.transitionFrom(fromVertex, conditionalExpression);
+ }
+
+ if (ret != null && m_conditionalDescription != null) {
+ String name=m_conditionalDescription.replace(' ', '_');
+ getModelFactory().setLabel(ret, name);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the start node for the activites
+ * represented by this BPMN activity implementation.
+ *
+ * @return The starting node
+ */
+ public Object getStartNode() {
+ Object ret=null;
+
+ if (isChoiceElement() == false) {
+ ret = m_choiceState.getStartNode();
+
+ } else if (getChildStates().size() > 0) {
+ BPMNActivity state=(BPMNActivity)getChildStates().get(0);
+ ret = state.getStartNode();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the end node for the activities
+ * represented by this BPMN activity implementation.
+ *
+ * @return The ending node
+ */
+ public Object getEndNode() {
+ Object ret=null;
+ int len=0;
+
+ if (isChoiceElement() == false) {
+ ret = m_junctionState.getEndNode();
+
+ } else if ((len=getChildStates().size()) > 0) {
+ BPMNActivity state=(BPMNActivity)getChildStates().get(len-1);
+ ret = state.getEndNode();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the start state.
+ *
+ * @return The start state
+ */
+ public BPMNActivity getStartState() {
+ BPMNActivity ret=null;
+
+ if (isChoiceElement() == false) {
+ ret = m_choiceState;
+
+ } else if (getChildStates().size() > 0) {
+ BPMNActivity state=(BPMNActivity)getChildStates().get(0);
+ ret = state;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the end state.
+ *
+ * @return The end state
+ */
+ public BPMNActivity getEndState() {
+ BPMNActivity ret=null;
+ int len=0;
+
+ if (isChoiceElement() == false) {
+ ret = m_junctionState;
+
+ } else if ((len=getChildStates().size()) > 0) {
+ BPMNActivity state=(BPMNActivity)getChildStates().get(len-1);
+ ret = state;
+ }
+
+ return(ret);
+ }
+
+ public void calculatePosition(int x, int y) {
+ if (isChoiceElement()) {
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ if (act instanceof SequenceActivity) {
+ act.calculatePosition(x, y);
+ }
+ }
+
+ } else {
+ int junctionY=y+getHeight()-VERTICAL_GAP;
+ //int junctionY=y+(getHeight()/2);
+
+ m_choiceState.calculatePosition(x, junctionY-
+ (m_choiceState.getHeight()/2));
+ m_junctionState.calculatePosition(x+getWidth()-
+ m_junctionState.getWidth(), junctionY-
+ (m_junctionState.getHeight()/2));
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ if (act instanceof SequenceActivity) {
+ act.calculatePosition(x+
+ m_choiceState.getWidth()+
+ HORIZONTAL_GAP, y);
+ }
+ }
+ }
+ }
+
+ public void draw(Object parent) {
+
+ // Construct notation
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.draw(parent);
+ }
+ }
+
+ private boolean m_completed=false;
+ private boolean m_choiceElement=false;
+
+ private BPMNActivity m_choiceState=null;
+ private BPMNActivity m_junctionState=null;
+ private String m_conditionalDescription=null;
+ private String m_conditionalExpression=null;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/JunctionActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/JunctionActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/JunctionActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+/**
+ * This class represents a junction within a
+ * BPMN process.
+ *
+ */
+public class JunctionActivity extends AbstractBPMNActivity {
+
+ /**
+ * This constructor initializes the junction activity.
+ *
+ * @param node The junction node
+ * @param parent The parent BPMN state
+ * @param model The BPMN model
+ */
+ public JunctionActivity(Object node,
+ BPMNActivity parent, org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation) {
+ super(parent, model, notation);
+
+ m_node = node;
+
+ }
+
+ /**
+ * This method returns the start node for the activites
+ * represented by this UML activity implementation.
+ *
+ * @return The starting node
+ */
+ public Object getStartNode() {
+ return(m_node);
+ }
+
+ /**
+ * This method returns the end node for the activities
+ * represented by this UML activity implementation.
+ *
+ * @return The ending node
+ */
+ public Object getEndNode() {
+ return(m_node);
+ }
+
+ /**
+ * This method returns the start state.
+ *
+ * @return The start state
+ */
+ public BPMNActivity getStartState() {
+ return(this);
+ }
+
+ /**
+ * This method returns the end state.
+ *
+ * @return The end state
+ */
+ public BPMNActivity getEndState() {
+ return(this);
+ }
+
+ public int getWidth() {
+ return(30);
+ }
+
+ public int getHeight() {
+ return(30);
+ }
+
+ public void draw(Object parent) {
+
+ if (getModelFactory().isDeleted(m_node) == false) {
+ getNotationFactory().createJunction(getModelFactory(),
+ m_node, parent, getX(), getY(), getWidth(), getHeight());
+ }
+ }
+
+ private Object m_node=null;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ParallelActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ParallelActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ParallelActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+import org.pi4soa.service.behavior.Parallel;
+import org.savara.tools.bpmn.generation.BPMNGenerationException;
+
+/**
+ * This class represents a parallel grouping of states within a
+ * UML state machine.
+ *
+ */
+public class ParallelActivity extends AbstractBPMNActivity {
+
+ /**
+ * This constructor initializes the parallel state.
+ *
+ * @param parallel The parallel
+ * @param parent The parent BPMN state
+ * @param model The BPMN model
+ */
+ public ParallelActivity(Parallel parallel, BPMNActivity parent,
+ org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation)
+ throws BPMNGenerationException {
+ super(parent, model, notation);
+
+ initialize(parallel);
+ }
+
+ /**
+ * This method performs the initialization of the
+ * parallel state.
+ *
+ * @param elem The parallel
+ * @throws BPMNGenerationException Failed to initialize
+ */
+ protected void initialize(Parallel elem) throws BPMNGenerationException {
+
+ // Get region
+ /*
+ Activity region=getTopLevelActivity();
+
+ // Create parallel state
+ ActivityNode parallelState = region.createNode(null,
+ UMLPackage.eINSTANCE.getForkNode());
+ parallelState.getInPartitions().add(getActivityPartition());
+ */
+ Object parallelState=getModelFactory().createANDGateway(getContainer());
+
+ m_forkState = new JunctionActivity(parallelState, this,
+ getModelFactory(), getNotationFactory());
+
+ // Create join state
+ /*
+ ActivityNode joinState = region.createNode(null,
+ UMLPackage.eINSTANCE.getJoinNode());
+ joinState.getInPartitions().add(getActivityPartition());
+ */
+
+ Object joinState=getModelFactory().createANDGateway(getContainer());
+
+ m_joinState = new JunctionActivity(joinState, this,
+ getModelFactory(), getNotationFactory());
+ }
+
+ /**
+ * This method indicates that the UML state for the
+ * child nodes is complete.
+ *
+ */
+ public void childrenComplete() {
+
+ if (m_completed == false) {
+ int width=m_forkState.getWidth()+m_joinState.getWidth()+
+ (2 * HORIZONTAL_GAP);
+ int height=0;
+
+ // Move the junction state to the end of the list
+ if (getChildStates().remove(m_joinState)) {
+ getChildStates().add(m_joinState);
+ }
+
+ // Join the child state vertex with transitions
+ int maxwidth=0;
+
+ for (int i=1; i < getChildStates().size()-1; i++) {
+ BPMNActivity umls=(BPMNActivity)getChildStates().get(i);
+
+ height += (umls.getHeight()+VERTICAL_GAP);
+
+ if (umls.getWidth() > maxwidth) {
+ maxwidth = umls.getWidth();
+ }
+
+ umls.transitionFrom(m_forkState, null);
+
+ // Check if state is a junction
+ Object endNode=umls.getEndNode();
+
+ /* Do not remove endpoint junctions from
+ * parallel elements, as this can cause issues
+ * with layout
+ if (getModelFactory().isJoin(endNode) || // instanceof org.eclipse.uml2.uml.MergeNode ||
+ getModelFactory().isTerminal(endNode)) { // instanceof org.eclipse.uml2.uml.FlowFinalNode) {
+
+ // Move the incoming transitions from the junction
+ // to the next state
+ java.util.List list=getModelFactory().getInboundControlLinks(endNode);
+ for (int j=list.size()-1; j >= 0; j--) {
+ Object transition=list.get(j);
+
+ getModelFactory().setTarget(transition,
+ m_joinState.getStartNode());
+ }
+
+ // Remove the junction
+ getModelFactory().delete(endNode);
+ } else {
+ */
+ m_joinState.transitionFrom(umls, null);
+ //}
+ }
+
+ width += maxwidth;
+
+ if (height >= HORIZONTAL_GAP) {
+ height -= HORIZONTAL_GAP;
+ }
+
+ if (height < m_forkState.getHeight()) {
+ height = m_forkState.getHeight();
+ }
+
+ if (height < m_joinState.getHeight()) {
+ height = m_joinState.getHeight();
+ }
+
+ setWidth(width);
+ setHeight(height);
+
+ adjustWidth(width);
+
+ m_completed = true;
+ }
+ }
+
+ /**
+ * This method returns the start node for the activites
+ * represented by this UML activity implementation.
+ *
+ * @return The starting node
+ */
+ public Object getStartNode() {
+ return(m_forkState.getStartNode());
+ }
+
+ /**
+ * This method returns the end node for the activities
+ * represented by this UML activity implementation.
+ *
+ * @return The ending node
+ */
+ public Object getEndNode() {
+ return(m_joinState.getEndNode());
+ }
+
+ /**
+ * This method returns the start state.
+ *
+ * @return The start state
+ */
+ public BPMNActivity getStartState() {
+ return(m_forkState);
+ }
+
+ /**
+ * This method returns the end state.
+ *
+ * @return The end state
+ */
+ public BPMNActivity getEndState() {
+ return(m_joinState);
+ }
+
+ public void adjustWidth(int width) {
+ int extrawidth=m_forkState.getWidth()+m_joinState.getWidth()+
+ (2 * HORIZONTAL_GAP);
+
+ setWidth(width);
+
+ // Adjust child widths
+ for (int i=1; i < getChildStates().size()-1; i++) {
+ BPMNActivity umls=(BPMNActivity)getChildStates().get(i);
+
+ umls.adjustWidth(width-extrawidth);
+ }
+ }
+
+ public void calculatePosition(int x, int y) {
+ int cury=y;
+ int midx=x+(getWidth()/2);
+ int midy=y+(getHeight()/2);
+
+ setX(x);
+ setY(y);
+
+ for (int i=1; i < getChildStates().size()-1; i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.calculatePosition(midx-(act.getWidth()/2), cury);
+ //midy-(act.getHeight()/2));
+
+ cury += (act.getHeight()+VERTICAL_GAP);
+ }
+
+ m_forkState.calculatePosition(x, midy);
+ m_joinState.calculatePosition(x+getWidth()-
+ m_joinState.getWidth(), midy);
+ }
+
+ public void draw(Object parent) {
+
+ // Construct notation
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.draw(parent);
+ }
+ }
+
+ private boolean m_completed=false;
+ private BPMNActivity m_forkState=null;
+ private BPMNActivity m_joinState=null;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/PerformActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/PerformActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/PerformActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+/**
+ * This class represents the BPMN activity node for a Perform activity.
+ *
+ */
+public class PerformActivity extends SimpleActivity {
+
+ /**
+ * This constructor initializes the receive state.
+ *
+ * @param act The behavioral activity
+ * @param parent The parent BPMN state
+ * @param model The BPMN model
+ */
+ public PerformActivity(org.pi4soa.service.behavior.ActivityType act,
+ BPMNActivity parent,
+ org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation) {
+ super(act, parent, model, notation);
+ }
+
+ /**
+ * This method causes the receive activity to break any
+ * existing control links, including removing preceeding
+ * nodes that only have these links as their outgoing
+ * links.
+ *
+ */
+ public void breakLinks() {
+ Object node=getStartNode();
+
+ java.util.List list=getModelFactory().getInboundControlLinks(node);
+
+ for (int i=list.size()-1; i >= 0; i--) {
+ Object edge=list.get(i);
+
+ tidyUpEdge(edge);
+ }
+ }
+
+ /**
+ * This method tidies up an activity edge, recursively being
+ * called if its source node only has a single incoming
+ * activity edge.
+ *
+ * @param edge The activity edge
+ */
+ protected void tidyUpEdge(Object edge) {
+
+ // Check if source node has only a single incoming link
+ // and if so, then remove the node
+ Object sourceNode=getModelFactory().getSource(edge);
+
+ getModelFactory().delete(edge);
+
+ // If has less than 2 incoming links and no
+ // outgoing link, then tidyup node and links recursively
+ if (getModelFactory().getInboundControlLinks(sourceNode).size() <= 1 &&
+ getModelFactory().getOutboundControlLinks(sourceNode).size() == 0 &&
+ (getModelFactory().isDecision(sourceNode) || // was decision node
+ getModelFactory().isJoin(sourceNode))) { // was merge node
+ if (getModelFactory().getInboundControlLinks(sourceNode).size() == 1) {
+ Object actedge=getModelFactory().
+ getInboundControlLinks(sourceNode).get(0);
+
+ tidyUpEdge(actedge);
+ }
+
+ getModelFactory().delete(sourceNode);
+ }
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ReceiveActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ReceiveActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/ReceiveActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+/**
+ * This class represents the UML activity node for a Receive activity.
+ *
+ */
+public class ReceiveActivity extends SimpleActivity {
+
+ /**
+ * This constructor initializes the receive state.
+ *
+ * @param act The behavioral activity
+ * @param parent The parent BPMN state
+ * @param model The BPMN model
+ */
+ public ReceiveActivity(org.pi4soa.service.behavior.Receive act,
+ BPMNActivity parent, org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation) {
+ super(act, parent, model, notation);
+
+ m_receive = act;
+ }
+
+ /**
+ * This method returns the behavioral receive activity.
+ *
+ * @return The receive activity
+ */
+ public org.pi4soa.service.behavior.Receive getReceive() {
+ return(m_receive);
+ }
+
+ /**
+ * This method causes the receive activity to break any
+ * existing control links, including removing preceeding
+ * nodes that only have these links as their outgoing
+ * links.
+ *
+ */
+ public void breakLinks() {
+ Object node=getStartNode();
+
+ java.util.List list=getModelFactory().getInboundControlLinks(node);
+
+ for (int i=list.size()-1; i >= 0; i--) {
+ Object edge=list.get(i);
+
+ tidyUpEdge(edge);
+ }
+ }
+
+ /**
+ * This method tidies up an activity edge, recursively being
+ * called if its source node only has a single incoming
+ * activity edge.
+ *
+ * @param edge The activity edge
+ */
+ protected void tidyUpEdge(Object edge) {
+
+ // Check if source node has only a single incoming link
+ // and if so, then remove the node
+ Object sourceNode=getModelFactory().getSource(edge);
+
+ getModelFactory().delete(edge);
+
+ // If has less than 2 incoming links and no
+ // outgoing link, then tidyup node and links recursively
+ if (getModelFactory().getInboundControlLinks(sourceNode).size() <= 1 &&
+ getModelFactory().getOutboundControlLinks(sourceNode).size() == 0 &&
+ (getModelFactory().isDecision(sourceNode) || // was decision node
+ getModelFactory().isJoin(sourceNode))) { // was merge node
+ if (getModelFactory().getInboundControlLinks(sourceNode).size() == 1) {
+ Object actedge=getModelFactory().
+ getInboundControlLinks(sourceNode).get(0);
+
+ tidyUpEdge(actedge);
+ }
+
+ getModelFactory().delete(sourceNode);
+ }
+ }
+
+ private org.pi4soa.service.behavior.Receive m_receive=null;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/SequenceActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/SequenceActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/SequenceActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+//import org.pi4soa.service.behavior.Sequence;
+
+/**
+ * This class represents a sequence of states within a
+ * UML state machine.
+ *
+ */
+public class SequenceActivity extends AbstractBPMNActivity {
+
+ /**
+ * This constructor initializes the sequence state.
+ *
+ * @param sequence The sequence
+ * @param parent The parent BPMN state
+ * @param model The BPMN model
+ */
+ public SequenceActivity(org.pi4soa.service.behavior.ActivityType sequence,
+ BPMNActivity parent,
+ org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation) {
+ super(parent, model, notation);
+
+ //addChildState(new SimpleState(null, this));
+ //addChildState(new SimpleState(null, this));
+ }
+
+ /**
+ * This method indicates that the UML state for the
+ * child nodes is complete.
+ *
+ */
+ public void childrenComplete() {
+
+ if (m_completed == false) {
+
+ // Join the child state vertex with transitions
+ /*
+ for (int i=1; i < getChildStates().size(); i++) {
+ UMLState v1=(UMLState)getChildStates().get(i-1);
+ UMLState v2=(UMLState)getChildStates().get(i);
+
+ v2.transitionFrom(v1);
+ }
+ */
+ transitionSequentialNodes();
+
+ m_completed = true;
+ }
+ }
+
+ public void calculatePosition(int x, int y) {
+ int curx=x;
+ int midy=y+(getHeight()/2);
+
+ setX(x);
+ setY(y);
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.calculatePosition(curx, midy-(act.getHeight()/2));
+
+ curx += (act.getWidth()+HORIZONTAL_GAP);
+ }
+ }
+
+ /**
+ * This method returns the start node for the activites
+ * represented by this UML activity implementation.
+ *
+ * @return The starting node
+ */
+ public Object getStartNode() {
+ Object ret=null;
+
+ if (getChildStates().size() > 0) {
+ BPMNActivity state=(BPMNActivity)getChildStates().get(0);
+ ret = state.getStartNode();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the end node for the activities
+ * represented by this UML activity implementation.
+ *
+ * @return The ending node
+ */
+ public Object getEndNode() {
+ Object ret=null;
+ int len=0;
+
+ if ((len=getChildStates().size()) > 0) {
+ BPMNActivity state=(BPMNActivity)getChildStates().get(len-1);
+ ret = state.getEndNode();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the start state.
+ *
+ * @return The start state
+ */
+ public BPMNActivity getStartState() {
+ BPMNActivity ret=null;
+
+ if (getChildStates().size() > 0) {
+ BPMNActivity state=(BPMNActivity)getChildStates().get(0);
+ ret = state;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the end state.
+ *
+ * @return The end state
+ */
+ public BPMNActivity getEndState() {
+ BPMNActivity ret=null;
+ int len=0;
+
+ if ((len=getChildStates().size()) > 0) {
+ BPMNActivity state=(BPMNActivity)getChildStates().get(len-1);
+ ret = state.getEndState();
+ }
+
+ return(ret);
+ }
+
+ public void adjustWidth(int width) {
+ float percentChange=((float)width)/((float)getWidth());
+
+ //setWidth(width);
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ int cur=act.getWidth();
+ int newWidth=(int)((float)cur * percentChange);
+
+ act.adjustWidth(newWidth);
+
+ int change=act.getWidth()-cur;
+
+ setWidth(getWidth()+change);
+ }
+ }
+
+ public void draw(Object parent) {
+
+ // Construct notation
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.draw(parent);
+ }
+ }
+
+ private boolean m_completed=false;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/SimpleActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/SimpleActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/SimpleActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+/**
+ * This class represents a simple task within a
+ * BPMN process.
+ *
+ */
+public class SimpleActivity extends AbstractBPMNActivity {
+
+ /**
+ * This constructor initializes the simple activity.
+ *
+ * @param act The behavioral activity
+ * @param parent The parent BPMN state
+ * @param model The BPMN model
+ */
+ public SimpleActivity(org.pi4soa.service.behavior.ActivityType act,
+ BPMNActivity parent,
+ org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation) {
+ super(parent, model, notation);
+
+ // Create a state
+ /*
+ Activity region=getTopLevelActivity();
+
+ if (region != null) {
+ m_node = (ActivityNode)
+ region.createNode(null, UMLPackage.eINSTANCE.getCallBehaviorAction());
+ m_node.getInPartitions().add(getActivityPartition());
+
+ if (label != null) {
+ m_node.setName(label);
+ }
+ }
+ */
+ m_node = model.createSimpleTask(getContainer(), act);
+
+ }
+
+ /**
+ * Internal constructor which can be used to wrap a vertex.
+ *
+ * @param vertex The vertex
+ * @param parent The parent state
+ */
+ /*
+ protected SimpleActivity(org.eclipse.uml2.uml.ActivityNode node, BPMNActivity parent) {
+ super(parent);
+
+ m_node = node;
+ }
+ */
+
+ /**
+ * This method sets the association between this state and
+ * the sub-state machine that it represents.
+ *
+ * @param subMachine The sub state machine
+ */
+ /*
+ public void setSubStateMachine(ActivityModel subMachine) {
+
+ ((State)m_node).setSubmachine(subMachine.getStateMachine());
+ }
+ */
+
+ /**
+ * This method returns the start node for the activites
+ * represented by this UML activity implementation.
+ *
+ * @return The starting node
+ */
+ public Object getStartNode() {
+ return(m_node);
+ }
+
+ /**
+ * This method returns the end node for the activities
+ * represented by this UML activity implementation.
+ *
+ * @return The ending node
+ */
+ public Object getEndNode() {
+ return(m_node);
+ }
+
+ /**
+ * This method returns the start state.
+ *
+ * @return The start state
+ */
+ public BPMNActivity getStartState() {
+ return(this);
+ }
+
+ /**
+ * This method returns the end state.
+ *
+ * @return The end state
+ */
+ public BPMNActivity getEndState() {
+ return(this);
+ }
+
+ public int getWidth() {
+ return(m_width);
+ }
+
+ public int getHeight() {
+ return(60);
+ }
+
+ public void adjustWidth(int width) {
+ m_width = width;
+ }
+
+ public void draw(Object parent) {
+ getNotationFactory().createTask(getModelFactory(),
+ m_node, parent, getX(), getY(), getWidth(), getHeight());
+ }
+
+ private Object m_node=null;
+ private int m_width=110;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/WhenActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/WhenActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/WhenActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,387 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+import org.pi4soa.service.behavior.When;
+import org.savara.tools.bpmn.generation.BPMNGenerationException;
+
+/**
+ * This class represents a when activity within a
+ * UML state machine.
+ *
+ */
+public class WhenActivity extends AbstractBPMNActivity {
+
+ /**
+ * This constructor initializes the when state.
+ *
+ * @param when The when
+ * @param parent The parent BPMN state
+ * @param model The BPMN model
+ */
+ public WhenActivity(When when, BPMNActivity parent,
+ org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation)
+ throws BPMNGenerationException {
+ super(parent, model, notation);
+
+ initialize(when);
+ }
+
+ /**
+ * This method performs the initialization of the
+ * when's state.
+ *
+ * @param elem The when
+ * @throws BPMNGenerationException Failed to initialize
+ */
+ protected void initialize(When elem) throws BPMNGenerationException {
+
+ if (org.pi4soa.common.util.NamesUtil.isSet(elem.getExpression())) {
+ m_conditionalExpression = elem.getExpression();
+ }
+
+ if (org.pi4soa.common.util.NamesUtil.isSet(elem.getReEvaluateExpression())) {
+ m_repeatExpression = elem.getReEvaluateExpression();
+ }
+
+ // Get region
+ /*
+ Activity region=getTopLevelActivity();
+
+ ActivityNode initialState = region.createNode(null,
+ UMLPackage.eINSTANCE.getCallBehaviorAction());
+ initialState.setName(UMLGenerationUtil.processName("When "+elem.getName()));
+ initialState.getInPartitions().add(getActivityPartition());
+ m_initialState = new SimpleActivity(initialState, this);
+ */
+
+ m_initialState = new SimpleActivity(elem, this, getModelFactory(),
+ getNotationFactory());
+
+ // Only create end choice if there is a possibility of repeating
+ if (m_repeatExpression != null) {
+ /*
+ ActivityNode endChoiceState = region.createNode(null,
+ UMLPackage.eINSTANCE.getDecisionNode());
+ endChoiceState.getInPartitions().add(getActivityPartition());
+
+ m_endChoiceState = new SimpleActivity(endChoiceState, this);
+ */
+
+ Object endChoiceState=getModelFactory().createDataBasedXORGateway(getContainer());
+
+ m_endChoiceState = new JunctionActivity(endChoiceState, this,
+ getModelFactory(), getNotationFactory());
+
+ // Create junction state
+ Object junctionState=getModelFactory().createFinalNode(getContainer());
+
+ m_junctionState = new JunctionActivity(junctionState, this,
+ getModelFactory(), getNotationFactory());
+ }
+ }
+
+ /**
+ * This method indicates that the UML state for the
+ * child nodes is complete.
+ *
+ */
+ public void childrenComplete() {
+
+ if (m_completed == false) {
+
+ // Move the end choice state to the end of the list
+ if (m_endChoiceState != null &&
+ getChildStates().remove(m_endChoiceState)) {
+ getChildStates().add(m_endChoiceState);
+ }
+
+ // Move the junction state to the end of the list
+ boolean junctionRemoved=false;
+
+ if (m_junctionState != null) {
+ junctionRemoved = getChildStates().remove(m_junctionState);
+ }
+
+ // If no repeat condition, then include junction before
+ // setting up sequential transitions
+ if (junctionRemoved && m_repeatExpression == null) {
+ getChildStates().add(m_junctionState);
+ }
+
+ // Join the child state vertex with transitions
+ // Don't join the endChoice and junction states here
+ transitionSequentialNodes();
+
+ /*
+ java.util.List list=m_initialState.getEndNode().getOutgoings();
+
+ if (list.size() > 0) {
+ ActivityEdge transition=(ActivityEdge)list.get(0);
+
+ org.eclipse.uml2.uml.OpaqueExpression expr=
+ (org.eclipse.uml2.uml.OpaqueExpression)
+ transition.createGuard("expression", null,
+ UMLPackage.eINSTANCE.getOpaqueExpression());
+
+ if (m_conditionalExpression != null) {
+ expr.getBodies().add(m_conditionalExpression);
+ } else {
+ expr.getBodies().add("<non-observable>");
+ }
+ }
+ */
+ java.util.List list=getModelFactory().getOutboundControlLinks(m_initialState.getEndNode());
+
+ if (list.size() > 0) {
+ Object outgoing=list.get(0);
+
+ if (m_conditionalExpression != null) {
+ getModelFactory().setLinkExpression(outgoing,
+ m_conditionalExpression);
+ } else {
+ getModelFactory().setLinkExpression(outgoing,
+ "<non-observable>");
+ }
+ }
+
+ // Junction is re-added after setting up the sequential transitions,
+ // so that it is not sequentially transitioned - only transition
+ // to the junction state based on an appropriate condition
+ // evaluation
+ if (junctionRemoved && m_repeatExpression != null) {
+ getChildStates().add(m_junctionState);
+ }
+
+ // Transition from end choice state to start vertex
+ // to represent the loop back
+ if (m_repeatExpression != null) {
+ /*
+ ActivityEdge loopback=
+ m_initialState.transitionFrom(m_endChoiceState);
+
+ org.eclipse.uml2.uml.OpaqueExpression expr=
+ (org.eclipse.uml2.uml.OpaqueExpression)
+ loopback.createGuard("expression", null,
+ UMLPackage.eINSTANCE.getOpaqueExpression());
+
+ expr.getBodies().add(m_repeatExpression);
+ */
+ m_initialState.transitionFrom(m_endChoiceState,
+ m_repeatExpression);
+
+ // Transition from end choice state to junction, to
+ // represent the situation where the loopback does
+ // not occur
+ /*
+ ActivityEdge whenEnd=
+ m_junctionState.transitionFrom(m_endChoiceState);
+
+ expr = (org.eclipse.uml2.uml.OpaqueExpression)
+ whenEnd.createGuard("expression", null,
+ UMLPackage.eINSTANCE.getOpaqueExpression());
+
+ expr.getBodies().add("false()");
+ */
+ m_junctionState.transitionFrom(m_endChoiceState,
+ "false()");
+ }
+
+ int width=0;
+ int height=0;
+
+ // Calculate extra width
+ if (m_junctionState != null) {
+ width = m_junctionState.getWidth()+HORIZONTAL_GAP;
+
+ height = m_initialState.getHeight();
+
+ if (m_junctionState != null &&
+ height < m_junctionState.getHeight()) {
+ height = m_junctionState.getHeight();
+ }
+
+ height += (VERTICAL_GAP*2);
+
+ if (m_endChoiceState != null) {
+ height += m_endChoiceState.getHeight()+VERTICAL_GAP;
+ }
+
+ setWidth(getWidth()+width);
+ setHeight(getHeight()+height);
+ }
+
+ m_completed = true;
+ }
+ }
+
+ public void calculatePosition(int x, int y) {
+
+ if (m_junctionState == null) {
+ int curx=x;
+ int midy=y+(getHeight()/2);
+
+ setX(x);
+ setY(y);
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.calculatePosition(curx, midy-(act.getHeight()/2));
+
+ curx += (act.getWidth()+HORIZONTAL_GAP);
+ }
+ } else {
+ /*
+ if (isChoiceElement()) {
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ if (act instanceof SequenceActivity) {
+ act.calculatePosition(x, y);
+ }
+ }
+
+ } else {
+ */
+ int junctionY=y+getHeight()-VERTICAL_GAP;
+ //int junctionY=y+(getHeight()/2);
+ int extraY=0;
+
+ m_initialState.calculatePosition(x, junctionY-
+ (m_initialState.getHeight()/2));
+
+ if (m_junctionState != null) {
+ m_junctionState.calculatePosition(x+getWidth()-
+ m_junctionState.getWidth(), junctionY-
+ (m_junctionState.getHeight()/2));
+ }
+
+ if (m_endChoiceState != null) {
+ m_endChoiceState.calculatePosition(x+getWidth()-
+// m_junctionState.getWidth(), y);
+ m_junctionState.getWidth()-
+ HORIZONTAL_GAP, junctionY-
+ (m_junctionState.getHeight()/2));
+ //extraY = m_endChoiceState.getHeight()+VERTICAL_GAP;
+ }
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ if (act instanceof SequenceActivity) {
+ act.calculatePosition(x+
+ m_initialState.getWidth()+
+ HORIZONTAL_GAP, y+extraY);
+ }
+ }
+ }
+ }
+
+ public void draw(Object parent) {
+
+ // Construct notation
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.draw(parent);
+ }
+ }
+ /**
+ * This method returns the start node for the activites
+ * represented by this UML activity implementation.
+ *
+ * @return The starting node
+ */
+ public Object getStartNode() {
+ Object ret=null;
+ BPMNActivity state=getStartState();
+
+ if (state != null) {
+ ret = state.getStartNode();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the start state.
+ *
+ * @return The start state
+ */
+ public BPMNActivity getStartState() {
+ BPMNActivity ret=null;
+
+ if (getChildStates().size() > 0) {
+ ret = (BPMNActivity)getChildStates().get(0);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the end state.
+ *
+ * @return The end state
+ */
+ public BPMNActivity getEndState() {
+ BPMNActivity ret=null;
+
+ if (m_junctionState != null) {
+ ret = m_junctionState;
+ } else if (getChildStates().size() > 0) {
+ BPMNActivity act=(BPMNActivity)
+ getChildStates().get(getChildStates().size()-1);
+ ret = act;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the end node for the activities
+ * represented by this UML activity implementation.
+ *
+ * @return The ending node
+ */
+ public Object getEndNode() {
+ Object ret=null;
+
+ if (m_junctionState != null) {
+ ret = m_junctionState.getEndNode();
+ } else if (getChildStates().size() > 0) {
+ BPMNActivity act=(BPMNActivity)
+ getChildStates().get(getChildStates().size()-1);
+ ret = act.getEndNode();
+ }
+
+ return(ret);
+ }
+
+ private boolean m_completed=false;
+
+ private BPMNActivity m_initialState=null;
+ private BPMNActivity m_endChoiceState=null;
+ private BPMNActivity m_junctionState=null;
+ private String m_conditionalExpression=null;
+ private String m_repeatExpression=null;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/WhileActivity.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/WhileActivity.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/components/WhileActivity.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,472 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 25, 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.components;
+
+import org.pi4soa.service.behavior.Choice;
+import org.pi4soa.service.behavior.While;
+import org.savara.tools.bpmn.generation.BPMNGenerationException;
+
+/**
+ * This class represents a while repetition within a
+ * UML state machine.
+ *
+ */
+public class WhileActivity extends AbstractBPMNActivity {
+
+ /**
+ * This constructor initializes the while state.
+ *
+ * @param while The while
+ * @param parent The parent BPMN state
+ * @param model The BPMN model
+ */
+ public WhileActivity(While whileElem, BPMNActivity parent,
+ org.savara.tools.bpmn.generation.BPMNModelFactory model,
+ org.savara.tools.bpmn.generation.BPMNNotationFactory notation)
+ throws BPMNGenerationException {
+ super(parent, model, notation);
+
+ initialize(whileElem);
+ }
+
+ /**
+ * This method performs the initialization of the
+ * whiles state.
+ *
+ * @param elem The while
+ * @throws BPMNGenerationException Failed to initialize
+ */
+ protected void initialize(While elem) throws BPMNGenerationException {
+ m_choiceElement = (elem.getParent() instanceof Choice);
+
+ m_conditionalDescription = elem.getName();
+
+ if (org.pi4soa.common.util.NamesUtil.isSet(elem.getExpression())) {
+ m_conditionalExpression = elem.getExpression();
+ }
+
+ if (org.pi4soa.common.util.NamesUtil.isSet(elem.getReEvaluateExpression()) &&
+ elem.getReEvaluateExpression().equals("true()") == false) {
+ m_repeatExpression = elem.getReEvaluateExpression();
+
+ if (isChoiceElement() && m_conditionalExpression != null) {
+ m_repeatExpression += " and "+m_conditionalExpression;
+ }
+ } else if (isChoiceElement() && m_conditionalExpression != null) {
+ m_repeatExpression = m_conditionalExpression;
+ }
+
+ // Get region
+ //Activity region=getTopLevelActivity();
+
+ if (isChoiceElement() == false) {
+
+ // Create choice state
+ /*
+ ActivityNode choiceState = region.createNode(null,
+ UMLPackage.eINSTANCE.getDecisionNode());
+ choiceState.getInPartitions().add(getActivityPartition());
+
+ m_initialChoiceState = new SimpleActivity(choiceState, this);
+ */
+ Object choiceState=getModelFactory().createDataBasedXORGateway(getContainer());
+
+ m_initialChoiceState = new JunctionActivity(choiceState, this,
+ getModelFactory(), getNotationFactory());
+ }
+
+ if (m_repeatExpression != null) {
+ /*
+ ActivityNode endChoiceState = region.createNode(null,
+ UMLPackage.eINSTANCE.getDecisionNode());
+ endChoiceState.getInPartitions().add(getActivityPartition());
+
+ m_endChoiceState = new SimpleActivity(endChoiceState, this);
+ */
+ Object endChoiceState=getModelFactory().createDataBasedXORGateway(getContainer());
+
+ m_endChoiceState = new JunctionActivity(endChoiceState, this,
+ getModelFactory(), getNotationFactory());
+ }
+
+ // Create junction state
+ /*
+ ActivityNode junctionState = region.createNode(null,
+ UMLPackage.eINSTANCE.getMergeNode());
+ junctionState.getInPartitions().add(getActivityPartition());
+
+ m_junctionState = new SimpleActivity(junctionState, this);
+ */
+ Object junctionState=getModelFactory().createDataBasedXORGateway(getContainer());
+
+ m_junctionState = new JunctionActivity(junctionState, this,
+ getModelFactory(), getNotationFactory());
+ }
+
+ /**
+ * This method determines whether the conditional is a
+ * choice element.
+ *
+ * @return Whether a choice element
+ */
+ protected boolean isChoiceElement() {
+ return(m_choiceElement);
+ }
+
+ /**
+ * This method indicates that the UML state for the
+ * child nodes is complete.
+ *
+ */
+ public void childrenComplete() {
+
+ if (m_completed == false) {
+
+ // Move the end choice state to the end of the list
+ if (m_endChoiceState != null &&
+ getChildStates().remove(m_endChoiceState)) {
+ getChildStates().add(m_endChoiceState);
+ }
+
+ // Move the junction state to the end of the list
+ boolean junctionRemoved=getChildStates().remove(m_junctionState);
+
+ // Join the child state vertex with transitions
+ // Don't join the endChoice and junction states here
+ transitionSequentialNodes();
+
+ // Label the expression on the choice outgoing link
+ /*
+ java.util.List list=
+ m_initialChoiceState.getEndNode().getOutgoings();
+ if (list != null && list.size() > 0) {
+ ActivityEdge t=(ActivityEdge)list.get(0);
+
+ if (t != null && m_conditionalDescription != null) {
+ String name=m_conditionalDescription.replace(' ', '_');
+ t.setName(name);
+
+ org.eclipse.uml2.uml.OpaqueExpression expr=
+ (org.eclipse.uml2.uml.OpaqueExpression)
+ t.createGuard("expression", null,
+ UMLPackage.eINSTANCE.getOpaqueExpression());
+
+ if (m_conditionalExpression != null) {
+ expr.getBodies().add(m_conditionalExpression);
+ } else {
+ expr.getBodies().add("<non-observable>");
+ }
+ }
+ }
+ */
+
+ if (m_initialChoiceState != null) {
+ java.util.List list=getModelFactory().getOutboundControlLinks(m_initialChoiceState.getEndNode());
+
+ if (list.size() > 0) {
+ Object outgoing=list.get(0);
+
+ if (m_conditionalExpression != null) {
+ getModelFactory().setLinkExpression(outgoing,
+ m_conditionalExpression);
+ } else {
+ getModelFactory().setLinkExpression(outgoing,
+ "<non-observable>");
+ }
+ }
+ }
+
+ // Junction is re-added after setting up the sequential transitions,
+ // so that it is not sequentially transitioned - only transition
+ // to the junction state based on an appropriate condition
+ // evaluation
+ BPMNActivity lastState=(BPMNActivity)getChildStates().
+ get(getChildStates().size()-1);
+
+ if (junctionRemoved) {
+ getChildStates().add(m_junctionState);
+ }
+
+ if (isChoiceElement() == false) {
+
+ // Have direct transition from choice to junction
+ // to represent the 'false' path
+ /*
+ ActivityEdge transition=
+ m_junctionState.transitionFrom(m_initialChoiceState);
+ //transition.setName("false");
+
+ org.eclipse.uml2.uml.OpaqueExpression expr=
+ (org.eclipse.uml2.uml.OpaqueExpression)
+ transition.createGuard("expression", null,
+ UMLPackage.eINSTANCE.getOpaqueExpression());
+
+ expr.getBodies().add("false()");
+ */
+ m_junctionState.transitionFrom(m_initialChoiceState,
+ "false()");
+ }
+
+ if (m_repeatExpression != null) {
+ // Transition from end choice state to start vertex
+ // to represent the loop back
+ /*
+ ActivityEdge loopback=
+ getStartState().transitionFrom(m_endChoiceState);
+
+ if (loopback != null && m_repeatExpression != null) {
+ org.eclipse.uml2.uml.OpaqueExpression expr=
+ (org.eclipse.uml2.uml.OpaqueExpression)
+ loopback.createGuard("expression", null,
+ UMLPackage.eINSTANCE.getOpaqueExpression());
+
+ expr.getBodies().add(m_repeatExpression);
+ }
+ */
+
+ getStartState().transitionFrom(m_endChoiceState,
+ m_repeatExpression != null?
+ m_repeatExpression:"<non-observable>");
+
+ // Transition from end choice state to junction, to
+ // represent the situation where the loopback does
+ // not occur
+ /*
+ ActivityEdge whileEnd=
+ m_junctionState.transitionFrom(m_endChoiceState);
+
+ org.eclipse.uml2.uml.OpaqueExpression expr=
+ (org.eclipse.uml2.uml.OpaqueExpression)
+ whileEnd.createGuard("expression", null,
+ UMLPackage.eINSTANCE.getOpaqueExpression());
+
+ expr.getBodies().add("false()");
+ */
+ m_junctionState.transitionFrom(m_endChoiceState,
+ "false()");
+ } else {
+ // Establish transition from last state to initial choice
+ //m_initialChoiceState.transitionFrom(lastState, null);
+ getStartState().transitionFrom(lastState, null);
+
+ if (isChoiceElement()) {
+ m_junctionState.transitionFrom(lastState,
+ "false()");
+ }
+ }
+
+ if (isChoiceElement() == false) {
+ int width=0;
+ int height=0;
+
+ // Calculate extra width
+ width = m_initialChoiceState.getWidth()+HORIZONTAL_GAP+
+ m_junctionState.getWidth()+HORIZONTAL_GAP;
+
+ height = m_initialChoiceState.getHeight();
+
+ if (height < m_junctionState.getHeight()) {
+ height = m_junctionState.getHeight();
+ }
+
+ height += (VERTICAL_GAP*2);
+
+ if (m_endChoiceState != null) {
+ height += m_endChoiceState.getHeight()+VERTICAL_GAP;
+ }
+
+ setWidth(getWidth()+width);
+ setHeight(getHeight()+height);
+ } else {
+
+ int width=0;
+ int height=0;
+
+ // Calculate extra width
+ width = m_junctionState.getWidth()+HORIZONTAL_GAP;
+
+ setWidth(getWidth()+width);
+ }
+
+ m_completed = true;
+ }
+ }
+
+ public void calculatePosition(int x, int y) {
+ int junctionY=y+getHeight()-VERTICAL_GAP;
+
+ if (isChoiceElement()) {
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ if (act instanceof SequenceActivity) {
+ act.calculatePosition(x, y);
+ }
+ }
+
+ m_junctionState.calculatePosition(x+getWidth()-
+ m_junctionState.getWidth(), junctionY-
+ (m_junctionState.getHeight()/2));
+
+ if (m_endChoiceState != null) {
+ m_endChoiceState.calculatePosition(x+getWidth()-
+ m_junctionState.getWidth()-HORIZONTAL_GAP-
+ m_endChoiceState.getWidth(),
+ junctionY-m_endChoiceState.getHeight()-
+ (VERTICAL_GAP/2));
+ //extraY = m_endChoiceState.getHeight()+VERTICAL_GAP;
+ }
+
+ } else {
+ //int junctionY=y+(getHeight()/2);
+ int extraY=0;
+
+ m_initialChoiceState.calculatePosition(x, junctionY-
+ (m_initialChoiceState.getHeight()/2));
+ m_junctionState.calculatePosition(x+getWidth()-
+ m_junctionState.getWidth(), junctionY-
+ (m_junctionState.getHeight()/2));
+
+ if (m_endChoiceState != null) {
+ m_endChoiceState.calculatePosition(x+getWidth()-
+ m_junctionState.getWidth()-HORIZONTAL_GAP-
+ m_endChoiceState.getWidth(),
+ junctionY-m_endChoiceState.getHeight()-
+ (VERTICAL_GAP/2));
+ //extraY = m_endChoiceState.getHeight()+VERTICAL_GAP;
+ }
+
+ SequenceActivity seq=null;
+
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ if (act instanceof SequenceActivity) {
+ seq = (SequenceActivity)act;
+
+ //act.calculatePosition(x+
+ // m_initialChoiceState.getWidth()+
+ // HORIZONTAL_GAP, y+extraY);
+ int gap=(VERTICAL_GAP/4);
+
+ if (m_endChoiceState != null) {
+ gap = VERTICAL_GAP;
+ }
+
+ act.calculatePosition(x+
+ m_initialChoiceState.getWidth()+
+ HORIZONTAL_GAP, junctionY-
+ act.getHeight()-gap);
+ }
+ }
+
+ // If a normal expression, then move the end
+ // node of the last child, to help with layout
+ if (m_endChoiceState == null && seq.getChildStates().size() > 0) {
+ BPMNActivity lastState=(BPMNActivity)seq.getEndState();
+
+ lastState.calculatePosition(x+getWidth()-
+ lastState.getWidth()-HORIZONTAL_GAP-
+ m_junctionState.getWidth(),
+ junctionY-lastState.getHeight()-
+ (VERTICAL_GAP/2));
+ }
+ }
+ }
+
+ public void draw(Object parent) {
+
+ // Construct notation
+ for (int i=0; i < getChildStates().size(); i++) {
+ BPMNActivity act=(BPMNActivity)getChildStates().get(i);
+
+ act.draw(parent);
+ }
+ }
+
+ /**
+ * This method returns the start node for the activites
+ * represented by this UML activity implementation.
+ *
+ * @return The starting node
+ */
+ public Object getStartNode() {
+ Object ret=null;
+ BPMNActivity state=getStartState();
+
+ if (state != null) {
+ ret = state.getStartNode();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the start state.
+ *
+ * @return The start state
+ */
+ public BPMNActivity getStartState() {
+ BPMNActivity ret=null;
+
+ if (isChoiceElement() == false) {
+ ret = m_initialChoiceState;
+
+ } else if (getChildStates().size() > 0) {
+ ret = (BPMNActivity)getChildStates().get(0);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the end state.
+ *
+ * @return The end state
+ */
+ public BPMNActivity getEndState() {
+ return(m_junctionState);
+ }
+
+ /**
+ * This method returns the end node for the activities
+ * represented by this UML activity implementation.
+ *
+ * @return The ending node
+ */
+ public Object getEndNode() {
+ return(m_junctionState.getEndNode());
+ }
+
+ public boolean canDeleteEndNode() {
+ return(false);
+ }
+
+ private boolean m_completed=false;
+ private boolean m_choiceElement=false;
+
+ private BPMNActivity m_initialChoiceState=null;
+ private BPMNActivity m_endChoiceState=null;
+ private BPMNActivity m_junctionState=null;
+ private String m_conditionalDescription=null;
+ private String m_conditionalExpression=null;
+ private String m_repeatExpression=null;
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/gmf/GMFBPMNNotationFactoryImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/gmf/GMFBPMNNotationFactoryImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/gmf/GMFBPMNNotationFactoryImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,341 @@
+/*
+ * Copyright 2005-6 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR 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 Jan 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.gmf;
+
+import org.eclipse.gmf.runtime.notation.*;
+import org.savara.tools.bpmn.generation.BPMNGenerationException;
+import org.savara.tools.bpmn.generation.BPMNModelFactory;
+import org.savara.tools.bpmn.generation.BPMNNotationFactory;
+
+public class GMFBPMNNotationFactoryImpl implements BPMNNotationFactory {
+
+ public String getFileExtension() {
+ return("bpmn_diagram");
+ }
+
+ public void saveNotation(String modelFileName, Object diagramModel,
+ String notationFileName, Object diagramNotation)
+ throws BPMNGenerationException {
+ try {
+ int pos=notationFileName.lastIndexOf(java.io.File.separator);
+
+ ((Diagram)diagramNotation).setName(notationFileName.substring(pos+1));
+
+ org.eclipse.emf.ecore.resource.ResourceSet resourceSet =
+ new org.eclipse.emf.ecore.resource.impl.ResourceSetImpl();
+
+// Register XML resource factory
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn_diagram",
+ new org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl());
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn",
+ new org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl());
+
+ resourceSet.getPackageRegistry().put(NotationPackage.eINSTANCE.getNsURI(), NotationPackage.eINSTANCE);
+ resourceSet.getPackageRegistry().put(org.eclipse.stp.bpmn.BpmnPackage.eINSTANCE.getNsURI(), org.eclipse.stp.bpmn.BpmnPackage.eINSTANCE);
+
+ org.eclipse.emf.ecore.resource.Resource modelResource =
+ resourceSet.createResource(org.eclipse.emf.common.util.URI.createFileURI(modelFileName));
+
+ if (modelResource instanceof org.eclipse.emf.ecore.xmi.XMLResource) {
+ setXMIId((org.eclipse.emf.ecore.xmi.XMLResource)modelResource,
+ (org.eclipse.stp.bpmn.BpmnDiagram)diagramModel);
+ }
+
+ modelResource.getContents().add((org.eclipse.emf.ecore.EObject)diagramModel);
+
+ org.eclipse.emf.ecore.resource.Resource notationResource =
+ resourceSet.createResource(org.eclipse.emf.common.util.URI.createFileURI(notationFileName));
+
+ if (notationResource instanceof org.eclipse.emf.ecore.xmi.XMLResource) {
+ setXMIId((org.eclipse.emf.ecore.xmi.XMLResource)notationResource,
+ (org.eclipse.emf.ecore.EObject)diagramNotation);
+ }
+
+ notationResource.getContents().add((org.eclipse.emf.ecore.EObject)diagramNotation);
+
+ /*
+ org.eclipse.emf.ecore.resource.Resource resource =
+ ((Diagram)diagramNotation).eResource();
+ resource.setURI(org.eclipse.emf.common.util.URI.createFileURI(fileName));
+ */
+
+ org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl xmi =
+ new org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl();
+ java.util.Map options=xmi.getDefaultSaveOptions();
+
+ options.put(org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl.OPTION_SAVE_TYPE_INFORMATION, Boolean.TRUE);
+ //options.put(org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl.OPTION_RECORD_ANY_TYPE_NAMESPACE_DECLARATIONS, Boolean.TRUE);
+ notationResource.save(options);
+ modelResource.save(options);
+
+
+/*
+ // Output the UML2 model to the supplied stream
+ final org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl xmi =
+ new org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl();
+ xmi.setURI(org.eclipse.emf.common.util.URI.createFileURI(fileName));
+
+ xmi.getResourceSet();
+
+ org.eclipse.emf.ecore.resource.impl.ResourceSetImpl set=
+ new org.eclipse.emf.ecore.resource.impl.ResourceSetImpl();
+
+ org.eclipse.stp.bpmn.BpmnPackage.eINSTANCE.getActivity();
+
+ System.out.println("Registry for '"+org.eclipse.stp.bpmn.BpmnPackage.eNS_URI
+ +": "+xmi.getResourceSet().getPackageRegistry().getEPackage(org.eclipse.stp.bpmn.BpmnPackage.eNS_URI));
+
+ xmi.getContents().add(diagramNotation);
+
+ xmi.doSave(ostream, xmi.getDefaultLoadOptions());
+*/
+ //ostream.close();
+
+ } catch(Exception e) {
+ throw new BPMNGenerationException("Failed to convert to XMI", e);
+ }
+ }
+
+ public Object createDiagram(BPMNModelFactory factory, Object diagramModel,
+ int x, int y, int width, int height) {
+ Diagram ret=NotationFactory.eINSTANCE.createDiagram();
+
+ ret.setType("Bpmn");
+ ret.setMeasurementUnit(MeasurementUnit.PIXEL_LITERAL);
+ ret.setElement((org.eclipse.emf.ecore.EObject)diagramModel);
+
+ ret.getStyles().add(NotationFactory.eINSTANCE.createPageStyle());
+ ret.getStyles().add(NotationFactory.eINSTANCE.createGuideStyle());
+ ret.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
+
+ /*
+ try {
+ org.eclipse.emf.ecore.resource.ResourceSet resourceSet =
+ new org.eclipse.emf.ecore.resource.impl.ResourceSetImpl();
+
+// Register XML resource factory
+resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn_diagram",
+ new org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl());
+
+resourceSet.getPackageRegistry().put(NotationPackage.eINSTANCE.getNsURI(), NotationPackage.eINSTANCE);
+resourceSet.getPackageRegistry().put(org.eclipse.stp.bpmn.BpmnPackage.eINSTANCE.getNsURI(), org.eclipse.stp.bpmn.BpmnPackage.eINSTANCE);
+
+org.eclipse.emf.ecore.resource.Resource resource =
+ resourceSet.createResource(org.eclipse.emf.common.util.URI.createFileURI("test.xmi"));
+// add the root object to the resource
+resource.getContents().add(ret);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ */
+
+ return(ret);
+ }
+
+ public Object createPool(BPMNModelFactory factory, Object poolModel,
+ Object diagramNotation, int x, int y, int width, int height) {
+ Node ret=NotationFactory.eINSTANCE.createNode();
+
+ ret.setElement((org.eclipse.emf.ecore.EObject)poolModel);
+ ret.setType("1001");
+
+ Bounds bounds=NotationFactory.eINSTANCE.createBounds();
+ bounds.setHeight(height);
+ bounds.setWidth(width+100);
+ bounds.setX(x);
+ bounds.setY(y);
+
+ ret.setLayoutConstraint(bounds);
+
+ FontStyle font=NotationFactory.eINSTANCE.createFontStyle();
+ font.setFontName("Ariel");
+ ret.getStyles().add(font);
+ ret.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
+
+ FillStyle fill=NotationFactory.eINSTANCE.createFillStyle();
+ fill.setFillColor(16771304);
+ ret.getStyles().add(fill);
+
+ LineStyle line=NotationFactory.eINSTANCE.createLineStyle();
+ line.setLineColor(11119017);
+ ret.getStyles().add(line);
+
+ Node nameNode=NotationFactory.eINSTANCE.createNode();
+ nameNode.setType("4008");
+ ret.insertChild(nameNode);
+
+ Node lineNode=NotationFactory.eINSTANCE.createNode();
+ lineNode.setType("5001");
+ ret.getStyles().add(NotationFactory.eINSTANCE.createDrawerStyle());
+ ret.getStyles().add(NotationFactory.eINSTANCE.createSortingStyle());
+ ret.getStyles().add(NotationFactory.eINSTANCE.createFilteringStyle());
+ ret.insertChild(lineNode);
+
+ ((Diagram)diagramNotation).insertChild(ret);
+
+ return(lineNode);
+ }
+
+ public Object createTask(BPMNModelFactory factory,
+ Object taskModel, Object parentNotation,
+ int x, int y, int width, int height) {
+ Node ret=NotationFactory.eINSTANCE.createNode();
+
+ ret.setElement((org.eclipse.emf.ecore.EObject)taskModel);
+ ret.setType("2001");
+
+ Bounds bounds=NotationFactory.eINSTANCE.createBounds();
+ bounds.setHeight(height);
+ bounds.setWidth(width);
+ bounds.setX(x);
+ bounds.setY(y);
+
+ ret.setLayoutConstraint(bounds);
+
+ FontStyle font=NotationFactory.eINSTANCE.createFontStyle();
+ font.setFontName("Ariel");
+ ret.getStyles().add(font);
+ ret.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
+
+ FillStyle fill=NotationFactory.eINSTANCE.createFillStyle();
+ fill.setFillColor(16771304);
+ ret.getStyles().add(fill);
+
+ LineStyle line=NotationFactory.eINSTANCE.createLineStyle();
+ line.setLineColor(11119017);
+ ret.getStyles().add(line);
+
+ Node nameNode=NotationFactory.eINSTANCE.createNode();
+ nameNode.setType("4001");
+ ret.insertChild(nameNode);
+
+ ((Node)parentNotation).insertChild(ret);
+
+ m_taskViews.put(taskModel, ret);
+
+ return(ret);
+ }
+
+
+ public Object createJunction(BPMNModelFactory factory,
+ Object junctionModel, Object parentNotation,
+ int x, int y, int width, int height) {
+ Node ret=NotationFactory.eINSTANCE.createNode();
+
+ ret.setElement((org.eclipse.emf.ecore.EObject)junctionModel);
+ ret.setType("2001");
+
+ Bounds bounds=NotationFactory.eINSTANCE.createBounds();
+ bounds.setHeight(height);
+ bounds.setWidth(width);
+ bounds.setX(x);
+ bounds.setY(y);
+
+ ret.setLayoutConstraint(bounds);
+
+ FontStyle font=NotationFactory.eINSTANCE.createFontStyle();
+ font.setFontName("Ariel");
+ ret.getStyles().add(font);
+ ret.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
+
+ FillStyle fill=NotationFactory.eINSTANCE.createFillStyle();
+ fill.setFillColor(16771304);
+ ret.getStyles().add(fill);
+
+ LineStyle line=NotationFactory.eINSTANCE.createLineStyle();
+ line.setLineColor(11119017);
+ ret.getStyles().add(line);
+
+ Node nameNode=NotationFactory.eINSTANCE.createNode();
+ nameNode.setType("4001");
+ ret.insertChild(nameNode);
+
+ ((Node)parentNotation).insertChild(ret);
+
+ return(ret);
+ }
+
+ public Object createMessageLink(BPMNModelFactory factory,
+ Object linkModel, Object diagramNotation) {
+ Edge ret=NotationFactory.eINSTANCE.createEdge();
+
+ Object source=factory.getSource(linkModel);
+ if (source != null) {
+ ret.setSource(getTaskView(source));
+ }
+
+ Object target=factory.getTarget(linkModel);
+ if (target != null) {
+ ret.setTarget(getTaskView(target));
+ }
+
+ ret.setElement((org.eclipse.emf.ecore.EObject)linkModel);
+ ret.setType("3002");
+
+ Node nameNode=NotationFactory.eINSTANCE.createNode();
+ nameNode.setType("4007");
+ ret.insertChild(nameNode);
+
+ Location layout=NotationFactory.eINSTANCE.createLocation();
+ layout.setY(40);
+ nameNode.setLayoutConstraint(layout);
+
+ ret.getStyles().add(NotationFactory.eINSTANCE.createRoutingStyle());
+
+ FontStyle font=NotationFactory.eINSTANCE.createFontStyle();
+ font.setFontName("Ariel");
+ ret.getStyles().add(font);
+ ret.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
+
+ RelativeBendpoints bendpoints=NotationFactory.eINSTANCE.createRelativeBendpoints();
+ //bendpoints.setPoints(arg0);
+ ret.setBendpoints(bendpoints);
+
+ ((Diagram)diagramNotation).insertEdge(ret);
+
+ return(ret);
+ }
+
+ protected View getTaskView(Object modelObject) {
+ View ret=(View)m_taskViews.get(modelObject);
+
+ return(ret);
+ }
+
+ protected void setXMIId(org.eclipse.emf.ecore.xmi.XMLResource res,
+ org.eclipse.emf.ecore.EObject eobj) {
+
+ if (eobj instanceof org.eclipse.stp.bpmn.Identifiable) {
+ res.setID((org.eclipse.stp.bpmn.Identifiable)eobj,
+ ((org.eclipse.stp.bpmn.Identifiable)eobj).getID());
+ } else if (eobj instanceof org.eclipse.gmf.runtime.notation.View) {
+ res.setID((org.eclipse.gmf.runtime.notation.View)eobj,
+ "_"+System.currentTimeMillis()+"_"+((org.eclipse.gmf.runtime.notation.View)eobj).hashCode());
+ }
+
+ java.util.List children=eobj.eContents();
+
+ for (int i=0; i < children.size(); i++) {
+ setXMIId(res, (org.eclipse.emf.ecore.EObject)children.get(i));
+ }
+ }
+
+ private java.util.Hashtable m_taskViews=new java.util.Hashtable();
+}
Added: trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/stp/STPBPMNModelFactoryImpl.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/stp/STPBPMNModelFactoryImpl.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.bpmn/src/java/org/savara/tools/bpmn/generation/stp/STPBPMNModelFactoryImpl.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,462 @@
+/*
+ * Copyright 2005-6 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR 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 Jan 2007 : Initial version created by gary
+ */
+package org.savara.tools.bpmn.generation.stp;
+
+import org.eclipse.stp.bpmn.*;
+import org.savara.tools.bpmn.generation.BPMNGenerationException;
+
+public class STPBPMNModelFactoryImpl implements org.savara.tools.bpmn.generation.BPMNModelFactory {
+
+ public String getFileExtension() {
+ return("bpmn");
+ }
+
+ public void saveModel(String fileName, Object diagram)
+ throws BPMNGenerationException {
+
+ /*
+ try {
+ org.eclipse.stp.bpmn.BpmnPackage.eINSTANCE.getActivity();
+
+ java.io.FileOutputStream ostream=
+ new java.io.FileOutputStream(fileName);
+
+ // Output the UML2 model to the supplied stream
+ final org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl xmi =
+ new org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl();
+ xmi.setURI(org.eclipse.emf.common.util.URI.createFileURI(fileName));
+ xmi.getContents().add(diagram);
+
+ xmi.doSave(ostream, xmi.getDefaultLoadOptions());
+
+ ostream.close();
+
+ } catch(Exception e) {
+ throw new BPMNGenerationException("Failed to convert to XMI", e);
+ }
+ */
+ }
+
+ public Object createDiagram() {
+ BpmnDiagram ret=BpmnFactory.eINSTANCE.createBpmnDiagram();
+ return(ret);
+ }
+
+ public Object createPool(Object diagram, String name) {
+ Pool ret = BpmnFactory.eINSTANCE.createPool();
+ ret.setName(name);
+
+ if (diagram instanceof BpmnDiagram) {
+ ((BpmnDiagram)diagram).getPools().add(ret);
+ }
+
+ return(ret);
+ }
+
+ public Object createInitialNode(Object container) {
+ org.eclipse.stp.bpmn.Activity ret=
+ org.eclipse.stp.bpmn.BpmnFactory.eINSTANCE.createActivity();
+
+ ret.setActivityType(ActivityType.EVENT_START_EMPTY_LITERAL);
+
+ if (container instanceof Graph) {
+ ((Graph)container).getVertices().add(ret);
+ }
+
+ return(ret);
+ }
+
+ public Object createSimpleTask(Object container,
+ org.pi4soa.service.behavior.ActivityType activity) {
+ org.eclipse.stp.bpmn.Activity ret=
+ org.eclipse.stp.bpmn.BpmnFactory.eINSTANCE.createActivity();
+
+ ret.setActivityType(ActivityType.TASK_LITERAL);
+
+ String label=activity.getName();
+
+ Class[] intf=activity.getClass().getInterfaces();
+ for (int i=0; i < intf.length; i++) {
+ if (intf[i].getName().startsWith("org.pi4soa.service.behavior")) {
+ int index=intf[i].getName().lastIndexOf('.');
+ label = intf[i].getName().substring(index+1);
+
+ if (activity instanceof org.pi4soa.service.behavior.Perform) {
+ label += " "+((org.pi4soa.service.behavior.Perform)
+ activity).getBehaviorDescription().getName();
+ } else if (activity.getName() != null) {
+ label += " "+activity.getName();
+ }
+ }
+ }
+
+ ret.setName(label);
+
+ if (container instanceof Graph) {
+ ((Graph)container).getVertices().add(ret);
+ }
+
+ return(ret);
+ }
+
+ public Object createControlLink(Object container,
+ Object fromNode, Object toNode,
+ String conditionalExpression) {
+ org.eclipse.stp.bpmn.SequenceEdge ret=
+ org.eclipse.stp.bpmn.BpmnFactory.eINSTANCE.createSequenceEdge();
+
+ if (fromNode instanceof Vertex) {
+ ret.setSource((Vertex)fromNode);
+ }
+
+ if (toNode instanceof Vertex) {
+ ret.setTarget((Vertex)toNode);
+ }
+
+ if (conditionalExpression != null) {
+ ret.setName(conditionalExpression);
+ }
+
+ if (container instanceof Graph) {
+ ((Graph)container).getSequenceEdges().add(ret);
+ }
+
+ return(ret);
+ }
+
+ public Object createMessageLink(Object container,
+ Object fromNode, Object toNode,
+ org.pi4soa.service.behavior.Receive receive) {
+ MessagingEdge ret=BpmnFactory.eINSTANCE.createMessagingEdge();
+
+ if (fromNode instanceof Activity) {
+ ret.setSource((Activity)fromNode);
+ }
+
+ if (toNode instanceof Activity) {
+ ret.setTarget((Activity)toNode);
+ }
+
+ String name=receive.getOperationName();
+ String mesgType=null;
+
+ if (receive.getMessageDefinition() != null &&
+ receive.getMessageDefinition().getInformationType() != null) {
+ mesgType = receive.getMessageDefinition().getInformationType().getType();
+
+ if (mesgType == null) {
+ mesgType = receive.getMessageDefinition().getInformationType().getElement();
+ }
+ }
+
+ if (mesgType != null) {
+ mesgType = org.pi4soa.common.xml.XMLUtils.getLocalname(mesgType);
+ }
+
+ if (name == null) {
+ name = mesgType;
+ } else if (mesgType != null) {
+ name += "("+mesgType+")";
+ } else {
+ name += "()";
+ }
+
+ if (name != null) {
+ ret.setName(name);
+ }
+
+ if (container instanceof BpmnDiagram) {
+ ((BpmnDiagram)container).getMessages().add(ret);
+ } else if (container instanceof Pool) {
+ ((Pool)container).getBpmnDiagram().getMessages().add(ret);
+ }
+
+ return(ret);
+ }
+
+ public Object setLinkExpression(Object link, String expression) {
+
+ if (expression != null &&
+ link instanceof org.eclipse.stp.bpmn.SequenceEdge) {
+ org.eclipse.stp.bpmn.SequenceEdge edge=
+ (org.eclipse.stp.bpmn.SequenceEdge)link;
+
+ edge.setName(expression);
+ }
+
+ return(link);
+ }
+
+ public Object createDataBasedXORGateway(Object container) {
+ org.eclipse.stp.bpmn.Activity ret=
+ org.eclipse.stp.bpmn.BpmnFactory.eINSTANCE.createActivity();
+
+ ret.setActivityType(ActivityType.GATEWAY_DATA_BASED_EXCLUSIVE_LITERAL);
+
+ if (container instanceof Graph) {
+ ((Graph)container).getVertices().add(ret);
+ }
+
+ return(ret);
+ }
+
+ public Object createEventBasedXORGateway(Object container) {
+ org.eclipse.stp.bpmn.Activity ret=
+ org.eclipse.stp.bpmn.BpmnFactory.eINSTANCE.createActivity();
+
+ ret.setActivityType(ActivityType.GATEWAY_EVENT_BASED_EXCLUSIVE_LITERAL);
+
+ if (container instanceof Graph) {
+ ((Graph)container).getVertices().add(ret);
+ }
+
+ return(ret);
+ }
+
+ public Object createANDGateway(Object container) {
+ org.eclipse.stp.bpmn.Activity ret=
+ org.eclipse.stp.bpmn.BpmnFactory.eINSTANCE.createActivity();
+
+ ret.setActivityType(ActivityType.GATEWAY_PARALLEL_LITERAL);
+
+ if (container instanceof Graph) {
+ ((Graph)container).getVertices().add(ret);
+ }
+
+ return(ret);
+ }
+
+ public Object createFinalNode(Object container) {
+ org.eclipse.stp.bpmn.Activity ret=
+ org.eclipse.stp.bpmn.BpmnFactory.eINSTANCE.createActivity();
+
+ ret.setActivityType(ActivityType.EVENT_END_EMPTY_LITERAL);
+
+ if (container instanceof Graph) {
+ ((Graph)container).getVertices().add(ret);
+ }
+
+ return(ret);
+ }
+
+ public boolean isDecision(Object node) {
+ boolean ret=false;
+
+ if (node instanceof org.eclipse.stp.bpmn.Activity &&
+ (((org.eclipse.stp.bpmn.Activity)node).getActivityType()
+ == ActivityType.GATEWAY_DATA_BASED_EXCLUSIVE_LITERAL ||
+ ((org.eclipse.stp.bpmn.Activity)node).getActivityType()
+ == ActivityType.GATEWAY_EVENT_BASED_EXCLUSIVE_LITERAL)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines if the supplied node is a join. This
+ * is true, if the node is a data or event based gateway,
+ * and as incoming edges. This is based on the fact that only
+ * a join gateway, at the point this method is invoked, would
+ * have incoming links, otherwise any other gateway would be
+ * assumed to be the initial gateway in a conditional grouping
+ * construct.
+ *
+ * @param node
+ * @return Whether the node is a join
+ */
+ public boolean isJoin(Object node) {
+ boolean ret=false;
+
+ if (node instanceof org.eclipse.stp.bpmn.Activity &&
+ (((org.eclipse.stp.bpmn.Activity)node).getActivityType()
+ == ActivityType.GATEWAY_DATA_BASED_EXCLUSIVE_LITERAL ||
+ ((org.eclipse.stp.bpmn.Activity)node).getActivityType()
+ == ActivityType.GATEWAY_EVENT_BASED_EXCLUSIVE_LITERAL) &&
+ ((org.eclipse.stp.bpmn.Activity)node).getIncomingEdges().size() > 0) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ public boolean isTerminal(Object node) {
+ boolean ret=false;
+
+ if (node instanceof org.eclipse.stp.bpmn.Activity &&
+ ((org.eclipse.stp.bpmn.Activity)node).getActivityType()
+ == ActivityType.EVENT_END_EMPTY_LITERAL) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ public void setLabel(Object entity, String label) {
+ if (entity instanceof Activity) {
+ ((Activity)entity).setName(label);
+ }
+ }
+
+ public Object getSource(Object link) {
+ Object ret=null;
+
+ if (link instanceof SequenceEdge) {
+ ret = ((SequenceEdge)link).getSource();
+ } else if (link instanceof MessagingEdge) {
+ ret = ((MessagingEdge)link).getSource();
+ }
+
+ return(ret);
+ }
+
+ public void setSource(Object link, Object node) {
+ if (link instanceof SequenceEdge && node instanceof Vertex) {
+ ((SequenceEdge)link).setSource((Vertex)node);
+ } else if (link instanceof MessagingEdge &&
+ node instanceof Activity) {
+ ((MessagingEdge)link).setSource((Activity)node);
+ }
+ }
+
+ public Object getTarget(Object link) {
+ Object ret=null;
+
+ if (link instanceof SequenceEdge) {
+ ret = ((SequenceEdge)link).getTarget();
+ } else if (link instanceof MessagingEdge) {
+ ret = ((MessagingEdge)link).getTarget();
+ }
+
+ return(ret);
+ }
+
+ public void setTarget(Object link, Object node) {
+ if (link instanceof SequenceEdge && node instanceof Vertex) {
+ ((SequenceEdge)link).setTarget((Vertex)node);
+ } else if (link instanceof MessagingEdge &&
+ node instanceof Activity) {
+ ((MessagingEdge)link).setTarget((Activity)node);
+ }
+ }
+
+ public java.util.List getInboundControlLinks(Object node) {
+ java.util.List ret=null;
+
+ if (node instanceof Vertex) {
+ ret = ((Vertex)node).getIncomingEdges();
+ }
+
+ return(ret);
+ }
+
+ public java.util.List getOutboundControlLinks(Object node) {
+ java.util.List ret=null;
+
+ if (node instanceof Vertex) {
+ ret = ((Vertex)node).getOutgoingEdges();
+ }
+
+ return(ret);
+ }
+
+ public java.util.List getInboundMessageLinks(Object node) {
+ java.util.List ret=null;
+
+ if (node instanceof Activity) {
+ ret = ((Activity)node).getIncomingMessages();
+ }
+
+ return(ret);
+ }
+
+ public java.util.List getOutboundMessageLinks(Object node) {
+ java.util.List ret=null;
+
+ if (node instanceof Activity) {
+ ret = ((Activity)node).getOutgoingMessages();
+ }
+
+ return(ret);
+ }
+
+ public void delete(Object entity) {
+//System.out.println("DELETE: "+entity);
+
+ if (entity instanceof Vertex) {
+ Vertex node=(Vertex)entity;
+
+ if (node.getGraph() != null) {
+ node.getGraph().getVertices().remove(node);
+ }
+
+ for (int i=node.getIncomingEdges().size()-1; i >= 0; i--) {
+ SequenceEdge edge=(SequenceEdge)node.getIncomingEdges().get(i);
+ delete(edge);
+ }
+
+ for (int i=node.getOutgoingEdges().size()-1; i >= 0; i--) {
+ SequenceEdge edge=(SequenceEdge)node.getOutgoingEdges().get(i);
+ delete(edge);
+ }
+ } else if (entity instanceof SequenceEdge) {
+ SequenceEdge edge=(SequenceEdge)entity;
+
+ edge.setSource(null);
+ edge.setTarget(null);
+
+ if (edge.getGraph() != null) {
+ edge.getGraph().getSequenceEdges().remove(edge);
+ }
+ } else if (entity instanceof Pool) {
+ Pool pool=(Pool)entity;
+
+ if (pool.getBpmnDiagram() != null) {
+ pool.getBpmnDiagram().getPools().remove(pool);
+ }
+ }
+ }
+
+ public boolean isDeleted(Object entity) {
+ boolean ret=false;
+
+ if (entity instanceof Vertex) {
+ Vertex node=(Vertex)entity;
+
+ if (node.getGraph() == null) {
+ ret = true;
+ }
+ } else if (entity instanceof SequenceEdge) {
+ SequenceEdge edge=(SequenceEdge)entity;
+
+ if (edge.getGraph() == null) {
+ ret = true;
+ }
+ } else if (entity instanceof Pool) {
+ Pool pool=(Pool)entity;
+
+ if (pool.getBpmnDiagram() != null) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/.classpath
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/.classpath (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/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/tools/plugins/org.savara.tools.monitor/.project
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/.project (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.tools.monitor</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/tools/plugins/org.savara.tools.monitor/LICENSE.txt
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/LICENSE.txt (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/LICENSE.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/tools/plugins/org.savara.tools.monitor/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA Tools Monitor Plug-in
+Bundle-SymbolicName: org.savara.tools.monitor;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.tools.monitor.eclipse.Activator
+Bundle-Vendor: www.savara.org
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.pi4soa.service,
+ org.pi4soa.cdl,
+ org.eclipse.core.resources,
+ org.eclipse.debug.core,
+ org.eclipse.jdt.launching,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.jface,
+ org.eclipse.jdt.debug.ui,
+ org.eclipse.ui.console,
+ org.eclipse.debug.ui,
+ org.eclipse.ui,
+ org.eclipse.jdt.core,
+ org.eclipse.emf.ecore,
+ org.pi4soa.common,
+ org.eclipse.wst.server.core,
+ org.eclipse.jst.server.core,
+ org.eclipse.jst.server.generic.core
+Eclipse-LazyStart: true
+Bundle-ClassPath: .
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added: trunk/tools/plugins/org.savara.tools.monitor/build.properties
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/build.properties (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,13 @@
+source.. = src/java/
+output.. = classes/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ LICENSE.txt
+src.includes = .classpath,\
+ .project,\
+ LICENSE.txt,\
+ META-INF/,\
+ build.properties,\
+ plugin.xml,\
+ src/
Added: trunk/tools/plugins/org.savara.tools.monitor/plugin.xml
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/plugin.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/plugin.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ id="org.savara.tools.monitor.eclipse.MonitorLauncher"
+ delegate="org.savara.tools.monitor.eclipse.MonitorLauncher"
+ modes="run"
+ name="Monitor">
+ <fileExtension extension="cdm" default="true"/>
+ </launchConfigurationType>
+ </extension>
+
+ <extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+ type="org.savara.tools.monitor.eclipse.MonitorLauncher"
+ class="org.savara.tools.monitor.eclipse.MonitorTabGroup"
+ id="org.eclipse.jdt.debug.ui.launchConfigurationTabGroup.monitor">
+ </launchConfigurationTabGroup>
+ </extension>
+
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ id="org.savara.tools.service.generation.contribution2"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.cdm">
+ <menu
+ id="org.savara.tools.menu"
+ label="Savara"
+ path="additions">
+ <separator name="group1"/>
+ </menu>
+ <action
+ label="Monitor"
+ class="org.savara.tools.monitor.eclipse.MonitorAction"
+ menubarPath="org.savara.tools.menu/group1"
+ enablesFor="1"
+ id="org.savara.tools.monitor.MonitorAction">
+ </action>
+ </objectContribution>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.savara.tools.preferences.SavaraPreferencePage"
+ id="org.savara.tools.preferences.SavaraPreferencePage"
+ name="Savara">
+ </page>
+ <page
+ category="org.savara.tools.preferences.SavaraPreferencePage"
+ class="org.savara.tools.monitor.preferences.MonitorPreferencePage"
+ id="org.savara.tools.monitor.preferences.MonitorPreferencePage"
+ name="Monitor">
+ </page>
+ </extension>
+
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.savara.tools.monitor.preferences.PreferenceInitializer">
+ </initializer>
+ </extension>
+</plugin>
Added: trunk/tools/plugins/org.savara.tools.monitor/pom.xml
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/pom.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,16 @@
+<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.tools</groupId>
+ <artifactId>org.savara.tools.monitor</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ToolsMonitor</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+</project>
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/CorrelationManagerListener.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/CorrelationManagerListener.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/CorrelationManagerListener.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,106 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor;
+
+import org.pi4soa.service.correlator.CorrelationSession;
+
+/**
+ * This interface represents a listener interested in changes
+ * that occur within the correlation manager.
+ *
+ */
+public interface CorrelationManagerListener {
+
+ /**
+ * This method indicates that a correlation session has
+ * started.
+ *
+ * @param session The correlation session
+ */
+ public void correlationSessionStarted(CorrelationSession session);
+
+ /**
+ * This method indicates that a correlation session has
+ * finished.
+ *
+ * @param session The correlation session
+ */
+ public void correlationSessionFinished(CorrelationSession session);
+
+ /**
+ * A new exchange event has been added to a correlation session.
+ *
+ * @param exchangeEvent The exchange event.
+ */
+ public void exchangeEventAdded(ExchangeEvent exchangeEvent);
+
+
+ /**
+ * An exchange event has been updated.
+ *
+ * @param exchangeEvent The exchange event.
+ */
+ public void exchangeEventUpdated(ExchangeEvent exchangeEvent);
+
+ /**
+ * An unexpected event has occured
+ *
+ * @param exchangeEvent. The exchange event.
+ * @param serviceName The service reporting the error
+ */
+ public void unexpectedExchangeEventAdded(ExchangeEvent exchangeEvent,
+ String serviceName);
+
+ /**
+ * An error occurred related to the specified correlation
+ * session.
+ *
+ * @param session The correlation session
+ * @param mesg The error message
+ * @param exception The optional exception trace
+ * @param serviceName The service reporting the error
+ */
+ public void error(CorrelationSession session, String mesg,
+ String exception, String serviceName);
+
+ /**
+ * A warning occurred related to the specified correlation
+ * session.
+ *
+ * @param session The correlation session
+ * @param mesg The warning message
+ * @param exception The optional exception trace
+ * @param serviceName The service reporting the warning
+ */
+ public void warning(CorrelationSession session, String mesg,
+ String exception, String serviceName);
+
+ /**
+ * An information event occurred related to the specified correlation
+ * session.
+ *
+ * @param session The correlation session
+ * @param mesg The information message
+ * @param serviceName The service reporting the information
+ */
+ public void information(CorrelationSession session,
+ String mesg, String serviceName);
+
+}
\ No newline at end of file
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ExchangeEvent.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ExchangeEvent.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ExchangeEvent.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,268 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor;
+
+import java.io.Serializable;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+import org.pi4soa.cdl.ExchangeDetails;
+import org.pi4soa.service.Message;
+import org.pi4soa.service.Channel;
+import org.pi4soa.service.correlator.CorrelationSession;
+
+/**
+ * This class represents the 'exchange' correlation event.
+ *
+ */
+public class ExchangeEvent implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1984285030410307153L;
+
+ Message m_message = null;
+
+ /**
+ * This class represents the 'exchange' correlation event.
+ *
+ * @param exchange The exchange details
+ * @param channel The channel
+ * @param session The session
+ * @param serviceDescriptionName The service description name
+ */
+ public ExchangeEvent(ExchangeDetails exchange,
+ Channel channel, CorrelationSession session,
+ String serviceDescriptionName, Message message) {
+ m_exchange = exchange;
+ m_channel = channel;
+ m_session = session;
+ m_serviceDescriptionName = serviceDescriptionName;
+ this.m_message = message;
+ }
+
+ /**
+ * This method returns the exchange details.
+ *
+ * @return The exchange details
+ */
+ public ExchangeDetails getExchange() {
+ return(m_exchange);
+ }
+
+ /**
+ * This method returns the channel.
+ *
+ * @return The channel
+ */
+ public Channel getChannel() {
+ return(m_channel);
+ }
+
+ /**
+ * This method returns the correlation session.
+ *
+ * @return The correlation session
+ */
+ public CorrelationSession getCorrelationSession() {
+ return(m_session);
+ }
+
+ /**
+ * This method returns the service description name.
+ *
+ * @return The service description name
+ */
+ public String getServiceDescriptionName() {
+ return(m_serviceDescriptionName);
+ }
+
+ /**
+ * This method returns the message.
+ *
+ * @return The service description name
+ */
+ public Message getMessage() {
+ return m_message;
+ }
+
+ /**
+ * This method returns whether the exchange has been
+ * initiated and completed.
+ *
+ * @return The 'complete' status of the exchange event
+ */
+ public boolean isExchangeComplete() {
+ return(m_initiated && m_completed);
+ }
+
+ /**
+ * This method determines whether the event has been
+ * initiated.
+ *
+ * @return Whether event has been initiated
+ */
+ public boolean getInitiated(){
+ return m_initiated;
+ }
+
+ /**
+ * This method determines whether the event has been
+ * completed.
+ *
+ * @return Whether event has been completed
+ */
+ public boolean getCompleted(){
+ return m_completed;
+ }
+
+ /**
+ * This method indicates that the exchange associated with
+ * the event has initiated.
+ *
+ */
+ public void initiated() {
+ m_initiated = true;
+ checkIfExchangeCorrelated();
+ }
+
+ /**
+ * This method indicates that the exchange associated with
+ * the event has completed.
+ *
+ */
+ public void completed() {
+ m_completed = true;
+ checkIfExchangeCorrelated();
+ }
+
+
+ protected void checkIfExchangeCorrelated() {
+ if (isExchangeComplete()) {
+ // logger.fine("EXCHANGE CORRELATED: "+this);
+ }
+ }
+
+ public int hashCode() {
+ return(m_message.getOperationName().hashCode());
+ }
+
+ public boolean equals(Object obj) {
+ boolean ret=false;
+ if (obj instanceof ExchangeEvent) {
+ ExchangeEvent other=(ExchangeEvent)obj;
+ if (m_exchange == null || other.getExchange() == null) {
+ // Compare on message basis
+ if (m_message.isRPCStyle() &&
+ other.getMessage().isRPCStyle()) {
+ if (m_message.getOperationName().equals(
+ other.getMessage().getOperationName()) &&
+ m_message.isRequest() == other.getMessage().isRequest() &&
+ m_message.getServiceType().equals(
+ other.getMessage().getServiceType())) {
+ ret = true;
+ }
+ } else if (m_message.isRPCStyle() == false &&
+ other.getMessage().isRPCStyle() == false) {
+ if (m_message.getType().equals(
+ other.getMessage().getType())) {
+ ret = true;
+ }
+ }
+ } else if (other.getExchange() == m_exchange &&
+ other.getChannel().getName().equals(m_channel.getName()) &&
+ other.getCorrelationSession() == m_session) {
+ ret = true;
+ }
+
+ if (ret) {
+
+ // Check identities
+ if (other.getMessage().getMessageIdentities().size()
+ == getMessage().getMessageIdentities().size()) {
+
+ for (int i=0; ret &&
+ i < getMessage().getMessageIdentities().size(); i++) {
+ ret = false;
+
+ org.pi4soa.service.Identity id=
+ getMessage().getMessageIdentities().get(i);
+
+ if (logger.isLoggable(Level.FINEST)) {
+ logger.finest("Checking message identity ("+i+
+ "): "+id);
+ }
+
+ for (int j=0; ret == false &&
+ j < other.getMessage().getMessageIdentities().size(); j++) {
+
+ if (id.equals(other.getMessage().getMessageIdentities().get(j))) {
+ ret = true;
+ }
+
+ if (logger.isLoggable(Level.FINEST)) {
+ logger.finest("Against message identity ("+j+
+ "): "+other.getMessage().getMessageIdentities().get(j)+
+ " = "+ret);
+ }
+ }
+ }
+ } else {
+ if (logger.isLoggable(Level.FINEST)) {
+ logger.finest("Message identity list length mismatch");
+ }
+
+ ret = false;
+ }
+ }
+ }
+ return(ret);
+ }
+
+ public String toString() {
+ StringBuffer ret=new StringBuffer();
+ ret.append("ExchangeEvent[");
+ if (m_exchange != null) {
+
+ // if (NamesUtil.isSet(m_exchange.getDescription())) {
+
+
+ if (m_exchange.getDescription() != null && "".equals(m_exchange.getDescription()) == false) {
+
+ ret.append(m_exchange.getDescription());
+ } else {
+ ret.append(m_exchange.getName());
+ }
+ ret.append(", ");
+ }
+ ret.append(m_message.toString()+"]");
+ return(ret.toString());
+ }
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.monitor");
+
+ private ExchangeDetails m_exchange=null;
+ private Channel m_channel=null;
+ private CorrelationSession m_session;
+ private String m_serviceDescriptionName=null;
+ private boolean m_initiated=false;
+ private boolean m_completed=false;
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/TxnMonitor.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/TxnMonitor.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/TxnMonitor.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,615 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.ExchangeDetails;
+import org.pi4soa.service.Channel;
+import org.pi4soa.service.Message;
+import org.pi4soa.service.ServiceException;
+import org.pi4soa.service.correlator.CorrelationSession;
+import org.pi4soa.service.correlator.ServiceCorrelator;
+import org.pi4soa.service.correlator.ServiceCorrelatorFactory;
+import org.pi4soa.service.correlator.ServiceCorrelatorListener;
+import org.pi4soa.service.tracker.ServiceTrackerClient;
+import org.pi4soa.service.tracker.jms.JMSServiceTrackerClient;
+
+/**
+ * The TxnMonitor class is a generic transaction monitor class that
+ * takes in a CDL description and monitors the progress of transactions,
+ * which are long lived interactions, against the CDL description.
+ * A TxnMonitor MAY be used as a generic monitor for any CDL description.
+ *
+ */
+public class TxnMonitor {
+
+ public TxnMonitor(String fname)
+ {
+ m_cdlFile = fname;
+ }
+
+ public void initialize() throws ServiceException
+ {
+
+ m_correlator=ServiceCorrelatorFactory.getServiceCorrelator();
+ m_correlator.addServiceCorrelatorListener(new CorrelatorListener());
+
+ // Obtain service tracker client
+ m_trackerClient = new JMSServiceTrackerClient();
+
+ // Check if system properties have been provided for JNDI
+ if (System.getProperty("java.naming.factory.initial") != null) {
+ m_trackerClient.setJNDIInitialContextFactory(System.getProperty("java.naming.factory.initial"));
+ }
+
+ if (System.getProperty("java.naming.provider.url") != null) {
+ m_trackerClient.setJNDIProviderURL(System.getProperty("java.naming.provider.url"));
+ }
+
+ if (System.getProperty("java.naming.factory.url.pkgs") != null) {
+ m_trackerClient.setJNDIFactoryURLPackages(System.getProperty("java.naming.factory.url.pkgs"));
+ }
+
+ if (System.getProperty("java.messaging.factory") != null) {
+ m_trackerClient.setJMSConnectionFactory(System.getProperty("java.messaging.factory"));
+ }
+
+ if (System.getProperty("java.messaging.destination") != null) {
+ m_trackerClient.setJMSDestination(System.getProperty("java.messaging.destination"));
+ }
+
+ // Add correlator as listener to the tracker
+ m_trackerClient.addServiceTrackerListener(m_correlator);
+
+ //System.err.println("");
+ //System.err.println("Staring to monitor events against " + m_cdlFile + " .... ");
+ //System.err.println("");
+ try {
+ monitor(m_cdlFile);
+ } catch(java.io.IOException ioe) {
+ throw new ServiceException("Failed to initialize monitor for '"+
+ m_cdlFile+"'", ioe);
+ }
+ }
+
+ /**
+ * This method returns the singleton for the TxnMonitor.
+ *
+ * @return The singleton
+ * @exception ServiceException Failed to obtain monitor
+ */
+ public static TxnMonitor getInstance(String fname) throws ServiceException {
+ // TODO: See if there is a better way to make an instance
+ // available to a view
+ if (m_instance == null) {
+ m_instance = new TxnMonitor(fname);
+ m_instance.initialize();
+ }
+
+ return(m_instance);
+ }
+
+ /**
+ * This method loads the choreography description associated
+ * with the supplied filename, and then monitors it, before
+ * returning it to the caller.
+ *
+ * @param filename The choreography description filename
+ * @return The choreography description being monitored
+ * @throws java.io.IOException Failed to load
+ * @throws ServiceException Failed to monitor
+ */
+ public org.pi4soa.cdl.Package monitor(String filename)
+ throws java.io.IOException, ServiceException {
+ org.pi4soa.cdl.Package ret=
+ org.pi4soa.cdl.CDLManager.load(filename);
+
+ monitor(ret);
+
+ return(ret);
+ }
+
+ /**
+ * This method initializes the correlator with the choreography
+ * description to be monitored.
+ *
+ * @param cdl The choreography description
+ * @exception ServiceException Failed to monitor choreography
+ * description
+ */
+ public void monitor(org.pi4soa.cdl.Package cdl)
+ throws ServiceException {
+ m_correlator.register(cdl);
+ }
+
+ /**
+ * This method disassociates the correlator from the choreography
+ * description being monitored.
+ *
+ * @param cdl The choreography description
+ * @exception ServiceException Failed to stop monitor choreography
+ * description
+ */
+ public void unmonitor(org.pi4soa.cdl.Package cdl)
+ throws ServiceException {
+ m_correlator.unregister(cdl);
+ }
+
+ /**
+ * @param args - the first argument in args is the location of the
+ * CDM file that will be used to drive the monitoring.
+ */
+ public static void main(String[] args)
+ {
+ // TODO Auto-generated method stub
+ String s = "Constructing a monitor for " + args[0];
+ logger.fine(s);
+
+ try {
+ TxnMonitor mon = TxnMonitor.getInstance(args[0]);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * This method will return an existing list, associated with the
+ * supplied session, or if not found, will create one - unless
+ * the session's event list has previously been removed and
+ * therefore a null will be returned (i.e. events to be
+ * ignored).
+ *
+ * @param session The session
+ * @return The list, or null if session to be ignored
+ */
+ protected java.util.List createEventList(CorrelationSession session) {
+ java.util.List ret=null;
+
+ logger.fine("createEventList for session - " + session);
+
+ synchronized(m_eventLists) {
+ ret = (java.util.List)m_eventLists.get(session);
+
+ if (ret == null) {
+ ret = new java.util.Vector();
+
+ logger.fine("Creating event list for session: "+session);
+
+ m_eventLists.put(session, ret);
+ }
+ }
+
+ logger.fine("createEventList returning - " + ret);
+
+ return(ret);
+ }
+
+ /**
+ * This method will remove the event list associated with
+ * the supplied session, and add the session to the list
+ * of sessions to be ignored from now on.
+ *
+ * @param session The session
+ */
+ protected void removeEventList(CorrelationSession session) {
+
+ synchronized(m_eventLists) {
+
+ logger.fine("Remove correlation session: "+session);
+
+ m_eventLists.remove(session);
+ }
+ }
+
+ protected void fireSessionStarted(CorrelationSession session) {
+ System.err.println(">>>> fireSessionStarted");
+ for (int i=0; i < m_listeners.size(); i++) {
+ CorrelationManagerListener l=
+ (CorrelationManagerListener)m_listeners.get(i);
+
+ l.correlationSessionStarted(session);
+ }
+ System.err.println(">>>> finished fireSessionStarted");
+ }
+
+ protected void fireSessionFinished(CorrelationSession session) {
+ System.err.println(">>>> fireSessionFinished");
+ for (int i=0; i < m_listeners.size(); i++) {
+ CorrelationManagerListener l=
+ (CorrelationManagerListener)m_listeners.get(i);
+
+ l.correlationSessionFinished(session);
+ }
+ logger.fine(">>>> finished fireSessionFinished");
+ }
+
+ protected void fireUpdatedSession(CorrelationSession session) {
+ logger.fine(">>>> fireSessionUpdated");
+ for (int i=0; i < m_listeners.size(); i++) {
+ CorrelationManagerListener l=
+ (CorrelationManagerListener)m_listeners.get(i);
+
+ // l.correlationSessionUpdated(session);
+ }
+ logger.fine(">>>> finished fireSessionUpdated");
+ }
+
+
+ protected void fireAddedExchangeEvent(ExchangeEvent exchangeEvent) {
+ for (int i=0; i < m_listeners.size(); i++) {
+ CorrelationManagerListener l=
+ (CorrelationManagerListener)m_listeners.get(i);
+
+ l.exchangeEventAdded(exchangeEvent);
+ }
+ }
+
+ protected void fireUpdatedExchangeEvent(ExchangeEvent exchangeEvent) {
+ for (int i=0; i < m_listeners.size(); i++) {
+ CorrelationManagerListener l=
+ (CorrelationManagerListener)m_listeners.get(i);
+
+ l.exchangeEventUpdated(exchangeEvent);
+ }
+ }
+
+ protected void fireAddedUnexpectedExchangeEvent(ExchangeEvent exchangeEvent,
+ String serviceName) {
+ logger.fine(">>>> fireAddedUnexpectedExchangeEvent");
+ for (int i=0; i < m_listeners.size(); i++) {
+ CorrelationManagerListener l=
+ (CorrelationManagerListener)m_listeners.get(i);
+
+ l.unexpectedExchangeEventAdded(exchangeEvent, serviceName);
+ }
+ logger.fine("<<<< fireAddedUnexpectedExchangeEvent");
+ }
+
+ protected void fireErrorEvent(CorrelationSession session,
+ String mesg, String exception, String serviceName) {
+ logger.fine(">>>> fireErrorEvent");
+ for (int i=0; i < m_listeners.size(); i++) {
+ CorrelationManagerListener l=
+ (CorrelationManagerListener)m_listeners.get(i);
+
+ l.error(session, mesg, exception, serviceName);
+ }
+ logger.fine("<<<< fireErrorEvent");
+ }
+
+ protected void fireWarningEvent(CorrelationSession session,
+ String mesg, String exception, String serviceName) {
+ logger.fine(">>>> fireWarningEvent");
+ for (int i=0; i < m_listeners.size(); i++) {
+ CorrelationManagerListener l=
+ (CorrelationManagerListener)m_listeners.get(i);
+
+ l.warning(session, mesg, exception, serviceName);
+ }
+ logger.fine("<<<< fireWarningEvent");
+ }
+
+ protected void fireInformationEvent(CorrelationSession session,
+ String mesg, String serviceName) {
+ logger.fine(">>>> fireInformationEvent");
+ for (int i=0; i < m_listeners.size(); i++) {
+ CorrelationManagerListener l=
+ (CorrelationManagerListener)m_listeners.get(i);
+
+ l.information(session, mesg, serviceName);
+ }
+ logger.fine("<<<< fireInformationEvent");
+ }
+
+ public void addCorrelationManagerListener(CorrelationManagerListener l) {
+ logger.fine(">>>> addCorrelationManagerListener");
+ m_listeners.add(l);
+ }
+
+ public void removeCorrelationManagerListener(CorrelationManagerListener l) {
+ logger.fine(">>>> removeCorrelationManagerListener");
+ m_listeners.remove(l);
+ }
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.monitor");
+
+ private static TxnMonitor m_instance=null;
+ private ServiceCorrelator m_correlator=null;
+ private JMSServiceTrackerClient m_trackerClient=null;
+ private java.util.Hashtable m_eventLists=new java.util.Hashtable();
+ private java.util.Vector m_listeners=new java.util.Vector();
+ private String m_cdlFile = null;
+
+
+ public class CorrelatorListener implements ServiceCorrelatorListener {
+
+ /**
+ * This method indicates that the supplied choreography
+ * description has been registered with the service
+ * correlator.
+ *
+ * @param cdlpack The choreography description
+ */
+ public void choreographyDescriptionRegistered(org.pi4soa.cdl.Package cdlpack) {
+ logger.fine(">>>> choreographyDescriptionRegistered");
+ }
+
+ /**
+ * This method indicates that the supplied choreography
+ * description has been unregistered from the service
+ * correlator.
+ *
+ * @param cdlpack The choreography description
+ */
+ public void choreographyDescriptionUnregistered(org.pi4soa.cdl.Package cdlpack) {
+ logger.fine(">>>> choreographyDescriptionUnregistered");
+ }
+
+ /**
+ * This method indicates that a new correlated session has
+ * been started.
+ *
+ * @param session The session
+ */
+ public void sessionStarted(CorrelationSession session) {
+ logger.fine(">>>> sessionStarted");
+ fireSessionStarted(session);
+ }
+
+ /**
+ * This method indicates that a correlated session has
+ * been finished.
+ *
+ * @param session The session
+ */
+ public void sessionFinished(CorrelationSession session) {
+ logger.fine(">>>> sessionFinished");
+ fireSessionFinished(session);
+ }
+
+ /**
+ * This method is invoked to indicate that a choreography
+ * exchange has been initiated by one participant.
+ *
+ * @param exchange The exchange details
+ * @param channel The channel associated with the exchange
+ * @param session The session
+ * @param serviceDescriptionName The name of the service
+ * description that caused this exchange to
+ * be initiated
+ */
+ public synchronized void exchangeInitiated(ExchangeDetails exchange,
+ Channel channel, Message message, CorrelationSession session,
+ String serviceDescriptionName) {
+
+ logger.fine(">>>> exchangeInitiated");
+
+ java.util.List list = createEventList(session);
+
+ if(list != null){
+ ExchangeEvent event = new ExchangeEvent(exchange, channel, session, serviceDescriptionName, message);
+ int index = 0;
+ boolean f_updated=false;
+
+ if ((index=list.indexOf(event)) == -1) {
+ logger.fine("Add new event '"+event+ "' to correlation session "+session);
+ list.add(event);
+ }
+ else{
+ logger.fine("Retrieve existing event for index "+index);
+ ExchangeEvent existingEvent=
+ (ExchangeEvent)list.get(index);
+
+ if (existingEvent.getInitiated() == false) {
+ event = existingEvent;
+
+ // Remove event from list
+ list.remove(index);
+
+ if (list.size() == 0) {
+ // Remove list
+ removeEventList(session);
+ }
+
+ f_updated = true;
+ } else {
+ logger.fine("Add new event '"+event+ "' to correlation session "+session);
+ list.add(event);
+ }
+ }
+
+ event.initiated();
+ logger.fine("EXCHANGE INITIATED: ");
+ logger.fine(" CHANNEL DETAILS: " + channel + " (" + channel.getName() + ") session " + session);
+ logger.fine(" EXCHANGE DETAILS: " + exchange);
+
+ if(f_updated == false){
+ fireAddedExchangeEvent(event);
+ }
+ else{
+ fireUpdatedExchangeEvent(event);
+ }
+ // fireUpdatedSession(session);
+ }
+ }
+
+ /**
+ * This method is invoked to indicate that a choreography
+ * exchange has been completed by the target participant.
+ *
+ * @param exchange The exchange details
+ * @param channel The channel associated with the exchange
+ * @param session The session
+ * @param serviceDescriptionName The name of the service
+ * description that caused this exchange to
+ * be completed
+ */
+ public synchronized void exchangeCompleted(ExchangeDetails exchange,
+ Channel channel, Message message, CorrelationSession session,
+ String serviceDescriptionName) {
+
+ logger.fine(">>>> exchangeCompleted");
+
+ java.util.List list=createEventList(session);
+
+ if (list != null) {
+ ExchangeEvent event=new ExchangeEvent(exchange, channel, session, serviceDescriptionName, message);
+
+ int index = 0;
+
+ if ((index=list.indexOf(event)) == -1) {
+ logger.fine("Add new event '"+event+ "' to correlation session "+session);
+ list.add(event);
+ }
+ else{
+ logger.fine("Retrieve existing event for index "+index);
+ ExchangeEvent existingEvent=
+ (ExchangeEvent)list.get(index);
+
+ if (existingEvent.getCompleted() == false) {
+ event = existingEvent;
+
+ // Remove event from list
+ list.remove(index);
+
+ if (list.size() == 0) {
+ // Remove list
+ removeEventList(session);
+ }
+ } else {
+ logger.fine("Add new event '"+event+ "' to correlation session "+session);
+ list.add(event);
+ }
+ }
+
+ event.completed();
+ logger.fine("EXCHANGE COMPLETED: ");
+ // logger.fine(" CHANNEL DETAILS: " + channel);
+ logger.fine(" CHANNEL DETAILS: " + channel + " (" + channel.getName() + ") session " + session);
+ logger.fine(" EXCHANGE DETAILS: " + exchange);
+
+ if(index == -1){
+ fireAddedExchangeEvent(event);
+ }
+ else{
+ fireUpdatedExchangeEvent(event);
+ }
+ // fireUpdatedSession(session);
+ logger.fine("<<<< exchangeCompleted");
+ }
+ }
+
+ /**
+ * This method is invoked to indicate that a message
+ * was unexpected at a participant.
+ *
+ * @param message The message
+ * @param session The session
+ * @param serviceDescriptionName The name of the service
+ * description that caused this unexpected
+ * message error
+ */
+ public synchronized void unexpectedMessage(Message message,
+ CorrelationSession session, String serviceDescriptionName) {
+
+ logger.fine(">>>> unexpectedMessage");
+ logger.fine("MESSAGE: " + message + " SESSION: " + session + " SERVICE: " + serviceDescriptionName);
+ logger.fine("MESSAGE: " + message);
+ logger.fine("Identities: " + message.getChannelIdentity());
+ //java.util.List list = createEventList(session);
+
+ //if(list != null){
+ ExchangeDetails exchange = null;
+ Channel channel = null;
+
+ logger.fine(">>>> creating unexpected event");
+
+ ExchangeEvent event = new ExchangeEvent(exchange, channel, session, serviceDescriptionName, message);
+
+ logger.fine(">>>> created unexpected event");
+
+ logger.fine("Add unexpected new event '"+event+ "' to correlation session "+session);
+ //list.add(event);
+
+ logger.fine(">>>> UNEXPECTED EVENT for session: " + session);
+
+ fireAddedUnexpectedExchangeEvent(event, serviceDescriptionName);
+
+
+ logger.fine(">>>> HANDLED UNEXPECTED EVENT for session: " + session);
+ //}
+ logger.fine("<<<< unexpectedMessage");
+ }
+
+ /**
+ * An error occurred related to the specified correlation
+ * session.
+ *
+ * @param mesg The error message
+ * @param exception The optional exception details
+ * @param session The correlation session
+ * @param serviceDescriptionName The service name
+ */
+ public void error(String mesg, String exception,
+ CorrelationSession session, String serviceDescriptionName) {
+ logger.fine(">>>> error");
+
+ fireErrorEvent(session, mesg, exception, serviceDescriptionName);
+
+ logger.fine("<<<< error");
+ }
+
+ /**
+ * A warning occurred related to the specified correlation
+ * session.
+ *
+ * @param mesg The warning message
+ * @param exception The optional exception details
+ * @param session The correlation session
+ * @param serviceDescriptionName The service name
+ */
+ public void warning(String mesg, String exception,
+ CorrelationSession session, String serviceDescriptionName) {
+ logger.fine(">>>> warning");
+
+ fireWarningEvent(session, mesg, exception, serviceDescriptionName);
+
+ logger.fine("<<<< warning");
+ }
+
+ /**
+ * An information event occurred related to the specified correlation
+ * session.
+ *
+ * @param mesg The information message
+ * @param session The correlation session
+ * @param serviceDescriptionName The service name
+ */
+ public void information(String mesg, CorrelationSession session,
+ String serviceDescriptionName) {
+ logger.fine(">>>> information");
+
+ fireInformationEvent(session, mesg, serviceDescriptionName);
+
+ logger.fine("<<<< information");
+ }
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/Activator.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/Activator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 16 Jan, 2008 : Initial version created by gary
+ */
+package org.savara.tools.monitor.eclipse;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.pi4soa.common.eclipse.BundleUtil;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.savara.tools.monitor";
+
+ // 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 {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+
+ static {
+ BundleUtil.registerClasspathEntries(PLUGIN_ID, false);
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorAction.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorAction.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorAction.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,179 @@
+/*
+ * 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 Jan, 2008 : Initial version created by gary
+ */
+package org.savara.tools.monitor.eclipse;
+
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.pi4soa.common.resource.eclipse.ResourceUtil;
+import org.savara.tools.monitor.preferences.MonitorPreferences;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.Launch;
+import org.eclipse.debug.core.DebugPlugin;
+
+/**
+ * This class invokes the monitor action on the selected
+ * choreography file.
+ *
+ */
+public class MonitorAction implements IObjectActionDelegate {
+
+ private static final String SET_LIBRARY_PATHS = "Need to set library paths. See Window->Preferences->Savara->Monitor.";
+ /**
+ * This method implements the action's run method.
+ *
+ * @param action The action
+ */
+ public void run(IAction action) {
+
+ if (m_selection instanceof StructuredSelection) {
+ StructuredSelection sel=(StructuredSelection)m_selection;
+
+ IResource res=(IResource)sel.getFirstElement();
+
+ // Make sure there are no markers associated
+ // with the resource
+ if (ResourceUtil.hasErrors(res) == false) {
+
+ if (MonitorPreferences.isLibraryPathsDefined()) {
+ launch(res.getProject().getName(),
+ res.getProjectRelativePath().toString());
+ } else {
+ error(SET_LIBRARY_PATHS);
+ }
+
+ } else {
+ error(ERRORS_NO_TEST);
+ }
+ }
+ }
+
+ /**
+ * This method invokes the launch action.
+ *
+ * @param project The project
+ * @param relativePath The relative path within the project
+ */
+ protected void launch(String project, String relativePath) {
+
+ MonitorLauncher launcher=new MonitorLauncher();
+
+ try {
+ ILaunchManager manager =
+ DebugPlugin.getDefault().getLaunchManager();
+
+ ILaunchConfigurationType type =
+ manager.getLaunchConfigurationType(
+ MonitorLaunchConfigurationConstants.LAUNCH_CONFIG_TYPE);
+ ILaunchConfiguration[] configurations =
+ manager.getLaunchConfigurations(type);
+
+ for (int i = 0; i < configurations.length; i++) {
+ ILaunchConfiguration configuration = configurations[i];
+ if (configuration.getName().equals(CHOREOGRAPHY_MONITOR)) {
+ configuration.delete();
+ break;
+ }
+ }
+
+ ILaunchConfigurationWorkingCopy workingCopy =
+ type.newInstance(null, CHOREOGRAPHY_MONITOR);
+
+ workingCopy.setAttribute(MonitorLaunchConfigurationConstants.ATTR_PROJECT_NAME,
+ project);
+ workingCopy.setAttribute(MonitorLaunchConfigurationConstants.ATTR_CHOREOGRAPHY_DESCRIPTION,
+ relativePath);
+
+ ILaunchConfiguration configuration=workingCopy.doSave();
+
+
+ Launch launch=new Launch(configuration, LAUNCH_MODE, null);
+
+ launcher.launch(configuration, LAUNCH_MODE, launch, null);
+
+ } catch(Exception e) {
+ logger.severe("Failed to launch monitor: "+e);
+
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * This method is used to report an error.
+ *
+ * @param mesg The error message
+ */
+ public void error(String mesg) {
+
+ logger.severe("Error occurred: "+mesg);
+
+ MessageBox mbox=new MessageBox(m_targetPart.getSite().getShell(),
+ SWT.ICON_ERROR|SWT.OK);
+
+ if (mesg == null) {
+ mesg = "Null pointer exception has occurred";
+ }
+
+ mbox.setMessage(mesg);
+ mbox.open();
+ }
+
+ /**
+ * This method indicates that the selection has changed.
+ *
+ * @param action The action
+ * @param selection The selection
+ */
+ public void selectionChanged(IAction action,
+ ISelection selection) {
+ m_selection = selection;
+ }
+
+ /**
+ * This method sets the currently active workbench part.
+ *
+ * @param action The action
+ * @param targetPart The active workbench part
+ */
+ public void setActivePart(IAction action,
+ IWorkbenchPart targetPart) {
+ m_targetPart = targetPart;
+ }
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.monitor.eclipse");
+
+ private ISelection m_selection=null;
+ private IWorkbenchPart m_targetPart=null;
+
+ private static final String ERRORS_NO_TEST = "Choreography Description has errors, so cannot run monitor";
+
+ private static final String LAUNCH_MODE = "run";
+ private static final String CHOREOGRAPHY_MONITOR = "Choreography Monitor";
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorLaunchConfigurationConstants.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorLaunchConfigurationConstants.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorLaunchConfigurationConstants.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,34 @@
+/*
+ * 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 Jan, 2008 : Initial version created by gary
+ */
+package org.savara.tools.monitor.eclipse;
+
+/**
+ * This interface defines the constants for the monitor
+ * launch configuration.
+ */
+public interface MonitorLaunchConfigurationConstants {
+
+ public static final String ATTR_PROJECT_NAME="project";
+
+ public static final String ATTR_CHOREOGRAPHY_DESCRIPTION="choreography";
+
+ public static final String LAUNCH_CONFIG_TYPE=
+ "org.savara.tools.monitor.eclipse.MonitorLauncher";
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorLauncher.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorLauncher.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorLauncher.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,482 @@
+/*
+ * 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 Jan, 2008 : Initial version created by gary
+ */
+package org.savara.tools.monitor.eclipse;
+
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.Map;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.IStreamListener;
+import org.eclipse.debug.core.model.IStreamMonitor;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
+import org.eclipse.jdt.launching.ExecutionArguments;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.IVMRunner;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+import org.eclipse.jst.server.core.internal.GenericRuntime;
+import org.eclipse.jst.server.generic.core.internal.GenericServerRuntime;
+import org.eclipse.osgi.util.ManifestElement;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.ServerCore;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.pi4soa.common.eclipse.BundleUtil;
+import org.savara.tools.monitor.preferences.MonitorPreferences;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Path;
+
+/**
+ * This class is responsible for launching a monitor against
+ * a choreography description.
+ */
+public class MonitorLauncher
+ extends AbstractJavaLaunchConfigurationDelegate {
+
+ /**
+ * This is the default constructor.
+ *
+ */
+ public MonitorLauncher() {
+ }
+
+ /**
+ * This method launches the monitor.
+ *
+ * @param configuration The launch configuration
+ * @param mode The mode (run or debug)
+ * @param launch The launch object
+ * @param monitor The optional progress monitor
+ */
+ public void launch(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor)
+ throws CoreException {
+
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ monitor.beginTask(MessageFormat.format("{0}...", new String[]{configuration.getName()}), 3); //$NON-NLS-1$
+ // check for cancellation
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ monitor.subTask("Verifying launch configuration....");
+
+ String mainTypeName = org.savara.tools.monitor.ui.Monitor.class.getName();
+
+ IVMInstall vm = verifyVMInstall(configuration);
+
+ IVMRunner runner = vm.getVMRunner(mode);
+ if (runner == null) {
+ abort("VM runner does not exist",
+ null, IJavaLaunchConfigurationConstants.ERR_VM_RUNNER_DOES_NOT_EXIST); //$NON-NLS-1$
+ }
+
+ File workingDir = verifyWorkingDirectory(configuration);
+ String workingDirName = null;
+ if (workingDir != null) {
+ workingDirName = workingDir.getAbsolutePath();
+ }
+
+ // Environment variables
+ String[] envp= DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
+
+ // Program & VM args
+ String filename=configuration.getAttribute(
+ MonitorLaunchConfigurationConstants.ATTR_PROJECT_NAME, "")+
+ "/"+configuration.getAttribute(
+ MonitorLaunchConfigurationConstants.ATTR_CHOREOGRAPHY_DESCRIPTION, "");
+
+ String pgmArgs="\""+getPathForResource(filename);
+
+ logger.fine("Launching monitor with args: "+pgmArgs);
+
+ String vmArgs = getVMArguments(configuration);
+
+ vmArgs += " -Djava.naming.factory.initial="+MonitorPreferences.getJNDIFactoryInitial();
+ vmArgs += " -Djava.naming.provider.url="+MonitorPreferences.getJNDIProviderURL();
+
+ String pkgs=MonitorPreferences.getJNDIFactoryInitial();
+
+ if (pkgs != null && pkgs.trim().length() > 0) {
+ vmArgs += " -Djava.naming.factory.url.pkgs="+MonitorPreferences.getJNDIFactoryURLPackages();
+ }
+
+ vmArgs += " -Djava.messaging.factory="+MonitorPreferences.getJMSFactory();
+ vmArgs += " -Djava.messaging.destination="+MonitorPreferences.getJMSDestination();
+
+ ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
+
+ // VM-specific attributes
+ Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
+
+ // Classpath
+ String[] classpath = getClasspath(configuration);
+
+ // Create VM config
+ VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
+ runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
+ runConfig.setEnvironment(envp);
+ runConfig.setVMArguments(execArgs.getVMArgumentsArray());
+ runConfig.setWorkingDirectory(workingDirName);
+ runConfig.setVMSpecificAttributesMap(vmAttributesMap);
+
+ // Bootpath
+ runConfig.setBootClassPath(getBootpath(configuration));
+
+ // check for cancellation
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ // stop in main
+ prepareStopInMain(configuration);
+
+ // done the verification phase
+ monitor.worked(1);
+
+ // Launch the configuration - 1 unit of work
+ runner.run(runConfig, launch, monitor);
+
+ IProcess[] processes=launch.getProcesses();
+ if (processes.length > 0) {
+ processes[0].getStreamsProxy().getOutputStreamMonitor().
+ addListener(new IStreamListener() {
+ public void streamAppended(String str, IStreamMonitor mon) {
+ handleResults(str, false);
+ }
+ });
+ processes[0].getStreamsProxy().getErrorStreamMonitor().
+ addListener(new IStreamListener() {
+ public void streamAppended(String str, IStreamMonitor mon) {
+ handleResults(str, true);
+ }
+ });
+ }
+
+ // check for cancellation
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ monitor.done();
+ }
+
+ /**
+ * This method handles the results produced by the launched
+ * monitor.
+ *
+ * @param results The results
+ * @param errorStream Whether the results are from the error
+ * stream
+ */
+ protected void handleResults(String results, boolean errorStream) {
+ //System.out.println(results);
+ }
+
+ /**
+ * This method returns the full path to the resource.
+ *
+ * @param relativePath The is the resource path beginning at
+ * the project
+ * @return The full path
+ */
+ protected String getPathForResource(String relativePath) {
+ String ret=null;
+
+ IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(relativePath));
+ if (file != null && file.exists()) {
+ ret = file.getLocation().toString();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method derives the classpath required to run the
+ * Monitor.
+ *
+ * @param configuration The launch configuation
+ * @return The list of classpath entries
+ */
+ /*
+ public String[] getClasspath(ILaunchConfiguration configuration) {
+ String[] ret=null;
+ Vector classpathEntries=new Vector();
+
+ // Add classpath entry for current Java project
+ try {
+ String projname=configuration.getAttribute(
+ MonitorLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
+
+ IProject project=
+ ResourcesPlugin.getWorkspace().getRoot().getProject(projname);
+
+ IJavaProject jproject=JavaCore.create(project);
+
+ // Add output location
+ IPath outputLocation=jproject.getOutputLocation();
+
+ IFolder folder=
+ ResourcesPlugin.getWorkspace().getRoot().getFolder(outputLocation);
+
+ String path=folder.getLocation().toString();
+
+ classpathEntries.add(path);
+
+ // Add other libraries to the classpath
+ IClasspathEntry[] curclspath=jproject.getRawClasspath();
+ for (int i=0; curclspath != null &&
+ i < curclspath.length; i++) {
+
+ if (curclspath[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+ IFile file=
+ ResourcesPlugin.getWorkspace().
+ getRoot().getFile(curclspath[i].getPath());
+
+ if (file.exists()) {
+ // Library is within the workspace
+ classpathEntries.add(file.getLocation().toString());
+ } else {
+ // Assume library is external to workspace
+ classpathEntries.add(curclspath[i].getPath().toString());
+ }
+
+ } else if (curclspath[i].getEntryKind() ==
+ IClasspathEntry.CPE_CONTAINER) {
+ // Container's not currently handled - but
+ // problem need to retrieve from project and
+ // iterate over container entries
+ }
+ }
+
+ } catch(Exception e) {
+ // TODO: report error
+ }
+
+ String[] cpes=BundleUtil.getClasspathEntries();
+
+ for (int i=0; i < cpes.length; i++) {
+ classpathEntries.add(cpes[i]);
+ }
+
+ ret = new String[classpathEntries.size()];
+ classpathEntries.copyInto(ret);
+
+ return(ret);
+ }
+ */
+
+ public String[] getClasspath(ILaunchConfiguration configuration) {
+ String[] ret=null;
+ java.util.Vector<String> classpathEntries=new java.util.Vector<String>();
+
+ // Add classpath entry for current Java project
+ try {
+ String projname=configuration.getAttribute(
+ MonitorLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
+
+ IProject project=
+ ResourcesPlugin.getWorkspace().getRoot().getProject(projname);
+
+ IJavaProject jproject=JavaCore.create(project);
+
+ // Add output location
+ IPath outputLocation=jproject.getOutputLocation();
+
+ IFolder folder=
+ ResourcesPlugin.getWorkspace().getRoot().getFolder(outputLocation);
+
+ String path=folder.getLocation().toString();
+
+ classpathEntries.add(path);
+
+ // Add other libraries to the classpath
+ IClasspathEntry[] curclspath=jproject.getRawClasspath();
+ for (int i=0; curclspath != null &&
+ i < curclspath.length; i++) {
+
+ if (curclspath[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+ IFile file=
+ ResourcesPlugin.getWorkspace().
+ getRoot().getFile(curclspath[i].getPath());
+
+ if (file.exists()) {
+ // Library is within the workspace
+ classpathEntries.add(file.getLocation().toString());
+ } else {
+ // Assume library is external to workspace
+ classpathEntries.add(curclspath[i].getPath().toString());
+ }
+
+ } else if (curclspath[i].getEntryKind() ==
+ IClasspathEntry.CPE_CONTAINER) {
+ // Container's not currently handled - but
+ // problem need to retrieve from project and
+ // iterate over container entries
+ }
+ }
+
+ } catch(Exception e) {
+ // TODO: report error
+ //e.printStackTrace();
+ }
+
+ buildClassPath("org.savara.tools.monitor", classpathEntries);
+ buildClassPath("org.pi4soa.service", classpathEntries);
+ buildClassPath("org.pi4soa.common", classpathEntries);
+ buildClassPath("org.pi4soa.cdl", classpathEntries);
+ buildClassPath("org.eclipse.emf.ecore", classpathEntries);
+ buildClassPath("org.eclipse.emf.ecore.xmi", classpathEntries);
+ buildClassPath("org.eclipse.emf.common", classpathEntries);
+ buildClassPath("org.apache.xalan", classpathEntries);
+ buildClassPath("org.apache.xml.serializer", classpathEntries);
+
+ // Access library paths to include all found jars
+ String paths=MonitorPreferences.getLibraryPaths();
+
+ java.util.StringTokenizer st=new java.util.StringTokenizer(paths, ":");
+
+ while (st.hasMoreTokens()) {
+ String libpath=st.nextToken();
+
+ java.io.File f=new java.io.File(libpath);
+ java.io.File[] childFiles=f.listFiles();
+
+ for (int i=0; i < childFiles.length; i++) {
+ if (childFiles[i].isFile() && childFiles[i].getName().endsWith(".jar")) {
+ classpathEntries.add(childFiles[i].getAbsolutePath());
+ }
+ }
+ }
+
+ // Return entries as an array
+ ret = new String[classpathEntries.size()];
+ classpathEntries.copyInto(ret);
+
+ if (logger.isLoggable(Level.FINEST)) {
+ logger.finest("Scenario Simulation Classpath:");
+ for (int i=0; i < ret.length; i++) {
+ logger.finest(" ["+i+"] "+ret[i]);
+ }
+ }
+
+ return(ret);
+ }
+
+ protected void buildClassPath(String bundleId, java.util.List<String> entries) {
+ Bundle bundle= Platform.getBundle(bundleId);
+ if (bundle != null) {
+ java.net.URL installLocation= bundle.getEntry("/");
+ java.net.URL local= null;
+ try {
+ local= Platform.asLocalURL(installLocation);
+ } catch (java.io.IOException e) {
+ e.printStackTrace();
+ }
+
+ String baseLocation = local.getFile();
+
+ try {
+ String requires = (String)bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH);
+ ManifestElement[] elements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, requires);
+
+ for (int i=0; elements != null && i < elements.length; i++) {
+
+ String path=baseLocation+elements[i].getValue();
+
+ // Check if path is for a Jar and that the
+ // file exists - if not see if a classes
+ // directory exists
+ if (path.endsWith(".jar")) {
+
+ if ((new File(path)).exists() == false) {
+ if ((new File(baseLocation+"classes")).exists()) {
+ path = baseLocation+"classes";
+ }
+ }
+ }
+
+ if (entries.contains(path) == false) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Adding classpath entry '"+
+ path+"'");
+ }
+ entries.add(path);
+
+ if (elements[i].getValue().equals(".")) {
+ if ((new File(baseLocation+"classes")).exists()) {
+ path = baseLocation+"classes";
+
+ entries.add(path);
+ }
+ }
+ }
+ }
+
+ if (elements == null) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Adding classpath entry '"+
+ baseLocation+"'");
+ }
+ entries.add(baseLocation);
+ }
+
+ /*
+ requires = (String)bundle.getHeaders().get(Constants.REQUIRE_BUNDLE);
+ elements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, requires);
+
+ for (int i=0; recursive &&
+ elements != null && i < elements.length; i++) {
+ buildClasspathEntries(elements[i].getValue(),
+ entries, false);
+ }
+ */
+
+ } catch(Exception e) {
+ logger.severe("Failed to construct classpath: "+e);
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.monitor.eclipse");
+}
\ No newline at end of file
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorMainTab.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorMainTab.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorMainTab.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,516 @@
+/*
+ * 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 Jan, 2008 : Initial version created by gary
+ */
+package org.savara.tools.monitor.eclipse;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+/**
+ * This class represents the first main tab within the tab group
+ * associated with the monitor launch configuration.
+ */
+public class MonitorMainTab extends AbstractLaunchConfigurationTab {
+
+ /**
+ * @see ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ setControl(comp);
+
+ GridLayout topLayout = new GridLayout();
+ topLayout.numColumns= 3;
+ comp.setLayout(topLayout);
+
+ Label label = new Label(comp, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalSpan = 3;
+ label.setLayoutData(gd);
+
+ createChoreographySection(comp);
+
+ label = new Label(comp, SWT.NONE);
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ label.setLayoutData(gd);
+
+ Dialog.applyDialogFont(comp);
+ validatePage();
+ }
+
+ /**
+ * This method creates the GUI components for the
+ * monitor tab.
+ *
+ * @param comp The composite
+ */
+ protected void createChoreographySection(Composite comp) {
+ GridData gd = new GridData();
+ gd.horizontalSpan = 3;
+
+ m_projectLabel = new Label(comp, SWT.NONE);
+ m_projectLabel.setText("Project");
+ gd= new GridData();
+ gd.horizontalIndent = 25;
+ m_projectLabel.setLayoutData(gd);
+
+ m_project= new Text(comp, SWT.SINGLE | SWT.BORDER);
+ m_project.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ m_project.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ validatePage();
+ updateLaunchConfigurationDialog();
+ m_choreographySearch.setEnabled(m_project.getText().length() > 0);
+ }
+ });
+
+ m_projectButton = new Button(comp, SWT.PUSH);
+ m_projectButton.setText("Browse");
+ m_projectButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleProjectButtonSelected();
+ }
+ });
+ setButtonGridData(m_projectButton);
+
+ m_choreographyLabel = new Label(comp, SWT.NONE);
+ gd = new GridData();
+ gd.horizontalIndent = 25;
+ m_choreographyLabel.setLayoutData(gd);
+ m_choreographyLabel.setText("Choreography");
+
+ m_choreography = new Text(comp, SWT.SINGLE | SWT.BORDER);
+ m_choreography.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ m_choreography.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ validatePage();
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ m_choreographySearch = new Button(comp, SWT.PUSH);
+ m_choreographySearch.setEnabled(m_project.getText().length() > 0);
+ m_choreographySearch.setText("Search");
+ m_choreographySearch.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleSearchButtonSelected();
+ }
+ });
+ setButtonGridData(m_choreographySearch);
+ }
+
+ protected static Image createImage(String path) {
+ return null;
+ }
+
+
+ /**
+ * @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration config) {
+ String projectName= "";
+ String choreography= "";
+
+ try {
+ projectName = config.getAttribute(MonitorLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
+ } catch (CoreException ce) {
+ }
+ m_project.setText(projectName);
+
+ try {
+ choreography = config.getAttribute(MonitorLaunchConfigurationConstants.ATTR_CHOREOGRAPHY_DESCRIPTION, ""); //$NON-NLS-1$
+ } catch (CoreException ce) {
+ }
+ m_choreography.setText(choreography);
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ }
+
+ /**
+ * @see AbstractLaunchConfigurationTab#getImage()
+ */
+ public Image getImage() {
+ return(null);
+ }
+
+ /**
+ * This method sets the grid data for the button.
+ *
+ * @param button The button
+ */
+ protected void setButtonGridData(Button button) {
+ GridData gridData= new GridData();
+ button.setLayoutData(gridData);
+ //SWTUtil.setButtonDimensionHint(button);
+ }
+
+ /**
+ * Show a dialog that lists all choreography files within the
+ * selected project
+ */
+ protected void handleSearchButtonSelected() {
+
+ IProject project = getProject();
+
+ ILabelProvider labelProvider=new LabelProvider() {
+ public String getText(Object obj) {
+ String ret="<unknown>";
+ if (obj instanceof IResource) {
+ String filename=((IResource)obj).getName();
+ if (filename.endsWith(org.pi4soa.cdl.CDLDefinitions.CDL_FILE_EXTENSION)) {
+ filename = filename.substring(0, filename.length()-
+ org.pi4soa.cdl.CDLDefinitions.CDL_FILE_EXTENSION.length()-1);
+ }
+ ret = filename+" ["+
+ ((IResource)obj).getParent().
+ getProjectRelativePath()+"]";
+ }
+ return(ret);
+ }
+ };
+
+ IResource[] choreos=null;
+
+ if (project.exists() == false) {
+ choreos = new IResource[0];
+ } else {
+ choreos = getChoreographies(project);
+ }
+
+ ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
+ dialog.setTitle("Choreographies");
+ dialog.setMessage("Select the relevant choreography");
+ dialog.setElements(choreos);
+
+ if (dialog.open() == Window.OK) {
+ IResource file=(IResource)dialog.getFirstResult();
+ m_choreography.setText(file.getProjectRelativePath().toString());
+ }
+ }
+
+ /**
+ * This method returns the list of choreography resource files within
+ * the supplied project.
+ *
+ * @param project The project
+ * @return The list of choreography resource files
+ */
+ protected IResource[] getChoreographies(IProject project) {
+ IResource[] ret=null;
+ final java.util.Vector list=new java.util.Vector();
+
+ try {
+ project.accept(new org.eclipse.core.resources.IResourceVisitor() {
+ public boolean visit(IResource res) {
+
+ if (res.getFileExtension() != null &&
+ res.getFileExtension().equals(
+ org.pi4soa.cdl.CDLDefinitions.CDL_FILE_EXTENSION)) {
+ list.add(res);
+ }
+
+ return(true);
+ }
+ });
+
+ ret = new IResource[list.size()];
+ list.copyInto(ret);
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * Show a dialog that lets the user select a project. This in turn provides
+ * context for the main type, allowing the user to key a main type name, or
+ * constraining the search for main types to the specified project.
+ */
+ protected void handleProjectButtonSelected() {
+ IProject project = chooseProject();
+ if (project == null) {
+ return;
+ }
+
+ String projectName = project.getName();
+ m_project.setText(projectName);
+ }
+
+ /**
+ * Realize a Java Project selection dialog and return the first selected project,
+ * or null if there was none.
+ */
+ protected IProject chooseProject() {
+ IProject[] projects;
+ try {
+ projects= getWorkspaceRoot().getProjects();
+ } catch (Exception e) {
+ projects= new IProject[0];
+ }
+
+ ILabelProvider labelProvider=new LabelProvider() {
+ public String getText(Object obj) {
+ String ret="<unknown>";
+ if (obj instanceof IResource) {
+ ret = ((IResource)obj).getName();
+ }
+ return(ret);
+ }
+ };
+
+ ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
+ dialog.setTitle("Projects");
+ dialog.setMessage("Select the relevant project");
+ dialog.setElements(projects);
+
+ IProject project = getProject();
+ if (project != null) {
+ dialog.setInitialSelections(new Object[] { project });
+ }
+ if (dialog.open() == Window.OK) {
+ return (IProject) dialog.getFirstResult();
+ }
+ return null;
+ }
+
+ /**
+ * Return the IProject corresponding to the project name in the project name
+ * text field, or null if the text does not match a project name.
+ */
+ protected IProject getProject() {
+ String projectName = m_project.getText().trim();
+ if (projectName.length() < 1) {
+ return null;
+ }
+ return(getWorkspaceRoot().getProject(projectName));
+ }
+
+ /**
+ * Convenience method to get the workspace root.
+ */
+ private IWorkspaceRoot getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration)
+ */
+ public boolean isValid(ILaunchConfiguration config) {
+ return getErrorMessage() == null;
+ }
+
+ /**
+ * This method validates the page.
+ *
+ */
+ private void validatePage() {
+ setErrorMessage(null);
+ setMessage(null);
+
+ String projectName = m_project.getText().trim();
+ if (projectName.length() == 0) {
+ setErrorMessage("Project name not specified");
+ return;
+ }
+
+ IProject project = getWorkspaceRoot().getProject(projectName);
+ if (!project.exists()) {
+ setErrorMessage("Project '"+projectName+"' does not exist");
+ return;
+ }
+
+ try {
+ String choreographyName = m_choreography.getText().trim();
+ if (choreographyName.length() == 0) {
+ setErrorMessage("Choreography has not been defined");
+ return;
+ }
+ IResource resource = project.findMember(choreographyName);
+ if (resource == null) {
+ setErrorMessage("Could not find choreography '"+choreographyName+"'");
+ } else {
+
+ // TODO: Check is valid choreography model
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+
+ IResource resource = getContext();
+ if (resource != null) {
+ initializeProject(resource, config);
+ } else {
+ config.setAttribute(MonitorLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
+ config.setAttribute(MonitorLaunchConfigurationConstants.ATTR_CHOREOGRAPHY_DESCRIPTION, "");
+ }
+ initializeTestAttributes(resource, config);
+ }
+
+ /**
+ * This method identifies the context associated with the
+ * monitor.
+ *
+ * @return The context resource
+ */
+ protected IResource getContext() {
+ IResource ret=null;
+ IWorkbenchPage page =
+ org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+ if (page != null) {
+ ISelection selection = page.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ if (!ss.isEmpty()) {
+ Object obj = ss.getFirstElement();
+ if (obj instanceof IResource) {
+ ret = (IResource)obj;
+ }
+ }
+ }
+
+ if (ret == null) {
+ IEditorPart part = page.getActiveEditor();
+ if (part != null) {
+ IEditorInput input = part.getEditorInput();
+ ret =(IResource)input.getAdapter(IResource.class);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method initializes the project details.
+ *
+ * @param resource The resource
+ * @param config The configuration
+ */
+ protected void initializeProject(IResource resource, ILaunchConfigurationWorkingCopy config) {
+ IProject project = resource.getProject();
+ String name = null;
+ if (project != null && project.exists()) {
+ name = project.getName();
+ }
+ config.setAttribute(MonitorLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
+ }
+
+ /**
+ * This method initializes the choreography details.
+ *
+ * @param resource The selected resource
+ * @param config The configuration
+ */
+ private void initializeTestAttributes(IResource resource, ILaunchConfigurationWorkingCopy config) {
+ if (resource != null && (resource.getType() == IResource.FOLDER ||
+ (resource.getType() == IResource.FILE &&
+ resource.getFileExtension().equals(
+ org.pi4soa.cdl.CDLDefinitions.CDL_FILE_EXTENSION)))) {
+
+ config.setAttribute(MonitorLaunchConfigurationConstants.ATTR_CHOREOGRAPHY_DESCRIPTION,
+ resource.getProjectRelativePath().toString());
+
+ initializeName(config, resource.getName());
+ }
+ }
+
+ /**
+ * This method initializes the launch configuration name.
+ *
+ * @param config The configuration
+ * @param name The name
+ */
+ private void initializeName(ILaunchConfigurationWorkingCopy config, String name) {
+ if (name == null) {
+ name= "";
+ }
+ if (name.length() > 0) {
+
+ int index = name.lastIndexOf('.');
+ if (index > 0) {
+ name = name.substring(0, index);
+ }
+ name= getLaunchConfigurationDialog().generateName(name);
+ config.rename(name);
+ }
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return("Monitor");
+ }
+
+ private Label m_projectLabel=null;
+ private Text m_project=null;
+ private Button m_projectButton=null;
+ private Label m_choreographyLabel=null;
+ private Text m_choreography=null;
+ private Button m_choreographySearch=null;
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorTabGroup.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorTabGroup.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/eclipse/MonitorTabGroup.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,56 @@
+/*
+ * 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 Jan, 2008 : Initial version created by gary
+ */
+package org.savara.tools.monitor.eclipse;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jdt.debug.ui.launchConfigurations.JavaJRETab;
+
+/**
+ * This class represents the UI tab group for the Scenario Test
+ * launcher.
+ */
+public class MonitorTabGroup extends
+ AbstractLaunchConfigurationTabGroup {
+
+ /**
+ * The default constructor for the scenario type tab group.
+ */
+ public MonitorTabGroup() {
+ }
+
+ /**
+ * This method creates the tabs for the scenario test launch
+ * configuration.
+ *
+ * @param dialog The launch configuration dialog
+ * @param mode The mode
+ */
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+ new MonitorMainTab(),
+ new JavaJRETab(),
+ new CommonTab()
+ };
+ setTabs(tabs);
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/MonitorPreferencePage.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/MonitorPreferencePage.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/MonitorPreferencePage.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2005-10 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR 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 March 2010 : Initial version created by gary
+ */
+package org.savara.tools.monitor.preferences;
+
+import org.eclipse.jface.preference.*;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * This class represents a preference page that
+ * is contributed to the Preferences dialog. By
+ * subclassing <samp>FieldEditorPreferencePage</samp>, we
+ * can use the field support built into JFace that allows
+ * us to create a page that is small and knows how to
+ * save, restore and apply itself.
+ * <p>
+ * This page is used to modify preferences only. They
+ * are stored in the preference store that belongs to
+ * the main plug-in class. That way, preferences can
+ * be accessed directly via the preference store.
+ */
+
+public class MonitorPreferencePage
+ extends FieldEditorPreferencePage
+ implements IWorkbenchPreferencePage {
+
+ public MonitorPreferencePage() {
+ super(GRID);
+ setPreferenceStore(org.savara.tools.monitor.eclipse.Activator.getDefault().getPreferenceStore());
+ setDescription("Preferences for the SAVARA Choreography Monitor");
+ }
+
+ /**
+ * Creates the field editors. Field editors are abstractions of
+ * the common GUI blocks needed to manipulate various types
+ * of preferences. Each field editor knows how to save and
+ * restore itself.
+ */
+ public void createFieldEditors() {
+ addField(new PathEditor(
+ MonitorPreferences.MONITOR_LIBRARIES,
+ "&Library Paths", "Library paths required to monitor target platform", getFieldEditorParent()));
+
+ addField(new StringFieldEditor(MonitorPreferences.JNDI_FACTORY_INITIAL,
+ "JNDI Initial Context Factory", getFieldEditorParent()));
+ addField(new StringFieldEditor(MonitorPreferences.JNDI_PROVIDER_URL,
+ "JNDI Provider URL", getFieldEditorParent()));
+ addField(new StringFieldEditor(MonitorPreferences.JNDI_FACTORY_URL_PKGS,
+ "JNDI Factory URL Packages", getFieldEditorParent()));
+ addField(new StringFieldEditor(MonitorPreferences.JMS_FACTORY,
+ "JMS Connection Factory", getFieldEditorParent()));
+ addField(new StringFieldEditor(MonitorPreferences.JMS_DESTINATION,
+ "JMS Destination", getFieldEditorParent()));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+}
\ No newline at end of file
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/MonitorPreferences.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/MonitorPreferences.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/MonitorPreferences.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,92 @@
+/*
+ * 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.tools.monitor.preferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+public class MonitorPreferences {
+
+ public static final String MONITOR_LIBRARIES="savara.monitor.libraries";
+ public static final String JNDI_FACTORY_INITIAL="savara.monitor.jndi.factory.initial";
+ public static final String JNDI_PROVIDER_URL="savara.monitor.jndi.provider.url";
+ public static final String JNDI_FACTORY_URL_PKGS="savara.monitor.jndi.factory.url.pkgs";
+ public static final String JMS_FACTORY="savara.monitor.jms.factory";
+ public static final String JMS_DESTINATION="savara.monitor.jms.destination";
+
+ public static String getLibraryPaths() {
+ IPreferenceStore prefs=
+ org.savara.tools.monitor.eclipse.Activator.getDefault().getPreferenceStore();
+
+ return(prefs.getString(MONITOR_LIBRARIES));
+ }
+
+ public static boolean isLibraryPathsDefined() {
+ boolean ret=false;
+
+ IPreferenceStore prefs=
+ org.savara.tools.monitor.eclipse.Activator.getDefault().getPreferenceStore();
+
+ String paths=prefs.getString(MONITOR_LIBRARIES);
+
+ if (paths != null && paths.length() > 0) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ public static String getJNDIFactoryInitial() {
+ IPreferenceStore prefs=
+ org.savara.tools.monitor.eclipse.Activator.getDefault().getPreferenceStore();
+
+ return(prefs.getString(JNDI_FACTORY_INITIAL));
+ }
+
+
+ public static String getJNDIProviderURL() {
+ IPreferenceStore prefs=
+ org.savara.tools.monitor.eclipse.Activator.getDefault().getPreferenceStore();
+
+ return(prefs.getString(JNDI_PROVIDER_URL));
+ }
+
+ public static String getJNDIFactoryURLPackages() {
+ IPreferenceStore prefs=
+ org.savara.tools.monitor.eclipse.Activator.getDefault().getPreferenceStore();
+
+ return(prefs.getString(JNDI_FACTORY_URL_PKGS));
+ }
+
+ public static String getJMSFactory() {
+ IPreferenceStore prefs=
+ org.savara.tools.monitor.eclipse.Activator.getDefault().getPreferenceStore();
+
+ return(prefs.getString(JMS_FACTORY));
+ }
+
+ public static String getJMSDestination() {
+ IPreferenceStore prefs=
+ org.savara.tools.monitor.eclipse.Activator.getDefault().getPreferenceStore();
+
+ return(prefs.getString(JMS_DESTINATION));
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/PreferenceInitializer.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/PreferenceInitializer.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/preferences/PreferenceInitializer.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,46 @@
+/*
+ * 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.tools.monitor.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ * Class used to initialize default preference values.
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = org.savara.tools.monitor.eclipse.Activator.getDefault().getPreferenceStore();
+ store.setDefault(MonitorPreferences.JNDI_FACTORY_INITIAL, "org.jnp.interfaces.NamingContextFactory");
+ store.setDefault(MonitorPreferences.JNDI_PROVIDER_URL, "jnp://localhost:1099");
+ store.setDefault(MonitorPreferences.JNDI_FACTORY_URL_PKGS, "org.jboss.naming:org.jnp.interfaces");
+ store.setDefault(MonitorPreferences.JMS_FACTORY, "ConnectionFactory");
+ store.setDefault(MonitorPreferences.JMS_DESTINATION, "topic/tracker");
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ChannelJPanel.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ChannelJPanel.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ChannelJPanel.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,558 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.logging.Logger;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
+
+import org.pi4soa.service.Identity;
+import org.pi4soa.service.correlator.CorrelationSession;
+
+
+/**
+ * The left hand pane contains a tree whose root is the
+ * choreography, and whose leaves are channels and transactions.
+ *
+ * Selecting a channel filters the exchange events list (or should
+ * do).
+ */
+public class ChannelJPanel extends JPanel{
+
+ public final static String UNEXPECTED_MESSAGES_NAME = "Unexpected Messages";
+ public final static String ERROR_NAME="Errors";
+ public final static String WARNING_NAME="Warnings";
+ public final static String INFORMATION_NAME="Information";
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.monitor.ui");
+
+ JTree tree = null;
+ TreeSelectionListener listener = null;
+ JScrollPane treeView = null;
+
+ ImageIcon channelLeafIcon = null;
+ ImageIcon channelOpenIcon = null;
+ ImageIcon channelClosedIcon = null;
+ ImageIcon channelEmptyIcon = null;
+ ImageIcon errorsLeafIcon = null;
+ ImageIcon unexpectedLeafIcon = null;
+ ImageIcon warningsLeafIcon = null;
+ ImageIcon issuesOpenIcon = null;
+ ImageIcon issuesClosedIcon = null;
+ ImageIcon issuesEmptyIcon = null;
+ ImageIcon txnLeafIcon = null;
+ ImageIcon txnOpenIcon = null;
+ ImageIcon txnClosedIcon = null;
+ ImageIcon txnEmptyIcon = null;
+
+ // Vector exchangeEvents = null;
+ ExchangeEventsData exchangeEventsData = null;
+
+ DefaultTreeModel treeModel = null;
+ DefaultMutableTreeNode rootNode = null;
+
+ //DefaultMutableTreeNode channelRoot = null;
+ DefaultMutableTreeNode issuesRoot = null;
+ DefaultMutableTreeNode errorsRoot = null;
+ DefaultMutableTreeNode warningsRoot = null;
+ DefaultMutableTreeNode unexpectedMessagesRoot = null;
+ DefaultMutableTreeNode sessionRoot = null;
+
+ String sessionRootName = "Sessions";
+ String channelRootName = "Channels";
+ String unexpectedMessagesRootName = UNEXPECTED_MESSAGES_NAME;
+ String errorsRootName = ERROR_NAME;
+ String warningsRootName = WARNING_NAME;
+ String issuesRootName = "Issues";
+
+
+
+ /**
+ * Creates a new ChannelJPanel.
+ *
+ * @param listener The listener for tree selection changes.
+ */
+ public ChannelJPanel(TreeSelectionListener listener){
+
+ this.listener = listener;
+ this.setBackground(Color.white);
+ this.setLayout(new BorderLayout());
+ }
+
+ public ChannelJPanel(ExchangeEventsData eed, TreeSelectionListener listener){
+ this.listener = listener;
+ this.setBackground(Color.white);
+ this.setLayout(new BorderLayout());
+ exchangeEventsData = eed;
+ }
+
+ ////////////////////////////////////////////
+
+ static public String getUnexpectedMessagesName()
+ {
+ return UNEXPECTED_MESSAGES_NAME;
+ }
+
+ static public String getErrorName() {
+ return(ERROR_NAME);
+ }
+
+ static public String getWarningName() {
+ return(WARNING_NAME);
+ }
+
+ static public String getInformationName() {
+ return(INFORMATION_NAME);
+ }
+
+ public void addedSession(CorrelationSession s)
+ {
+ logger.fine("ADD SESSION TO PANEL " + s);
+ logger.fine("rootNote child count is: " + rootNode.getChildCount());
+ String name = ChannelJPanel.getSessionIdentity(s);
+ if (name == null)
+ {
+ name = "Session :" + s.toString().substring(s.getClass().getName().length());
+ }
+ logger.info("ADDING SESSION FOR TXN: " + name);
+
+ addObject(sessionRoot,new ProxyTreeNode(name, s),true);
+ }
+
+ static public String getSessionIdentity(CorrelationSession s)
+ {
+ String identityString = null;
+ java.util.List<Identity> messageIdentityArray = s.getIdentities();
+ if (messageIdentityArray != null)
+ logger.info("sessionIdentArray length is: " + messageIdentityArray.size());
+ else
+ logger.info("messageIdentityArray was null");
+ if(messageIdentityArray == null || messageIdentityArray.size() == 0)
+ {
+ return identityString;
+ } else {
+ Identity firstMessageIdentity = messageIdentityArray.get(0);
+ // messageIdentityString = firstMessageIdentity.toText();
+ String tokens[] = firstMessageIdentity.getTokens();
+ // value
+ Object values_obj[] = firstMessageIdentity.getValues();
+
+ String[] values = new String[values_obj.length];
+
+ for (int values_index=0; values_index < values_obj.length; values_index++)
+ {
+ values[values_index] = values_obj[values_index].toString();
+ if (values_obj[values_index] instanceof String)
+ {
+ values[values_index] = (String)values_obj[values_index];
+ }
+ else if (values_obj[values_index] instanceof java.util.List)
+ {
+ java.util.List list = (java.util.List)values_obj[values_index];
+ values[values_index] = "{";
+ for (int i=0; (i < list.size()); i++ )
+ {
+ values[values_index] += (String)list.get(i);
+ }
+ values[values_index] += "}";
+ } else {
+ logger.severe("Problem creating an identity string, values is of unknown type.");
+ }
+
+ }
+
+ if(tokens == null || values == null)
+ {
+ if(tokens == null)
+ {
+ logger.fine("identity.getTokens() returned null");
+ // messageIdentityString = "null tokens";
+ }
+
+ if(values == null)
+ {
+ logger.fine("identity.getValues() returned null");
+ // messageIdentityString = "null values";
+ }
+
+ identityString = firstMessageIdentity.toString();
+ } else {
+ if(tokens != null && values != null && tokens.length == values.length)
+ {
+ identityString = "";
+ for(int i = 0; i < tokens.length - 1; i++)
+ {
+ identityString += values[i] + " (" + tokens[i] + "), ";
+ }
+ identityString += values[tokens.length - 1] + " (" + tokens[tokens.length - 1]+")";
+ } else {
+ identityString = "tokens/values mismatch";
+ }
+ }
+ }
+
+ return identityString;
+ }
+
+ /**
+ * Adds the channel nodes to the tree, sorted in name order.
+ */
+ public void createAndAddTree(org.pi4soa.cdl.Package choreography){
+ if(tree != null){
+ // remove the current tree ...
+ this.remove(treeView);
+ treeView = null;
+ tree = null;
+ }
+
+ rootNode = new DefaultMutableTreeNode(choreography.getName());
+ if (treeModel == null){
+ treeModel = new DefaultTreeModel(rootNode);
+ treeModel.addTreeModelListener(new MonitorTreeModelListener());
+ }
+
+ createChannelNodes(treeModel, choreography);
+
+ tree = new JTree(treeModel); // instead of rootNode instead of treeModel
+ ChannelTreeCellRenderer renderer = new ChannelTreeCellRenderer();
+
+ if(txnLeafIcon == null) txnLeafIcon = MonitorMainPanel.createImageIcon("icons/txnleaf.png");
+ if(txnOpenIcon == null) txnOpenIcon = MonitorMainPanel.createImageIcon("icons/txnopen.png");
+ if(txnClosedIcon == null) txnClosedIcon = MonitorMainPanel.createImageIcon("icons/txnclosed.png");
+ if(txnEmptyIcon == null) txnEmptyIcon = MonitorMainPanel.createImageIcon("icons/txnempty.png");
+ if(channelLeafIcon == null) channelLeafIcon = MonitorMainPanel.createImageIcon("icons/channelleaf.png");
+ if(channelOpenIcon == null) channelOpenIcon = MonitorMainPanel.createImageIcon("icons/channelopen.png");
+ if(channelClosedIcon == null) channelClosedIcon = MonitorMainPanel.createImageIcon("icons/channelclosed.png");
+ if(channelEmptyIcon == null) channelEmptyIcon = MonitorMainPanel.createImageIcon("icons/channelempty.png");
+ if(errorsLeafIcon == null) errorsLeafIcon = MonitorMainPanel.createImageIcon("icons/errorsleaf.png");
+ if(warningsLeafIcon == null) warningsLeafIcon = MonitorMainPanel.createImageIcon("icons/warningsleaf.png");
+ if(unexpectedLeafIcon == null) unexpectedLeafIcon = MonitorMainPanel.createImageIcon("icons/unexpectedleaf.png");
+ if(issuesOpenIcon == null) issuesOpenIcon = MonitorMainPanel.createImageIcon("icons/issuesopen.png");
+ if(issuesClosedIcon == null) issuesClosedIcon = MonitorMainPanel.createImageIcon("icons/issuesclosed.png");
+ if(issuesEmptyIcon == null) issuesEmptyIcon = MonitorMainPanel.createImageIcon("icons/issuesempty.png");
+
+ tree.setCellRenderer(renderer);
+
+ tree.setRootVisible(false);
+
+ tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+
+ // Listen for when the selection changes.
+ tree.addTreeSelectionListener(listener);
+
+ treeView = new JScrollPane(this.tree);
+ this.add(treeView, BorderLayout.CENTER);
+
+ // hack.
+ this.revalidate();
+ }
+
+ /**
+ * Adds the channel nodes to the tree, sorted in name order.
+ */
+ private void createChannelNodes(DefaultTreeModel t, org.pi4soa.cdl.Package choreography){
+
+ issuesRoot = addObject(null, issuesRootName);
+ unexpectedMessagesRoot = addObject(issuesRoot,unexpectedMessagesRootName); // was nullChannel
+ errorsRoot = addObject(issuesRoot,errorsRootName); // was nullChannel
+ warningsRoot = addObject(issuesRoot,warningsRootName); // was nullChannel
+
+ sessionRoot = addObject(null,sessionRootName); // was sessionRoot
+
+ logger.fine("createChannelNodes(new)");
+
+ //channelRoot = addObject(null,channelRootName); // was channelRoot
+
+ org.pi4soa.cdl.TypeDefinitions typeDefinitions = choreography.getTypeDefinitions();
+ org.eclipse.emf.common.util.EList channelTypes = typeDefinitions.getChannelTypes();
+
+ // we would like to sort the list of channels first
+
+ org.eclipse.emf.common.util.ECollections.sort(channelTypes, new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return ((org.pi4soa.cdl.ChannelType) o1).getName().compareTo(
+ ((org.pi4soa.cdl.ChannelType) o2).getName()
+ );
+ }
+ });
+
+ /*
+ Iterator listIterator = channelTypes.iterator();
+ while(listIterator.hasNext()){
+ org.pi4soa.cdl.ChannelType channelType = (org.pi4soa.cdl.ChannelType) listIterator.next();
+ ProxyTreeNode node = new ProxyTreeNode(channelType.getName(),
+ channelType);
+ logger.fine("Adding channel type to tree: " + channelType.getName());
+ addObject(channelRoot,node);
+ }
+ */
+ }
+
+
+ /** Add child to the currently selected node. */
+ public DefaultMutableTreeNode addObject(Object child) {
+ logger.fine("addObject " + child.toString() + " to child");
+ DefaultMutableTreeNode parentNode = null;
+ TreePath parentPath = tree.getSelectionPath();
+
+ if (parentPath == null) {
+ parentNode = rootNode;
+ } else {
+ parentNode = (DefaultMutableTreeNode)
+ (parentPath.getLastPathComponent());
+ }
+
+ return addObject(parentNode, child, true);
+ }
+
+ public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
+ Object child) {
+ logger.fine("addObject " + child.toString() + " to parent");
+ return addObject(parent, child, false);
+ }
+
+ public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
+ Object child,
+ boolean shouldBeVisible) {
+ logger.fine("addObject " + child.toString() + " to parent with visibility " + shouldBeVisible);
+ DefaultMutableTreeNode childNode =
+ new DefaultMutableTreeNode(child);
+
+ if (parent == null) {
+ parent = rootNode;
+ }
+
+ treeModel.insertNodeInto(childNode, parent,
+ parent.getChildCount());
+
+ //Make sure the user can see the lovely new node.
+ if (shouldBeVisible) {
+ tree.scrollPathToVisible(new TreePath(childNode.getPath()));
+ }
+ return childNode;
+ }
+
+
+ /**
+ * Adds the channel nodes to the tree, sorted in name order.
+ */
+ public void setChannelSelectionOn(boolean channelSelection){
+ if(channelSelection == true){
+ tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+ }
+ else{
+
+ }
+ }
+
+
+ /**
+ *
+ */
+ public JTree getTree(){
+ return tree;
+ }
+
+
+ /**
+ *
+ */
+ public void redraw(){
+ tree.setSelectionPaths(tree.getSelectionPaths());
+ tree.revalidate();
+ tree.repaint();
+ }
+
+ public class ProxyTreeNode {
+
+ public ProxyTreeNode(String label, Object obj) {
+ m_label = label;
+ m_object = obj;
+ }
+
+ public String getLabel() {
+ return(m_label);
+ }
+
+ public Object getObject() {
+ return(m_object);
+ }
+
+ public String toString() {
+ return(m_label);
+ }
+
+ private String m_label=null;
+ private Object m_object=null;
+ }
+
+ public class ChannelTreeCellRenderer extends DefaultTreeCellRenderer{
+
+ private Color originalTextNonSelectionColor = null;
+ private Color originalTextSelectionColor = null;
+
+ /**
+ *
+ */
+ public Component getTreeCellRendererComponent(JTree tree,
+ Object value,
+ boolean selected,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus){
+
+ logger.fine("getTreeCellRendererComponent(" + value.toString() + ")");
+
+ if(originalTextNonSelectionColor == null) originalTextNonSelectionColor = this.getTextNonSelectionColor();
+ if(originalTextSelectionColor == null) originalTextSelectionColor = this.getTextSelectionColor();
+
+ boolean nodeHasErrors = false;
+ boolean nodeHasWarnings = false;
+ boolean nodeHasUnexpectedMessage = false;
+
+ if(leaf == true){
+ if(exchangeEventsData.getHasErrorsForChannel(value.toString()) == true ||
+ exchangeEventsData.getHasErrorsForSession(value.toString())) {
+ nodeHasErrors = true;
+ }
+ else if(exchangeEventsData.getHasWarningsForChannel(value.toString()) == true ||
+ exchangeEventsData.getHasWarningsForSession(value.toString())) {
+ nodeHasWarnings = true;
+ }
+ else if (exchangeEventsData.getHasUnexpectedExchangeEventsForChannel(value.toString()) == true ||
+ exchangeEventsData.getHasUnexpectedExchangeEventsForSession(value.toString())) {
+ nodeHasUnexpectedMessage = true;
+ }
+ }
+ else{
+ //nodeHasErrors = exchangeEventsData.getHasErrors();
+ //nodeHasWarnings = exchangeEventsData.getHasWarnings();
+ //nodeHasUnexpectedMessage = exchangeEventsData.getHasUnexpectedMessages();
+ }
+
+ //
+ // Sets the left panel colors
+ //
+ if(nodeHasErrors == true){
+ logger.fine("hasErrors - dark red");
+ this.setTextNonSelectionColor(Color.red.darker());
+ this.setTextSelectionColor(Color.red.darker());
+ }
+ else if(nodeHasWarnings == true){
+ logger.fine("hasWarnings - orange");
+ this.setTextNonSelectionColor(Color.orange);
+ this.setTextSelectionColor(Color.orange);
+ }
+ else if (nodeHasUnexpectedMessage == true) {
+ logger.fine("hasUnexpectedMessages - red");
+ this.setTextNonSelectionColor(Color.red);
+ this.setTextSelectionColor(Color.red);
+ }
+ else{
+ logger.fine("hasOkay");
+ this.setTextNonSelectionColor(originalTextNonSelectionColor);
+ this.setTextSelectionColor(originalTextSelectionColor);
+ }
+
+ if (value instanceof DefaultMutableTreeNode) {
+ m_lastValue = ((DefaultMutableTreeNode)value).getUserObject();
+ } else {
+ m_lastValue = value;
+ }
+
+ return super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
+ }
+
+ public Icon getOpenIcon() {
+ Icon ret=super.getOpenIcon();
+
+ if (m_lastValue.toString().equals(sessionRootName)) {
+ ret = txnOpenIcon;
+ } else if (m_lastValue.toString().equals(channelRootName)) {
+ ret = channelOpenIcon;
+ } else if (m_lastValue.toString().equals(issuesRootName)) {
+ ret = issuesOpenIcon;
+ }
+
+ logger.info("Returning open icon for "+m_lastValue);
+ return(ret);
+ }
+
+ public Icon getClosedIcon() {
+ Icon ret=super.getClosedIcon();
+
+ if (m_lastValue.toString().equals(sessionRootName)) {
+ ret = txnClosedIcon;
+ } else if (m_lastValue.toString().equals(channelRootName)) {
+ ret = channelClosedIcon;
+ } else if (m_lastValue.toString().equals(issuesRootName)) {
+ ret = issuesClosedIcon;
+ }
+
+ logger.info("Returning closed icon for "+m_lastValue);
+ return(ret);
+ }
+
+ public Icon getLeafIcon() {
+ Icon ret=super.getLeafIcon();
+
+ if (m_lastValue instanceof ProxyTreeNode) {
+ if (((ProxyTreeNode)m_lastValue).getObject() instanceof CorrelationSession) {
+ ret = txnLeafIcon;
+ } else if (((ProxyTreeNode)m_lastValue).getObject()
+ instanceof org.pi4soa.cdl.ChannelType) {
+ ret = channelLeafIcon;
+ }
+ } else if (m_lastValue.toString().equals(sessionRootName)) {
+ ret = txnEmptyIcon;
+ } else if (m_lastValue.toString().equals(channelRootName)) {
+ ret = channelEmptyIcon;
+ } else if (m_lastValue.toString().equals(unexpectedMessagesRootName)) {
+ ret = unexpectedLeafIcon;
+ } else if (m_lastValue.toString().equals(errorsRootName)) {
+ ret = errorsLeafIcon;
+ } else if (m_lastValue.toString().equals(warningsRootName)) {
+ ret = warningsLeafIcon;
+ }
+ logger.info("Returning leaf icon for "+m_lastValue+" of type "+m_lastValue.getClass());
+ return(ret);
+ }
+
+ private Object m_lastValue=null;
+ }
+
+}
+
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ExchangeEventWrapper.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ExchangeEventWrapper.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ExchangeEventWrapper.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,797 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui;
+
+
+import org.pi4soa.cdl.Interaction;
+import org.pi4soa.cdl.RoleType;
+import org.pi4soa.cdl.Variable;
+
+import org.pi4soa.service.Message;
+import org.pi4soa.service.Identity;
+
+import org.pi4soa.service.correlator.CorrelationSession;
+import org.savara.tools.monitor.ExchangeEvent;
+
+import java.io.Serializable;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.util.logging.Logger;
+
+
+
+/**
+ *
+ */
+public class ExchangeEventWrapper implements Serializable{
+
+ Integer index = null;
+
+ String realSessionName = null;
+ String sessionName = null;
+ String description = null;
+ String toRoleTypeName = null;
+ String fromRoleTypeName = null;
+ String serviceName=null;
+ String sendVariableString = null;
+ String sendVariableTypeString = null;
+ String messageTypeString = "";
+ String messageTypeNoNamespaceString = "";
+ String operationString = null;
+ String messageValueString = null;
+ String exceptionValueString = null;
+ String messageIdentityString = null;
+ String channelType = null;
+ String correlationSessionString = null;
+
+ // don't serialize this one ...
+ transient private ExchangeEvent exchangeEvent = null;
+
+ String status = null;
+ boolean hasFrozenStatus = false;
+
+ boolean hasSetErrorsAndWarnings = false;
+ boolean isError = false;
+ boolean isWarning = false;
+
+ boolean isErrorMessage=false;
+ boolean isWarningMessage=false;
+ boolean isInformationMessage=false;
+
+ boolean isFault = false;
+ boolean hasSetIsFault = false;
+
+ boolean isRequest;
+
+ boolean isUnexpected = false;
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.monitor.ui");
+
+ public ExchangeEventWrapper(CorrelationSession session,
+ Integer index, String mesgValue, String exception){
+ this.index = index;
+
+ correlationSessionString = (session == null?
+ "<unknown>":session.toString());
+
+ setMessageValue(mesgValue);
+
+ if (messageValueString == null) {
+ messageValueString = "";
+ }
+
+ exceptionValueString = exception;
+
+ messageIdentityString = "";
+ operationString = "";
+ description = "";
+ sendVariableString="";
+
+ setRealSessionName(session);
+ setSessionName(session);
+ }
+
+ /**
+ *
+ */
+ public ExchangeEventWrapper(ExchangeEvent event, Integer index){
+ this.index = index;
+ this.exchangeEvent = event;
+
+ correlationSessionString = (event.getCorrelationSession() == null?
+ "<unknown>":event.getCorrelationSession().toString());
+
+ Message message = exchangeEvent.getMessage();
+ if(message != null){
+
+ if (exchangeEvent.getExchange() != null) {
+ isRequest = (exchangeEvent.getExchange().getAction()
+ == org.pi4soa.cdl.ExchangeActionType.REQUEST);
+ } else {
+ isRequest = message.isRequest();
+ }
+
+ messageTypeString = message.getType();
+
+ messageTypeNoNamespaceString =
+ org.pi4soa.common.xml.NameSpaceUtil.getLocalPart(message.getType());
+
+ }
+ else{
+ logger.fine(">>>> Null message");
+ isRequest = true;
+ }
+
+ setRealSessionName(event.getCorrelationSession());
+ setSessionName(event.getCorrelationSession());
+ setDescription(event);
+ setFromRoleTypeName(event);
+ setToRoleTypeName(event);
+ setSendVariableName(event);
+ setSendVariableTypeName(event);
+ setOperationString(event);
+ setMessageValue(event);
+ setMessageIdentity(event);
+ setChannelType(event);
+ }
+
+ /**
+ *
+ */
+ public Integer getIndex(){ return index; }
+
+
+ /**
+ *
+ */
+ public String getRealSessionName() { return realSessionName; }
+ public String getSessionName() { return sessionName; }
+
+ /**
+ *
+ */
+ public void setRealSessionName(CorrelationSession s){
+
+ if (s == null) {
+ realSessionName = "Session:unknown";
+ } else {
+ realSessionName = "Session:" + s.toString().substring(s.getClass().getName().length());
+ }
+
+ logger.fine("Set real session name in wrapper: " + realSessionName);
+ }
+
+ public void setSessionName(CorrelationSession s){
+
+ if (s == null) {
+ sessionName = "unknown";
+ } else {
+ sessionName = ChannelJPanel.getSessionIdentity(s);
+ }
+
+ logger.fine("Set session name alias in wrapper: " + sessionName);
+ }
+ /**
+ *
+ */
+ public String getDescription(){ return description; }
+
+ /**
+ *
+ */
+ protected void setDescription(ExchangeEvent exchangeEvent){
+ if(exchangeEvent == null || exchangeEvent.getExchange() == null){
+ description = "null exchange";
+ }
+ else{
+ description = exchangeEvent.getExchange().getDescription();
+ if(description != null){
+ String newDescription = description.replaceAll("\\s+", " ");
+ description = newDescription;
+ }
+ else{
+ description = "";
+ }
+ }
+ }
+
+
+ /**
+ *
+ */
+ public String getStatus(){
+ String returnValue = null;
+ if(hasFrozenStatus == true){
+ returnValue = status;
+ } else {
+ if (exchangeEvent == null) {
+ returnValue = "";
+ } else if (exchangeEvent.getChannel() == null) {
+ returnValue = "Unexpected";
+ } else if(exchangeEvent.isExchangeComplete()) {
+ returnValue = "Completed";
+ } else{
+ returnValue = "Initiated";
+ }
+ }
+
+ return returnValue;
+ }
+
+
+ /**
+ *
+ */
+ public void freezeStatus(){
+ status = getStatus();
+ hasFrozenStatus = true;
+ }
+
+
+ /**
+ *
+ */
+ public boolean equals(Object object){
+ boolean result = false;
+
+ if (object != null && object instanceof ExchangeEventWrapper) {
+ ExchangeEventWrapper other = (ExchangeEventWrapper) object;
+ if(other.exchangeEvent != null && this.exchangeEvent != null){
+ if(other.exchangeEvent.equals(this.exchangeEvent)){
+ result = true;
+ }
+ }
+ else{
+ result = other.getDescription().equals(this.getDescription()) &&
+ other.getFromRoleTypeName().equals(this.getFromRoleTypeName()) &&
+ other.getToRoleTypeName().equals(this.getToRoleTypeName()) &&
+ other.getSendVariableName().equals(this.getSendVariableName()) &&
+ other.getOperationString().equals(this.getOperationString()) &&
+ other.getMessageValue().equals(this.getMessageValue()) &&
+ other.getMessageIdentity().equals(this.getMessageIdentity()) &&
+ other.getChannelType().equals(this.getChannelType());
+ }
+
+ }
+
+ return result;
+ }
+
+
+
+ /**
+ *
+ */
+ public String getFromRoleTypeName(){
+ if (exchangeEvent == null || exchangeEvent.getChannel() == null)
+ {
+ return(""); // "Unknown From Role";
+ }
+ if(isRequest){
+ return fromRoleTypeName;
+ }
+ else{
+ return toRoleTypeName;
+ }
+ }
+
+
+ /**
+ *
+ */
+ protected void setFromRoleTypeName(ExchangeEvent exchangeEvent){
+ if(exchangeEvent.getExchange() == null){
+ fromRoleTypeName = ""; //"Unknown From Role";
+ }
+ else{
+ Interaction interaction = exchangeEvent.getExchange().getInteraction();
+ if(interaction != null){
+ RoleType fromRoleType = interaction.getFromRoleType();
+ if(fromRoleType != null){
+ fromRoleTypeName = fromRoleType.getName() != null ? fromRoleType.getName() : "";
+ }
+ else{
+ fromRoleTypeName = ""; //"null fromRoleType";
+ }
+ }
+ else{
+ fromRoleTypeName = ""; //"null interaction";
+ }
+ }
+ }
+
+ protected void setServiceName(String name) {
+ serviceName = name;
+ }
+
+ public String getServiceName() { return serviceName; }
+
+ /**
+ *
+ */
+ public String getToRoleTypeName(){
+ if (exchangeEvent == null || exchangeEvent.getChannel() == null)
+ {
+ return(""); // "Unknown To Role";
+ }
+ if(isRequest){
+ return toRoleTypeName;
+ }
+ else{
+ return fromRoleTypeName;
+ }
+ }
+
+
+ /**
+ *
+ */
+ protected void setToRoleTypeName(ExchangeEvent exchangeEvent){
+ if(exchangeEvent == null || exchangeEvent.getExchange() == null){
+ toRoleTypeName = ""; //"Unknown To Role";
+ }
+ else{
+ Interaction interaction = exchangeEvent.getExchange().getInteraction();
+ if(interaction != null){
+ RoleType toRoleType = interaction.getToRoleType();
+ if(toRoleType != null){
+ toRoleTypeName = toRoleType.getName() != null ? toRoleType.getName() : "";
+ }
+ else{
+ toRoleTypeName = ""; //"null toRoleType";
+ }
+ }
+ else{
+ toRoleTypeName = ""; //"null interaction";
+ }
+ }
+ }
+
+
+ /**
+ *
+ */
+ public String getSendVariableName(){ return sendVariableString; }
+ public String getSendVariableTypeName() { return sendVariableTypeString; }
+
+ /**
+ *
+ */
+ protected void setSendVariableTypeName(ExchangeEvent exchangeEvent)
+ {
+ if(exchangeEvent.getExchange() == null){
+ if (exchangeEvent.getMessage().getType() != null) {
+ String tmp = exchangeEvent.getMessage().getType();
+ sendVariableTypeString = tmp.substring(tmp.indexOf("}")+1);
+ // Need to abberivate after the last "{"
+ } else {
+ sendVariableTypeString = "Unknown type";
+ }
+ }
+ else{
+ Variable sendVariable = exchangeEvent.getExchange().getSendVariable();
+ if(sendVariable != null){
+ //sendVariableString = sendVariable.getName() != null ? sendVariable.getName() : "Type: " + sendVariable.getType().getName();
+ sendVariableTypeString = sendVariable.getType().getName();
+ }
+ }
+ }
+ /**
+ *
+ */
+ protected void setSendVariableName(ExchangeEvent exchangeEvent){
+ if(exchangeEvent.getExchange() == null){
+ if (exchangeEvent.getMessage().getType() != null) {
+ String tmp = exchangeEvent.getMessage().getType();
+ sendVariableString = "None : " + tmp.substring(tmp.indexOf("}")+1);
+ // Need to abberivate after the last "{"
+ } else
+ sendVariableString = "null exchange";
+ }
+ else{
+ Variable sendVariable = exchangeEvent.getExchange().getSendVariable();
+ if(sendVariable != null){
+ //sendVariableString = sendVariable.getName() != null ? sendVariable.getName() : "Type: " + sendVariable.getType().getName();
+ sendVariableString = sendVariable.getName() != null ? sendVariable.getName() : " : " + sendVariable.getType().getName();
+ }
+ else{
+ sendVariableString = "None : " + exchangeEvent.getExchange().getType().getName();
+ //sendVariableString = "null sendVariable";
+ }
+ }
+ }
+
+
+ /**
+ *
+ */
+ public String getOperationString(){ return operationString; }
+
+
+
+ /**
+ *
+ */
+ protected void setOperationString(ExchangeEvent exchangeEvent){
+ if(exchangeEvent.getExchange() == null){
+ operationString = ""; //"Unknown Operation";
+ }
+ Message message = exchangeEvent.getMessage();
+ if(message == null){
+ operationString = ""; //"null message";
+ }
+ else{
+ operationString = message.getOperationName();
+ if(operationString == null){
+ operationString = ""; //"null operation";
+ }
+ }
+ }
+
+ public String getMessageSummary() {
+ String ret="";
+
+ if (exchangeEvent != null) {
+ String op=getOperationString();
+ if (op != null && op.trim().length() > 0) {
+ ret += op+"(";
+ }
+
+ ret += getMessageTypeNoNamespace();
+ if (op != null && op.trim().length() > 0) {
+ ret += ")";
+ }
+ } else {
+ ret = getMessageValue();
+ }
+
+ if (ret != null && ret.length() > 0 &&
+ ret.charAt(0) == '<') {
+ ret = getChannelType()+" ...";
+ }
+
+ return(ret);
+ }
+
+ /**
+ *
+ */
+ public String getMessageValue(){ return messageValueString; }
+
+ public String getExceptionValue() { return exceptionValueString; }
+
+ /**
+ *
+ */
+ protected void setMessageValue(ExchangeEvent exchangeEvent){
+ logger.fine("**** Setting message value");
+ messageValueString = "";
+ Message message = exchangeEvent.getMessage();
+ if(message == null){
+ logger.fine("**** null message");
+ messageValueString = "null message";
+ }
+ else{
+ Serializable messageValue = message.getValue();
+ if(messageValue == null){
+ messageValueString = "null message value";
+ logger.fine("**** null message value");
+ }
+ else{
+ setMessageValue(messageValue.toString());
+ }
+ }
+ }
+
+ protected void setMessageValue(String originalMessageValueString) {
+ logger.fine("**** original message = " + originalMessageValueString);
+
+ logger.fine("**** prettifying");
+
+ messageValueString = XmlPrettyPrinter.prettify(originalMessageValueString);
+
+ logger.fine("**** prettified");
+
+ logger.fine(messageValueString);
+
+ if(messageValueString == null) {
+
+ logger.fine("**** prettified string was null");
+
+ // messageValueString = originalMessageValueString;
+ // messageValueString = "prettyprinting failed";
+ messageValueString = originalMessageValueString.replaceAll("[ \\t]+", " ");
+
+ logger.fine("**** reprettified");
+ logger.fine(messageValueString);
+ }
+ }
+
+
+ /**
+ *
+ */
+ public String getMessageIdentity(){ return messageIdentityString; }
+
+ public String getMessageType() { return messageTypeString; }
+
+ public String getMessageTypeNoNamespace() { return messageTypeNoNamespaceString; }
+
+ /**
+ *
+ */
+ protected void setMessageIdentity(ExchangeEvent exchangeEvent){
+ Message message = exchangeEvent.getMessage();
+ if(message == null){
+ messageIdentityString = "null message";
+ }
+ else{
+ java.util.List<Identity> messageIdentityArray=message.getMessageIdentities();
+ if(messageIdentityArray == null || messageIdentityArray.size() == 0){
+ messageIdentityString = "no identities";
+ }
+ else{
+ Identity firstMessageIdentity = messageIdentityArray.get(0);
+ // messageIdentityString = firstMessageIdentity.toText();
+ String tokens[] = firstMessageIdentity.getTokens();
+ // valu
+ Object values_obj[] = firstMessageIdentity.getValues();
+
+ String[] values = new String[values_obj.length];
+
+ for (int values_index=0; values_index < values_obj.length; values_index++)
+ {
+ values[values_index] = values_obj[values_index].toString();
+ }
+
+ if(tokens == null || values == null){
+ if(tokens == null){
+ logger.fine("identity.getTokens() returned null");
+ // messageIdentityString = "null tokens";
+ }
+
+ if(values == null){
+ logger.fine("identity.getValues() returned null");
+ // messageIdentityString = "null values";
+ }
+
+ messageIdentityString = firstMessageIdentity.toString();
+ }
+ else{
+ if(tokens != null && values != null && tokens.length == values.length){
+ messageIdentityString = "";
+ for(int i = 0; i < tokens.length - 1; i++){
+ messageIdentityString += values[i] + " (" + tokens[i] + "), ";
+ }
+ messageIdentityString += values[tokens.length - 1] + " (" + tokens[tokens.length - 1]+")";
+ }
+ else{
+ messageIdentityString = "tokens/values mismatch";
+ }
+ }
+ }
+ }
+ }
+
+ public void setMessageIdentity(String ident)
+ {
+ messageIdentityString = ident;
+ }
+
+
+ /**
+ *
+ */
+ public boolean isFault(){
+ if(hasSetIsFault == false){
+ if(exchangeEvent != null && exchangeEvent.getExchange() != null){
+ isFault = exchangeEvent.getExchange().isFault();
+ }
+ //else{
+ // isFault = true;
+ //}
+ hasSetIsFault = true;
+ }
+ return isFault;
+ }
+
+
+ /**
+ *
+ */
+ private void setErrorsAndWarnings(){
+ if(hasSetErrorsAndWarnings == false){
+ if(getToRoleTypeName().toLowerCase().matches("exception")){
+ if(getOperationString().toLowerCase().matches("fatal")){
+ isError = true;
+ }
+ else{
+ isWarning = true;
+ }
+ }
+ else if(getFromRoleTypeName().toLowerCase().matches("exception")){
+ if(isFault()){
+ isError = true;
+ }
+ }
+ else{
+ if(exchangeEvent != null && exchangeEvent.getExchange() == null){
+ isUnexpected = true;
+ }
+ else if(isFault()){
+ isWarning = true;
+ }
+
+ // if the session was terminated early. color me red.
+ }
+ hasSetErrorsAndWarnings = true;
+ }
+ }
+
+ public void setErrorMessage(boolean b) {
+ isErrorMessage = b;
+
+ if (b) {
+ channelType = ChannelJPanel.getErrorName();
+ }
+ }
+
+ public boolean isErrorMessage() {
+ return(isErrorMessage);
+ }
+
+ public void setWarningMessage(boolean b) {
+ isWarningMessage = b;
+
+ if (b) {
+ channelType = ChannelJPanel.getWarningName();
+ }
+ }
+
+ public boolean isWarningMessage() {
+ return(isWarningMessage);
+ }
+
+ public void setInformationMessage(boolean b) {
+ isInformationMessage = b;
+
+ if (b) {
+ channelType = ChannelJPanel.getInformationName();
+ }
+ }
+
+ public boolean isInformationMessage() {
+ return(isInformationMessage);
+ }
+
+ /**
+ *
+ */
+ public boolean isError(){
+ if(hasSetErrorsAndWarnings == false){
+ setErrorsAndWarnings();
+ }
+ return(isError || isErrorMessage());
+ }
+
+ public boolean isUnexpected(){
+ return isUnexpected;
+ }
+
+ public void setUnexpected(boolean b){
+ isUnexpected = b;
+ }
+
+ /**
+ *
+ */
+ public boolean isWarning(){
+ if(hasSetErrorsAndWarnings == false){
+ setErrorsAndWarnings();
+ }
+ return(isWarning || isWarningMessage());
+ }
+
+
+ /**
+ *
+ */
+ public String getChannelType(){ return channelType; }
+
+ protected void setChannelType(String ctype) {
+ channelType = ctype;
+ }
+
+ /**
+ *
+ */
+ public String getCorrelationSession(){ return correlationSessionString; }
+
+ /**
+ *
+ */
+ public String toString()
+ {
+ String s = "EXCHANGE EVENT WRAPPER: " +
+ "<sessionName = " + sessionName + ">" +
+ "<realSessionName = " + realSessionName + ">" +
+ "<serviceName = " + serviceName + ">" +
+ "<description = " + description + ">" +
+ "<toRoleTypeName = " + toRoleTypeName + ">" +
+ "<fromRoleTypeName = " + fromRoleTypeName + ">" +
+ "<sendVariableString = " + sendVariableString + ">" +
+ "<operationString = " + operationString + ">" +
+ "<messageValueString = " + messageValueString + ">" +
+ "<messageIdentityString = " + messageIdentityString + ">" +
+ "<channelType = " + channelType + ">" +
+ "<correlationSessionString = " + correlationSessionString + ">" +
+ "<status = " + status + ">" +
+ "<hasFrozenStatus = " + hasFrozenStatus + ">" +
+ "<hasSetErrorsAndWarnings = " + hasSetErrorsAndWarnings + ">" +
+ "<isError = " + isError + ">" +
+ "<isWarning = " + isWarning + ">" +
+ "<isFault = " + isFault + ">" +
+ "<hasSetIsFault = " + hasSetIsFault + ">" +
+ "<isRequest = " + isRequest + ">" +
+ "<isUnexpected = " + isUnexpected + ">";
+
+ return s;
+ }
+ /**
+ *
+ */
+
+ protected void setChannelType(ExchangeEvent exchangeEvent){
+ if(exchangeEvent.getChannel() == null){
+ channelType = ChannelJPanel.getUnexpectedMessagesName();
+ }
+ else{
+ channelType = exchangeEvent.getExchange().getInteraction().getChannelVariable().getType().getName(); // Not getType
+ logger.fine("Channel type name: " + channelType);
+ logger.fine("Channel service type name: " + exchangeEvent.getChannel().getServiceType());
+ logger.fine("Channel instance name: " + exchangeEvent.getChannel().getName());
+ logger.fine("OR Channel instance name: " + exchangeEvent.getExchange().getInteraction().getChannelVariable().getType().getName());
+ }
+ }
+
+ // Serialization support
+
+
+ /**
+ *
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException{
+ // to make sure that this has been set.
+ boolean myIsError = this.isError();
+ boolean myIsFault = this.isFault();
+ freezeStatus();
+ out.defaultWriteObject();
+ }
+
+
+ /**
+ *
+ */
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{
+ in.defaultReadObject();
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ExchangeEventsData.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ExchangeEventsData.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/ExchangeEventsData.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,449 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui;
+
+import java.util.Vector;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.logging.Logger;
+
+import java.io.FileOutputStream;
+import java.io.ObjectOutputStream;
+
+import java.io.FileInputStream;
+import java.io.ObjectInputStream;
+
+
+import org.pi4soa.service.correlator.CorrelationSession;
+import org.savara.tools.monitor.ExchangeEvent;
+
+/**
+ *
+ */
+public class ExchangeEventsData{
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.monitor.ui");
+
+ Vector exchangeEvents = null;
+
+ Vector warningAndErrorExchangeEvents = null;
+
+ Vector errorExchangeEvents = null;
+
+ Vector warningExchangeEvents = null;
+
+ Vector unexpectedExchangeEvents = null;
+
+ Hashtable exchangeEventsByChannelTable = null;
+
+ Hashtable exchangeEventsBySessionTable = null;
+
+ Hashtable sessionHasErrorsTable = null;
+ Hashtable sessionHasWarningsTable = null;
+ Hashtable sessionHasUnexpectedMessagesTable = null;
+ Hashtable channelHasErrorsTable = null;
+ Hashtable channelHasWarningsTable = null;
+ Hashtable channelHasUnexpectedMessagesTable = null;
+
+ Hashtable exchangeEventToWrapperMap = null;
+
+ boolean hasErrors = false;
+
+ boolean hasWarnings = false;
+
+ boolean hasUnexpectedMessages = false;
+
+ /**
+ *
+ */
+ public ExchangeEventsData(){
+ exchangeEvents = new Vector();
+ warningAndErrorExchangeEvents = new Vector();
+ errorExchangeEvents = new Vector();
+ warningExchangeEvents = new Vector();
+ unexpectedExchangeEvents = new Vector();
+ exchangeEventsByChannelTable = new Hashtable();
+ exchangeEventsBySessionTable = new Hashtable();
+ exchangeEventToWrapperMap = new Hashtable();
+ channelHasErrorsTable = new Hashtable();
+ channelHasUnexpectedMessagesTable = new Hashtable();
+ channelHasWarningsTable = new Hashtable();
+ sessionHasErrorsTable = new Hashtable();
+ sessionHasUnexpectedMessagesTable = new Hashtable();
+ sessionHasWarningsTable = new Hashtable();
+ }
+
+
+
+ /**
+ *
+ */
+ public void clear(){
+ exchangeEvents.clear();
+ exchangeEventsByChannelTable.clear();
+ exchangeEventsBySessionTable.clear();
+ exchangeEventToWrapperMap.clear();
+ warningAndErrorExchangeEvents.clear();
+ errorExchangeEvents.clear();
+ warningExchangeEvents.clear();
+ unexpectedExchangeEvents.clear();
+ channelHasErrorsTable.clear();
+ channelHasWarningsTable.clear();
+ channelHasUnexpectedMessagesTable.clear();
+ sessionHasErrorsTable.clear();
+ sessionHasWarningsTable.clear();
+ sessionHasUnexpectedMessagesTable.clear();
+ hasErrors = false;
+ hasWarnings = false;
+ }
+
+
+ /**
+ *
+ */
+ public boolean exportEvents(String path){
+ try{
+ FileOutputStream fileOutputStream = new FileOutputStream(path);
+ ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
+ objectOutputStream.writeObject(exchangeEvents);
+ objectOutputStream.close();
+ }
+ catch(Exception e){
+ logger.severe("Exception: " + e);
+ return false;
+ }
+
+ return true;
+ }
+
+
+
+ /**
+ *
+ */
+ public boolean importEvents(String path){
+ clear();
+
+ Vector v = null;
+
+ try{
+ FileInputStream fileInputStream = new FileInputStream(path);
+ ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
+ v = (Vector) objectInputStream.readObject();
+ objectInputStream.close();
+ }
+ catch(Exception e){
+ logger.severe("Exception: " + e);
+ return false;
+ }
+
+ Iterator iterator = v.iterator();
+ int i = 0;
+ while(iterator.hasNext()){
+ ExchangeEventWrapper wrapper = (ExchangeEventWrapper) iterator.next();
+
+ logger.fine("Getting wrapper message value");
+
+ String wrapperMessageValue = wrapper.getMessageValue();
+
+ logger.fine("Imported event wrapper message value = " + wrapperMessageValue);
+
+ Integer key = new Integer(i);
+ i++;
+ exchangeEventToWrapperMap.put(key, wrapper);
+ addExchangeEvent(wrapper);
+ }
+
+ return true;
+ }
+
+
+
+
+ /**
+ *
+ */
+ public ExchangeEventWrapper createExchangeEventWrapper(ExchangeEvent exchangeEvent){
+ ExchangeEventWrapper wrapper=null;
+
+ logger.fine(">>>> creating new wrapper");
+ wrapper = new ExchangeEventWrapper(exchangeEvent, new Integer(exchangeEvents.size()));
+ logger.fine(">>>> created new wrapper");
+
+ java.util.List list=(java.util.List)
+ exchangeEventToWrapperMap.get(exchangeEvent);
+
+ if (list == null) {
+ list = new java.util.Vector();
+ exchangeEventToWrapperMap.put(exchangeEvent, list);
+ logger.fine("Added new list for map entry: "+exchangeEvent);
+ }
+
+ list.add(wrapper);
+
+ return wrapper;
+ }
+
+ public ExchangeEventWrapper matchExchangeEventWrapper(ExchangeEvent exchangeEvent){
+ logger.info("getExchangeEventWrapper for " + exchangeEvent);
+ logger.fine(">>>> looking for pre-existing wrapper for " + exchangeEvent);
+
+ java.util.List list=
+ (java.util.List)exchangeEventToWrapperMap.get(exchangeEvent);
+
+ ExchangeEventWrapper wrapper=null;
+
+ if (list != null && list.size() > 0) {
+ wrapper = (ExchangeEventWrapper)list.remove(0);
+
+ if (list.size() == 0) {
+ exchangeEventToWrapperMap.remove(exchangeEvent);
+
+ logger.fine("Cleaned up map entry for: "+exchangeEvent);
+ }
+ }
+
+ if(wrapper == null){
+ logger.severe(">>>> Failed to find existing wrapper: "+exchangeEvent);
+ }
+ else{
+ logger.fine(">>>> found old wrapper");
+
+ // Remove from map
+ exchangeEventToWrapperMap.remove(exchangeEvent);
+ }
+
+ return wrapper;
+ }
+
+ public ExchangeEventWrapper errorExchangeEventWrapper(ExchangeEvent exchangeEvent){
+ ExchangeEventWrapper wrapper=null;
+
+ logger.fine(">>>> creating new error wrapper");
+ wrapper = new ExchangeEventWrapper(exchangeEvent, new Integer(exchangeEvents.size()));
+ logger.fine(">>>> created new error wrapper");
+
+ return wrapper;
+ }
+
+ public ExchangeEventWrapper simpleWrapper(CorrelationSession session,
+ String text, String exception) {
+ ExchangeEventWrapper wrapper=null;
+
+ logger.fine(">>>> creating new empty wrapper");
+ wrapper = new ExchangeEventWrapper(session,
+ new Integer(exchangeEvents.size()), text, exception);
+ logger.fine(">>>> created new empty wrapper");
+
+ return wrapper;
+ }
+
+ /**
+ *
+ */
+ public void addExchangeEvent(ExchangeEventWrapper wrapper){
+
+ String channelType = wrapper.getChannelType();
+ String sessionName = wrapper.getSessionName();
+
+ Vector exchangeEventsByChannel = (Vector) exchangeEventsByChannelTable.get(channelType);
+ Vector exchangeEventsBySession = (Vector) exchangeEventsBySessionTable.get(sessionName);
+
+
+ if(exchangeEventsByChannel == null){
+ exchangeEventsByChannel = new Vector();
+ }
+ logger.info("addExchangeEvent for CHANNEL TYPE: " + channelType);
+ exchangeEventsByChannel.add(wrapper);
+
+ if (exchangeEventsBySession == null){
+ exchangeEventsBySession = new Vector();
+ }
+ logger.info("addExchangeEvent for SESSION: " + sessionName);
+ exchangeEventsBySession.add(wrapper);
+
+ // is this necessary if we already had an entry?
+ exchangeEventsByChannelTable.put(channelType, exchangeEventsByChannel);
+ exchangeEventsBySessionTable.put(sessionName, exchangeEventsBySession);
+
+ exchangeEvents.add(wrapper);
+
+ logger.fine(">>>> added to exchange events list. size = " + exchangeEvents.size());
+
+ // OLD fault handling.
+ // if(wrapper.isFault() == true){
+ // channelHasErrorsTable.put(channelType, new Boolean(true));
+ // hasErrors = true;
+ // }
+
+ // NEW fault handling.
+logger.warning("Checking if error....");
+ if(wrapper.isWarning() == true || wrapper.isError() == true || wrapper.isUnexpected() == true){
+ // channelHasErrorsTable.put(channelType, new Boolean(true));
+ // hasErrors = true;
+
+ warningAndErrorExchangeEvents.add(wrapper);
+
+ if (wrapper.isError() == true) {
+ errorExchangeEvents.add(wrapper);
+logger.warning("RECORD ERROR channel="+channelType);
+ channelHasErrorsTable.put(channelType, new Boolean(true));
+ sessionHasErrorsTable.put(sessionName, new Boolean(true));
+ hasErrors = true;
+ } else if(wrapper.isWarning() == true){
+ warningExchangeEvents.add(wrapper);
+ channelHasWarningsTable.put(channelType, new Boolean(true));
+ sessionHasWarningsTable.put(sessionName, new Boolean(true));
+logger.warning("RECORD WARNING channel="+channelType);
+ hasWarnings = true;
+ } else if (wrapper.isUnexpected() == true) {
+ unexpectedExchangeEvents.add(wrapper);
+ channelHasUnexpectedMessagesTable.put(channelType, new Boolean(true));
+ sessionHasUnexpectedMessagesTable.put(sessionName, new Boolean(true));
+ hasUnexpectedMessages = true;
+ logger.info("ADDED UNEXPECTED WRAPPER TO ExchangeEventData for channelType " + channelType);
+ }
+logger.warning("Checked");
+ }
+ }
+
+
+ /**
+ *
+ */
+ public ExchangeEventWrapper getWrapper(int i){ return (ExchangeEventWrapper) exchangeEvents.elementAt(i); }
+
+
+
+ /**
+ *
+ */
+ public Vector getExchangeEventsForChannel(String channel){
+ return (Vector) exchangeEventsByChannelTable.get(channel);
+ }
+
+ public Vector getExchangeEventsForSession(String session) {
+ return (Vector)exchangeEventsBySessionTable.get(session);
+ }
+
+
+ /**
+ *
+ */
+ public Vector getExchangeEvents(){ return exchangeEvents; }
+
+ /**
+ *
+ */
+ public Vector getWarningAndErrorExchangeEvents(){ return warningAndErrorExchangeEvents; }
+
+ /**
+ *
+ */
+ public Vector getErrorExchangeEvents(){ return errorExchangeEvents; }
+
+ /**
+ *
+ */
+ public Vector getWarningExchangeEvents(){ return warningExchangeEvents; }
+
+ /**
+ *
+ */
+ public Vector getUnexpectedExchangeEvents() { return unexpectedExchangeEvents; }
+
+ /**
+ *
+ */
+ public boolean getHasUnexpectedExchangeEventsForChannel(String channel){
+ if(hasUnexpectedMessages == true){
+ Boolean hasUnexpectedMessagesForChannel = (Boolean) channelHasUnexpectedMessagesTable.get(channel);
+ if (hasUnexpectedMessagesForChannel != null) return true;
+ }
+ return false;
+ }
+
+ public boolean getHasUnexpectedExchangeEventsForSession(String session){
+ if(hasUnexpectedMessages == true){
+ Boolean hasUnexpectedMessagesForSession = (Boolean) sessionHasUnexpectedMessagesTable.get(session);
+ if (hasUnexpectedMessagesForSession != null) return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ public boolean getHasErrorsForChannel(String channel){
+ if(hasErrors == true){
+ Boolean hasErrorsForChannel = (Boolean) channelHasErrorsTable.get(channel);
+ if (hasErrorsForChannel != null) return true;
+ }
+ return false;
+ }
+
+ public boolean getHasErrorsForSession(String session){
+ if(hasErrors == true){
+ Boolean hasErrorsForSession = (Boolean) sessionHasErrorsTable.get(session);
+ if (hasErrorsForSession != null) return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ public boolean getHasWarningsForChannel(String channel){
+ if(hasWarnings == true){
+ Boolean hasWarningsForChannel = (Boolean) channelHasWarningsTable.get(channel);
+ if (hasWarningsForChannel != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean getHasWarningsForSession(String session){
+ if(hasWarnings == true){
+ Boolean hasWarningsForSession = (Boolean) sessionHasWarningsTable.get(session);
+ if (hasWarningsForSession != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ *
+ */
+ public boolean getHasUnexpectedMessages(){ return hasUnexpectedMessages; }
+ /**
+ *
+ */
+ public boolean getHasErrors(){ return hasErrors; }
+
+
+ /**
+ *
+ */
+ public boolean getHasWarnings(){ return hasWarnings; }
+
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/Monitor.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/Monitor.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/Monitor.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,503 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui;
+
+import javax.swing.*;
+
+import java.awt.BorderLayout;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.pi4soa.service.correlator.CorrelationSession;
+import org.savara.tools.monitor.CorrelationManagerListener;
+import org.savara.tools.monitor.ExchangeEvent;
+import org.savara.tools.monitor.TxnMonitor;
+
+/**
+ * Monitor user interface class.
+ */
+public class Monitor extends JApplet implements CorrelationManagerListener /* , TreeSelectionListener */{
+
+ private static final long serialVersionUID = -4323114698930604980L;
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.monitor.ui");
+
+ static final int NEW_FRAME_WIDTH = 800;
+ static final int NEW_FRAME_HEIGHT = 600;
+
+ MonitorMainPanel smPanel = null;
+
+ String choreographyPath = null;
+
+ org.pi4soa.cdl.Package choreography = null;
+
+ TxnMonitor txnMonitor = null;
+
+ ExchangeEventsData exchangeEventsData = null;
+
+ boolean isMonitoring = false;
+ boolean choreographyProvided = false;
+
+ /**
+ * Initialisation.
+ */
+ public Monitor(boolean choreoProvided) {
+
+ exchangeEventsData = new ExchangeEventsData();
+
+ smPanel = new MonitorMainPanel(exchangeEventsData, choreoProvided);
+
+ this.getContentPane().setLayout(new BorderLayout());
+ this.getContentPane().add(smPanel, BorderLayout.CENTER);
+
+ smPanel.setApplet(this);
+ }
+
+
+ /**
+ * Initialisation.
+ */
+ public void init() {
+ // hack to get around system event queue check - which doesn't work, of course
+ this.getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
+ }
+
+
+ /**
+ * Returns info about the acceptable parameters
+ */
+ public String[][] getParameterInfo()
+ {
+ String pinfo[][] = {
+ // actual parameters might include
+ // ip address, directories, colors
+ // etc.
+
+ // properties should be used for
+ // most stuff
+
+ {"parameter1", "String", "A String."},
+ {"parameter2", "String", "Another String."},
+ {"parameter3", "integer", "An integer."},
+ };
+
+ return pinfo;
+ }
+
+ /**
+ *
+ */
+ public static void main(String args[]){
+ Monitor monitor = new Monitor(args.length > 0);
+ JFrame jFrame = new JFrame("SAVARA Monitor");
+ jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ jFrame.getContentPane().setLayout(new BorderLayout());
+ jFrame.getContentPane().add(monitor, BorderLayout.CENTER);
+ monitor.init();
+
+ jFrame.setIconImage(MonitorMainPanel.createImageIcon("icons/monitor.png").getImage());
+
+ jFrame.setSize(NEW_FRAME_WIDTH, NEW_FRAME_HEIGHT);
+
+ java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
+ java.awt.Dimension frameSize = jFrame.getSize();
+ if (frameSize.height > screenSize.height) {
+ frameSize.height = screenSize.height;
+ }
+ if (frameSize.width > screenSize.width) {
+ frameSize.width = screenSize.width;
+ }
+ jFrame.setLocation( (screenSize.width - frameSize.width) / 2,
+ (screenSize.height - frameSize.height) / 2);
+ jFrame.setVisible(true);
+
+ if(args.length > 0){
+ if(monitor.loadChoreography(args[0])){
+ monitor.startMonitoring();
+ } else {
+ System.exit(1);
+ }
+ }
+ }
+
+ //////////////////////////
+
+
+ /**
+ *
+ */
+ public boolean isMonitoring(){ return isMonitoring; }
+
+ public boolean isChoreographyLoaded() { return choreography!=null; }
+
+ /**
+ *
+ */
+ public void setIsMonitoring(boolean isMonitoring){ this.isMonitoring = isMonitoring; }
+
+ public void close() {
+ this.destroy();
+ System.exit(0);
+ }
+
+ /**
+ *
+ */
+ public boolean loadChoreography(String choreographyPath){
+
+ logger.info("Loading " + choreographyPath);
+ smPanel.setStatus("Loading " + choreographyPath);
+
+ // try and read the new one ...
+ org.pi4soa.cdl.Package newChoreography = null;
+
+ try{
+ newChoreography = org.pi4soa.cdl.CDLManager.load(choreographyPath);
+ }
+ catch(IOException e){
+ logger.severe("Exception: " + e);
+ smPanel.setStatus("Failed to load " + choreographyPath);
+
+ JOptionPane.showMessageDialog(null,
+ "Failed to load "+choreographyPath,
+ "Error", JOptionPane.ERROR_MESSAGE);
+
+ return false;
+ }
+
+ // ok, we were successful ...
+ if(this.choreographyPath != null){
+ if(this.isMonitoring() == true){
+ // stop monitoring
+ }
+
+ exchangeEventsData.clear();
+ }
+
+ this.choreographyPath = choreographyPath;
+ this.choreography = newChoreography;
+
+ // tell the panel we loaded a new choreography ...
+ smPanel.loadedChoreography(choreography);
+
+ return true;
+ }
+
+
+ /**
+ *
+ */
+ public boolean startMonitoring(){
+
+ logger.info("Starting monitoring");
+
+ if(this.isMonitoring() == true){
+ logger.info("Already monitoring");
+ return false;
+ }
+
+ if(this.choreography == null){
+ logger.info("No choreography to monitor");
+ return false;
+ }
+
+ smPanel.setStatus("Trying to monitor " + choreography.getName());
+ logger.info("Trying to monitor " + choreography.getName());
+
+ try{
+ this.txnMonitor = TxnMonitor.getInstance(choreographyPath);
+ this.txnMonitor.addCorrelationManagerListener(this);
+ }
+ catch(Exception e){
+ // hack
+ logger.log(Level.SEVERE, "Exception while trying to monitor choreography " + e, e);
+
+ JOptionPane.showMessageDialog(null,
+ "Failed to initialize monitor: "+e.getLocalizedMessage(),
+ "Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ logger.fine("Past txnMonitor calls");
+
+ this.setIsMonitoring(true);
+
+ // tell the panel
+ smPanel.startedMonitoring();
+
+ return true;
+ }
+
+
+ /**
+ *
+ */
+ public boolean stopMonitoring(){
+ if(this.isMonitoring() == false){
+ logger.info("Not monitoring");
+ return false;
+ }
+
+ this.txnMonitor.removeCorrelationManagerListener(this);
+
+ try{
+ this.txnMonitor.unmonitor(this.choreography);
+ }
+ catch(Exception e){
+ logger.severe("Exception: " + e);
+ return false;
+ }
+
+ this.setIsMonitoring(false);
+
+ // tell the panel
+ smPanel.stoppedMonitoring();
+
+ return true;
+ }
+
+
+ /**
+ *
+ */
+ public boolean importEvents(String path){
+ boolean result = exchangeEventsData.importEvents(path);
+ smPanel.importedEvents();
+ return result;
+ }
+
+
+ /**
+ *
+ */
+ public boolean exportEvents(String path){
+ return exchangeEventsData.exportEvents(path);
+ //
+ // try{
+ // FileOutputStream fileOutputStream = new FileOutputStream(path);
+ // ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
+ // objectOutputStream.writeObject(exchangeEvents);
+ // objectOutputStream.close();
+ // }
+ // catch(Exception e){
+ // System.err.println("Exception: " + e);
+ // return false;
+ // }
+ //
+ // return true;
+ }
+
+
+ // CorrelationManagerListener interface
+
+ /**
+ * This method indicates that a correlation session has
+ * started.
+ *
+ * @param session The correlation session
+ */
+ public void correlationSessionStarted(CorrelationSession session){
+ logger.info(">>>> CORRELATION SESSION STARTED: " + session );
+
+ // TO DO: Need to add something to the sessionPanel at this point.
+ ChannelJPanel cp = smPanel.getChannelPanel();
+ cp.addedSession(session);
+ }
+
+
+ /**
+ * This method indicates that a correlation session has
+ * finished.
+ *
+ * @param session The correlation session
+ */
+ public void correlationSessionFinished(CorrelationSession session){
+ logger.info(">>>> CORRELATION SESSION FINSIHED: " + session);
+ smPanel.getChannelPanel().addedSession(session);
+ // TO DO: Need to change colour for the same session item in the session Panel
+ }
+
+
+ /**
+ * A new exchange event has been added to a correlation session.
+ *
+ * @param exchangeEvent The exchange event.
+ */
+ public void exchangeEventAdded(ExchangeEvent exchangeEvent){
+ logger.fine(">>>> ADDING EXCHANGE EVENT" + exchangeEvent);
+ // System.err.println(">>>> Adding exchange event");
+ // System.err.println(">>>> Getting correlation session");
+ CorrelationSession session = exchangeEvent.getCorrelationSession();
+ logger.fine("Identity for new exchange is: " + ChannelJPanel.getSessionIdentity(exchangeEvent.getCorrelationSession()));
+ // System.err.println(">>>> Getting wrapper");
+ ExchangeEventWrapper wrapper = exchangeEventsData.createExchangeEventWrapper(exchangeEvent);
+ // System.err.println(">>>> Adding to data");
+ exchangeEventsData.addExchangeEvent(wrapper);
+ // System.err.println(">>>> updating smPanel");
+ smPanel.addedExchangeEvent(wrapper);
+ logger.fine(">>>> ADDED EXCHANGE EVENT FOR SESSION: " + session);
+ }
+
+
+ /**
+ * An exchange event has been updated.
+ *
+ * @param exchangeEvent The exchange event.
+ */
+ public void exchangeEventUpdated(ExchangeEvent exchangeEvent){
+ ExchangeEventWrapper wrapper = exchangeEventsData.matchExchangeEventWrapper(exchangeEvent);
+ logger.fine("Identity for updated exchange is: " + ChannelJPanel.getSessionIdentity(exchangeEvent.getCorrelationSession()));
+ smPanel.updatedExchangeEvent(wrapper);
+ }
+
+ /**
+ * An unexpcted exchange event has occured
+ *
+ * @param exchangeEvent. The exchange event.
+ * @param serviceName The service reporting the error
+ */
+ public void unexpectedExchangeEventAdded(ExchangeEvent exchangeEvent,
+ String serviceName)
+ {
+ logger.info(">>>> unexpectedExchangeEventAdded");
+
+ //CorrelationSession session = exchangeEvent.getCorrelationSession();
+ String ident = null;
+
+ if (exchangeEvent.getCorrelationSession() != null) {
+ ident = ChannelJPanel.getSessionIdentity(exchangeEvent.getCorrelationSession());
+ }
+
+ logger.info("Identity for unexpected is: " + ident);
+ ExchangeEventWrapper wrapper = exchangeEventsData.errorExchangeEventWrapper(exchangeEvent);
+ wrapper.setUnexpected(true);
+ wrapper.setMessageIdentity(ident);
+ wrapper.setServiceName(serviceName);
+ exchangeEventsData.addExchangeEvent(wrapper);
+ smPanel.addedUnexpectedExchangeEvent(wrapper);
+
+ logger.fine("<<<< unexpectedExchangeEventAdded");
+ }
+
+ /**
+ * An error occurred related to the specified correlation
+ * session.
+ *
+ * @param session The correlation session
+ * @param mesg The error message
+ * @param exception The optional exception
+ * @param serviceName The service reporting the error
+ */
+ public void error(CorrelationSession session, String mesg,
+ String exception, String serviceName) {
+ logger.info(">>>> error");
+
+ //CorrelationSession session = exchangeEvent.getCorrelationSession();
+ String ident = null;
+
+ if (session != null) {
+ ident = ChannelJPanel.getSessionIdentity(session);
+ }
+
+ logger.info("Identity for unexpected is: " + ident);
+ ExchangeEventWrapper wrapper =
+ exchangeEventsData.simpleWrapper(session, mesg,
+ exception);
+ wrapper.setErrorMessage(true);
+ wrapper.setMessageIdentity(ident);
+ wrapper.setChannelType(ChannelJPanel.getErrorName());
+ wrapper.setServiceName(serviceName);
+ exchangeEventsData.addExchangeEvent(wrapper);
+ smPanel.addedErrorEvent(wrapper);
+
+ logger.fine("<<<< error");
+ }
+
+ /**
+ * A warning occurred related to the specified correlation
+ * session.
+ *
+ * @param session The correlation session
+ * @param mesg The warning message
+ * @param exception The optional exception
+ * @param serviceName The service reporting the warning
+ */
+ public void warning(CorrelationSession session, String mesg,
+ String exception, String serviceName) {
+ logger.info(">>>> warning");
+
+ //CorrelationSession session = exchangeEvent.getCorrelationSession();
+ String ident = null;
+
+ if (session != null) {
+ ident = ChannelJPanel.getSessionIdentity(session);
+ }
+
+ logger.info("Identity for unexpected is: " + ident);
+ ExchangeEventWrapper wrapper =
+ exchangeEventsData.simpleWrapper(session, mesg,
+ exception);
+ wrapper.setWarningMessage(true);
+ wrapper.setMessageIdentity(ident);
+ wrapper.setChannelType(ChannelJPanel.getWarningName());
+ wrapper.setServiceName(serviceName);
+ exchangeEventsData.addExchangeEvent(wrapper);
+ smPanel.addedErrorEvent(wrapper);
+
+ logger.fine("<<<< warning");
+ }
+
+ /**
+ * An information event occurred related to the specified correlation
+ * session.
+ *
+ * @param session The correlation session
+ * @param mesg The information message
+ * @param serviceName The service reporting the information
+ */
+ public void information(CorrelationSession session, String mesg,
+ String serviceName) {
+ logger.info(">>>> information");
+
+ //CorrelationSession session = exchangeEvent.getCorrelationSession();
+ String ident = null;
+
+ if (session != null) {
+ ident = ChannelJPanel.getSessionIdentity(session);
+ }
+
+ logger.info("Identity for unexpected is: " + ident);
+ ExchangeEventWrapper wrapper =
+ exchangeEventsData.simpleWrapper(session, mesg, null);
+ wrapper.setInformationMessage(true);
+ wrapper.setMessageIdentity(ident);
+ wrapper.setChannelType(ChannelJPanel.getInformationName());
+ wrapper.setServiceName(serviceName);
+ exchangeEventsData.addExchangeEvent(wrapper);
+ smPanel.addedErrorEvent(wrapper);
+
+ logger.fine("<<<< information");
+ }
+
+
+} // End of Applet
+
+// EOF
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorExchangeEvent.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorExchangeEvent.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorExchangeEvent.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,134 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui;
+
+
+import java.util.Date;
+
+import org.pi4soa.cdl.ExchangeDetails;
+import org.pi4soa.service.Channel;
+import org.pi4soa.cdl.ExchangeActionType;
+
+/**
+ * Convenience class for representing an exchange, and providing
+ * convenient access to data for display.
+ */
+public class MonitorExchangeEvent {
+
+ Date initiatedDate = null;
+ Date completedDate = null;
+
+ Channel channel = null;
+ ExchangeDetails exchangeDetails = null;
+
+ /**
+ *
+ */
+ public MonitorExchangeEvent(Channel channel, ExchangeDetails exchangeDetails){
+ this.channel = channel;
+ this.exchangeDetails = exchangeDetails;
+ }
+
+ /**
+ *
+ */
+ public String getChannelName(){
+ return channel.getName();
+ }
+
+ /**
+ *
+ */
+ public String getAction(){
+ if(exchangeDetails.getAction() == ExchangeActionType.REQUEST) return "Request";
+ else return "Response";
+ }
+
+
+ /**
+ *
+ */
+ public String getName(){
+ return exchangeDetails.getName();
+ }
+
+
+ /**
+ *
+ */
+ public String getDescription(){
+ return exchangeDetails.getDescription();
+ }
+
+
+ /**
+ *
+ */
+ public Date getInitiatedDate(){
+ return initiatedDate;
+ }
+
+
+ /**
+ *
+ */
+ public Date getCompletedDate(){
+ return completedDate;
+ }
+
+
+ /**
+ *
+ */
+ public String getStatus(){
+ if(completedDate != null) return "Completed";
+ else return "Initiated";
+ }
+
+
+ /**
+ *
+ */
+ public int hashCode(){
+ return exchangeDetails.hashCode();
+ }
+
+
+ /**
+ *
+ */
+ public boolean equals(Object object){
+ boolean result = false;
+
+ if(object instanceof MonitorExchangeEvent){
+ MonitorExchangeEvent other = (MonitorExchangeEvent) object;
+
+ if(other.exchangeDetails == this.exchangeDetails &&
+ other.getChannelName().equals(this.getChannelName())){
+ /* other.getCorrelationSession() == m_session) { */
+ result = true;
+ }
+ }
+
+ return result;
+ }
+
+
+} // End of class
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorFileFilter.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorFileFilter.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorFileFilter.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,253 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui;
+
+import java.io.File;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import javax.swing.filechooser.*;
+
+/**
+ * A convenience implementation of FileFilter that filters out
+ * all files except for those type extensions that it knows about.
+ *
+ * Extensions are of the type ".foo", which is typically found on
+ * Windows and Unix boxes, but not on Macinthosh. Case is ignored.
+ *
+ * Example - create a new filter that filerts out all files
+ * but gif and jpg image files:
+ *
+ * JFileChooser chooser = new JFileChooser();
+ * ExampleFileFilter filter = new ExampleFileFilter(
+ * new String{"gif", "jpg"}, "JPEG & GIF Images")
+ * chooser.addChoosableFileFilter(filter);
+ * chooser.showOpenDialog(this);
+ *
+ * @version 1.9 04/23/99
+ * @author Jeff Dinkins
+ */
+public class MonitorFileFilter extends FileFilter {
+
+ //private static String TYPE_UNKNOWN = "Type Unknown";
+ //private static String HIDDEN_FILE = "Hidden File";
+
+ private Hashtable filters = null;
+ private String description = null;
+ private String fullDescription = null;
+ private boolean useExtensionsInDescription = true;
+
+ /**
+ * Creates a file filter. If no filters are added, then all
+ * files are accepted.
+ *
+ * @see #addExtension
+ */
+ public MonitorFileFilter() {
+ this.filters = new Hashtable();
+ }
+
+ /**
+ * Creates a file filter that accepts files with the given extension.
+ * Example: new ExampleFileFilter("jpg");
+ *
+ * @see #addExtension
+ */
+ public MonitorFileFilter(String extension) {
+ this(extension,null);
+ }
+
+ /**
+ * Creates a file filter that accepts the given file type.
+ * Example: new ExampleFileFilter("jpg", "JPEG Image Images");
+ *
+ * Note that the "." before the extension is not needed. If
+ * provided, it will be ignored.
+ *
+ * @see #addExtension
+ */
+ public MonitorFileFilter(String extension, String description) {
+ this();
+ if(extension!=null) addExtension(extension);
+ if(description!=null) setDescription(description);
+ }
+
+ /**
+ * Creates a file filter from the given string array.
+ * Example: new ExampleFileFilter(String {"gif", "jpg"});
+ *
+ * Note that the "." before the extension is not needed adn
+ * will be ignored.
+ *
+ * @see #addExtension
+ */
+ public MonitorFileFilter(String[] filters) {
+ this(filters, null);
+ }
+
+ /**
+ * Creates a file filter from the given string array and description.
+ * Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
+ *
+ * Note that the "." before the extension is not needed and will be ignored.
+ *
+ * @see #addExtension
+ */
+ public MonitorFileFilter(String[] filters, String description) {
+ this();
+ for (int i = 0; i < filters.length; i++) {
+ // add filters one by one
+ addExtension(filters[i]);
+ }
+ if(description!=null) setDescription(description);
+ }
+
+ /**
+ * Return true if this file should be shown in the directory pane,
+ * false if it shouldn't.
+ *
+ * Files that begin with "." are ignored.
+ *
+ * @see #getExtension
+ * @see FileFilter#accepts
+ */
+ public boolean accept(File f) {
+ if(f != null) {
+ if(f.isDirectory()) {
+ return true;
+ }
+ String extension = getExtension(f);
+ if(extension != null && filters.get(getExtension(f)) != null) {
+ return true;
+ };
+ }
+ return false;
+ }
+
+ /**
+ * Return the extension portion of the file's name .
+ *
+ * @see #getExtension
+ * @see FileFilter#accept
+ */
+ public String getExtension(File f) {
+ if(f != null) {
+ String filename = f.getName();
+ int i = filename.lastIndexOf('.');
+ if(i>0 && i<filename.length()-1) {
+ return filename.substring(i+1).toLowerCase();
+ };
+ }
+ return null;
+ }
+
+ /**
+ * Adds a filetype "dot" extension to filter against.
+ *
+ * For example: the following code will create a filter that filters
+ * out all files except those that end in ".jpg" and ".tif":
+ *
+ * ExampleFileFilter filter = new ExampleFileFilter();
+ * filter.addExtension("jpg");
+ * filter.addExtension("tif");
+ *
+ * Note that the "." before the extension is not needed and will be ignored.
+ */
+ public void addExtension(String extension) {
+ if(filters == null) {
+ filters = new Hashtable(5);
+ }
+ filters.put(extension.toLowerCase(), this);
+ fullDescription = null;
+ }
+
+
+ /**
+ * Returns the human readable description of this filter. For
+ * example: "JPEG and GIF Image Files (*.jpg, *.gif)"
+ *
+ * @see setDescription
+ * @see setExtensionListInDescription
+ * @see isExtensionListInDescription
+ * @see FileFilter#getDescription
+ */
+ public String getDescription() {
+ if(fullDescription == null) {
+ if(description == null || isExtensionListInDescription()) {
+ fullDescription = description==null ? "(" : description + " (";
+ // build the description from the extension list
+ Enumeration extensions = filters.keys();
+ if(extensions != null) {
+ fullDescription += "." + (String) extensions.nextElement();
+ while (extensions.hasMoreElements()) {
+ fullDescription += ", " + (String) extensions.nextElement();
+ }
+ }
+ fullDescription += ")";
+ } else {
+ fullDescription = description;
+ }
+ }
+ return fullDescription;
+ }
+
+ /**
+ * Sets the human readable description of this filter. For
+ * example: filter.setDescription("Gif and JPG Images");
+ *
+ * @see setDescription
+ * @see setExtensionListInDescription
+ * @see isExtensionListInDescription
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ fullDescription = null;
+ }
+
+ /**
+ * Determines whether the extension list (.jpg, .gif, etc) should
+ * show up in the human readable description.
+ *
+ * Only relevent if a description was provided in the constructor
+ * or using setDescription();
+ *
+ * @see getDescription
+ * @see setDescription
+ * @see isExtensionListInDescription
+ */
+ public void setExtensionListInDescription(boolean b) {
+ useExtensionsInDescription = b;
+ fullDescription = null;
+ }
+
+ /**
+ * Returns whether the extension list (.jpg, .gif, etc) should
+ * show up in the human readable description.
+ *
+ * Only relevent if a description was provided in the constructor
+ * or using setDescription();
+ *
+ * @see getDescription
+ * @see setDescription
+ * @see setExtensionListInDescription
+ */
+ public boolean isExtensionListInDescription() {
+ return useExtensionsInDescription;
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorMainPanel.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorMainPanel.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorMainPanel.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,1038 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui;
+
+import java.awt.Component;
+
+import java.util.Vector;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Comparator;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+import javax.swing.JTree;
+import javax.swing.JTable;
+import javax.swing.JScrollPane;
+import javax.swing.JLabel;
+import javax.swing.JSplitPane;
+import javax.swing.JPanel;
+import javax.swing.ImageIcon;
+import javax.swing.JTextArea;
+import javax.swing.JEditorPane;
+
+import javax.swing.ListSelectionModel;
+import javax.swing.SpringLayout;
+import javax.swing.JCheckBox;
+//import javax.swing.JPopupMenu;
+import javax.swing.JComboBox;
+
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.ListSelectionEvent;
+
+import javax.swing.event.ListSelectionListener;
+
+import javax.swing.tree.TreeSelectionModel;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableCellRenderer;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.Dimension;
+import java.awt.Color;
+
+import java.awt.event.ItemListener;
+import java.awt.event.ItemEvent;
+
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import java.io.StringWriter;
+import java.io.StringReader;
+
+//import org.pi4soa.cdl.ExchangeDetails;
+import org.pi4soa.service.correlator.CorrelationSession;
+import org.pi4soa.cdl.ExchangeActionType;
+import org.savara.tools.monitor.ExchangeEvent;
+import org.savara.tools.monitor.ui.table.TableSorter;
+
+
+/**
+ * This is the main user interface for the swing monitor.
+ *
+ * It comprises a three-panel display, listing Channels, Exchange
+ * Events, and Exchange Event Details.
+ *
+ * @author Martin Redington
+ */
+public class MonitorMainPanel extends JPanel{
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.monitor.ui");
+
+ // Vector exchangeEvents = null;
+ ExchangeEventsData exchangeEventsData = null;
+
+ MonitorMenuBar menuBar =null;
+
+ ControlPanel controlPanel = null;
+
+ ChannelJPanel channelPanel = null;
+ StatusPanel statusPanel = null;
+
+ ExchangeEventsTableModel exchangeEventsTableModel = null;
+ TableSorter sorter = null;
+
+ String choreographyName = null;
+
+ ExchangeJPanel exchangePanel = null;
+
+ public static final Comparator INTEGER_COMPARATOR = new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return ((Integer) o1).intValue() - ((Integer) o2).intValue();
+ }
+ };
+
+ /**
+ * Constructor.
+ */
+ public MonitorMainPanel(ExchangeEventsData exchangeEventsData,
+ boolean choreoProvided){
+
+ this.menuBar = new MonitorMenuBar(choreoProvided);
+
+ this.exchangeEventsData = exchangeEventsData;
+
+ this.setLayout(new BorderLayout());
+ this.add(menuBar, BorderLayout.PAGE_START);
+
+ JPanel layoutPanel = new JPanel();
+ layoutPanel.setLayout(new BorderLayout());
+
+ controlPanel = new ControlPanel();
+ layoutPanel.add(controlPanel, BorderLayout.PAGE_START);
+
+ MessageJPanel exchangeDetailPanel = null;
+
+ if(true){
+ exchangeDetailPanel = new MessageJPanel(true);
+ }
+
+ exchangeDetailPanel.setPreferredSize(new Dimension(600, 100));
+ exchangeDetailPanel.setMinimumSize(new Dimension(400, 100));
+
+ exchangePanel = new ExchangeJPanel(exchangeDetailPanel);
+ exchangePanel.setPreferredSize(new Dimension(600, 350));
+ exchangePanel.setMinimumSize(new Dimension(400, 200));
+
+ channelPanel = new ChannelJPanel(this.exchangeEventsData,exchangeEventsTableModel);
+ channelPanel.setPreferredSize(new Dimension(200, 580));
+ channelPanel.setMinimumSize(new Dimension(180, 400));
+
+ statusPanel = new StatusPanel();
+
+
+ JSplitPane otherPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, exchangePanel, exchangeDetailPanel);
+ JSplitPane mainPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, channelPanel, otherPanel);
+ layoutPanel.add(mainPanel, BorderLayout.CENTER);
+ layoutPanel.add(statusPanel, BorderLayout.SOUTH);
+
+ this.add(layoutPanel, BorderLayout.CENTER);
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /** Returns the Channel Panel **/
+ public ChannelJPanel getChannelPanel()
+ {
+ return channelPanel;
+ }
+
+ /** Returns an ImageIcon, or null if the path was invalid. */
+ protected static ImageIcon createImageIcon(String path) {
+ java.net.URL imgURL = MonitorMainPanel.class.getResource(path);
+ if (imgURL != null) {
+ return new ImageIcon(imgURL);
+ } else {
+ System.err.println("Couldn't find file: " + path);
+ return null;
+ }
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public void loadedChoreography(org.pi4soa.cdl.Package choreography){
+ channelPanel.createAndAddTree(choreography);
+ exchangeEventsTableModel.fireTableDataChanged();
+ menuBar.loadedChoreography();
+ choreographyName = choreography.getName();
+ setStatus("Loaded " + choreographyName);
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public void startedMonitoring(){
+ menuBar.startedMonitoring();
+ setStatus("Monitoring " + choreographyName);
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public void stoppedMonitoring(){
+ menuBar.stoppedMonitoring();
+ setStatus("Stopped monitoring " + choreographyName);
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public void importedEvents(){
+ exchangeEventsTableModel.cancelFiltering();
+ exchangeEventsTableModel.fireTableDataChanged();
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /**
+ * Can't remember what this is for.
+ */
+ public void setApplet(Monitor applet) {
+ // ui.setApplet(applet);
+ menuBar.setMonitor(applet);
+ }
+
+
+
+ ////////////////////////////////////////////
+
+ /**
+ * Called by the SwingMonitor when a new exchange event occurs.
+ *
+ * The event will already have been added to the vector or
+ * exchange events.
+ */
+ public void addedExchangeEvent(ExchangeEventWrapper wrapper){
+ logger.fine(">>>> addedExchangeEvent");
+
+ String selectedChannelName = (String) exchangeEventsTableModel.getSelectedChannelName();
+ logger.fine("channel is: " + selectedChannelName);
+
+ // we are trying to fix the flickering updates here ...
+ if(selectedChannelName == null || wrapper.getChannelType().equals(selectedChannelName)){
+ logger.fine("fix flickering ...");
+ int index = -1;
+ if((index = exchangeEventsTableModel.indexOfExchangeEventWrapperInFilteredList(wrapper)) != -1){
+ logger.fine("inner ...");
+ // This might not work when we hack the table ...
+ // exchangeEventsTableModel.fireTableRowsInserted(index, index);
+ int newIndex = exchangeEventsTableModel.getRowCount() - 1 - index;
+ exchangeEventsTableModel.fireTableRowsInserted(newIndex, newIndex);
+ }
+ }
+
+ updateTreeIfEventIsFault(wrapper);
+ logger.fine("<<<< addedExchangeEvent");
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ * Called by the SwingMonitor when a new exchange event occurs.
+ *
+ * The event will already have been added to the vector or
+ * exchange events.
+ */
+ public void addedUnexpectedExchangeEvent(ExchangeEventWrapper wrapper){
+ logger.fine(">>>> addedUnexpectedExchangeEvent");
+ String selectedChannelName = ChannelJPanel.getUnexpectedMessagesName();
+ logger.fine("channel is: " + selectedChannelName);
+ // we are trying to fix the flickering updates here ...
+ if(selectedChannelName == null || wrapper.getChannelType().equals(selectedChannelName)){
+ logger.fine("fix flickering ...");
+ int index = -1;
+ if((index = exchangeEventsTableModel.indexOfExchangeEventWrapperInFilteredList(wrapper)) != -1){
+ // This might not work when we hack the table ...
+ // exchangeEventsTableModel.fireTableRowsInserted(index, index);
+ logger.fine("inner ...");
+ int newIndex = exchangeEventsTableModel.getRowCount() - 1 - index;
+ exchangeEventsTableModel.fireTableRowsInserted(newIndex, newIndex);
+ } else {
+ exchangeEventsTableModel.fireTableDataChanged();
+ }
+ }
+ exchangeEventsTableModel.fireTableDataChanged();
+ updateTreeIfEventIsFault(wrapper);
+
+ logger.fine("<<<< addedUnexpectedExchangeEvent");
+ }
+
+ public void addedErrorEvent(ExchangeEventWrapper wrapper){
+ logger.fine(">>>> addedErrorEvent");
+ String selectedChannelName = ChannelJPanel.getErrorName();
+ logger.fine("channel is: " + selectedChannelName);
+ // we are trying to fix the flickering updates here ...
+ if(selectedChannelName == null || wrapper.getChannelType().equals(selectedChannelName)){
+ logger.fine("fix flickering ...");
+ int index = -1;
+ if((index = exchangeEventsTableModel.indexOfExchangeEventWrapperInFilteredList(wrapper)) != -1){
+ // This might not work when we hack the table ...
+ // exchangeEventsTableModel.fireTableRowsInserted(index, index);
+ logger.fine("inner ...");
+ int newIndex = exchangeEventsTableModel.getRowCount() - 1 - index;
+ exchangeEventsTableModel.fireTableRowsInserted(newIndex, newIndex);
+ } else {
+ exchangeEventsTableModel.fireTableDataChanged();
+ }
+ }
+ exchangeEventsTableModel.fireTableDataChanged();
+ updateTreeIfEventIsFault(wrapper);
+
+ logger.fine("<<<< addedErrorEvent");
+ }
+
+ public void addedWarningEvent(ExchangeEventWrapper wrapper){
+ logger.fine(">>>> addedErrorEvent");
+ String selectedChannelName = ChannelJPanel.getWarningName();
+ logger.fine("channel is: " + selectedChannelName);
+ // we are trying to fix the flickering updates here ...
+ if(selectedChannelName == null || wrapper.getChannelType().equals(selectedChannelName)){
+ logger.fine("fix flickering ...");
+ int index = -1;
+ if((index = exchangeEventsTableModel.indexOfExchangeEventWrapperInFilteredList(wrapper)) != -1){
+ // This might not work when we hack the table ...
+ // exchangeEventsTableModel.fireTableRowsInserted(index, index);
+ logger.fine("inner ...");
+ int newIndex = exchangeEventsTableModel.getRowCount() - 1 - index;
+ exchangeEventsTableModel.fireTableRowsInserted(newIndex, newIndex);
+ } else {
+ exchangeEventsTableModel.fireTableDataChanged();
+ }
+ }
+ exchangeEventsTableModel.fireTableDataChanged();
+ updateTreeIfEventIsFault(wrapper);
+
+ logger.fine("<<<< addedErrorEvent");
+ }
+
+ public void addedInformationEvent(ExchangeEventWrapper wrapper){
+ logger.fine(">>>> addedErrorEvent");
+ String selectedChannelName = ChannelJPanel.getInformationName();
+ logger.fine("channel is: " + selectedChannelName);
+ // we are trying to fix the flickering updates here ...
+ if(selectedChannelName == null || wrapper.getChannelType().equals(selectedChannelName)){
+ logger.fine("fix flickering ...");
+ int index = -1;
+ if((index = exchangeEventsTableModel.indexOfExchangeEventWrapperInFilteredList(wrapper)) != -1){
+ // This might not work when we hack the table ...
+ // exchangeEventsTableModel.fireTableRowsInserted(index, index);
+ logger.fine("inner ...");
+ int newIndex = exchangeEventsTableModel.getRowCount() - 1 - index;
+ exchangeEventsTableModel.fireTableRowsInserted(newIndex, newIndex);
+ } else {
+ exchangeEventsTableModel.fireTableDataChanged();
+ }
+ }
+ exchangeEventsTableModel.fireTableDataChanged();
+ updateTreeIfEventIsFault(wrapper);
+
+ logger.fine("<<<< addedErrorEvent");
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ * Called by the SwingMonitor when an existing exchange event is updated.
+ *
+ */
+ public void updatedExchangeEvent(ExchangeEventWrapper wrapper){
+
+ String selectedChannelName = (String) exchangeEventsTableModel.getSelectedChannelName();
+
+ // we are trying to fix the flickering updates here ...
+ if(selectedChannelName == null || wrapper.getChannelType().equals(selectedChannelName)){
+ int index = -1;
+ if((index = exchangeEventsTableModel.indexOfExchangeEventWrapperInFilteredList(wrapper)) != -1){
+ int newIndex = exchangeEventsTableModel.getRowCount() - 1 - index;
+ exchangeEventsTableModel.fireTableRowsUpdated(newIndex, newIndex);
+ }
+ }
+
+ updateTreeIfEventIsFault(wrapper);
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ void updateTreeIfEventIsFault(ExchangeEventWrapper wrapper){
+ if(wrapper.isFault()){
+ channelPanel.revalidate();
+ channelPanel.redraw();
+ }
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public void setStatus(String status){
+ statusPanel.setStatus(status);
+ }
+
+ ////////////////// Inner classes
+
+
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+
+ ////////////////////////////////////////////
+
+ /**
+ * The upper pane contains a table listing the exchange events.
+ */
+ public class ExchangeJPanel extends JPanel{
+
+ /**
+ *
+ */
+ public ExchangeJPanel(ListSelectionListener listSelectionListener){
+
+ exchangeEventsTableModel = new ExchangeEventsTableModel();
+
+ final ExchangeEventRenderer exchangeEventRenderer = new ExchangeEventRenderer(true);
+
+ JTable table = new JTable() {
+ public TableCellRenderer getCellRenderer(int row, int column) {
+ return exchangeEventRenderer;
+ }
+ };
+ table.setModel(exchangeEventsTableModel);
+
+ table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ table.setColumnSelectionAllowed(false);
+ table.getTableHeader().setReorderingAllowed(false);
+
+ table.getColumnModel().getColumn(0).setPreferredWidth(40);
+ table.getColumnModel().getColumn(3).setPreferredWidth(200);
+ table.getColumnModel().getColumn(4).setPreferredWidth(40);
+
+ ListSelectionModel rowSM = table.getSelectionModel();
+ rowSM.addListSelectionListener(listSelectionListener);
+
+ JScrollPane scrollpane = new JScrollPane(table);
+ this.setLayout(new BorderLayout());
+ this.add(scrollpane, BorderLayout.CENTER);
+ }
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public class ExchangeEventRenderer extends JLabel implements TableCellRenderer{
+
+ public ExchangeEventRenderer(boolean isBordered) {
+ // this.isBordered = isBordered;
+ setOpaque(true); //MUST do this for background to show up.
+ }
+
+ public Component getTableCellRendererComponent(JTable table, Object object,
+ boolean isSelected, boolean hasFocus,
+ int row, int column) {
+ Integer index = exchangeEventsTableModel.getEventIndexForRow(row);
+
+ ExchangeEventWrapper wrapper = exchangeEventsData.getWrapper(index.intValue());
+
+ logger.fine("RENDERING EXCHANGE:");
+ logger.fine("EXCHANGE IS: " + wrapper);
+
+ if(isSelected){
+ setForeground(table.getSelectionForeground());
+ setBackground(table.getSelectionBackground());
+ }
+ else{
+ setForeground(table.getForeground());
+ setBackground(table.getBackground());
+ }
+
+ if (object != null) {
+ setText(object.toString());
+ } else {
+ setText("");
+ }
+
+ //
+ // Sets the individual exchange color
+ //
+ if(wrapper.isError()){
+ logger.info("isError - setting color dark red");
+ setForeground(Color.red.darker());
+ }
+ else if (wrapper.isUnexpected()){
+ logger.info("isUnexpected - setting color red");
+ setForeground(Color.red);
+ }
+ else if(wrapper.isWarning()){
+ logger.info("isWarning - setting color orange");
+ setForeground(Color.orange);
+ }
+ else if(wrapper.isInformationMessage() && column == 3){
+ logger.info("isInformationMessage - setting color blue");
+ setForeground(Color.blue);
+ }
+ if (wrapper.isUnexpected())
+ setToolTipText("This message, '" + wrapper.getSendVariableTypeName()+ "' is invalid for this choreography.");
+ else
+ setToolTipText(wrapper.getDescription()); //Discussed in the following section
+
+ return this;
+ }
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public class ExchangeEventsTableModel extends AbstractTableModel implements TreeSelectionListener{
+
+ String selectedChannelName = null;
+
+ Vector filteredExchangeEvents = null;
+
+ Vector emptyVector = new Vector();
+
+ boolean filterByChannel = true;
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public ExchangeEventsTableModel(){
+ this.filteredExchangeEvents = exchangeEventsData.getExchangeEvents();
+ }
+
+ ////////////////////////////////////////////
+
+ public int getColumnCount() {
+ return 5;
+ }
+
+ ////////////////////////////////////////////
+
+ public int getRowCount() {
+ return filteredExchangeEvents.size();
+ }
+
+ ////////////////////////////////////////////
+
+ public String getColumnName(int col) {
+ return getColumnNameSTP(col);
+ }
+
+ ////////////////////////////////////////////
+
+ public String getColumnNameSTP(int col) {
+ if(col == 0){ return "Session Id"; }
+ else if(col == 1){ return "From"; }
+ else if(col == 2){ return "To"; }
+ else if(col == 3){ return "Msg"; }
+ else return "Status";
+ // else return "Priority";
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public Object getValueAt(int row, int col) {
+ return getValueAtSTP(row, col);
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public Class getColumnClass(int col) {
+ return Object.class;
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ protected ExchangeEventWrapper getWrapperForRow(int row) {
+ return (ExchangeEventWrapper) filteredExchangeEvents.elementAt(filteredExchangeEvents.size() - (row + 1));
+ }
+
+ ////////////////////////////////////////////
+
+
+ /**
+ *
+ */
+ public Integer getEventIndexForRow(int row) {
+ ExchangeEventWrapper wrapper = getWrapperForRow(row);
+ return wrapper.getIndex();
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public Object getValueAtSTP(int row, int col) {
+ ExchangeEventWrapper wrapper = getWrapperForRow(row);
+ // ExchangeEvent exchangeEvent = wrapper.getExchangeEvent();
+
+ Object result = null;
+
+ switch(col){
+ case 0:
+ result = wrapper.getMessageIdentity();
+ break;
+ case 1:
+ result="";
+
+ if (wrapper.getFromRoleTypeName() != null &&
+ wrapper.getFromRoleTypeName().trim().length() > 0) {
+ result = wrapper.getFromRoleTypeName();
+ } else if (wrapper.getServiceName() != null) {
+ result = org.pi4soa.common.xml.NameSpaceUtil.getLocalPart(
+ wrapper.getServiceName());
+ }
+ break;
+ case 2:
+ result="";
+
+ if (wrapper.getToRoleTypeName() != null) {
+ result = wrapper.getToRoleTypeName();
+ }
+ break;
+ case 3:
+ result = wrapper.getMessageSummary();
+ break;
+ case 4:
+ result = wrapper.getStatus();
+ break;
+ default:
+ break;
+ }
+
+ return result;
+ }
+
+ ////////////////////////////////////////////
+
+
+ /**
+ *
+ */
+ public void cancelFiltering(){
+ JTree tree = channelPanel.getTree();
+
+ Vector exchangeEvents = exchangeEventsData.getExchangeEvents();
+ if(this.filteredExchangeEvents != exchangeEvents){
+ this.filteredExchangeEvents = exchangeEvents;
+ }
+ selectedChannelName = null;
+ fireTableDataChanged();
+ tree.clearSelection();
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public void setFilterByChannel(boolean filterByChannel){
+ this.filterByChannel = filterByChannel;
+ JTree tree = channelPanel.getTree();
+
+ if(filterByChannel == true){
+ valueChangedForTree(tree);
+ }
+ else{
+ Vector exchangeEvents = exchangeEventsData.getExchangeEvents();
+ if(this.filteredExchangeEvents != exchangeEvents){
+ this.filteredExchangeEvents = exchangeEvents;
+ }
+ selectedChannelName = null;
+ fireTableDataChanged();
+
+ tree.clearSelection();
+ }
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public void setFilterByEventType(int index, ControlPanel controlPanel){
+
+ Vector oldFilteredExchangeEvents = filteredExchangeEvents;
+ Vector newFilteredExchangeEvents = null;
+
+ switch(index){
+ case 0:
+ newFilteredExchangeEvents = exchangeEventsData.getExchangeEvents();
+ break;
+ case 1:
+ newFilteredExchangeEvents = exchangeEventsData.getWarningAndErrorExchangeEvents();
+ break;
+ case 2:
+ newFilteredExchangeEvents = exchangeEventsData.getErrorExchangeEvents();
+ break;
+ case 3:
+ newFilteredExchangeEvents = exchangeEventsData.getWarningExchangeEvents();
+ break;
+ default:
+ // this ain't gonna happen
+ return;
+ //break;
+ }
+ /*
+ if(oldFilteredExchangeEvents != newFilteredExchangeEvents){
+ // we should also reset the enablement of the channel filtering ...
+ if(index == 0){
+ controlPanel.setFilterEventsByChannelIsEnabled(true);
+ }
+ else{
+ controlPanel.setFilterEventsByChannelIsEnabled(false);
+ }
+
+ this.filteredExchangeEvents = newFilteredExchangeEvents;
+ fireTableDataChanged();
+ }
+ */
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /**
+ * When the channel panel selection changes, we (should) filter
+ * the exchange event list.
+ *
+ * Right now, we simply print the selection name to stderr.
+ */
+ public void valueChanged(TreeSelectionEvent e) {
+
+ logger.fine("valueChanged");
+ if(filterByChannel == false){
+ return;
+ }
+
+ JTree tree = (JTree) e.getSource();
+
+ valueChangedForTree(tree);
+ }
+
+
+ /**
+ *
+ */
+ public void valueChangedForTree(JTree tree) {
+ logger.fine("valueChangedForTree");
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
+
+ if(node == null) {
+ selectedChannelName = null;
+ return;
+ }
+
+ Vector oldFilteredExchangeEvents = filteredExchangeEvents;
+
+ if (node.isLeaf()) {
+ logger.fine("Selected is: " + node.getUserObject().toString());
+ selectedChannelName = (String) node.getUserObject().toString();
+ logger.fine("SelectedChannelName is " + selectedChannelName);
+ Vector newVector = exchangeEventsData.getExchangeEventsForChannel(selectedChannelName);
+
+ // avoid npe's
+ if(newVector == null) {
+ newVector = exchangeEventsData.getExchangeEventsForSession(selectedChannelName);
+ if (newVector == null) {
+ this.filteredExchangeEvents = emptyVector;
+ logger.fine("emptyVector");
+ } else {
+ this.filteredExchangeEvents = newVector;
+ logger.fine("newVector (" + newVector.size() + ")");
+ }
+ } else {
+ this.filteredExchangeEvents = newVector;
+ logger.fine("newVector (" + newVector.size() + ")");
+ }
+
+
+
+ } else {
+ this.filteredExchangeEvents = exchangeEventsData.getExchangeEvents();
+ selectedChannelName = null;
+ }
+
+ if(oldFilteredExchangeEvents != filteredExchangeEvents) {
+ fireTableDataChanged();
+ }
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public String getSelectedChannelName(){
+ return selectedChannelName;
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public int indexOfExchangeEventWrapperInFilteredList(Object o){
+ return filteredExchangeEvents.indexOf(o);
+ }
+ }
+
+ ////////////////////////////////////////////
+
+ public class StatusPanel extends JPanel{
+ JLabel statusJLabel = new JLabel();
+
+ public StatusPanel(){
+ this.setLayout(new BorderLayout());
+ this.add(statusJLabel, BorderLayout.LINE_START);
+ setStatus("No choreography loaded");
+ }
+
+ public void setStatus(String status){
+ statusJLabel.setText(status);
+ }
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ public class ControlPanel extends JPanel implements ItemListener, ActionListener{
+ //JCheckBox filterEventsByChannelJCheckBox = new JCheckBox("Filter by channel", true);
+
+ Object sessionItems[] = { "All sessions" };
+ //JComboBox sessionPopupMenu = new JComboBox(sessionItems);
+
+ // add the sessions to the jpopup menu ...
+ // JComboBox sessionPopupMenu = new JComboBox(sessionItems);
+
+ //Object showItems[] = { "All Events", "Errors and Warnings", "Errors", "Warnings" };
+ //JComboBox showPopupMenu = new JComboBox(showItems);
+
+ // JComboBox showPopupMenu = new JComboBox("Show: ");
+
+
+
+ /**
+ *
+ */
+ public ControlPanel(){
+ this.setLayout(new BorderLayout());
+ //this.add(filterEventsByChannelJCheckBox, BorderLayout.WEST);
+
+ //filterEventsByChannelJCheckBox.addItemListener(this);
+
+ // this.add(sessionPopupMenu, BorderLayout.CENTER);
+ //JPanel layoutPanel = new JPanel();
+ // layoutPanel.setLayout(new FlowLayout());
+
+ //layoutPanel.add(new JLabel("Show: "));
+ //layoutPanel.add(showPopupMenu);
+ //showPopupMenu.addActionListener(this);
+
+ //this.add(layoutPanel, BorderLayout.EAST);
+ }
+
+
+ /**
+ *
+ *
+ public void itemStateChanged(ItemEvent e) {
+ Object source = e.getItemSelectable();
+ if(source == filterEventsByChannelJCheckBox){
+ boolean filterByChannel = filterEventsByChannelJCheckBox.isSelected();
+ exchangeEventsTableModel.setFilterByChannel(filterByChannel);
+ }
+ }
+ */
+ public void itemStateChanged(ItemEvent e) {}
+
+
+ /**
+ *
+ *
+ public void actionPerformed(ActionEvent e) {
+ Object source = e.getSource();
+ if(source == showPopupMenu){
+ int index = showPopupMenu.getSelectedIndex();
+ exchangeEventsTableModel.setFilterByEventType(index, this);
+ }
+ }
+ */
+ public void actionPerformed(ActionEvent e) {}
+
+
+
+ /**
+ *
+ *
+ public void setFilterEventsByChannelIsEnabled(boolean setFilterEventsByChannelIsEnabled){
+ if(setFilterEventsByChannelIsEnabled == false){
+ filterEventsByChannelJCheckBox.setSelected(false);
+ }
+ filterEventsByChannelJCheckBox.setEnabled(setFilterEventsByChannelIsEnabled);
+ }
+ */
+ public void setFilterEventsByChannelIsEnabled(boolean setFilterEventsByChannelIsEnabled){}
+
+ }
+
+ ////////////////////////////////////////////
+
+ /**
+ *
+ */
+ // public class MessageJPanel extends ExchangeDetailJPanel implements ListSelectionListener{
+ public class MessageJPanel extends JPanel implements ListSelectionListener{
+
+ JTextArea msgTextArea = null;
+
+ /**
+ *
+ */
+ public MessageJPanel(boolean dummy){
+ msgTextArea = new JTextArea();
+ msgTextArea.setEditable(false);
+ JScrollPane scrollpane = new JScrollPane(msgTextArea);
+ this.setLayout(new BorderLayout());
+ this.add(scrollpane, BorderLayout.CENTER);
+ }
+
+
+ public void valueChanged(ListSelectionEvent e) {
+
+ logger.fine(">>>> valueChanged - new message selected");
+
+ //Ignore extra messages.
+ if (e.getValueIsAdjusting()) {
+ logger.fine(">>>> just adjusting - returning early");
+ return;
+ }
+
+ ListSelectionModel lsm = (ListSelectionModel)e.getSource();
+
+ if (lsm.isSelectionEmpty()){
+ logger.fine(">>>> no rows selected");
+ // no rows are selected
+ }
+ else{
+ // selectedRow is selected
+ // harhar. grab the first value ...
+ int selectedRowIndex = lsm.getMinSelectionIndex();
+
+ logger.fine(">>>> selectedIndex = " + selectedRowIndex);
+
+ Integer index = (Integer) exchangeEventsTableModel.getEventIndexForRow(selectedRowIndex);
+
+ // ExchangeEventWrapper wrapper = (ExchangeEventWrapper) exchangeEvents.elementAt(index.intValue());
+ ExchangeEventWrapper wrapper = exchangeEventsData.getWrapper(index.intValue());
+
+
+ // avoid NPE's
+ if(wrapper != null){
+ this.updateDetails(wrapper);
+ }
+ else{
+ logger.fine(">>>> null exception wrapper");
+ }
+ }
+ }
+
+
+ /**
+ *
+ */
+ public void updateDetails(ExchangeEventWrapper exchangeEventWrapper){
+ String text = exchangeEventWrapper.getMessageValue();
+ logger.info("MESSAGE PAYLOAD: " + text);
+
+ try {
+ org.w3c.dom.Node node=org.pi4soa.common.xml.XMLUtils.getNode(text);
+
+ text = org.pi4soa.common.xml.XMLUtils.getText(node, true);
+
+ } catch (Exception e) {
+ //text = "Unable to display message\r\n\r\n"+e;
+ }
+
+ if (exchangeEventWrapper.getExceptionValue() != null) {
+ text += "\r\n\r\nException Trace:\r\n"+
+ exchangeEventWrapper.getExceptionValue();
+ }
+
+ msgTextArea.setText(text);
+ msgTextArea.setBackground(Color.lightGray);
+ msgTextArea.setCaretPosition(0);
+ }
+ }
+
+}
+
+
+// EOF
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorMenuBar.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorMenuBar.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorMenuBar.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,318 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui;
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.io.*;
+
+/**
+ *
+ */
+public class MonitorMenuBar extends JMenuBar {
+
+ MonitorMenuBar menuBar = this;
+
+ static final int NEW_FRAME_WIDTH = 415;
+ static final int NEW_FRAME_HEIGHT = 330;
+
+ JMenu fileMenu = new JMenu("File");
+ JMenu editMenu = new JMenu("Edit");
+ JMenu monitorMenu = new JMenu("Monitor");
+ JMenu helpMenu = new JMenu("Help");
+
+ JMenuItem openItem = new JMenuItem("Open Choreography...");
+ JMenuItem importItem = new JMenuItem("Import Events...");
+ JMenuItem exportItem = new JMenuItem("Export Events...");
+ JMenuItem exitItem = new JMenuItem("Exit");
+
+ JMenuItem undoItem = new JMenuItem("Undo");
+ JMenuItem cutItem = new JMenuItem("Cut");
+ JMenuItem copyItem = new JMenuItem("Copy");
+ JMenuItem pasteItem = new JMenuItem("Paste");
+ JMenuItem selectAllItem = new JMenuItem("Select All");
+ JMenuItem clearItem = new JMenuItem("Clear");
+ JMenuItem preferencesItem = new JMenuItem("Preferences...");
+
+ JMenuItem startMonitoringItem = new JMenuItem("Start Monitoring");
+ JMenuItem stopMonitoringItem = new JMenuItem("Stop Monitoring");
+
+ JMenuItem helpItem = new JMenuItem("About Choreography Monitor");
+
+ Monitor monitor;
+
+ /**
+ *
+ */
+ public MonitorMenuBar(boolean choreoProvided){
+ setUpFileMenu(choreoProvided);
+ setUpEditMenu(choreoProvided);
+ setUpMonitorMenu(choreoProvided);
+ setUpHelpMenu(choreoProvided);
+ }
+
+
+ /**
+ *
+ */
+ private void setUpFileMenu(boolean choreoProvided){
+ openItem.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.Event.META_MASK));
+ exitItem.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.Event.META_MASK));
+
+ openItem.setEnabled(true);
+ importItem.setEnabled(true);
+ exportItem.setEnabled(false);
+ exitItem.setEnabled(true);
+
+ openItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setDialogTitle("Open Choreography");
+
+ // Note: source for ExampleFileFilter can be found in FileChooserDemo,
+ // under the demo/jfc directory in the Java 2 SDK, Standard Edition.
+ MonitorFileFilter filter = new MonitorFileFilter();
+ filter.addExtension("cdm");
+ filter.setDescription("CDM Files");
+ chooser.setFileFilter(filter);
+ int returnVal = chooser.showOpenDialog(menuBar);
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ File directory = chooser.getCurrentDirectory();
+ String fileName = chooser.getSelectedFile().getName();
+ File path = new File(directory, fileName);
+ monitor.loadChoreography(path.getPath());
+
+ // now that we've opened, start monitoring should be enabled.
+ }
+ }
+ });
+
+
+ importItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setDialogTitle("Import Events");
+
+ // Note: source for ExampleFileFilter can be found in FileChooserDemo,
+ // under the demo/jfc directory in the Java 2 SDK, Standard Edition.
+ MonitorFileFilter filter = new MonitorFileFilter();
+ filter.addExtension("data");
+ filter.setDescription("Exchange Events");
+ chooser.setFileFilter(filter);
+ int returnVal = chooser.showOpenDialog(menuBar);
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ File directory = chooser.getCurrentDirectory();
+ String fileName = chooser.getSelectedFile().getName();
+ File path = new File(directory, fileName);
+ monitor.importEvents(path.getPath());
+ }
+ }
+ });
+
+
+ exportItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setDialogTitle("Export Events");
+
+ // Note: source for ExampleFileFilter can be found in FileChooserDemo,
+ // under the demo/jfc directory in the Java 2 SDK, Standard Edition.
+ // ExampleFileFilter filter = new ExampleFileFilter();
+ // filter.addExtension("data");
+ // filter.setDescription("Exchange Events");
+ // chooser.setFileFilter(filter);
+ int returnVal = chooser.showSaveDialog(menuBar);
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ File directory = chooser.getCurrentDirectory();
+ String fileName = chooser.getSelectedFile().getName();
+ File path = new File(directory, fileName);
+ monitor.exportEvents(path.getPath());
+ }
+ }
+ });
+
+ exitItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ monitor.close();
+ }
+ });
+
+ if (!choreoProvided) {
+ fileMenu.add(openItem);
+ fileMenu.add(new JSeparator());
+ }
+
+ // Disable import/export in this version
+ // If re-enabled, need to sort out message summary
+ // persistence, as it uses the exchange event which
+ // is transient
+ //fileMenu.add(importItem);
+ //fileMenu.add(exportItem);
+ //fileMenu.add(new JSeparator());
+
+ fileMenu.add(exitItem);
+
+ this.add(fileMenu);
+ }
+
+
+ /**
+ *
+ */
+ private void setUpEditMenu(boolean choreoProvided){
+
+ undoItem.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.Event.META_MASK));
+ cutItem.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.Event.META_MASK));
+ copyItem.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.Event.META_MASK));
+ pasteItem.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.Event.META_MASK));
+ selectAllItem.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.Event.META_MASK));
+ preferencesItem.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P /* was VK_SEMICOLON */,
+ java.awt.Event.META_MASK));
+
+ undoItem.setEnabled(false);
+ cutItem.setEnabled(false);
+ copyItem.setEnabled(false);
+ pasteItem.setEnabled(false);
+ selectAllItem.setEnabled(false);
+ clearItem.setEnabled(false);
+
+ // preferences menu implementation
+ preferencesItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ // preferences.setVisible(true);
+ }
+ });
+
+ editMenu.add(undoItem);
+ editMenu.add(new JSeparator());
+ editMenu.add(cutItem);
+ editMenu.add(copyItem);
+ editMenu.add(pasteItem);
+ editMenu.add(selectAllItem);
+ editMenu.add(clearItem);
+ editMenu.add(new JSeparator());
+ editMenu.add(preferencesItem);
+
+ /*
+ this.add(editMenu);
+ */
+ }
+
+
+ /**
+ *
+ */
+ private void setUpMonitorMenu(boolean choreoProvided){
+ startMonitoringItem.setEnabled(false);
+ stopMonitoringItem.setEnabled(false);
+
+ startMonitoringItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ monitor.startMonitoring();
+ }
+ });
+
+ stopMonitoringItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ monitor.stopMonitoring();
+ }
+ });
+
+ monitorMenu.add(startMonitoringItem);
+ monitorMenu.add(stopMonitoringItem);
+
+ if (!choreoProvided) {
+ this.add(monitorMenu);
+ }
+ }
+
+
+ /**
+ *
+ */
+ private void setUpHelpMenu(boolean choreoProvided){
+ helpItem.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
+ helpMenu.add(helpItem);
+ helpItem.setEnabled(true);
+
+ helpItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(null,
+ "pi4soa Choreography Monitor\r\n\r\n" +
+ "Version 1\r\n\r\n" +
+ "(c) Pi4 Technologies Ltd, 2005-8",
+ "About ...", JOptionPane.INFORMATION_MESSAGE);
+ }
+ });
+
+ this.add(helpMenu);
+ }
+
+
+ /**
+ *
+ */
+ public void setMonitor(Monitor monitor) {
+ this.monitor = monitor;
+ }
+
+
+ /**
+ *
+ */
+ public void loadedChoreography(){
+ startMonitoringItem.setEnabled(true);
+ }
+
+
+ /**
+ *
+ */
+ public void startedMonitoring(){
+ openItem.setEnabled(false);
+ importItem.setEnabled(false);
+ exportItem.setEnabled(true);
+ startMonitoringItem.setEnabled(false);
+ stopMonitoringItem.setEnabled(true);
+ }
+
+
+ /**
+ *
+ */
+ public void stoppedMonitoring(){
+ openItem.setEnabled(true);
+ importItem.setEnabled(true);
+ exportItem.setEnabled(true);
+ startMonitoringItem.setEnabled(true);
+ stopMonitoringItem.setEnabled(false);
+ }
+
+ /**
+ *
+ */
+ public void importedEvents(){
+ exportItem.setEnabled(true);
+ }
+
+} // End of class
+
+
+// EOF
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorTreeModelListener.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorTreeModelListener.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/MonitorTreeModelListener.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui;
+
+import java.util.logging.Logger;
+
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeSelectionModel;
+
+import org.pi4soa.service.correlator.CorrelationSession;
+
+
+/**
+ * The left hand pane contains a tree whose root is the
+ * choreography, and whose leaves are channels.
+ *
+ * Selecting a channel filters the exchange events list (or should
+ * do).
+ */
+class MonitorTreeModelListener implements TreeModelListener {
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.monitor.ui");
+
+ public void treeNodesChanged(TreeModelEvent e) {
+ DefaultMutableTreeNode node;
+ node = (DefaultMutableTreeNode)
+ (e.getTreePath().getLastPathComponent());
+
+ /*
+ * If the event lists children, then the changed
+ * node is the child of the node we've already
+ * gotten. Otherwise, the changed node and the
+ * specified node are the same.
+ */
+ try {
+ int index = e.getChildIndices()[0];
+ node = (DefaultMutableTreeNode)
+ (node.getChildAt(index));
+ } catch (NullPointerException exc) {}
+
+ logger.fine(">>> CHANGED NODE");
+ logger.fine("The user has finished editing the node.");
+ logger.fine("New value: " + node.getUserObject());
+ }
+ public void treeNodesInserted(TreeModelEvent e) {
+ logger.fine(">>> INSERTED NODE");
+ }
+ public void treeNodesRemoved(TreeModelEvent e) {
+ logger.fine(">>> REMOVED NODE");
+ }
+ public void treeStructureChanged(TreeModelEvent e) {
+ logger.fine(">>> TREE STRUCTURE CHANGED");
+ }
+}
\ No newline at end of file
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/SpringUtilities.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/SpringUtilities.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/SpringUtilities.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,213 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui;
+
+import javax.swing.*;
+import javax.swing.SpringLayout;
+import java.awt.*;
+
+/**
+ * A 1.4 file that provides utility methods for
+ * creating form- or grid-style layouts with SpringLayout.
+ * These utilities are used by several programs, such as
+ * SpringBox and SpringCompactGrid.
+ */
+public class SpringUtilities {
+ /**
+ * A debugging utility that prints to stdout the component's
+ * minimum, preferred, and maximum sizes.
+ */
+ public static void printSizes(Component c) {
+ System.out.println("minimumSize = " + c.getMinimumSize());
+ System.out.println("preferredSize = " + c.getPreferredSize());
+ System.out.println("maximumSize = " + c.getMaximumSize());
+ }
+
+ /**
+ * Aligns the first <code>rows</code> * <code>cols</code>
+ * components of <code>parent</code> in
+ * a grid. Each component is as big as the maximum
+ * preferred width and height of the components.
+ * The parent is made just big enough to fit them all.
+ *
+ * @param rows number of rows
+ * @param cols number of columns
+ * @param initialX x location to start the grid at
+ * @param initialY y location to start the grid at
+ * @param xPad x padding between cells
+ * @param yPad y padding between cells
+ */
+ public static void makeGrid(Container parent,
+ int rows, int cols,
+ int initialX, int initialY,
+ int xPad, int yPad) {
+ SpringLayout layout;
+ try {
+ layout = (SpringLayout)parent.getLayout();
+ } catch (ClassCastException exc) {
+ System.err.println("The first argument to makeGrid must use SpringLayout.");
+ return;
+ }
+
+ Spring xPadSpring = Spring.constant(xPad);
+ Spring yPadSpring = Spring.constant(yPad);
+ Spring initialXSpring = Spring.constant(initialX);
+ Spring initialYSpring = Spring.constant(initialY);
+ int max = rows * cols;
+
+ //Calculate Springs that are the max of the width/height so that all
+ //cells have the same size.
+ Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).
+ getWidth();
+ Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).
+ getWidth();
+ for (int i = 1; i < max; i++) {
+ SpringLayout.Constraints cons = layout.getConstraints(
+ parent.getComponent(i));
+
+ maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
+ maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
+ }
+
+ //Apply the new width/height Spring. This forces all the
+ //components to have the same size.
+ for (int i = 0; i < max; i++) {
+ SpringLayout.Constraints cons = layout.getConstraints(
+ parent.getComponent(i));
+
+ cons.setWidth(maxWidthSpring);
+ cons.setHeight(maxHeightSpring);
+ }
+
+ //Then adjust the x/y constraints of all the cells so that they
+ //are aligned in a grid.
+ SpringLayout.Constraints lastCons = null;
+ SpringLayout.Constraints lastRowCons = null;
+ for (int i = 0; i < max; i++) {
+ SpringLayout.Constraints cons = layout.getConstraints(
+ parent.getComponent(i));
+ if (i % cols == 0) { //start of new row
+ lastRowCons = lastCons;
+ cons.setX(initialXSpring);
+ } else { //x position depends on previous component
+ cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST),
+ xPadSpring));
+ }
+
+ if (i / cols == 0) { //first row
+ cons.setY(initialYSpring);
+ } else { //y position depends on previous row
+ cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH),
+ yPadSpring));
+ }
+ lastCons = cons;
+ }
+
+ //Set the parent's size.
+ SpringLayout.Constraints pCons = layout.getConstraints(parent);
+ pCons.setConstraint(SpringLayout.SOUTH,
+ Spring.sum(
+ Spring.constant(yPad),
+ lastCons.getConstraint(SpringLayout.SOUTH)));
+ pCons.setConstraint(SpringLayout.EAST,
+ Spring.sum(
+ Spring.constant(xPad),
+ lastCons.getConstraint(SpringLayout.EAST)));
+ }
+
+ /* Used by makeCompactGrid. */
+ private static SpringLayout.Constraints getConstraintsForCell(
+ int row, int col,
+ Container parent,
+ int cols) {
+ SpringLayout layout = (SpringLayout) parent.getLayout();
+ Component c = parent.getComponent(row * cols + col);
+ return layout.getConstraints(c);
+ }
+
+ /**
+ * Aligns the first <code>rows</code> * <code>cols</code>
+ * components of <code>parent</code> in
+ * a grid. Each component in a column is as wide as the maximum
+ * preferred width of the components in that column;
+ * height is similarly determined for each row.
+ * The parent is made just big enough to fit them all.
+ *
+ * @param rows number of rows
+ * @param cols number of columns
+ * @param initialX x location to start the grid at
+ * @param initialY y location to start the grid at
+ * @param xPad x padding between cells
+ * @param yPad y padding between cells
+ */
+ public static void makeCompactGrid(Container parent,
+ int rows, int cols,
+ int initialX, int initialY,
+ int xPad, int yPad) {
+ SpringLayout layout;
+ try {
+ layout = (SpringLayout)parent.getLayout();
+ } catch (ClassCastException exc) {
+ System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
+ return;
+ }
+
+ //Align all cells in each column and make them the same width.
+ Spring x = Spring.constant(initialX);
+ for (int c = 0; c < cols; c++) {
+ Spring width = Spring.constant(0);
+ for (int r = 0; r < rows; r++) {
+ width = Spring.max(width,
+ getConstraintsForCell(r, c, parent, cols).
+ getWidth());
+ }
+ for (int r = 0; r < rows; r++) {
+ SpringLayout.Constraints constraints =
+ getConstraintsForCell(r, c, parent, cols);
+ constraints.setX(x);
+ constraints.setWidth(width);
+ }
+ x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
+ }
+
+ //Align all cells in each row and make them the same height.
+ Spring y = Spring.constant(initialY);
+ for (int r = 0; r < rows; r++) {
+ Spring height = Spring.constant(0);
+ for (int c = 0; c < cols; c++) {
+ height = Spring.max(height,
+ getConstraintsForCell(r, c, parent, cols).
+ getHeight());
+ }
+ for (int c = 0; c < cols; c++) {
+ SpringLayout.Constraints constraints =
+ getConstraintsForCell(r, c, parent, cols);
+ constraints.setY(y);
+ constraints.setHeight(height);
+ }
+ y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
+ }
+
+ //Set the parent's size.
+ SpringLayout.Constraints pCons = layout.getConstraints(parent);
+ pCons.setConstraint(SpringLayout.SOUTH, y);
+ pCons.setConstraint(SpringLayout.EAST, x);
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/XmlPrettyPrinter.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/XmlPrettyPrinter.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/XmlPrettyPrinter.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui;
+
+
+import org.w3c.dom.Document;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+//import org.apache.xml.serialize.OutputFormat;
+//import org.apache.xml.serialize.XMLSerializer;
+
+import java.io.IOException;
+import java.io.StringBufferInputStream;
+import java.io.ByteArrayOutputStream;
+
+import org.xml.sax.SAXException;
+
+/**
+ *
+ */
+public class XmlPrettyPrinter{
+
+ /**
+ *
+ */
+ public static String prettify(String input){
+
+ // Find the implementation
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = null;
+
+ try{
+ builder = factory.newDocumentBuilder();
+ }
+ catch(ParserConfigurationException pce){
+ System.err.println("Exception: " + pce);
+ return null;
+ }
+
+ StringBufferInputStream stringBufferInputStream = new StringBufferInputStream(input);
+
+ Document doc = null;
+
+ try{
+ doc = builder.parse(stringBufferInputStream);
+ }
+ catch(SAXException se){
+ System.err.println("Exception: " + se);
+ return null;
+ }
+ catch(IOException ioe){
+ System.err.println("Exception: " + ioe);
+ return null;
+ }
+
+ String text=null;
+
+ try {
+ text = org.pi4soa.common.xml.XMLUtils.getText(doc, true);
+ } catch(Exception e) {
+ System.err.println("Exception: " + e);
+ }
+
+ return(text);
+
+ /*
+ OutputFormat format = new OutputFormat(doc);
+ format.setLineWidth(65);
+ format.setIndenting(true);
+ format.setIndent(2);
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XMLSerializer serializer = new XMLSerializer(byteArrayOutputStream, format);
+
+ try{
+ serializer.serialize(doc);
+ }
+ catch(IOException ioe){
+ System.err.println("Exception: " + ioe);
+ return null;
+ }
+
+ return byteArrayOutputStream.toString();
+ */
+ }
+
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelclosed.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelclosed.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelempty.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelempty.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelleaf.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelleaf.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelopen.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/channelopen.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/errorsleaf.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/errorsleaf.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/issuesclosed.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/issuesclosed.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/issuesempty.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/issuesempty.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/issuesopen.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/issuesopen.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/monitor.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/monitor.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnclosed.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnclosed.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnempty.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnempty.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnleaf.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnleaf.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnopen.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/txnopen.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/unexpectedleaf.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/unexpectedleaf.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/warningsleaf.png
===================================================================
(Binary files differ)
Property changes on: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/icons/warningsleaf.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/table/TableSorter.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/table/TableSorter.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/monitor/ui/table/TableSorter.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,450 @@
+/*
+ * 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:
+ * 16 Jan, 2008 : Initial version created by martin
+ */
+package org.savara.tools.monitor.ui.table;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import java.util.List;
+
+import javax.swing.*;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.*;
+
+public class TableSorter extends AbstractTableModel {
+ protected TableModel tableModel;
+
+ public static final int DESCENDING = -1;
+ public static final int NOT_SORTED = 0;
+ public static final int ASCENDING = 1;
+
+ private static Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED);
+
+ public static final Comparator COMPARABLE_COMAPRATOR = new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return ((Comparable) o1).compareTo(o2);
+ }
+ };
+ public static final Comparator LEXICAL_COMPARATOR = new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return o1.toString().compareTo(o2.toString());
+ }
+ };
+
+ private Row[] viewToModel;
+ private int[] modelToView;
+
+ private JTableHeader tableHeader;
+ private MouseListener mouseListener;
+ private TableModelListener tableModelListener;
+ private Map columnComparators = new HashMap();
+ private List sortingColumns = new ArrayList();
+
+ public TableSorter() {
+ this.mouseListener = new MouseHandler();
+ this.tableModelListener = new TableModelHandler();
+ }
+
+ public TableSorter(TableModel tableModel) {
+ this();
+ setTableModel(tableModel);
+ }
+
+ public TableSorter(TableModel tableModel, JTableHeader tableHeader) {
+ this();
+ setTableHeader(tableHeader);
+ setTableModel(tableModel);
+ }
+
+ private void clearSortingState() {
+ viewToModel = null;
+ modelToView = null;
+ }
+
+ public TableModel getTableModel() {
+ return tableModel;
+ }
+
+ public void setTableModel(TableModel tableModel) {
+ if (this.tableModel != null) {
+ this.tableModel.removeTableModelListener(tableModelListener);
+ }
+
+ this.tableModel = tableModel;
+ if (this.tableModel != null) {
+ this.tableModel.addTableModelListener(tableModelListener);
+ }
+
+ clearSortingState();
+ fireTableStructureChanged();
+ }
+
+ public JTableHeader getTableHeader() {
+ return tableHeader;
+ }
+
+ public void setTableHeader(JTableHeader tableHeader) {
+ if (this.tableHeader != null) {
+ this.tableHeader.removeMouseListener(mouseListener);
+ TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
+ if (defaultRenderer instanceof SortableHeaderRenderer) {
+ this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
+ }
+ }
+ this.tableHeader = tableHeader;
+ if (this.tableHeader != null) {
+ this.tableHeader.addMouseListener(mouseListener);
+ this.tableHeader.setDefaultRenderer(
+ new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer()));
+ }
+ }
+
+ public boolean isSorting() {
+ return sortingColumns.size() != 0;
+ }
+
+ private Directive getDirective(int column) {
+ for (int i = 0; i < sortingColumns.size(); i++) {
+ Directive directive = (Directive)sortingColumns.get(i);
+ if (directive.column == column) {
+ return directive;
+ }
+ }
+ return EMPTY_DIRECTIVE;
+ }
+
+ public int getSortingStatus(int column) {
+ return getDirective(column).direction;
+ }
+
+ private void sortingStatusChanged() {
+ clearSortingState();
+ fireTableDataChanged();
+ if (tableHeader != null) {
+ tableHeader.repaint();
+ }
+ }
+
+ public void setSortingStatus(int column, int status) {
+ Directive directive = getDirective(column);
+ if (directive != EMPTY_DIRECTIVE) {
+ sortingColumns.remove(directive);
+ }
+ if (status != NOT_SORTED) {
+ sortingColumns.add(new Directive(column, status));
+ }
+ sortingStatusChanged();
+ }
+
+ protected Icon getHeaderRendererIcon(int column, int size) {
+ Directive directive = getDirective(column);
+ if (directive == EMPTY_DIRECTIVE) {
+ return null;
+ }
+ return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive));
+ }
+
+ private void cancelSorting() {
+ sortingColumns.clear();
+ sortingStatusChanged();
+ }
+
+ public void setColumnComparator(Class type, Comparator comparator) {
+ if (comparator == null) {
+ columnComparators.remove(type);
+ } else {
+ columnComparators.put(type, comparator);
+ }
+ }
+
+ protected Comparator getComparator(int column) {
+ Class columnType = tableModel.getColumnClass(column);
+ Comparator comparator = (Comparator) columnComparators.get(columnType);
+ if (comparator != null) {
+ return comparator;
+ }
+ if (Comparable.class.isAssignableFrom(columnType)) {
+ return COMPARABLE_COMAPRATOR;
+ }
+ return LEXICAL_COMPARATOR;
+ }
+
+ private Row[] getViewToModel() {
+ if (viewToModel == null) {
+ int tableModelRowCount = tableModel.getRowCount();
+ viewToModel = new Row[tableModelRowCount];
+ for (int row = 0; row < tableModelRowCount; row++) {
+ viewToModel[row] = new Row(row);
+ }
+
+ if (isSorting()) {
+ Arrays.sort(viewToModel);
+ }
+ }
+ return viewToModel;
+ }
+
+ public int modelIndex(int viewIndex) {
+ return getViewToModel()[viewIndex].modelIndex;
+ }
+
+ private int[] getModelToView() {
+ if (modelToView == null) {
+ int n = getViewToModel().length;
+ modelToView = new int[n];
+ for (int i = 0; i < n; i++) {
+ modelToView[modelIndex(i)] = i;
+ }
+ }
+ return modelToView;
+ }
+
+ // TableModel interface methods
+
+ public int getRowCount() {
+ return (tableModel == null) ? 0 : tableModel.getRowCount();
+ }
+
+ public int getColumnCount() {
+ return (tableModel == null) ? 0 : tableModel.getColumnCount();
+ }
+
+ public String getColumnName(int column) {
+ return tableModel.getColumnName(column);
+ }
+
+ public Class getColumnClass(int column) {
+ return tableModel.getColumnClass(column);
+ }
+
+ public boolean isCellEditable(int row, int column) {
+ return tableModel.isCellEditable(modelIndex(row), column);
+ }
+
+ public Object getValueAt(int row, int column) {
+ return tableModel.getValueAt(modelIndex(row), column);
+ }
+
+ public void setValueAt(Object aValue, int row, int column) {
+ tableModel.setValueAt(aValue, modelIndex(row), column);
+ }
+
+ // Helper classes
+
+ private class Row implements Comparable {
+ private int modelIndex;
+
+ public Row(int index) {
+ this.modelIndex = index;
+ }
+
+ public int compareTo(Object o) {
+ int row1 = modelIndex;
+ int row2 = ((Row) o).modelIndex;
+
+ for (Iterator it = sortingColumns.iterator(); it.hasNext();) {
+ Directive directive = (Directive) it.next();
+ int column = directive.column;
+ Object o1 = tableModel.getValueAt(row1, column);
+ Object o2 = tableModel.getValueAt(row2, column);
+
+ int comparison = 0;
+ // Define null less than everything, except null.
+ if (o1 == null && o2 == null) {
+ comparison = 0;
+ } else if (o1 == null) {
+ comparison = -1;
+ } else if (o2 == null) {
+ comparison = 1;
+ } else {
+ comparison = getComparator(column).compare(o1, o2);
+ }
+ if (comparison != 0) {
+ return directive.direction == DESCENDING ? -comparison : comparison;
+ }
+ }
+ return 0;
+ }
+ }
+
+ private class TableModelHandler implements TableModelListener {
+ public void tableChanged(TableModelEvent e) {
+ // If we're not sorting by anything, just pass the event along.
+ if (!isSorting()) {
+ clearSortingState();
+ fireTableChanged(e);
+ return;
+ }
+
+ // If the table structure has changed, cancel the sorting; the
+ // sorting columns may have been either moved or deleted from
+ // the model.
+ if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
+ cancelSorting();
+ fireTableChanged(e);
+ return;
+ }
+
+ // We can map a cell event through to the view without widening
+ // when the following conditions apply:
+ //
+ // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
+ // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
+ // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
+ // d) a reverse lookup will not trigger a sort (modelToView != null)
+ //
+ // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
+ //
+ // The last check, for (modelToView != null) is to see if modelToView
+ // is already allocated. If we don't do this check; sorting can become
+ // a performance bottleneck for applications where cells
+ // change rapidly in different parts of the table. If cells
+ // change alternately in the sorting column and then outside of
+ // it this class can end up re-sorting on alternate cell updates -
+ // which can be a performance problem for large tables. The last
+ // clause avoids this problem.
+ int column = e.getColumn();
+ if (e.getFirstRow() == e.getLastRow()
+ && column != TableModelEvent.ALL_COLUMNS
+ && getSortingStatus(column) == NOT_SORTED
+ && modelToView != null) {
+ int viewIndex = getModelToView()[e.getFirstRow()];
+ fireTableChanged(new TableModelEvent(TableSorter.this,
+ viewIndex, viewIndex,
+ column, e.getType()));
+ return;
+ }
+
+ // Something has happened to the data that may have invalidated the row order.
+ clearSortingState();
+ fireTableDataChanged();
+ return;
+ }
+ }
+
+ private class MouseHandler extends MouseAdapter {
+ public void mouseClicked(MouseEvent e) {
+ JTableHeader h = (JTableHeader) e.getSource();
+ TableColumnModel columnModel = h.getColumnModel();
+ int viewColumn = columnModel.getColumnIndexAtX(e.getX());
+ int column = columnModel.getColumn(viewColumn).getModelIndex();
+ if (column != -1) {
+ int status = getSortingStatus(column);
+ if (!e.isControlDown()) {
+ cancelSorting();
+ }
+ // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
+ // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
+ status = status + (e.isShiftDown() ? -1 : 1);
+ status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
+ setSortingStatus(column, status);
+ }
+ }
+ }
+
+ private static class Arrow implements Icon {
+ private boolean descending;
+ private int size;
+ private int priority;
+
+ public Arrow(boolean descending, int size, int priority) {
+ this.descending = descending;
+ this.size = size;
+ this.priority = priority;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ Color color = c == null ? Color.GRAY : c.getBackground();
+ // In a compound sort, make each succesive triangle 20%
+ // smaller than the previous one.
+ int dx = (int)(size/2*Math.pow(0.8, priority));
+ int dy = descending ? dx : -dx;
+ // Align icon (roughly) with font baseline.
+ y = y + 5*size/6 + (descending ? -dy : 0);
+ int shift = descending ? 1 : -1;
+ g.translate(x, y);
+
+ // Right diagonal.
+ g.setColor(color.darker());
+ g.drawLine(dx / 2, dy, 0, 0);
+ g.drawLine(dx / 2, dy + shift, 0, shift);
+
+ // Left diagonal.
+ g.setColor(color.brighter());
+ g.drawLine(dx / 2, dy, dx, 0);
+ g.drawLine(dx / 2, dy + shift, dx, shift);
+
+ // Horizontal line.
+ if (descending) {
+ g.setColor(color.darker().darker());
+ } else {
+ g.setColor(color.brighter().brighter());
+ }
+ g.drawLine(dx, 0, 0, 0);
+
+ g.setColor(color);
+ g.translate(-x, -y);
+ }
+
+ public int getIconWidth() {
+ return size;
+ }
+
+ public int getIconHeight() {
+ return size;
+ }
+ }
+
+ private class SortableHeaderRenderer implements TableCellRenderer {
+ private TableCellRenderer tableCellRenderer;
+
+ public SortableHeaderRenderer(TableCellRenderer tableCellRenderer) {
+ this.tableCellRenderer = tableCellRenderer;
+ }
+
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+ Component c = tableCellRenderer.getTableCellRendererComponent(table,
+ value, isSelected, hasFocus, row, column);
+ if (c instanceof JLabel) {
+ JLabel l = (JLabel) c;
+ l.setHorizontalTextPosition(JLabel.LEFT);
+ int modelColumn = table.convertColumnIndexToModel(column);
+ l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
+ }
+ return c;
+ }
+ }
+
+ private static class Directive {
+ private int column;
+ private int direction;
+
+ public Directive(int column, int direction) {
+ this.column = column;
+ this.direction = direction;
+ }
+ }
+}
Added: trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/preferences/SavaraPreferencePage.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/preferences/SavaraPreferencePage.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.monitor/src/java/org/savara/tools/preferences/SavaraPreferencePage.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2005-10 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR 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 March 2010 : Initial version created by gary
+ */
+package org.savara.tools.preferences;
+
+import org.eclipse.jface.preference.*;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * This class represents a preference page that
+ * is contributed to the Preferences dialog. By
+ * subclassing <samp>FieldEditorPreferencePage</samp>, we
+ * can use the field support built into JFace that allows
+ * us to create a page that is small and knows how to
+ * save, restore and apply itself.
+ * <p>
+ * This page is used to modify preferences only. They
+ * are stored in the preference store that belongs to
+ * the main plug-in class. That way, preferences can
+ * be accessed directly via the preference store.
+ */
+
+public class SavaraPreferencePage
+ extends FieldEditorPreferencePage
+ implements IWorkbenchPreferencePage {
+
+ public SavaraPreferencePage() {
+ super(GRID);
+ setDescription("SAVARA Preferences");
+ }
+
+ /**
+ * Creates the field editors. Field editors are abstractions of
+ * the common GUI blocks needed to manipulate various types
+ * of preferences. Each field editor knows how to save and
+ * restore itself.
+ */
+ public void createFieldEditors() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+}
\ No newline at end of file
Added: trunk/tools/plugins/org.savara.tools.validator/.classpath
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/.classpath (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/plugins/org.savara.tools.validator/.project
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/.project (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.tools.validator</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/tools/plugins/org.savara.tools.validator/Copyright.txt
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/Copyright.txt (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/Copyright.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/tools/plugins/org.savara.tools.validator/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA Tools Validator Plug-in
+Bundle-SymbolicName: org.savara.tools.validator;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.tools.validator.osgi.Activator
+Bundle-Vendor: www.savara.org
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.pi4soa.common,
+ org.eclipse.core.resources,
+ org.pi4soa.cdl
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
Added: trunk/tools/plugins/org.savara.tools.validator/build.properties
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/build.properties (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,14 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ Copyright.txt
+src.includes = .classpath,\
+ .project,\
+ .settings/,\
+ Copyright.txt,\
+ META-INF/,\
+ build.properties,\
+ plugin.xml,\
+ src/
Added: trunk/tools/plugins/org.savara.tools.validator/plugin.xml
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/plugin.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/plugin.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.pi4soa.common.annotationsManager">
+ <annotationsManager
+ class="org.savara.tools.validator.osgi.ValidatorAnnotations">
+ </annotationsManager>
+ </extension>
+
+</plugin>
Added: trunk/tools/plugins/org.savara.tools.validator/pom.xml
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/pom.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,16 @@
+<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.tools</groupId>
+ <artifactId>org.savara.tools.validator</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ToolsValidator</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+</project>
Added: trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/Activator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,74 @@
+package org.savara.tools.validator.osgi;
+
+import java.util.logging.Logger;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.savara.tools.validator";
+
+ // 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 {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * This method logs an error against the plugin.
+ *
+ * @param mesg The error message
+ * @param t The optional exception
+ */
+ public static void logError(String mesg, Throwable t) {
+
+ if (getDefault() != null) {
+ Status status=new Status(IStatus.ERROR,
+ PLUGIN_ID, 0, mesg, t);
+
+ getDefault().getLog().log(status);
+ }
+
+ logger.severe("LOG ERROR: "+mesg+
+ (t == null ? "" : ": "+t));
+ }
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.validator.osgi");
+}
Added: trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/ValidatorAnnotations.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/ValidatorAnnotations.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/ValidatorAnnotations.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 21 Oct 2008 : Initial version created by gary
+ */
+package org.savara.tools.validator.osgi;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.pi4soa.common.annotations.eclipse.EclipseAnnotationsManager;
+
+/**
+ * This class implements the AnnotationsManager extension point.
+ */
+public class ValidatorAnnotations extends EclipseAnnotationsManager {
+
+ public ValidatorAnnotations() {
+ super(Activator.PLUGIN_ID);
+ }
+
+ /**
+ * This method returns an input stream associated with the
+ * supplied URL. The URL can also reference a local relative
+ * file path.
+ *
+ * @param url The URL, or relative file path
+ * @return The input stream
+ */
+ protected java.io.InputStream getInputStream(String url) {
+ java.io.InputStream ret=null;
+
+ try {
+ String path=ANNOTATIONS_FOLDER +
+ PATH_SEPARATOR + url;
+
+ logger.fine("Load from path: "+path);
+
+ ret = ValidatorAnnotations.class.getResourceAsStream(path);
+
+ } catch(Exception e) {
+ logger.severe("Failed to get input stream for URL '"+
+ url+"': "+e);
+ }
+
+ if (logger.isLoggable(Level.FINEST)) {
+ logger.finest("Ret="+ret);
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.savara.tools.validator.osgi");
+
+ private static final String ANNOTATIONS_FOLDER="annotations";
+ private static final String PATH_SEPARATOR = "/";
+}
Added: trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/annotations.xml
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/annotations.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/annotations.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,8 @@
+<annotations>
+ <annotation type="validator" component="org.pi4soa.cdl.ExchangeDetails" >
+ <template url="cdl/validator.template"
+ processor="org.pi4soa.common.annotations.impl.DefaultTemplateProcessor" />
+ <presentation url="cdl/validator.presentation"
+ processor="org.pi4soa.common.annotations.impl.XSLTPresentationProcessor" />
+ </annotation>
+</annotations>
\ No newline at end of file
Added: trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/cdl/validator.presentation
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/cdl/validator.presentation (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/cdl/validator.presentation 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,3 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/">
+The Service destination is <xsl:if test="validator/destination/@name != ''" >'<xsl:value-of select="validator/destination/@name" />' </xsl:if><xsl:if test="validator/destination/@name = ''" >'undefined' </xsl:if> [Type=<xsl:value-of select="validator/destination/@type"/>] [Dynamic Reply-To Destination=<xsl:value-of select="validator/destination/@dynamicReplyTo"/>]</xsl:template></xsl:stylesheet>
\ No newline at end of file
Added: trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/cdl/validator.template
===================================================================
--- trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/cdl/validator.template (rev 0)
+++ trunk/tools/plugins/org.savara.tools.validator/src/java/org/savara/tools/validator/osgi/annotations/cdl/validator.template 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,5 @@
+<validator>
+ <destination name="{{Destination;The URI for the destination;string;;}}"
+ type="{{Type;The type of destination;enum;endpoint address,service name;endpoint address}}" />
+ dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
+</validator>
Added: trunk/tools/plugins/org.savara.tools.wsdl/.classpath
===================================================================
--- trunk/tools/plugins/org.savara.tools.wsdl/.classpath (rev 0)
+++ trunk/tools/plugins/org.savara.tools.wsdl/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <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="src" path="src/java"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
Added: trunk/tools/plugins/org.savara.tools.wsdl/.project
===================================================================
--- trunk/tools/plugins/org.savara.tools.wsdl/.project (rev 0)
+++ trunk/tools/plugins/org.savara.tools.wsdl/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.tools.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/tools/plugins/org.savara.tools.wsdl/Copyright.txt
===================================================================
--- trunk/tools/plugins/org.savara.tools.wsdl/Copyright.txt (rev 0)
+++ trunk/tools/plugins/org.savara.tools.wsdl/Copyright.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/tools/plugins/org.savara.tools.wsdl/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.savara.tools.wsdl/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.savara.tools.wsdl/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA Tools WSDL Plug-in
+Bundle-SymbolicName: org.savara.tools.wsdl;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.tools.wsdl.osgi.Activator
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: www.savara.org
+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.eclipse.core.resources,
+ org.eclipse.jface,
+ org.eclipse.ui,
+ org.scribble.eclipse;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.core.runtime,
+ org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)",
+ org.savara.wsdl
+Bundle-ActivationPolicy: lazy
Added: trunk/tools/plugins/org.savara.tools.wsdl/build.properties
===================================================================
--- trunk/tools/plugins/org.savara.tools.wsdl/build.properties (rev 0)
+++ trunk/tools/plugins/org.savara.tools.wsdl/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,14 @@
+source.. = src/java/
+output.. = classes/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ build.properties,\
+ Copyright.txt
+src.includes = .classpath,\
+ .project,\
+ Copyright.txt,\
+ META-INF/,\
+ build.properties,\
+ plugin.xml,\
+ src/
Added: trunk/tools/plugins/org.savara.tools.wsdl/plugin.xml
===================================================================
--- trunk/tools/plugins/org.savara.tools.wsdl/plugin.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tools.wsdl/plugin.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ id="org.jboss.tools.overlord.cdl.bpel.object.contribution"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.cdm">
+ <menu
+ id="org.savara.tools.menu"
+ label="Savara"
+ path="additions">
+ <separator name="group1"/>
+ </menu>
+ <menu
+ id="generate.menu"
+ label="Generate"
+ path="org.savara.tools.menu/additions">
+ <separator name="group2"/>
+ </menu>
+ <action
+ label="WSDL"
+ class="org.savara.tools.wsdl.actions.GenerateAction"
+ menubarPath="org.savara.tools.menu/generate.menu/group2"
+ enablesFor="1"
+ id="org.savara.tools.wsdl.actions.GenerateAction">
+ </action>
+ </objectContribution>
+ </extension>
+
+</plugin>
Added: trunk/tools/plugins/org.savara.tools.wsdl/pom.xml
===================================================================
--- trunk/tools/plugins/org.savara.tools.wsdl/pom.xml (rev 0)
+++ trunk/tools/plugins/org.savara.tools.wsdl/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,29 @@
+<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.tools</groupId>
+ <artifactId>org.savara.tools.wsdl</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ToolsWSDL</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <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.wsdl</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
Added: trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/actions/GenerateAction.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/actions/GenerateAction.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/actions/GenerateAction.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,314 @@
+/*
+ * 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.actions;
+
+import org.apache.commons.logging.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.Interface;
+import org.savara.contract.model.Namespace;
+import org.savara.tools.wsdl.util.XMLUtils;
+import org.savara.wsdl.generator.WSDLGeneratorFactory;
+import org.savara.wsdl.generator.soap.SOAPDocLitWSDLBinding;
+import org.scribble.conversation.model.ConversationModel;
+import org.scribble.eclipse.util.*;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.Model;
+import org.scribble.model.ModelReference;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.model.admin.ModelRepository;
+
+/**
+ * This class implements the action to generate the choreography
+ * as a set of WSDL definition.
+ */
+public class GenerateAction implements IObjectActionDelegate {
+
+ private static final String CANNOT_GENERATE = "Choreography has errors, so cannot generate";
+
+ public GenerateAction() {
+ }
+
+ /**
+ * This method implements the action's run method.
+ *
+ * @param action The action
+ */
+ public void run(IAction action) {
+ if (m_selection instanceof StructuredSelection) {
+ StructuredSelection sel=(StructuredSelection)m_selection;
+
+ IResource res=(IResource)sel.getFirstElement();
+
+ if (res instanceof IFile) {
+
+ if (ResourceUtil.hasErrors(res) == false) {
+
+ generateWSDL((IFile)res);
+
+ } else {
+ warn(CANNOT_GENERATE);
+ }
+ }
+ }
+ }
+
+ /**
+ * This method generates the WSDL associated
+ * with the supplied file resource.
+ *
+ * @param res The file
+ */
+ protected void generateWSDL(IFile res) {
+ ModelReference ref=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.createReference(res);
+ ConversationModel conversationModel=null;
+ java.util.List<ModelReference> localModelRefs=null;
+
+ if (ref != null) {
+ ModelRepository mrep=(ModelRepository)
+ RegistryFactory.getRegistry().getExtension(
+ ModelRepository.class, null);
+
+ if (mrep != null) {
+ Model model=mrep.getModel(ref,
+ new DefaultModelListener());
+
+ if (model instanceof ConversationModel) {
+ conversationModel = (ConversationModel)model;
+
+ localModelRefs = conversationModel.getLocalModels(ref);
+ }
+ }
+ }
+
+ if (conversationModel == null) {
+ logger.error("Unable to load model used to generate " +
+ "the BPEL artefacts", null);
+ } else if (localModelRefs != null) {
+ for (ModelReference mref : localModelRefs) {
+
+ try {
+ generateWSDL(conversationModel, mref, res);
+ } catch(Exception e) {
+ org.savara.tools.wsdl.osgi.Activator.logError("Failed to generate WSDL for '"+res+"'", e);
+ }
+ }
+ }
+ }
+
+ protected void generateWSDL(ConversationModel cm, ModelReference ref, IResource cdmResource) throws Exception {
+
+ if (ref.getAnnotations().containsKey(Contract.class.getName())) {
+ javax.wsdl.xml.WSDLWriter writer=
+ javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
+ org.savara.wsdl.generator.WSDLGenerator generator=
+ WSDLGeneratorFactory.getWSDLGenerator();
+ Contract contract=(Contract)ref.getAnnotations().get(Contract.class.getName());
+
+ // Generate WSDL folder
+ IPath wsdlFolderPath=cdmResource.getParent().getFullPath();
+
+ // Generate definition
+ java.util.List<javax.wsdl.Definition> defns=generator.generate(contract,
+ new SOAPDocLitWSDLBinding());
+
+ // Check if contract has atleast one message exchange pattern
+ boolean f_hasMEP=false;
+
+ java.util.Iterator<Interface> iter=contract.getInterfaces().iterator();
+
+ while (f_hasMEP == false && iter.hasNext()) {
+ Interface intf=iter.next();
+ f_hasMEP = (intf.getMessageExchangePatterns().size() > 0);
+ }
+
+ for (int i=defns.size()-1; i >= 0; i--) {
+ javax.wsdl.Definition defn=defns.get(i);
+
+ // Check if definition has a port type
+ if (defn.getPortTypes().size() > 0 || defn.getMessages().size() > 0
+ || (f_hasMEP && defn.getServices().size() > 0)) {
+ byte[] b=null; // Bytes to write out
+
+ String num="";
+ if (i > 0) {
+ num += i;
+ }
+
+ String filename=cm.getModelName().getName()+"_"+ref.getLocatedRole()+num+".wsdl";
+
+ if (i > 0) {
+ javax.wsdl.Import imp=defns.get(0).createImport();
+
+ imp.setDefinition(defn);
+ imp.setNamespaceURI(defn.getTargetNamespace());
+ imp.setLocationURI(filename);
+
+ defns.get(0).addImport(imp);
+
+ java.io.ByteArrayOutputStream baos=new java.io.ByteArrayOutputStream();
+
+ writer.writeWSDL(defn, baos);
+
+ b=baos.toByteArray();
+
+ baos.close();
+
+ } else {
+
+ // NOTE: Unfortunate workaround due to issue with WSDLWriter not
+ // generating output for extensible elements created to represent
+ // the xsd:schema/xsd:import elements. So instead had to obtain
+ // the DOM document and insert the relevant elements.
+
+ org.w3c.dom.Document doc=writer.getDocument(defn);
+
+ if (contract.getNamespaces().size() > 0) {
+ org.w3c.dom.Element defnElem=doc.getDocumentElement();
+
+ // Added types node
+ org.w3c.dom.Element types=doc.createElementNS("http://schemas.xmlsoap.org/wsdl/",
+ "types");
+
+ org.w3c.dom.Element schema=doc.createElementNS("http://www.w3.org/2001/XMLSchema",
+ "schema");
+
+ types.appendChild(schema);
+
+ // Generate imports for specified message schema
+ for (Namespace ns : contract.getNamespaces()) {
+
+ if (ns.getSchemaLocation() != null &&
+ ns.getSchemaLocation().trim().length() > 0) {
+
+ java.util.StringTokenizer st=new java.util.StringTokenizer(ns.getSchemaLocation());
+
+ while (st.hasMoreTokens()) {
+ String location=st.nextToken();
+ IFile file=cdmResource.getParent().getFile(new Path(location));
+
+ org.w3c.dom.Element imp=doc.createElementNS("http://www.w3.org/2001/XMLSchema",
+ "import");
+
+ imp.setAttribute("namespace", ns.getURI());
+
+ if (file.exists()) {
+ IPath relative=file.getFullPath().makeRelativeTo(wsdlFolderPath);
+ imp.setAttribute("schemaLocation", relative.toPortableString());
+ } else {
+ imp.setAttribute("schemaLocation", location);
+ }
+
+ schema.appendChild(imp);
+ }
+ }
+ }
+
+ defnElem.insertBefore(types, defnElem.getFirstChild());
+ }
+
+ // Create bytearray from DOM
+ java.io.ByteArrayOutputStream xmlstr=
+ new java.io.ByteArrayOutputStream();
+
+ DOMSource source=new DOMSource();
+ source.setNode(doc);
+
+ StreamResult result=new StreamResult(xmlstr);
+
+ Transformer trans=
+ TransformerFactory.newInstance().newTransformer();
+ trans.transform(source, result);
+
+ xmlstr.close();
+
+ b = XMLUtils.format(new String(xmlstr.toByteArray())).getBytes();
+ }
+
+ IPath wsdlPath=wsdlFolderPath.append(filename);
+
+ IFile wsdlFile=cdmResource.getProject().getWorkspace().getRoot().getFile(wsdlPath);
+
+ wsdlFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ wsdlFile.setContents(new java.io.ByteArrayInputStream(b), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+ }
+ }
+ }
+
+
+ /**
+ * This method indicates that the selection has changed.
+ *
+ * @param action The action
+ * @param selection The selection
+ */
+ public void selectionChanged(IAction action,
+ ISelection selection) {
+ m_selection = selection;
+ }
+
+ /**
+ * This method sets the currently active workbench part.
+ *
+ * @param action The action
+ * @param targetPart The active workbench part
+ */
+ public void setActivePart(IAction action,
+ IWorkbenchPart targetPart) {
+ m_targetPart = targetPart;
+ }
+
+ /**
+ * This method is used to report a warning.
+ *
+ * @param mesg The warning message
+ */
+ public void warn(String mesg) {
+
+ MessageBox mbox=new MessageBox(m_targetPart.getSite().getShell(),
+ SWT.ICON_WARNING|SWT.OK);
+ mbox.setMessage(mesg);
+ mbox.open();
+ }
+
+ private static Log logger = LogFactory.getLog(GenerateAction.class);
+
+ private ISelection m_selection=null;
+ private IWorkbenchPart m_targetPart=null;
+}
Added: trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/osgi/Activator.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,73 @@
+package org.savara.tools.wsdl.osgi;
+
+import org.apache.commons.logging.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.savara.tools.wsdl";
+
+ // 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 {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * This method logs an error against the plugin.
+ *
+ * @param mesg The error message
+ * @param t The optional exception
+ */
+ public static void logError(String mesg, Throwable t) {
+
+ if (getDefault() != null) {
+ Status status=new Status(IStatus.ERROR,
+ PLUGIN_ID, 0, mesg, t);
+
+ getDefault().getLog().log(status);
+ }
+
+ logger.error("LOG ERROR: "+mesg+
+ (t == null ? "" : ": "+t), t);
+ }
+
+ private static Log logger = LogFactory.getLog(Activator.class);
+}
Added: trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/util/XMLUtils.java
===================================================================
--- trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/util/XMLUtils.java (rev 0)
+++ trunk/tools/plugins/org.savara.tools.wsdl/src/java/org/savara/tools/wsdl/util/XMLUtils.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.tools.wsdl.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/tools/plugins/org.scribble.eclipse/.classpath
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/.classpath (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/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/tools/plugins/org.scribble.eclipse/.project
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/.project (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.scribble.eclipse</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/tools/plugins/org.scribble.eclipse/LICENSE.txt
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/LICENSE.txt (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/LICENSE.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/tools/plugins/org.scribble.eclipse/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scribble Eclipse Support Plug-in
+Bundle-SymbolicName: org.scribble.eclipse;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.scribble.eclipse.osgi.Activator
+Bundle-Vendor: www.scribble.org
+Require-Bundle: org.eclipse.core.runtime,
+ org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.core.resources,
+ org.eclipse.swt,
+ org.eclipse.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.editors,
+ org.eclipse.jdt.core
+Bundle-ActivationPolicy: lazy
+Scribble-Extensions: org.scribble.eclipse.model.admin.OSGIModelRepository
+Export-Package: org.scribble.eclipse.model.admin,
+ org.scribble.eclipse.util
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added: trunk/tools/plugins/org.scribble.eclipse/build.properties
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/build.properties (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,5 @@
+source.. = src/java/
+output.. = classes/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: trunk/tools/plugins/org.scribble.eclipse/plugin.xml
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/plugin.xml (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/plugin.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.startup">
+ <startup
+ class="org.scribble.eclipse.osgi.Activator">
+ </startup>
+ </extension>
+
+ <extension
+ id="org.scribble.ScribbleProblem"
+ name="Testable Architecture Problem"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.core.resources.problemmarker">
+ </super>
+ <persistent
+ value="true">
+ </persistent>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.ide.markerResolution">
+ <markerResolutionGenerator
+ markerType="org.scribble.ScribbleProblem"
+ class="org.scribble.eclipse.resolutions.MarkerResolutionGenerator">
+ </markerResolutionGenerator>
+ </extension>
+
+<!--
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ id="org.scribble.contribution.spr"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.spr">
+ <menu
+ id="org.scribble.menu"
+ label="Scribble"
+ path="additions">
+ <separator name="group1"/>
+ </menu>
+ <action
+ label="Project"
+ class="org.scribble.eclipse.actions.ProjectAction"
+ menubarPath="org.scribble.menu/group1"
+ enablesFor="1"
+ id="org.scribble.eclipse.actions.ProjectAction">
+ </action>
+ <action
+ label="Export as Text"
+ class="org.scribble.eclipse.actions.ExportTextAction"
+ menubarPath="org.scribble.menu/group1"
+ enablesFor="1"
+ id="org.scribble.eclipse.actions.ExportTextAction">
+ </action>
+ </objectContribution>
+ <objectContribution
+ id="org.scribble.contribution.scv"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.scv">
+ <menu
+ id="org.scribble.menu"
+ label="Scribble"
+ path="additions">
+ <separator name="group1"/>
+ </menu>
+ <action
+ label="Project"
+ class="org.scribble.eclipse.actions.ProjectAction"
+ menubarPath="org.scribble.menu/group1"
+ enablesFor="1"
+ id="org.scribble.eclipse.actions.ProjectAction">
+ </action>
+ <action
+ label="Export as Text"
+ class="org.scribble.eclipse.actions.ExportTextAction"
+ menubarPath="org.scribble.menu/group1"
+ enablesFor="1"
+ id="org.scribble.eclipse.actions.ExportTextAction">
+ </action>
+ </objectContribution>
+ </extension>
+-->
+
+</plugin>
Added: trunk/tools/plugins/org.scribble.eclipse/pom.xml
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/pom.xml (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.tools</groupId>
+ <artifactId>org.scribble.eclipse</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ScribbleEclipse</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</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>
+ </dependencies>
+</project>
Added: trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIDefinitions.java
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIDefinitions.java (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIDefinitions.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,30 @@
+/*
+ * 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:
+ * 21 Feb 2008 : Initial version created by gary
+ */
+package org.scribble.eclipse.model.admin;
+
+/**
+ * This class contains common definitions used by Scribble OSGI related
+ * components.
+ */
+public class OSGIDefinitions {
+
+ public static final String SCRIBBLE_PROBLEM = "org.scribble.ScribbleProblem";
+
+}
Added: trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelListener.java
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelListener.java (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelListener.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,327 @@
+/*
+ * 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.eclipse.model.admin;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.scribble.eclipse.osgi.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.util.*;
+
+/**
+ * This class implements a model listener that reports information to
+ * the Eclipse problems view.
+ */
+public class OSGIModelListener implements org.scribble.model.admin.ModelListener {
+
+ public static final String MODEL_NOTATION = "modelNotation";
+ public static final String MODEL_LOCATED_ROLE = "modelLocatedRole";
+ public static final String MODEL_LOCALPART = "modelLocalpart";
+ public static final String MODEL_NAMESPACE = "modelNamespace";
+ public static final String MODEL_PROP_PREFIX = "_mp_";
+ public static final String SOURCE_MODEL_OBJECT_URI = "sourceModelObjectURI";
+ public static final String SOURCE_COMPONENT_URI = "sourceComponentURI";
+
+ /**
+ * This method is the constructor for the validation model
+ * listener.
+ *
+ * @param ref The model reference
+ */
+ public OSGIModelListener(ModelReference ref) {
+ m_reference = ref;
+
+ m_resource = OSGIModelRepository.getFile(m_reference);
+
+ if (m_resource == null) {
+ logger.severe("Resource not found - cannot listen for problems: "+
+ m_reference);
+ }
+ }
+
+ /**
+ * This method is the constructor for the validation model
+ * listener.
+ *
+ * @param ref The model reference
+ */
+ public OSGIModelListener(IResource res) {
+ m_resource = res;
+ }
+
+ public void error(ModelIssue issue) {
+ reportIssue(issue, ReportEntry.ERROR_TYPE);
+ }
+
+ public void warning(ModelIssue issue) {
+ reportIssue(issue, ReportEntry.WARNING_TYPE);
+ }
+
+ protected void reportIssue(ModelIssue issue, int issueType) {
+
+ if (m_resource != null) {
+ // Find notation for the resource name
+ org.scribble.model.Notation notation=
+ ResourceUtil.getNotation(m_resource.getName());
+
+ 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) {
+ em.enrich(issue);
+ }
+ }
+
+ synchronized(m_entries) {
+ m_entries.add(new ReportEntry(issue, issueType));
+ }
+
+ if (m_finished) {
+ // Publish immediately
+ finished();
+ }
+ }
+ }
+
+ public void finished() {
+ org.eclipse.swt.widgets.Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+
+ if (m_resource != null && m_resource.exists()) {
+ // Clear current markers
+ try {
+ synchronized(m_entries) {
+
+ if (m_finished == false) {
+ m_resource.deleteMarkers(OSGIDefinitions.SCRIBBLE_PROBLEM, true,
+ IResource.DEPTH_INFINITE);
+ m_finished = true;
+ }
+
+ // Update the markers
+ for (int i=0; i < m_entries.size(); i++) {
+ ReportEntry re=(ReportEntry)m_entries.get(i);
+
+ if (m_reported.contains(re) == false) {
+ createMarker(re.getSource(), re.getStartPosition(),
+ re.getEndPosition(),
+ re.getMessage(), re.getType(),
+ re.getProperties());
+
+ m_reported.add(re);
+ }
+ }
+
+ m_entries.clear();
+ }
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to update problems", e);
+ Activator.logError("Failed to update problems " +
+ "view with validation messages",e);
+ }
+ }
+ }
+ });
+ }
+
+ protected void createMarker(ModelObject src, int startPos, int endPos, String mesg,
+ int type, java.util.Map<String,Object> props) {
+
+ // Create marker for message
+ try {
+ IMarker marker=m_resource.createMarker(OSGIDefinitions.SCRIBBLE_PROBLEM);
+
+ // Initialize the attributes on the marker
+ marker.setAttribute(IMarker.MESSAGE, mesg);
+
+ if (type == ReportEntry.ERROR_TYPE) {
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ } else if (type == ReportEntry.WARNING_TYPE) {
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
+ } else if (type == ReportEntry.INFORMATION_TYPE) {
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
+ }
+
+ if (startPos >= 0) {
+ marker.setAttribute(IMarker.CHAR_START, startPos);
+ }
+
+ if (endPos >= 0) {
+ marker.setAttribute(IMarker.CHAR_END, endPos);
+ }
+
+ if (src != null && src.getSource() != null) {
+ marker.setAttribute(SOURCE_MODEL_OBJECT_URI, src.getSource().getModelObjectURI());
+ marker.setAttribute(SOURCE_COMPONENT_URI, src.getSource().getComponentURI());
+ }
+
+ if (m_reference != null) {
+ marker.setAttribute(MODEL_NAMESPACE, m_reference.getNamespace());
+ marker.setAttribute(MODEL_LOCALPART, m_reference.getLocalpart());
+ marker.setAttribute(MODEL_LOCATED_ROLE, m_reference.getLocatedRole());
+ marker.setAttribute(MODEL_NOTATION, m_reference.getNotation());
+
+ java.util.Iterator<String> propiter=m_reference.getPropertyNames().iterator();
+
+ while (propiter.hasNext()) {
+ String name=propiter.next();
+ Object val=convertValue(m_reference.getProperty(name));
+
+ if (val != null) {
+ marker.setAttribute(MODEL_PROP_PREFIX+name, val);
+ }
+ }
+ }
+
+ // Transfer properties
+ if (props != null) {
+ java.util.Iterator<String> iter=props.keySet().iterator();
+
+ while (iter.hasNext()) {
+ String prop=iter.next();
+ Object value=props.get(prop);
+
+ if (value != null) {
+ value = convertValue(value);
+
+ if (value instanceof Integer) {
+ marker.setAttribute(prop, ((Integer)value).intValue());
+ } else if (value instanceof Boolean) {
+ marker.setAttribute(prop, ((Boolean)value).booleanValue());
+ } else if (value instanceof String) {
+ marker.setAttribute(prop, value);
+ } else {
+ logger.warning("Could not record property '"+
+ prop+"' as not int, boolean or string");
+ }
+ }
+ }
+ }
+ } catch(Exception e) {
+
+ // TODO: report error
+ e.printStackTrace();
+ }
+ }
+
+ protected Object convertValue(Object value) {
+ Object ret=value;
+
+ if (value instanceof ModelReference) {
+ org.eclipse.core.resources.IFile file=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.getFile(
+ (ModelReference)value);
+
+ if (file == null || file.exists() == false) {
+ file = org.scribble.eclipse.model.admin.OSGIModelRepository.getGlobalFile(
+ (ModelReference)value);
+ }
+
+ if (file != null && file.exists()) {
+ ret = file.getFullPath().toPortableString();
+ }
+ } else if (value instanceof IResource) {
+ ret = ((IResource)value).getFullPath().toPortableString();
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.scribble.eclipse");
+
+ private ModelReference m_reference=null;
+ private IResource m_resource=null;
+ private boolean m_finished=false;
+ private java.util.Vector<ReportEntry> m_entries=new java.util.Vector<ReportEntry>();
+ private java.util.Vector<ReportEntry> m_reported=new java.util.Vector<ReportEntry>();
+
+ /**
+ * This is a simple data container class to hold the
+ * information reported during validation.
+ *
+ */
+ public class ReportEntry {
+ public ReportEntry(ModelIssue issue, int type) {
+ m_issue = issue;
+ m_type = type;
+ }
+
+ public ModelObject getSource() {
+ return(m_issue.getModelObject());
+ }
+
+ public int getStartPosition() {
+ return(m_issue.getModelObject() == null ? -1 : m_issue.getModelObject().getSource().getStartPosition());
+ }
+
+ public int getEndPosition() {
+ return(m_issue.getModelObject() == null ? -1 : m_issue.getModelObject().getSource().getEndPosition());
+ }
+
+ public String getMessage() {
+ return(m_issue.getMessage());
+ }
+
+ public int getType() {
+ return(m_type);
+ }
+
+ public java.util.Map<String,Object> getProperties() {
+ java.util.Map<String,Object> ret=m_issue.getProperties();
+
+ if (m_issue.getResolutions().size() > 0) {
+ java.util.Map<String,Object> resProps=
+ ModelIssueUtil.serializeResolutions(m_issue.getResolutions());
+
+ ret.putAll(resProps);
+ }
+
+ return(ret);
+ }
+
+ public int hashCode() {
+ return(m_issue.hashCode());
+ }
+
+ public boolean equals(Object obj) {
+ boolean ret=false;
+
+ if (obj instanceof ReportEntry) {
+ ret = m_issue.equals(((ReportEntry)obj).m_issue);
+ }
+
+ return(ret);
+ }
+
+ public static final int ERROR_TYPE=0;
+ public static final int WARNING_TYPE=1;
+ public static final int INFORMATION_TYPE=2;
+
+ private ModelIssue m_issue=null;
+ private int m_type=0;
+ }
+}
Added: trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelRepository.java
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelRepository.java (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelRepository.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,403 @@
+/*
+ * 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.eclipse.model.admin;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.AbstractModelRepository;
+import org.scribble.model.admin.ModelRepository;
+
+import java.util.logging.*;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.IJavaProject;
+
+/**
+ * This class represents the abstract implementation for the
+ * OSGi model repository. Derived classes will be responsible
+ * for grounding the implementation with a specific Scribble
+ * notation type.
+ *
+ */
+ at RegistryInfo(extension=ModelRepository.class)
+public class OSGIModelRepository extends AbstractModelRepository {
+
+ private static final String SUB_DEFN_PATH_SEPARATOR = "$";
+
+ /**
+ * This is the default constructor for the abstract OSGi Model Repository.
+ */
+ public OSGIModelRepository() {
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ protected void updateModel(ModelReference ref, java.io.InputStream is)
+ throws java.io.IOException {
+ IFile file=getFile(ref);
+
+ /* GPB: 29/6/09 not sure should change file, as the contents
+ * will be geared towards the located file.
+ *
+ if (file == null) {
+ file = getGlobalFile(ref);
+ }
+ */
+
+ if (file != null) {
+ try {
+ file.setContents(is, true, true, new NullProgressMonitor());
+ } catch (CoreException e) {
+ throw new java.io.IOException("Failed to update file contents");
+ }
+
+ is.close();
+ }
+ }
+
+ /**
+ * This method returns the input stream for the source associated
+ * with the model reference.
+ *
+ * @param ref The model reference
+ * @return The input stream
+ */
+ public java.io.InputStream getInputStream(ModelReference ref) {
+ java.io.InputStream ret=null;
+
+ IFile file=getFile(ref);
+
+ if (file != null) {
+ try {
+ ret = file.getContents();
+ } catch(Exception e) {
+ // Ignore for now
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the file for the global source associated
+ * with the model reference.
+ *
+ * @param ref The model reference
+ * @return The file
+ */
+ public static IFile getGlobalFile(ModelReference ref) {
+ IFile ret=null;
+
+ Object obj=ref.getProperty(GLOBAL_RESOURCE_PROPERTY);
+
+ if (obj instanceof IFile) {
+ ret = (IFile)obj;
+
+ } else if (obj instanceof String) {
+ // Assume is URL for the project
+ IWorkspaceRoot root=
+ ResourcesPlugin.getWorkspace().getRoot();
+
+ ret = root.getFile(new Path((String)obj));
+
+ if (ret != null) {
+ // Replace with File object to avoid
+ // having to resolve again
+ ref.setProperty(GLOBAL_RESOURCE_PROPERTY, ret);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns a reference to a file associated with
+ * the supplied model reference. The file may refer to an
+ * existing resource, and this must be checked by the client.
+ *
+ * @param ref The model reference
+ * @return The created file, or null if no project information
+ * was associated with the reference
+ */
+ public static IFile createFile(ModelReference ref) {
+ IFile ret=null;
+
+ if (ref.getProperty(PROJECT_PROPERTY) != null &&
+ ref.getNamespace() != null &&
+ ref.getLocalpart() != null) {
+
+ // Need to locate resource based on namespace, localpart
+ // and notation
+ String path=ref.getNamespace();
+
+ path = path.replace('.', java.io.File.separatorChar);
+
+ path += java.io.File.separator+ref.getLocalpart();
+
+ if (ref.getLocatedRole() != null) {
+ path += ModelReference.LOCATED_REFERENCE_SEPARATOR+
+ ref.getLocatedRole();
+ }
+
+ path += "."+ref.getNotation();
+
+ IProject project=getProject(ref);
+
+ ret = project.getFile(path);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the project associated with the
+ * supplied object.
+ *
+ * @param ref The model reference
+ * @return The project, or null if not found
+ */
+ public static IProject getProject(ModelReference ref) {
+ IProject ret=null;
+
+ Object obj=ref.getProperty(PROJECT_PROPERTY);
+
+ if (obj instanceof IProject) {
+ ret = (IProject)obj;
+ } else if (obj instanceof String) {
+ // Assume is URL for the project
+ IWorkspaceRoot root=
+ ResourcesPlugin.getWorkspace().getRoot();
+
+ ret = root.getProject((String)obj);
+
+ if (ret != null) {
+ // Replace with Project object to avoid
+ // having to resolve again
+ ref.setProperty(PROJECT_PROPERTY, ret);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the file for the source associated
+ * with the model reference.
+ *
+ * @param ref The model reference
+ * @return The file
+ */
+ public static IFile getFile(ModelReference ref) {
+ IFile ret=null;
+
+ Object obj=ref.getProperty(RESOURCE_PROPERTY);
+
+ if (obj instanceof IFile) {
+ ret = (IFile)obj;
+
+ } else if (obj instanceof String) {
+ // Assume is URL for the project
+ IWorkspaceRoot root=
+ ResourcesPlugin.getWorkspace().getRoot();
+
+ ret = root.getFile(new Path((String)obj));
+
+ if (ret != null) {
+ // Replace with File object to avoid
+ // having to resolve again
+ ref.setProperty(RESOURCE_PROPERTY, ret);
+ }
+ } else if (ref.hasProperty(PROJECT_PROPERTY) &&
+ ref.getNamespace() != null &&
+ ref.getLocalpart() != null) {
+
+ // Need to locate resource based on namespace, localpart
+ // and notation
+ String path=ref.getNamespace();
+
+ path = path.replace('.', java.io.File.separatorChar);
+
+ path += java.io.File.separator+ref.getLocalpart();
+
+ if (ref.getLocatedRole() != null) {
+
+ // Check if sub definition path defined
+ for (int i=0; i < ref.getSubDefinitionPath().getPathElementCount(); i++) {
+ path += SUB_DEFN_PATH_SEPARATOR+ref.getSubDefinitionPath().getPathElement(i);
+ }
+
+ path += ModelReference.LOCATED_REFERENCE_SEPARATOR+
+ ref.getLocatedRole();
+ }
+
+ path += "."+ref.getNotation();
+
+ IProject project=getProject(ref);
+
+ ret = findFileInProjectPath(project, path);
+
+ if (ret != null && ret.exists()) {
+ ref.setProperty(RESOURCE_PROPERTY, ret);
+ } else {
+ ret = null;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method sets the file as the resource associated
+ * with the model reference.
+ *
+ * @param ref The reference
+ * @param file The file
+ */
+ public static void setFile(ModelReference ref, IFile file) {
+ ref.setProperty(RESOURCE_PROPERTY, file);
+ }
+
+ protected static IFile findFileInProjectPath(IProject project, String path) {
+ IFile ret=null;
+
+ // Find project associated with the reference
+ if (project != null) {
+ ret = project.getFile(path);
+
+ if (ret == null || ret.exists() == false) {
+
+ ret = null;
+
+ // Check related projects
+ IJavaProject jproject=JavaCore.create(project);
+
+ try {
+ // Check if a Java project
+ if (project.hasNature(JavaCore.NATURE_ID)) {
+ String projects[]=jproject.getRequiredProjectNames();
+
+ for (int i=0; ret == null && i < projects.length; i++) {
+ IProject dependent=
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().
+ getRoot().getProject(projects[i]);
+
+ ret = findFileInProjectPath(dependent, path);
+
+ logger.info("Checking project '"+projects[i]+"' for: "+path);
+ }
+ }
+ } catch(Exception e) {
+ logger.severe("Failed to check dependent projects: "+e);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ public static ModelReference createReference(IResource res) {
+ ModelReference ret=null;
+
+ // Identify the model reference from the resource
+ org.eclipse.core.runtime.IPath path=res.getFullPath();
+ org.eclipse.core.runtime.IPath fqnPath=path.removeFirstSegments(1);
+
+ String[] segments=fqnPath.segments();
+
+ String local=segments[segments.length-1];
+
+ String namespace="";
+
+ for (int i=0; i < segments.length-1; i++) {
+ if (i > 0) {
+ namespace += ".";
+ }
+ namespace += segments[i];
+ }
+
+ String notation=null;
+ String located=null;
+ String[] subdefnpath=null;
+
+ if (local != null) {
+ int nindex=local.lastIndexOf('.');
+ if (nindex != -1) {
+ notation = local.substring(nindex+1);
+ local = local.substring(0, nindex);
+
+ int pindex=local.lastIndexOf(ModelReference.LOCATED_REFERENCE_SEPARATOR);
+ if (pindex != -1) {
+ located = local.substring(pindex+1);
+ local = local.substring(0, pindex);
+ }
+
+ if (located != null && local.indexOf(SUB_DEFN_PATH_SEPARATOR) != -1) {
+
+ // Retrieve sub definition path
+ subdefnpath = local.split("\\"+SUB_DEFN_PATH_SEPARATOR);
+
+ local = subdefnpath[0];
+ }
+
+ /*
+ // Check if notation is supported
+ if (isNotationSupported(notation) == false) {
+ notation = local+"."+notation;
+
+ if (isNotationSupported(notation) == false) {
+ // TODO: Report error?
+ }
+ }
+ */
+ }
+ }
+
+ ret = new ModelReference(namespace, local, located, notation);
+
+ if (subdefnpath != null) {
+ for (int i=1; i < subdefnpath.length; i++) {
+ ret.getSubDefinitionPath().addPathElement(subdefnpath[i]);
+ }
+ }
+
+ if (res.exists()) {
+ ret.setProperty(RESOURCE_PROPERTY, res);
+ }
+
+ ret.setProperty(PROJECT_PROPERTY, res.getProject());
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.scribble.osgi.model");
+
+ private static final String PROJECT_PROPERTY = "project";
+ private static final String RESOURCE_PROPERTY = "resource";
+ private static final String GLOBAL_RESOURCE_PROPERTY = "globalResource";
+}
Added: trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelResource.java
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelResource.java (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelResource.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,150 @@
+/*
+ * 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.eclipse.model.admin;
+
+import java.util.logging.Logger;
+
+import org.scribble.model.ModelReference;
+import org.scribble.model.admin.ModelResource;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IFile;
+
+/**
+ * This class implements the ModelResource interface for
+ * OSGI based resources.
+ */
+public class OSGIModelResource implements ModelResource {
+
+ /**
+ * This constructor is initialized with the Eclipse
+ * file resource.
+ *
+ * @param file The file
+ */
+ public OSGIModelResource(IFile file) {
+ m_reference = new ModelReference(file.getFileExtension());
+
+ OSGIModelRepository.setFile(m_reference,
+ file);
+ }
+
+ /**
+ * This constructor is initialised with the reference
+ * that it represents.
+ *
+ * @param ref The reference
+ */
+ public OSGIModelResource(ModelReference ref) {
+ m_reference = ref;
+ }
+
+ /**
+ * This method returns the URI of the model resource.
+ *
+ * @return The URI
+ */
+ public java.net.URI getURI() {
+ java.net.URI ret=null;
+
+ IResource thisRes=OSGIModelRepository.getFile(m_reference);
+
+ if (thisRes != null) {
+ ret = thisRes.getLocationURI();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * 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 {
+ java.io.InputStream ret=null;
+
+ IFile thisRes=OSGIModelRepository.getFile(m_reference);
+
+ try {
+ ret = ((IFile)thisRes).getContents();
+ } catch(Exception e) {
+ throw new java.io.IOException("Failed to obtain contents: "+e);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the model reference.
+ *
+ * @return The model reference
+ */
+ public ModelReference getReference() {
+ return(m_reference);
+ }
+
+ public boolean equals(Object obj) {
+ boolean ret=false;
+
+ if (obj instanceof ModelResource) {
+ ModelReference otherRef=((ModelResource)obj).getReference();
+
+ if (otherRef != null) {
+ // Get the OSGI resource from the references
+ IResource otherRes=OSGIModelRepository.getFile(otherRef);
+ IResource thisRes=OSGIModelRepository.getFile(m_reference);
+
+ logger.finest("EQUAL: "+otherRef+" against "+m_reference);
+ logger.finest("EQUAL: "+otherRes+" against "+thisRes);
+
+ if (otherRes != null && thisRes != null) {
+ ret = otherRes.equals(thisRes);
+ logger.finest("EQUAL RES: "+ret);
+ } else {
+ ret = otherRef.equals(m_reference);
+ logger.finest("EQUAL REF: "+ret);
+ }
+ }
+ } else if (obj instanceof ModelReference) {
+ ModelReference otherRef=(ModelReference)obj;
+
+ ret = otherRef.equals(m_reference);
+
+ logger.info(">>>> CHECK EQUAL: "+otherRef+" against "+m_reference+" ret="+ret);
+ }
+
+ return(ret);
+ }
+
+ public String toString() {
+ IResource thisRes=OSGIModelRepository.getFile(m_reference);
+ return("["+m_reference+" resource="+thisRes+"]");
+ }
+
+ public int hashCode() {
+ return(m_reference.hashCode());
+ }
+
+ private static Logger logger = Logger.getLogger("org.scribble.osgi.model");
+
+ private ModelReference m_reference=null;
+}
Added: trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/osgi/Activator.java (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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:
+ * 26 April 2008 : Initial version created by gary
+ */
+package org.scribble.eclipse.osgi;
+
+import java.util.logging.Logger;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
+import org.scribble.model.ModelReference;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin implements org.eclipse.ui.IStartup {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.scribble.osgi";
+
+ // 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 {
+ super.start(context);
+ plugin = this;
+
+ // Reference class in core to cause it to be loaded
+ new ModelReference("");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * This method logs an error against the plugin.
+ *
+ * @param mesg The error message
+ * @param t The optional exception
+ */
+ public static void logError(String mesg, Throwable t) {
+
+ if (getDefault() != null) {
+ Status status=new Status(IStatus.ERROR,
+ PLUGIN_ID, 0, mesg, t);
+
+ getDefault().getLog().log(status);
+ }
+
+ logger.severe("LOG ERROR: "+mesg+
+ (t == null ? "" : ": "+t));
+ }
+
+ public void earlyStartup() {
+ }
+
+ private static Logger logger = Logger.getLogger("org.scribble.osgi.eclipse");
+}
Added: trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,206 @@
+/*
+ * 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.eclipse.resolutions;
+
+import java.util.Comparator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.internal.UIPlugin;
+import org.scribble.eclipse.model.admin.OSGIModelListener;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.resolutions.Resolution;
+import org.scribble.util.*;
+
+/**
+ * This class represents the implementation of the marker
+ * resolution generator interface, responsible for
+ * providing resolutions related to markers.
+ *
+ */
+public class MarkerResolutionGenerator
+ implements org.eclipse.ui.IMarkerResolutionGenerator2 {
+
+ /**
+ * This method determines whether there are available resolutions
+ * for the supplied marker.
+ *
+ * @param marker The marker
+ * @return Whether resolutions are available
+ */
+ public boolean hasResolutions(org.eclipse.core.resources.IMarker marker) {
+ boolean ret=false;
+
+ try {
+ ret = ModelIssueUtil.hasResolutions(marker.getAttributes());
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns any available resolutions for the supplied
+ * marker.
+ *
+ * @param marker The marker
+ * @return The list of available resolutions
+ */
+ public org.eclipse.ui.IMarkerResolution[] getResolutions(org.eclipse.core.resources.IMarker marker) {
+ org.eclipse.ui.IMarkerResolution[] ret=null;
+
+ try {
+ java.util.List<Resolution> resolutions=
+ ModelIssueUtil.deserializeResolutions(marker.getAttributes());
+
+ java.util.Collections.sort(resolutions, new ResolutionComparator());
+
+ ret = new org.eclipse.ui.IMarkerResolution[resolutions.size()];
+
+ for (int i=0; i < resolutions.size(); i++) {
+ ret[i] = new MarkerResolutionWrapper(resolutions.get(i));
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ /*
+ String resolutions=marker.getAttribute(org.scribble.model.ModelListener.RESOLUTIONS, null);
+
+ try {
+ java.util.List<org.eclipse.ui.IMarkerResolution> impls=
+ new java.util.Vector<org.eclipse.ui.IMarkerResolution>();
+
+ java.util.StringTokenizer st=new java.util.StringTokenizer(resolutions,",");
+
+ while (st.hasMoreTokens()) {
+ String resolution=st.nextToken();
+
+ if (resolution.equals(ModelListener.SHOW_EXTERNAL_ISSUE_RESOLUTION)) {
+ impls.add(new ShowExternalIssue());
+ } else if (resolution.equals(ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION)) {
+ impls.add(new ShowReferencedDescription());
+ } else {
+ try {
+ Class<?> cls=Class.forName(resolution);
+
+ org.eclipse.ui.IMarkerResolution res=
+ (org.eclipse.ui.IMarkerResolution)cls.newInstance();
+
+ impls.add(res);
+ } catch(Exception cnfe) {
+ org.scribble.osgi.eclipse.Activator.logError(
+ "Failed to instantiate resolution '"+resolution+"'", cnfe);
+ }
+ }
+ }
+
+ ret = new org.eclipse.ui.IMarkerResolution[impls.size()];
+
+ impls.toArray(ret);
+
+ } catch(Exception e) {
+ org.scribble.osgi.eclipse.Activator.logError(
+ "Failed to instantiate resolution '"+resolutions+"'", e);
+ }
+ */
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.scribble.osgi.resolutions");
+
+ public class ResolutionComparator implements Comparator<Resolution> {
+
+ public int compare(Resolution res1, Resolution res2) {
+ return(res1.getName().compareTo(res2.getName()));
+ }
+ }
+
+ public class MarkerResolutionWrapper implements org.eclipse.ui.IMarkerResolution2 {
+
+ public MarkerResolutionWrapper(Resolution res) {
+ m_resolution = res;
+ }
+
+ public String getLabel() {
+ return(m_resolution.getName());
+ }
+
+ public String getDescription() {
+ return(m_resolution.getDescription());
+ }
+
+ public Image getImage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void run(IMarker marker) {
+ try {
+ ModelIssue issue=new ModelIssue();
+ issue.setMessage((String)marker.getAttribute(IMarker.MESSAGE));
+ issue.getProperties().putAll(marker.getAttributes());
+
+ SourceRef obj=new SourceRef();
+ obj.setStartPosition(((Integer)marker.getAttribute(IMarker.CHAR_START, 0)).intValue());
+ obj.setEndPosition(((Integer)marker.getAttribute(IMarker.CHAR_END, 0)).intValue());
+ obj.setModelObjectURI((String)marker.getAttribute(OSGIModelListener.SOURCE_MODEL_OBJECT_URI));
+ obj.setComponentURI((String)marker.getAttribute(OSGIModelListener.SOURCE_COMPONENT_URI));
+
+ ModelReference ref=new ModelReference(
+ (String)marker.getAttribute(OSGIModelListener.MODEL_NAMESPACE),
+ (String)marker.getAttribute(OSGIModelListener.MODEL_LOCALPART),
+ (String)marker.getAttribute(OSGIModelListener.MODEL_LOCATED_ROLE),
+ (String)marker.getAttribute(OSGIModelListener.MODEL_NOTATION));
+
+ // Recover the properties for model ref
+ java.util.Iterator<String> iter=
+ marker.getAttributes().keySet().iterator();
+ while (iter.hasNext()) {
+ String name=iter.next();
+
+ if (name.startsWith(OSGIModelListener.MODEL_PROP_PREFIX)) {
+ Object value=marker.getAttributes().get(name);
+
+ name = name.substring(OSGIModelListener.MODEL_PROP_PREFIX.length());
+
+ ref.setProperty(name, value);
+ }
+ }
+
+ m_resolution.resolve(ref, obj, issue);
+ } catch(Exception e) {
+
+ org.eclipse.jface.dialogs.MessageDialog.openError(
+ UIPlugin.getDefault().getWorkbench().getDisplay().getActiveShell(),
+ "Error", e.getLocalizedMessage());
+
+ logger.log(Level.SEVERE, "Failed to resolve", e);
+ }
+ }
+
+ private Resolution m_resolution=null;
+ }
+}
Added: trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/util/ResourceUtil.java
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/util/ResourceUtil.java (rev 0)
+++ trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/util/ResourceUtil.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.eclipse.util;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.scribble.eclipse.model.admin.*;
+
+public class ResourceUtil {
+
+ /**
+ * This method determines if the supplied resource has any
+ * errors associated with it.
+ *
+ * @param res The resource
+ * @return Whether any errors are associated with the resource
+ */
+ public static boolean hasErrors(IResource res) {
+ boolean ret=false;
+
+ if (res != null) {
+
+ try {
+ IMarker[] markers=
+ res.findMarkers(IMarker.PROBLEM,
+ true, IResource.DEPTH_ZERO);
+
+ for (int i=0; markers != null && ret == false &&
+ i < markers.length; i++) {
+ Object obj=markers[i].getAttribute(IMarker.SEVERITY);
+
+ if (obj instanceof Integer &&
+ ((Integer)obj).intValue() == IMarker.SEVERITY_ERROR) {
+ ret = true;
+ }
+ }
+
+ // If no errors, check for scribble specific issues
+ if (ret == false) {
+ markers = res.findMarkers(OSGIDefinitions.SCRIBBLE_PROBLEM,
+ true, IResource.DEPTH_ZERO);
+
+ for (int i=0; markers != null && ret == false &&
+ i < markers.length; i++) {
+ Object obj=markers[i].getAttribute(IMarker.SEVERITY);
+
+ if (obj instanceof Integer &&
+ ((Integer)obj).intValue() == IMarker.SEVERITY_ERROR) {
+ ret = true;
+ }
+ }
+ }
+ } catch(Exception e) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/pom.xml
===================================================================
--- trunk/tools/plugins/pom.xml (rev 0)
+++ trunk/tools/plugins/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,32 @@
+<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.tools</groupId>
+ <artifactId>plugins</artifactId>
+ <packaging>pom</packaging>
+ <version>1.2.0-SNAPSHOT</version>
+ <name>Savara::Tools::Plugins</name>
+
+ <parent>
+ <groupId>org.savara</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <modules>
+ <module>org.savara.pi4soa.cdm</module>
+ <module>org.savara.protocol.contract</module>
+ <module>org.savara.tap.model</module>
+ <module>org.savara.tap.validation</module>
+ <module>org.savara.tap.eclipse</module>
+ <module>org.savara.tools.wsdl</module>
+ <module>org.savara.tools.bpel</module>
+ <module>org.savara.tools.validator</module>
+ <module>org.savara.tools.bpmn</module>
+ <module>org.savara.tools.monitor</module>
+ <module>org.scribble.eclipse</module>
+ </modules>
+
+</project>
+
Added: trunk/tools/pom.xml
===================================================================
--- trunk/tools/pom.xml (rev 0)
+++ trunk/tools/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,167 @@
+<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>tools</artifactId>
+ <packaging>pom</packaging>
+ <version>1.2.0-SNAPSHOT</version>
+ <name>Savara::Tools</name>
+
+ <properties>
+ <jaxb.version>2.1</jaxb.version>
+ <tycho-version>0.10.0</tycho-version>
+ <tychoVersion>0.10.0</tychoVersion>
+ <BUILD_ALIAS>Beta2</BUILD_ALIAS>
+ </properties>
+
+ <modules>
+ <module>plugins</module>
+ <module>features</module>
+ <module>tests</module>
+ <module>site</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <!--
+ <plugin>
+ <groupId>org.sonatype.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.sonatype.tycho</groupId>
+ <artifactId>target-platform-configuration</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <resolver>p2</resolver>
+ <pomDependencies>consider</pomDependencies>
+ </configuration>
+ </plugin>
+-->
+ <plugin>
+ <groupId>org.sonatype.tycho</groupId>
+ <artifactId>maven-osgi-packaging-plugin</artifactId>
+ <version>${tychoVersion}</version>
+ <configuration>
+ <format>'v'yyyyMMdd-HHmm'-${BUILD_ALIAS}'</format>
+ <archiveSite>true</archiveSite>
+ <environments>
+ <environment>
+ <os>macosx</os>
+ <ws>cocoa</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>macosx</os>
+ <ws>carbon</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>win32</os>
+ <ws>win32</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>linux</os>
+ <ws>gtk</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>linux</os>
+ <ws>gtk</ws>
+ <arch>x86_64</arch>
+ </environment>
+ </environments>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.sonatype.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${tychoVersion}</version>
+ <extensions>true</extensions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.sonatype.tycho</groupId>
+ <artifactId>target-platform-configuration</artifactId>
+ <version>${tychoVersion}</version>
+ <configuration>
+ <resolver>p2</resolver>
+ <ignoreTychoRepositories>true</ignoreTychoRepositories>
+ <pomDependencies>consider</pomDependencies>
+ <environments>
+ <environment>
+ <os>macosx</os>
+ <ws>cocoa</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>macosx</os>
+ <ws>carbon</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>win32</os>
+ <ws>win32</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>linux</os>
+ <ws>gtk</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>linux</os>
+ <ws>gtk</ws>
+ <arch>x86_64</arch>
+ </environment>
+ </environments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>jboss-developer-repository-group</id>
+ <name>JBoss Developer Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/developer/</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>pi4soa</id>
+ <url>http://download.jboss.org/jbosstools/builds/staging/pi4soa/all/repo/</url>
+ <layout>p2</layout>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ <repository>
+ <id>eclipse-helios</id>
+ <url>http://download.eclipse.org/releases/helios</url>
+ <layout>p2</layout>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+</project>
+
Added: trunk/tools/pomOrig.xml
===================================================================
--- trunk/tools/pomOrig.xml (rev 0)
+++ trunk/tools/pomOrig.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,95 @@
+<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>tools</artifactId>
+ <packaging>pom</packaging>
+ <version>1.2.0-SNAPSHOT</version>
+ <name>Savara::Tools</name>
+
+ <!-- use JBoss Tools' trunk/build/parent/pom.xml - must be built locally first!
+ Then, build like this to suck in latest pi4soa + target-platform:
+ mvn3 clean install -U -B -e -fae -P jbosstools-nightly-trunk,helios-remote-target,\!helios
+ -->
+ <parent>
+ <groupId>org.jboss.tools</groupId>
+ <artifactId>org.jboss.tools.parent.pom</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+
+ <!-- Don't use Savara's own local parent-pom.xml. ~nickb
+ <parent>
+ <relativePath>parent-pom.xml</relativePath>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>org.savara.tools.parent.pom</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent> -->
+
+ <properties>
+ <jaxb.version>2.1</jaxb.version>
+ </properties>
+
+ <modules>
+ <module>plugins</module>
+ <module>features</module>
+ <module>tests</module>
+ <module>site</module>
+ </modules>
+
+
+<!-- No need for distribution details as there are no artifacts to publish
+ <distributionManagement>
+ <repository>
+ <id>jboss-releases-repository</id>
+ <name>JBoss Releases Repository</name>
+ <url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</url>
+ </repository>
+ <snapshotRepository>
+ <id>jboss-snapshots-repository</id>
+ <name>JBoss Snapshots Repository</name>
+ <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
+ </snapshotRepository>
+ </distributionManagement>
+-->
+
+ <repositories>
+ <repository>
+ <id>jboss-developer-repository-group</id>
+ <name>JBoss Developer Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/developer/</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>pi4soa</id>
+ <url>http://download.jboss.org/jbosstools/builds/staging/pi4soa/all/repo/</url>
+ <layout>p2</layout>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ <repository>
+ <id>eclipse-helios</id>
+ <url>http://download.eclipse.org/releases/helios</url>
+ <layout>p2</layout>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+</project>
+
Added: trunk/tools/site/pom.xml
===================================================================
--- trunk/tools/site/pom.xml (rev 0)
+++ trunk/tools/site/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,90 @@
+<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.tools</groupId>
+ <artifactId>site</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-update-site</packaging>
+ <name>Savara::Tools::Site</name>
+
+ <parent>
+ <groupId>org.savara</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <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.bpel</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.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.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.conversation.projector</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.scribble.conversation.comparator</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.scribble.conversation.validation</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.scribble.conversation.export.text</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.scribble.lang.model</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
+
Added: trunk/tools/site/site.xml
===================================================================
--- trunk/tools/site/site.xml (rev 0)
+++ trunk/tools/site/site.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<site>
+ <description name="Savara Tools Update Site">
+ This is the update site for the Savara tools.
+ </description>
+ <feature url="features/org.savara.tools.feature_0.0.0.jar" id="org.savara.tools.feature" version="0.0.0">
+ <category name="Savara"/>
+ </feature>
+ <feature url="features/org.scribble.protocol.feature_0.0.0.jar" id="org.scribble.protocol.feature" version="0.0.0">
+ <category name="Savara"/>
+ </feature>
+ <category-def name="Savara" label="Savara">
+ <description>
+ Savara Tools update site
+ </description>
+ </category-def>
+</site>
Added: trunk/tools/tests/org.savara.protocol.contract.tests/.classpath
===================================================================
--- trunk/tools/tests/org.savara.protocol.contract.tests/.classpath (rev 0)
+++ trunk/tools/tests/org.savara.protocol.contract.tests/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <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="src" path="src/java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/tests/org.savara.protocol.contract.tests/.project
===================================================================
--- trunk/tools/tests/org.savara.protocol.contract.tests/.project (rev 0)
+++ trunk/tools/tests/org.savara.protocol.contract.tests/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.protocol.contract.tests</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/tools/tests/org.savara.protocol.contract.tests/Copyright.txt
===================================================================
--- trunk/tools/tests/org.savara.protocol.contract.tests/Copyright.txt (rev 0)
+++ trunk/tools/tests/org.savara.protocol.contract.tests/Copyright.txt 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/tools/tests/org.savara.protocol.contract.tests/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/tests/org.savara.protocol.contract.tests/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/tests/org.savara.protocol.contract.tests/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA Protocol Contract Tests Plugin
+Bundle-SymbolicName: org.savara.protocol.contract.tests
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.protocol.contract.tests.osgi.Activator
+Bundle-Vendor: www.savara.org
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.core,
+ org.scribble.conversation.model,
+ org.savara.contract.model,
+ org.savara.protocol.contract,
+ org.junit4
+Export-Package: org.savara.protocol.contract
Added: trunk/tools/tests/org.savara.protocol.contract.tests/build.properties
===================================================================
--- trunk/tools/tests/org.savara.protocol.contract.tests/build.properties (rev 0)
+++ trunk/tools/tests/org.savara.protocol.contract.tests/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,4 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/tools/tests/org.savara.protocol.contract.tests/pom.xml
===================================================================
--- trunk/tools/tests/org.savara.protocol.contract.tests/pom.xml (rev 0)
+++ trunk/tools/tests/org.savara.protocol.contract.tests/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.tools</groupId>
+ <artifactId>org.savara.protocol.contract.tests</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-test-plugin</packaging>
+ <name>Savara::Tools::Tests::ProtocolContract</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>tests</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>
+ </dependencies>
+</project>
Added: trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/ContractGeneratorTest.java
===================================================================
--- trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/ContractGeneratorTest.java (rev 0)
+++ trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/ContractGeneratorTest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,66 @@
+package org.savara.protocol.contract;
+
+import static org.junit.Assert.*;
+
+import org.savara.protocol.contract.ContractGenerator;
+import org.savara.protocol.contract.ContractGeneratorFactory;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.model.LocatedName;
+import org.scribble.model.Role;
+
+public class ContractGeneratorTest {
+
+ @org.junit.Test
+ public void testGenerateProtocolNull() {
+
+ ContractGenerator generator=ContractGeneratorFactory.getContractGenerator();
+
+ try {
+ Conversation conv=null;
+
+ generator.generate(conv);
+
+ fail("Should have thrown IllegalArgumentException");
+
+ } catch(IllegalArgumentException iae) {
+ // Test worked
+ }
+ }
+
+ @org.junit.Test
+ public void testGenerateProtocolNotLocated() {
+
+ ContractGenerator generator=ContractGeneratorFactory.getContractGenerator();
+
+ try {
+ Conversation conv=new Conversation();
+ LocatedName ln=new LocatedName();
+ conv.setLocatedName(ln);
+
+ generator.generate(conv);
+
+ fail("Should have thrown IllegalArgumentException");
+
+ } catch(IllegalArgumentException iae) {
+ // Test worked
+ }
+ }
+
+ @org.junit.Test
+ public void testGenerateConversationAndRoleNotNull2() {
+
+ ContractGenerator generator=ContractGeneratorFactory.getContractGenerator();
+
+ try {
+ Conversation conv=new Conversation();
+ LocatedName ln=new LocatedName();
+ ln.setRole(new Role());
+ conv.setLocatedName(ln);
+
+ generator.generate(conv);
+
+ } catch(IllegalArgumentException iae) {
+ fail("Should NOT have thrown IllegalArgumentException");
+ }
+ }
+}
Added: trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/ProtocolContractAllTests.java
===================================================================
--- trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/ProtocolContractAllTests.java (rev 0)
+++ trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/ProtocolContractAllTests.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,33 @@
+/*
+ * 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.protocol.contract;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+import org.savara.protocol.contract.impl.*;
+
+ at RunWith(Suite.class)
+ at Suite.SuiteClasses( { ContractGeneratorTest.class,
+ ContractIntrospectorTest.class})
+public class ProtocolContractAllTests {
+}
Added: trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/impl/ContractIntrospectorTest.java
===================================================================
--- trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/impl/ContractIntrospectorTest.java (rev 0)
+++ trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/impl/ContractIntrospectorTest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,304 @@
+/*
+ * 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.protocol.contract.impl;
+
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.Interface;
+import org.savara.contract.model.MessageExchangePattern;
+import org.savara.contract.model.OneWayRequestMEP;
+import org.savara.contract.model.RequestResponseMEP;
+import org.savara.contract.model.Type;
+import org.savara.protocol.contract.impl.ContractIntrospector;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.conversation.model.ConversationReference;
+import org.scribble.conversation.model.Run;
+import org.scribble.model.LocatedName;
+import org.scribble.model.MessageSignature;
+import org.scribble.model.Role;
+import org.scribble.model.TypeReference;
+
+import static org.junit.Assert.*;
+
+public class ContractIntrospectorTest {
+
+ private static final String MY_ROLE = "myRole";
+ private static final String TYPE_NS = "typeNS";
+ private static final String TYPE_LP = "typeLP";
+ private static final String OP_NAME = "opName";
+
+ @org.junit.Test
+ public void testNoSubProtocolWithoutRun() {
+ Role r=new Role();
+ r.setName("role");
+
+ LocatedName ln1=new LocatedName();
+ ln1.setName("top");
+ ln1.setRole(r);
+ LocatedName ln2=new LocatedName();
+ ln2.setName("mid");
+ ln2.setRole(r);
+ LocatedName ln3=new LocatedName();
+ ln3.setName("sub");
+ ln3.setRole(r);
+
+ Conversation top=new Conversation();
+ top.setLocatedName(ln1);
+
+ Conversation mid=new Conversation();
+ mid.setLocatedName(ln2);
+
+ Conversation sub=new Conversation();
+ sub.setLocatedName(ln3);
+
+ ConversationReference ref=new ConversationReference();
+ ref.setLocalpart("sub");
+ ref.setLocatedRole(r.getName());
+
+ Run run=new Run();
+ run.setReference(ref);
+
+ top.getBlock().getContents().add(mid);
+
+ mid.getBlock().getContents().add(run);
+ mid.getBlock().getContents().add(sub);
+
+ ContractIntrospector introspector=new ContractIntrospector(top);
+
+ introspector.process();
+
+ if (introspector.getProcessedProtocols().size() != 0) {
+ fail("Expecting 0 processed protocol, but got: "+introspector.getProcessedProtocols().size());
+ }
+ }
+
+ @org.junit.Test
+ public void testSubProtocolWithRun() {
+ Role r=new Role();
+ r.setName("role");
+
+ LocatedName ln1=new LocatedName();
+ ln1.setName("top");
+ ln1.setRole(r);
+ LocatedName ln2=new LocatedName();
+ ln2.setName("mid");
+ ln2.setRole(r);
+ LocatedName ln3=new LocatedName();
+ ln3.setName("sub");
+ ln3.setRole(r);
+
+ Conversation top=new Conversation();
+ top.setLocatedName(ln1);
+
+ Conversation mid=new Conversation();
+ mid.setLocatedName(ln2);
+
+ Conversation sub=new Conversation();
+ sub.setLocatedName(ln3);
+
+ ConversationReference ref1=new ConversationReference();
+ ref1.setLocalpart("mid");
+ ref1.setLocatedRole(r.getName());
+ ref1.setInner(true);
+
+ Run run1=new Run();
+ run1.setReference(ref1);
+
+ top.getBlock().getContents().add(run1);
+ top.getBlock().getContents().add(mid);
+
+ ConversationReference ref2=new ConversationReference();
+ ref2.setLocalpart("sub");
+ ref2.setLocatedRole(r.getName());
+ ref2.setInner(true);
+
+ Run run2=new Run();
+ run2.setReference(ref2);
+
+ mid.getBlock().getContents().add(run2);
+ mid.getBlock().getContents().add(sub);
+
+ ContractIntrospector introspector=new ContractIntrospector(top);
+
+ introspector.process();
+
+ if (introspector.getProcessedProtocols().size() != 2) {
+ fail("Expecting 2 processed protocol, but got: "+introspector.getProcessedProtocols().size());
+ }
+
+ if (introspector.getProcessedProtocols().contains(mid) == false) {
+ fail("Should contain mid");
+ }
+
+ if (introspector.getProcessedProtocols().contains(sub) == false) {
+ fail("Should contain sub");
+ }
+ }
+
+ @org.junit.Test
+ public void testCreateSingleInterface() {
+ Conversation protocol=new Conversation();
+ Role role=new Role();
+ role.setName(MY_ROLE);
+ LocatedName ln=new LocatedName();
+ ln.setRole(role);
+ protocol.setLocatedName(ln);
+
+ ContractIntrospector introspector=new ContractIntrospector(protocol);
+
+ if (introspector.getContract().getInterfaces().size() != 0) {
+ fail("Should be 0 interfaces: "+introspector.getContract().getInterfaces().size());
+ }
+
+ Interface intf=introspector.getInterface();
+
+ if (intf == null) {
+ fail("Interface not created");
+ }
+
+ if (introspector.getContract().getInterfaces().size() != 1) {
+ fail("Should be 1 interface: "+introspector.getContract().getInterfaces().size());
+ }
+
+ Interface intf2=introspector.getInterface();
+
+ if (intf2 != intf) {
+ fail("Interfaces are different");
+ }
+
+ if (introspector.getContract().getInterfaces().size() != 1) {
+ fail("Should still only be 1 interface: "+introspector.getContract().getInterfaces().size());
+ }
+ }
+
+ @org.junit.Test
+ public void testVisitInteractionOneWayRequestRPC() {
+ Conversation protocol=new Conversation();
+ Role role=new Role();
+ role.setName(MY_ROLE);
+ LocatedName ln=new LocatedName();
+ ln.setRole(role);
+ protocol.setLocatedName(ln);
+
+ ContractIntrospector introspector=new ContractIntrospector(protocol);
+
+ ConversationInteraction interaction=new ConversationInteraction();
+
+ MessageSignature msig=new MessageSignature();
+ msig.setOperation(OP_NAME);
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(TYPE_LP);
+ tref.setNamespace(TYPE_NS);
+ msig.getTypes().add(tref);
+
+ interaction.setMessageSignature(msig);
+ interaction.setFromRole(new Role());
+
+ introspector.visitInteraction(interaction);
+
+ Contract contract=introspector.getContract();
+
+ Interface intf=contract.getInterface(role.getName());
+
+ if (intf == null) {
+ fail("Interface '"+role.getName()+"' not found");
+ }
+
+ MessageExchangePattern mep=intf.getMessageExchangePatternForOperation(OP_NAME);
+
+ if (mep == null) {
+ fail("Operation '"+OP_NAME+"' not found");
+ }
+
+ if ((mep instanceof OneWayRequestMEP) == false) {
+ fail("Not a oneway request");
+ }
+
+ if (mep.getTypes().size() != 1) {
+ fail("One type expected, but got: "+mep.getTypes().size());
+ }
+
+ Type t=mep.getTypes().get(0);
+
+ if (t.getName().equals(TYPE_LP) == false) {
+ fail("Type name not correct: "+t.getName());
+ }
+ }
+
+
+ @org.junit.Test
+ public void testVisitInteractionRequestResponseRPCOnlyRequest() {
+ Conversation protocol=new Conversation();
+ Role role=new Role();
+ role.setName(MY_ROLE);
+ LocatedName ln=new LocatedName();
+ ln.setRole(role);
+ protocol.setLocatedName(ln);
+
+ ContractIntrospector introspector=new ContractIntrospector(protocol);
+
+ ConversationInteraction interaction=new ConversationInteraction();
+
+ MessageSignature msig=new MessageSignature();
+ msig.setOperation(OP_NAME);
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(TYPE_LP);
+ tref.setNamespace(TYPE_NS);
+ msig.getTypes().add(tref);
+
+ interaction.setMessageSignature(msig);
+ interaction.setFromRole(new Role());
+ interaction.setRequestLabel("label");
+
+ introspector.visitInteraction(interaction);
+
+ Contract contract=introspector.getContract();
+
+ Interface intf=contract.getInterface(role.getName());
+
+ if (intf == null) {
+ fail("Interface '"+role.getName()+"' not found");
+ }
+
+ MessageExchangePattern mep=intf.getMessageExchangePatternForOperation(OP_NAME);
+
+ if (mep == null) {
+ fail("Operation '"+OP_NAME+"' not found");
+ }
+
+ if ((mep instanceof RequestResponseMEP) == false) {
+ fail("Not a request/response MEP");
+ }
+
+ if (mep.getTypes().size() != 1) {
+ fail("One type expected, but got: "+mep.getTypes().size());
+ }
+
+ Type t=mep.getTypes().get(0);
+
+ if (t.getName().equals(TYPE_LP) == false) {
+ fail("Type name not correct: "+t.getName());
+ }
+ }
+}
Added: trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/tests/osgi/Activator.java
===================================================================
--- trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/tests/osgi/Activator.java (rev 0)
+++ trunk/tools/tests/org.savara.protocol.contract.tests/src/java/org/savara/protocol/contract/tests/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.protocol.contract.tests.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/tools/tests/org.savara.tools.bpel.tests/.classpath
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/.classpath (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/.classpath 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <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="src" path="src/java"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/.project
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/.project (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/.project 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.tools.bpel.tests</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/tools/tests/org.savara.tools.bpel.tests/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/META-INF/MANIFEST.MF 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Boss SAVARA Tools BPEL Tests Plug-in
+Bundle-SymbolicName: org.savara.tools.bpel.tests
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.tools.bpel.tests.osgi.Activator
+Bundle-Vendor: www.savara.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ 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.eclipse.core.resources,
+ org.scribble.eclipse;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jdt.core,
+ org.junit,
+ 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.tools.bpel,
+ org.savara.contract.model,
+ org.savara.tools.wsdl,
+ org.eclipse.ui.ide,
+ org.eclipse.jst.common.frameworks,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.wst.common.project.facet.core,
+ org.scribble.conversation.projector;bundle-version="[1.0.0,2.0.0)",
+ org.savara.bpel,
+ org.savara.core
Added: trunk/tools/tests/org.savara.tools.bpel.tests/build.properties
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/build.properties (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/build.properties 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,12 @@
+source.. = src/java/
+output.. = classes/
+bin.includes = META-INF/,\
+ .,\
+ test.xml
+src.includes = test.xml,\
+ src/,\
+ build.properties,\
+ META-INF/,\
+ .settings/,\
+ .project,\
+ .classpath
Added: trunk/tools/tests/org.savara.tools.bpel.tests/pom.xml
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/pom.xml (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,43 @@
+<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.tools</groupId>
+ <artifactId>org.savara.tools.bpel.tests</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-test-plugin</packaging>
+ <name>Savara::Tools::Tests::ToolsBPEL</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>tests</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.projector</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.bpel</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>
+ </dependencies>
+</project>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/GeneratorTest.java
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/GeneratorTest.java (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/GeneratorTest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,314 @@
+/*
+ * 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.bpel.generator;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.savara.bpel.model.BPELNotation;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.pi4soa.cdm.model.CDMNotation;
+import org.savara.util.XMLUtils;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.Definition;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SubDefinitionPath;
+import org.scribble.model.change.ModelGenerator;
+
+public class GeneratorTest {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Choreography->BPEL Generator Tests");
+
+ suite.addTest(new ChoreographyToBPELTester("ESBBroker", "Broker"));
+ suite.addTest(new ChoreographyToBPELTester("ESBBroker", "Buyer"));
+ suite.addTest(new ChoreographyToBPELTester("ESBBroker", "CreditAgency"));
+ suite.addTest(new ChoreographyToBPELTester("ESBBroker",
+ new SubDefinitionPath(new String[]{"CompleteTransaction"}),
+ "SupplierTxnProcessor"));
+ suite.addTest(new ChoreographyToBPELTester("ESBBroker",
+ new SubDefinitionPath(new String[]{"RequestForQuote"}),
+ "SupplierQuoteEngine"));
+ suite.addTest(new ChoreographyToBPELTester("PurchaseGoods", "Buyer"));
+ suite.addTest(new ChoreographyToBPELTester("PurchaseGoods", "CreditAgency"));
+ suite.addTest(new ChoreographyToBPELTester("PurchaseGoods", "Store"));
+ suite.addTest(new ChoreographyToBPELTester("ReqRespFault", "Buyer"));
+ suite.addTest(new ChoreographyToBPELTester("ReqRespFault", "Seller"));
+
+ return suite;
+ }
+
+ public static class ChoreographyToBPELTester extends TestCase {
+
+ /**
+ * This constructor is initialized with the test
+ * name.
+ *
+ * @param name The test name
+ * @param role The role
+ */
+ public ChoreographyToBPELTester(String name,
+ String role) {
+ super(name+"@"+role);
+ m_name = name;
+ m_role = role;
+ }
+
+ /**
+ * This constructor is initialized with the test
+ * name.
+ *
+ * @param name The test name
+ * @param role The role
+ */
+ public ChoreographyToBPELTester(String name,
+ SubDefinitionPath sdp, String role) {
+ super(name+sdp.toString()+"@"+role);
+ m_name = name;
+ m_subDefinitionPath = sdp;
+ m_role = role;
+ }
+
+ /**
+ * This method runs the test.
+ *
+ * @param result The test result
+ */
+ public void run(TestResult result) {
+ result.startTest(this);
+
+ String filename="testmodels/"+m_name+".cdm";
+
+ java.io.InputStream is=
+ ChoreographyToBPELTester.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(CDMNotation.NOTATION_CODE);
+ org.scribble.model.admin.DefaultModelListener 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);
+ }
+
+ // Check if subpath definition defined
+ if (m_subDefinitionPath != null) {
+ defn = defn.getSubDefinition(m_subDefinitionPath);
+ }
+
+ java.util.List<org.scribble.model.Role> roles=defn.getRoles();
+ //new org.scribble.model.Role(m_role);
+
+ 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,
+ m_subDefinitionPath, role, l);
+
+ /* Currently if a 'fail' is performed in Tycho build, it
+ * hangs the build.
+ if (l.getErrors().size() > 0) {
+ fail("Projection has errors: "+l.getErrors());
+ } else if (projected == null) {
+ fail("Projected model is null, for "+filename+" role "+role);
+ }
+ */
+
+ ModelGenerator generator=(ModelGenerator)
+ RegistryFactory.getRegistry().getExtension(
+ ModelGenerator.class, null);
+
+ defns = projected.getDefinitions();
+ defn = null;
+
+ if (defns.size() == 1) {
+ defn = defns.get(0);
+ }
+
+ if (generator != null && defn != null) {
+ ModelReference targetRef=
+ new ModelReference(BPELNotation.NOTATION_CODE);
+ targetRef.setAlias(m_name);
+ targetRef.setLocatedRole(m_role);
+
+ DefaultBPELLanguageModel target=
+ new DefaultBPELLanguageModel(targetRef);
+
+ generator.generate(targetRef, role,
+ target, projected);
+
+ if (target.getBPELProcess().getDOMElement() != null) {
+ try {
+ String text=XMLUtils.toText(target.getBPELProcess().getDOMElement());
+ checkResults(result, text);
+ } catch(Exception e) {
+ result.addError(this, e);
+ }
+ } else {
+ result.addError(this,
+ new Throwable("No BPEL generated"));
+ }
+
+ } else {
+ result.addError(this,
+ new Throwable("Unable to find Model Generator"));
+ }
+ }
+ }
+ }
+
+ result.endTest(this);
+ }
+
+ /**
+ * This method checks the generated BPEL against a
+ * previously stored correct version.
+ *
+ * @param result The test result
+ * @param bpel The BPEL
+ */
+ protected void checkResults(TestResult result, String bpel) {
+ boolean f_valid=false;
+
+ String filename="results/"+m_name+"@"+m_role+".bpel";
+
+ java.io.InputStream is=
+ ChoreographyToBPELTester.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(bpel) == false) {
+ result.addError(this,
+ new Throwable("Generated Conversation does not match stored version"));
+ } else {
+ f_valid = true;
+ }
+ } catch(Exception e) {
+ result.addError(this, e);
+ }
+ } else {
+ result.addError(this,
+ new Throwable("Resulting BPEL '"+filename+
+ "' not found for comparison"));
+ }
+
+ if (f_valid == false) {
+ String bpelfile="testmodels/"+m_name+".cdm";
+
+ java.net.URL url=ChoreographyToBPELTester.class.getResource(bpelfile);
+
+ /*
+ 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+"@"+m_role+".expected");
+
+ if (resultFile.exists() == false) {
+ try {
+ java.io.FileOutputStream fos=new java.io.FileOutputStream(resultFile);
+
+ fos.write(bpel.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 CDM model source '"+
+ m_name+"': "+url));
+ }
+ }
+ }
+ }
+
+ private String m_name=null;
+ private SubDefinitionPath m_subDefinitionPath=null;
+ private String m_role=null;
+ }
+}
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Broker.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Broker.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Broker.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,66 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.LoanBroker at Broker" name="ESBBrokerProcess_Broker" targetNamespace="http://www.pi4soa.org/ESBBroker/Broker" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_BrokerArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <partnerLinks>
+ <partnerLink myRole="BrokerBehavior" name="BuyerToBroker" partnerLinkType="brk:BuyerToBrokerServiceLT"/>
+ <partnerLink name="BrokerToSupplierQuoteEngine" partnerLinkType="brk:BrokerToSupplierQuoteEngineLT" partnerRole="SupplierQuoteEngineRequester"/>
+ <partnerLink name="BrokerToCreditAgency" partnerLinkType="brk:BrokerToCreditAgencyLT" partnerRole="CreditAgencyRequester"/>
+ <partnerLink name="BrokerToSupplierTxnProcessor" partnerLinkType="brk:BrokerToSupplierTxnProcessorLT" partnerRole="SupplierTxnProcessorRequester"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="brk:makeEnquiryRequest" name="makeEnquiryRequestVar"/>
+ <variable messageType="spr:getQuoteRequest" name="getQuoteRequestVar"/>
+ <variable messageType="spr:getQuoteResponse" name="getQuoteResponseVar"/>
+ <variable messageType="brk:makeEnquiryResponse" name="makeEnquiryResponseVar"/>
+ <variable messageType="brk:buyRequest" name="buyRequestVar"/>
+ <variable messageType="cay:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="cay:checkCreditResponse" name="checkCreditResponseVar"/>
+ <variable messageType="spr:confirmRequest" name="confirmRequestVar"/>
+ <variable messageType="spr:confirmResponse" name="confirmResponseVar"/>
+ <variable messageType="brk:buyResponse" name="buyResponseVar"/>
+ <variable messageType="brk:rejectedFault" name="rejectedFaultVar"/>
+ <variable messageType="brk:cancelRequest" name="cancelRequestVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_enquiry" operation="makeEnquiry" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="makeEnquiryRequestVar"/>
+ <while>
+ <sequence>
+ <scope>
+ <sequence>
+ <invoke inputVariable="getQuoteRequestVar" name="Send_requestForQuote" operation="getQuote" outputVariable="getQuoteResponseVar" partnerLink="BrokerToSupplierQuoteEngine" portType="spr:SupplierBehavior"/>
+ </sequence>
+ </scope>
+ </sequence>
+ </while>
+ <reply name="Send_quoteList" operation="makeEnquiry" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="makeEnquiryResponseVar"/>
+ <pick>
+ <onMessage operation="buy" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="buyRequestVar">
+ <sequence>
+ <scope>
+ <sequence>
+ <scope>
+ <faultHandlers>
+ <catch faultMessageType="cay:invalidCreditFault" faultName="cay:invalidCredit" faultVariable="invalidCreditFaultVar">
+ <sequence>
+ <reply faultName="brk:rejected" name="Send_orderRejected" operation="buy" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="rejectedFaultVar"/>
+ </sequence>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <invoke inputVariable="checkCreditRequestVar" name="Send_CreditCheckRequest" operation="checkCredit" outputVariable="checkCreditResponseVar" partnerLink="BrokerToCreditAgency" portType="cay:CreditAgencyBehavior"/>
+ <invoke inputVariable="confirmRequestVar" name="Send_orderConfirmed" operation="confirm" outputVariable="confirmResponseVar" partnerLink="BrokerToSupplierTxnProcessor" portType="spr:SupplierBehavior"/>
+ <reply name="Send_bookingReference" operation="buy" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="buyResponseVar"/>
+ </sequence>
+ </scope>
+ </sequence>
+ </scope>
+ </sequence>
+ </onMessage>
+ <onMessage operation="cancel" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="cancelRequestVar">
+ <sequence/>
+ </onMessage>
+ </pick>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Buyer.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Buyer.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Buyer.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,43 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.LoanBroker at Buyer" name="ESBBrokerProcess_Buyer" targetNamespace="http://www.pi4soa.org/ESBBroker/Buyer" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_BuyerArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Buyer"/>
+ <partnerLinks>
+ <partnerLink myRole="BrokerBehavior" name="BuyerToBroker" partnerLinkType="byr:BuyerToBrokerLT" partnerRole="BrokerRequester"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="brk:makeEnquiryRequest" name="makeEnquiryRequestVar"/>
+ <variable messageType="brk:makeEnquiryResponse" name="makeEnquiryResponseVar"/>
+ <variable messageType="brk:buyRequest" name="buyRequestVar"/>
+ <variable messageType="brk:buyResponse" name="buyResponseVar"/>
+ <variable messageType="brk:cancelRequest" name="cancelRequestVar"/>
+ </variables>
+ <sequence>
+ <invoke inputVariable="makeEnquiryRequestVar" name="Send_enquiry" operation="makeEnquiry" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior"/>
+ <receive name="Receive_quoteList" operation="makeEnquiry" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="makeEnquiryResponseVar"/>
+ <if>
+ <sequence>
+ <scope>
+ <sequence>
+ <scope>
+ <faultHandlers>
+ <catch faultMessageType="brk:rejectedFault" faultName="brk:rejected" faultVariable="rejectedFaultVar">
+ <sequence/>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <invoke inputVariable="buyRequestVar" name="Send_buy" operation="buy" outputVariable="buyResponseVar" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior"/>
+ </sequence>
+ </scope>
+ </sequence>
+ </scope>
+ </sequence>
+ <else>
+ <sequence>
+ <invoke inputVariable="cancelRequestVar" name="Send_cancel" operation="cancel" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at CreditAgency.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at CreditAgency.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at CreditAgency.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,36 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.Common at CreditAgency" name="ESBBrokerProcess_CreditAgency" targetNamespace="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgencyArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <partnerLinks>
+ <partnerLink myRole="CreditAgencyService" name="BrokerToCreditAgency" partnerLinkType="cay:BrokerToCreditAgencyServiceLT"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="cay:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="cay:checkCreditResponse" name="checkCreditResponseVar"/>
+ <variable messageType="cay:invalidCreditFault" name="invalidCreditFaultVar"/>
+ </variables>
+ <sequence>
+ <pick>
+ <onMessage operation="checkCredit" partnerLink="BrokerToCreditAgency" portType="cay:CreditAgencyBehavior" variable="checkCreditRequestVar">
+ <sequence>
+ <scope>
+ <sequence>
+ <if>
+ <sequence>
+ <reply name="Send_CreditCheckOk" operation="checkCredit" partnerLink="BrokerToCreditAgency" portType="cay:CreditAgencyBehavior" variable="checkCreditResponseVar"/>
+ </sequence>
+ <else>
+ <sequence>
+ <reply faultName="cay:invalidCredit" name="Send_CreditCheckInvalid" operation="checkCredit" partnerLink="BrokerToCreditAgency" portType="cay:CreditAgencyBehavior" variable="invalidCreditFaultVar"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+ </scope>
+ </sequence>
+ </onMessage>
+ </pick>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Supplier.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Supplier.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at Supplier.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,3 @@
+<process name="ESBBrokerProcess_Supplier" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <sequence/>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at SupplierQuoteEngine.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at SupplierQuoteEngine.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at SupplierQuoteEngine.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,15 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.LoanBroker at SupplierQuoteEngine" name="RequestForQuote_SupplierQuoteEngine" targetNamespace="http://www.pi4soa.org/ESBBroker/Supplier" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="RequestForQuote_SupplierQuoteEngine.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="RequestForQuote_SupplierQuoteEngineArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <partnerLinks>
+ <partnerLink myRole="SupplierBehavior" name="BrokerToSupplierQuoteEngine" partnerLinkType="spr:BrokerToSupplierQuoteEngineServiceLT"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="spr:getQuoteRequest" name="getQuoteRequestVar"/>
+ <variable messageType="spr:getQuoteResponse" name="getQuoteResponseVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_requestForQuote" operation="getQuote" partnerLink="BrokerToSupplierQuoteEngine" portType="spr:SupplierBehavior" variable="getQuoteRequestVar"/>
+ <reply name="Send_quote" operation="getQuote" partnerLink="BrokerToSupplierQuoteEngine" portType="spr:SupplierBehavior" variable="getQuoteResponseVar"/>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at SupplierTxnProcessor.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at SupplierTxnProcessor.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ESBBroker at SupplierTxnProcessor.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,20 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.LoanBroker at SupplierTxnProcessor" name="CompleteTransaction_SupplierTxnProcessor" targetNamespace="http://www.pi4soa.org/ESBBroker/Supplier" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="CompleteTransaction_SupplierTxnProcessor.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="CompleteTransaction_SupplierTxnProcessorArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <partnerLinks>
+ <partnerLink myRole="SupplierTxnProcessorService" name="BrokerToSupplierTxnProcessor" partnerLinkType="spr:BrokerToSupplierTxnProcessorServiceLT"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="spr:confirmRequest" name="confirmRequestVar"/>
+ <variable messageType="spr:confirmResponse" name="confirmResponseVar"/>
+ </variables>
+ <sequence>
+ <pick createInstance="yes">
+ <onMessage operation="confirm" partnerLink="BrokerToSupplierTxnProcessor" portType="spr:SupplierBehavior" variable="confirmRequestVar">
+ <sequence>
+ <reply name="Send_bookingReference" operation="confirm" partnerLink="BrokerToSupplierTxnProcessor" portType="spr:SupplierBehavior" variable="confirmResponseVar"/>
+ </sequence>
+ </onMessage>
+ </pick>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at Buyer.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at Buyer.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at Buyer.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,24 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:pur="java:org.jboss.savara.examples.purchasing" xmlns:sto="http://www.jboss.org/examples/store" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="savara.samples.Purchasing at Buyer" name="PurchaseGoodsProcess_Buyer" targetNamespace="http://www.jboss.org/savara/examples" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_BuyerArtifacts.wsdl" namespace="http://www.jboss.org/savara/examples"/>
+ <partnerLinks>
+ <partnerLink name="BuyerToStore" partnerLinkType="tns:BuyerToStoreLT" partnerRole="StoreRequester"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="sto:buyRequest" name="buyRequestVar"/>
+ <variable messageType="sto:buyResponse" name="buyResponseVar"/>
+ </variables>
+ <sequence>
+ <scope>
+ <faultHandlers>
+ <catch faultMessageType="sto:BuyFailedFault" faultName="sto:BuyFailed" faultVariable="BuyFailedFaultVar">
+ <sequence/>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <invoke inputVariable="buyRequestVar" name="Send_BuyRequest" operation="buy" outputVariable="buyResponseVar" partnerLink="BuyerToStore" portType="sto:StoreInterface"/>
+ </sequence>
+ </scope>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at CreditAgency.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at CreditAgency.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at CreditAgency.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,26 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:pur="java:org.jboss.savara.examples.purchasing" xmlns:sto="http://www.jboss.org/examples/store" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="savara.samples.Common at CreditAgency" name="PurchaseGoodsProcess_CreditAgency" targetNamespace="java:org.jboss.savara.examples.purchasing" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgencyArtifacts.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
+ <partnerLinks>
+ <partnerLink myRole="CreditAgencyInterface" name="StoreToCreditAgency" partnerLinkType="pur:StoreToCreditAgencyServiceLT"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="pur:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="pur:checkCreditResponse" name="checkCreditResponseVar"/>
+ <variable messageType="pur:CreditCheckFailedFault" name="CreditCheckFailedFaultVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_CreditCheckRequest" operation="checkCredit" partnerLink="StoreToCreditAgency" portType="pur:CreditAgencyInterface" variable="checkCreditRequestVar"/>
+ <if>
+ <sequence>
+ <reply name="Send_CreditCheckOk" operation="checkCredit" partnerLink="StoreToCreditAgency" portType="pur:CreditAgencyInterface" variable="checkCreditResponseVar"/>
+ </sequence>
+ <else>
+ <sequence>
+ <reply faultName="pur:CreditCheckFailed" name="Send_CreditCheckInvalid" operation="checkCredit" partnerLink="StoreToCreditAgency" portType="pur:CreditAgencyInterface" variable="CreditCheckFailedFaultVar"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at Store.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at Store.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/PurchaseGoods at Store.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,32 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:pur="java:org.jboss.savara.examples.purchasing" xmlns:sto="http://www.jboss.org/examples/store" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="savara.samples.Purchasing at Store" name="PurchaseGoodsProcess_Store" targetNamespace="http://www.jboss.org/examples/store" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_StoreArtifacts.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <partnerLinks>
+ <partnerLink myRole="StoreInterface" name="BuyerToStore" partnerLinkType="sto:BuyerToStoreServiceLT"/>
+ <partnerLink name="StoreToCreditAgency" partnerLinkType="sto:StoreToCreditAgencyLT" partnerRole="CreditAgencyRequester"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="sto:buyRequest" name="buyRequestVar"/>
+ <variable messageType="pur:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="pur:checkCreditResponse" name="checkCreditResponseVar"/>
+ <variable messageType="sto:buyResponse" name="buyResponseVar"/>
+ <variable messageType="sto:BuyFailedFault" name="BuyFailedFaultVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_BuyRequest" operation="buy" partnerLink="BuyerToStore" portType="sto:StoreInterface" variable="buyRequestVar"/>
+ <scope>
+ <faultHandlers>
+ <catch faultMessageType="pur:CreditCheckFailedFault" faultName="pur:CreditCheckFailed" faultVariable="CreditCheckFailedFaultVar">
+ <sequence>
+ <reply faultName="sto:BuyFailed" name="Send_BuyFailed" operation="buy" partnerLink="BuyerToStore" portType="sto:StoreInterface" variable="BuyFailedFaultVar"/>
+ </sequence>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <invoke inputVariable="checkCreditRequestVar" name="Send_CreditCheckRequest" operation="checkCredit" outputVariable="checkCreditResponseVar" partnerLink="StoreToCreditAgency" portType="pur:CreditAgencyInterface"/>
+ <reply name="Send_BuyConfirmed" operation="buy" partnerLink="BuyerToStore" portType="sto:StoreInterface" variable="buyResponseVar"/>
+ </sequence>
+ </scope>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ReqRespFault at Buyer.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ReqRespFault at Buyer.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ReqRespFault at Buyer.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,23 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:byr="http://www.pi4soa.org/ReqRespFault/Buyer" xmlns:slr="http://www.pi4soa.org/ReqRespFault/Seller" xmlns:tns="http://www.pi4soa.org/ReqRespFault" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.LoanBroker at Buyer" name="ReqRespFaultProcess_Buyer" targetNamespace="http://www.pi4soa.org/ReqRespFault/Buyer" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ReqRespFaultProcess_Seller.wsdl" namespace="http://www.pi4soa.org/ReqRespFault/Seller"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ReqRespFaultProcess_BuyerArtifacts.wsdl" namespace="http://www.pi4soa.org/ReqRespFault/Buyer"/>
+ <partnerLinks>
+ <partnerLink name="BuyerToSeller" partnerLinkType="byr:BuyerToSellerLT" partnerRole="SellerRequester"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="slr:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="slr:checkCreditResponse" name="checkCreditResponseVar"/>
+ </variables>
+ <sequence>
+ <scope>
+ <faultHandlers>
+ <catch faultMessageType="slr:insufficientCreditFault" faultName="slr:insufficientCredit" faultVariable="insufficientCreditFaultVar">
+ <sequence/>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <invoke inputVariable="checkCreditRequestVar" name="Send_CreditCheckRequest" operation="checkCredit" outputVariable="checkCreditResponseVar" partnerLink="BuyerToSeller" portType="slr:SellerBehavior"/>
+ </sequence>
+ </scope>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ReqRespFault at Seller.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ReqRespFault at Seller.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/results/ReqRespFault at Seller.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,25 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:byr="http://www.pi4soa.org/ReqRespFault/Buyer" xmlns:slr="http://www.pi4soa.org/ReqRespFault/Seller" xmlns:tns="http://www.pi4soa.org/ReqRespFault" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="org.pi4soa.reqrespfault.reqrespfault.ReqRespFaultProcess at Seller" name="ReqRespFaultProcess_Seller" targetNamespace="http://www.pi4soa.org/ReqRespFault/Seller" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ReqRespFaultProcess_Seller.wsdl" namespace="http://www.pi4soa.org/ReqRespFault/Seller"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ReqRespFaultProcess_SellerArtifacts.wsdl" namespace="http://www.pi4soa.org/ReqRespFault/Seller"/>
+ <partnerLinks>
+ <partnerLink myRole="SellerBehavior" name="BuyerToSeller" partnerLinkType="slr:BuyerToSellerServiceLT"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="slr:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="slr:checkCreditResponse" name="checkCreditResponseVar"/>
+ <variable messageType="slr:insufficientCreditFault" name="insufficientCreditFaultVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_CreditCheckRequest" operation="checkCredit" partnerLink="BuyerToSeller" portType="slr:SellerBehavior" variable="checkCreditRequestVar"/>
+ <if>
+ <sequence>
+ <reply name="Send_CreditCheckOk" operation="checkCredit" partnerLink="BuyerToSeller" portType="slr:SellerBehavior" variable="checkCreditResponseVar"/>
+ </sequence>
+ <else>
+ <sequence>
+ <reply faultName="slr:insufficientCredit" name="Send_CreditCheckInvalid" operation="checkCredit" partnerLink="BuyerToSeller" portType="slr:SellerBehavior" variable="insufficientCreditFaultVar"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/ESBBroker.cdm
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/ESBBroker.cdm (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/ESBBroker.cdm 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<org.pi4soa.cdl:Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org.pi4soa.cdl="http:///org/pi4soa/cdl.ecore" description="The choreography description for ESBBroker" name="ESBBroker" author="gary" version="0.2" targetNamespace="http://www.pi4soa.org/ESBBroker">
+ <typeDefinitions>
+ <nameSpaces description="Target Namespace for ESBBroker" prefix="tns" uRI="http://www.pi4soa.org/ESBBroker"/>
+ <nameSpaces description="XML Schema Namespace" prefix="xsd" uRI="http://www.w3.org/2001/XMLSchema"/>
+ <nameSpaces description="Target Namespace for ESBBroker" prefix="brk" uRI="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <nameSpaces description="Target Namespace for ESBBroker" prefix="byr" uRI="http://www.pi4soa.org/ESBBroker/Buyer"/>
+ <nameSpaces description="Target Namespace for ESBBroker" prefix="cay" uRI="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <nameSpaces description="Target Namespace for ESBBroker" prefix="spr" uRI="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <informationTypes description="This is the information type BookingReference" name="BookingReference" elementName="bookingReference"/>
+ <informationTypes description="This is the information type Buy" name="Buy" elementName="buy"/>
+ <informationTypes description="This is the information type Cancel" name="Cancel" elementName="cancel"/>
+ <informationTypes description="This is the information type CreditInformation" name="CreditInformation" elementName="CreditCheckRequest"/>
+ <informationTypes description="This is the information type CreditInvalid" name="CreditInvalid" elementName="CreditCheckInvalid"/>
+ <informationTypes description="This is the information type CreditValid" name="CreditValid" elementName="CreditCheckOk"/>
+ <informationTypes description="This is the information type Enquiry" name="Enquiry" typeName="" elementName="enquiry"/>
+ <informationTypes description="This is the information type OrderConfirmed" name="OrderConfirmed" elementName="orderConfirmed"/>
+ <informationTypes description="This is the information type OrderRejected" name="OrderRejected" elementName="orderRejected"/>
+ <informationTypes description="This is the information type Quote" name="Quote" elementName="quote"/>
+ <informationTypes description="This is the information type QuoteList" name="QuoteList" elementName="quoteList"/>
+ <informationTypes description="This is the information type RequestForQuote" name="RequestForQuote" elementName="requestForQuote"/>
+ <informationTypes description="This is the information type URIType" name="URIType"/>
+ <tokens description="This is the token URI" name="URI" informationType="//@typeDefinitions/@informationTypes.12"/>
+ <roleTypes description="This is the role type Broker" name="Broker">
+ <behaviors description="This is the behavior BrokerBehavior" name="BrokerBehavior"/>
+ </roleTypes>
+ <roleTypes description="This is the role type Buyer" name="Buyer">
+ <behaviors description="This is the behavior BuyerBehavior" name="BuyerBehavior"/>
+ </roleTypes>
+ <roleTypes description="This is the role type CreditAgency" name="CreditAgency">
+ <behaviors description="This is the behavior CreditAgencyBehavior" name="CreditAgencyBehavior"/>
+ </roleTypes>
+ <roleTypes description="This is the role type Supplier" name="Supplier">
+ <behaviors description="This is the behavior SupplierBehavior" name="SupplierBehavior"/>
+ </roleTypes>
+ <relationshipTypes description="Relationship between Broker and CreditAgency" name="BrokerToCreditAgencyRel" firstRoleType="//@typeDefinitions/@roleTypes.0" secondRoleType="//@typeDefinitions/@roleTypes.2"/>
+ <relationshipTypes description="Relationship between Broker and Supplier" name="BrokerToSupplierRel" firstRoleType="//@typeDefinitions/@roleTypes.0" secondRoleType="//@typeDefinitions/@roleTypes.3"/>
+ <relationshipTypes description="Relationship between Buyer and Broker" name="BuyerToBrokerRel" firstRoleType="//@typeDefinitions/@roleTypes.1" secondRoleType="//@typeDefinitions/@roleTypes.0"/>
+ <participantTypes description="This is the participant type brk:Broker" name="brk:Broker" roleTypes="//@typeDefinitions/@roleTypes.0">
+ <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at Broker" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type byr:Buyer" name="byr:Buyer" roleTypes="//@typeDefinitions/@roleTypes.1">
+ <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at Buyer" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type cay:CreditAgency" name="cay:CreditAgency" roleTypes="//@typeDefinitions/@roleTypes.2">
+ <semanticAnnotations annotation="overlord.cdl.samples.Common at CreditAgency" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type spr:Supplier" name="spr:Supplier" roleTypes="//@typeDefinitions/@roleTypes.3">
+ <semanticAnnotations annotation="" name="conversationType"/>
+ </participantTypes>
+ <channelTypes description="This is the channel type BrokerChannelType" name="BrokerChannelType" referenceToken="//@typeDefinitions/@tokens.0" roleType="//@typeDefinitions/@roleTypes.0"/>
+ <channelTypes description="This is the channel type CreditAgencyChannelType" name="CreditAgencyChannelType" referenceToken="//@typeDefinitions/@tokens.0" roleType="//@typeDefinitions/@roleTypes.2"/>
+ <channelTypes description="This is the channel type SupplierChannelType" name="SupplierChannelType" referenceToken="//@typeDefinitions/@tokens.0" roleType="//@typeDefinitions/@roleTypes.3"/>
+ </typeDefinitions>
+ <choreographies description="Choreography flow for the ESBBroker process" name="ESBBrokerProcess" root="true">
+ <enclosedChoreographies name="CompleteTransaction">
+ <participantDefinitions name="SupplierTxnProcessor" roleTypes="//@typeDefinitions/@roleTypes.3">
+ <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at SupplierTxnProcessor" name="conversationType"/>
+ </participantDefinitions>
+ <variableDefinitions description="Channel to facilitate interaction to Broker" name="BrokerChannel" type="//@typeDefinitions/@channelTypes.0" free="true" roleTypes="//@typeDefinitions/@roleTypes.0 //@typeDefinitions/@roleTypes.1"/>
+ <variableDefinitions description="Channel to facilitate interaction to CreditAgency" name="CreditAgencyChannel" type="//@typeDefinitions/@channelTypes.1"/>
+ <variableDefinitions description="Channel to facilitate interaction to Supplier" name="SupplierChannel" type="//@typeDefinitions/@channelTypes.2"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="Buy" operation="buy" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction Buy" name="BuyRequestExchange" type="//@typeDefinitions/@informationTypes.1"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CheckCredit" operation="checkCredit" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction CheckCredit" name="CheckCreditRequestExchange" type="//@typeDefinitions/@informationTypes.3"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Choice" description="Evaluate Credit Check Result">
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Sufficient Credit">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CheckCreditResponse" operation="checkCredit" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CheckCreditResponse" name="CheckCreditResponseRespondExchange" type="//@typeDefinitions/@informationTypes.5" action="Respond"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="ConfirmBooking" operation="confirm" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.2" relationship="//@typeDefinitions/@relationshipTypes.1" toParticipant="//@choreographies.0/@enclosedChoreographies.0/@participantDefinitions.0">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction ConfirmBooking" name="ConfirmBookingRequestExchange" type="//@typeDefinitions/@informationTypes.7"/>
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction ConfirmBooking" name="ConfirmBookingRequestExchange" type="//@typeDefinitions/@informationTypes.0" action="Respond"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="Buy" operation="buy" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction Buy" name="BuyRespondExchange" type="//@typeDefinitions/@informationTypes.0" action="Respond" faultName=""/>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Insufficient Credit">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CheckCreditFailed" operation="checkCredit" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CheckCreditFailed" name="CheckCreditFailedRespondExchange" type="//@typeDefinitions/@informationTypes.4" action="Respond" faultName="invalidCredit"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="Buy" operation="buy" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction Buy" name="BuyRespondExchange" type="//@typeDefinitions/@informationTypes.8" action="Respond" faultName="rejected"/>
+ </activities>
+ </activities>
+ </activities>
+ </enclosedChoreographies>
+ <enclosedChoreographies name="RequestForQuote">
+ <participantDefinitions name="SupplierQuoteEngine" roleTypes="//@typeDefinitions/@roleTypes.3">
+ <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at SupplierQuoteEngine" name="conversationType"/>
+ </participantDefinitions>
+ <variableDefinitions description="Channel to facilitate interaction to Supplier" name="SupplierChannel" type="//@typeDefinitions/@channelTypes.2"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="RFQ" operation="getQuote" channelVariable="//@choreographies.0/@enclosedChoreographies.1/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1" toParticipant="//@choreographies.0/@enclosedChoreographies.1/@participantDefinitions.0">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction RFQ" name="RFQRequestExchange" type="//@typeDefinitions/@informationTypes.11"/>
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction RFQ" name="RFQRespondExchange" type="//@typeDefinitions/@informationTypes.9" action="Respond"/>
+ </activities>
+ </enclosedChoreographies>
+ <variableDefinitions description="Channel to facilitate interaction to Broker" name="BrokerChannel" type="//@typeDefinitions/@channelTypes.0" roleTypes="//@typeDefinitions/@roleTypes.0 //@typeDefinitions/@roleTypes.1"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="Enquiry" operation="makeEnquiry" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction Enquiry" name="EnquiryRequestExchange" type="//@typeDefinitions/@informationTypes.6"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:While" name="SendRFQToSuppliers">
+ <activities xsi:type="org.pi4soa.cdl:Perform" choreography="//@choreographies.0/@enclosedChoreographies.1"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:When" name="WhenQuotesReceivedOrTimeout">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="Enquiry" operation="makeEnquiry" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction Enquiry" name="EnquiryRespondExchange" type="//@typeDefinitions/@informationTypes.10" action="Respond"/>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Choice">
+ <activities xsi:type="org.pi4soa.cdl:Sequence">
+ <activities xsi:type="org.pi4soa.cdl:Perform" choreography="//@choreographies.0/@enclosedChoreographies.0" waitForCompletion="false">
+ <bindDetails name="BindBrokerChannel" thisVariable="//@choreographies.0/@variableDefinitions.0" thisRole="//@typeDefinitions/@roleTypes.1" freeVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" freeRole="//@typeDefinitions/@roleTypes.1"/>
+ <bindDetails name="BindBrokerChannel" thisVariable="//@choreographies.0/@variableDefinitions.0" thisRole="//@typeDefinitions/@roleTypes.0" freeVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" freeRole="//@typeDefinitions/@roleTypes.0"/>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="Cancel" operation="cancel" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction Cancel" name="CancelRequestExchange" type="//@typeDefinitions/@informationTypes.2"/>
+ </activities>
+ </activities>
+ </activities>
+ </choreographies>
+</org.pi4soa.cdl:Package>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/PurchaseGoods.cdm
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/PurchaseGoods.cdm (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/PurchaseGoods.cdm 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<org.pi4soa.cdl:Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org.pi4soa.cdl="http:///org/pi4soa/cdl.ecore" description="The choreography description for PurchaseGoods" name="PurchaseGoods" author="gary" version="0.1" targetNamespace="http://www.jboss.org/savara/examples">
+ <typeDefinitions>
+ <nameSpaces description="Target Namespace for PurchaseGoods" prefix="tns" uRI="http://www.jboss.org/savara/examples"/>
+ <nameSpaces description="XML Schema Namespace" prefix="xsd" uRI="http://www.w3.org/2001/XMLSchema"/>
+ <nameSpaces prefix="pur" uRI="java:org.jboss.savara.examples.purchasing"/>
+ <nameSpaces prefix="sto" uRI="http://www.jboss.org/examples/store"/>
+ <informationTypes description="This is the information type BuyConfirmed" name="BuyConfirmed" typeName="sto:BuyConfirmed" elementName=""/>
+ <informationTypes description="This is the information type BuyFailed" name="BuyFailed" typeName="sto:BuyFailed" elementName=""/>
+ <informationTypes description="This is the information type BuyRequest" name="BuyRequest" typeName="sto:BuyRequest" elementName=""/>
+ <informationTypes description="This is the information type CreditCheckInvalid" name="CreditCheckInvalid" typeName="pur:CreditCheckInvalid" elementName=""/>
+ <informationTypes description="This is the information type CreditCheckOk" name="CreditCheckOk" typeName="pur:CreditCheckOk" elementName=""/>
+ <informationTypes description="This is the information type CreditCheckRequest" name="CreditCheckRequest" typeName="pur:CreditCheckRequest" elementName=""/>
+ <informationTypes description="This is the information type IDType" name="IDType" typeName="xsd:string"/>
+ <informationTypes description="This is the information type URITokenType" name="URITokenType" typeName="xsd:anyURI"/>
+ <tokens description="This is the token ID" name="ID" informationType="//@typeDefinitions/@informationTypes.6"/>
+ <tokens description="This is the token URIToken" name="URIToken" informationType="//@typeDefinitions/@informationTypes.7"/>
+ <tokenLocators description="This is the token locator BuyFailedIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.1" query="//@id" name="BuyFailedIDLocator"/>
+ <tokenLocators description="This is the token locator BuyRequestIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.2" query="//@id" name="BuyRequestIDLocator"/>
+ <tokenLocators description="This is the token locator BuyResponseIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.0" query="//@id" name="BuyResponseIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckInvalidIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.3" query="//@id" name="CreditCheckInvalidIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckRequestIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.5" query="//@id" name="CreditCheckRequestIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckResponseIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.4" query="//@id" name="CreditCheckResponseIDLocator"/>
+ <roleTypes description="This is the role type Buyer" name="Buyer">
+ <behaviors description="This is the behavior BuyerBehavior" name="BuyerBehavior"/>
+ </roleTypes>
+ <roleTypes description="This is the role type CreditAgency" name="CreditAgency">
+ <behaviors description="This is the behavior CreditAgencyBehavior" name="CreditAgencyBehavior" interface="pur:CreditAgencyInterface"/>
+ </roleTypes>
+ <roleTypes description="This is the role type Store" name="Store">
+ <behaviors description="This is the behavior StoreBehavior" name="StoreBehavior" interface="sto:StoreInterface"/>
+ </roleTypes>
+ <relationshipTypes description="Relationship between Buyer and Store" name="BuyerToStoreRel" firstRoleType="//@typeDefinitions/@roleTypes.0" secondRoleType="//@typeDefinitions/@roleTypes.2"/>
+ <relationshipTypes description="Relationship between Store and CreditAgency" name="StoreToCreditAgencyRel" firstRoleType="//@typeDefinitions/@roleTypes.2" secondRoleType="//@typeDefinitions/@roleTypes.1"/>
+ <participantTypes description="This is the participant type Buyer" name="Buyer" roleTypes="//@typeDefinitions/@roleTypes.0">
+ <semanticAnnotations annotation="savara.samples.Purchasing at Buyer" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type pur:CreditAgency" name="pur:CreditAgency" roleTypes="//@typeDefinitions/@roleTypes.1">
+ <semanticAnnotations annotation="savara.samples.Common at CreditAgency" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type sto:Store" name="sto:Store" roleTypes="//@typeDefinitions/@roleTypes.2">
+ <semanticAnnotations annotation="savara.samples.Purchasing at Store" name="conversationType"/>
+ </participantTypes>
+ <channelTypes description="This is the channel type CreditAgencyChannelType" name="CreditAgencyChannelType" referenceToken="//@typeDefinitions/@tokens.1" roleType="//@typeDefinitions/@roleTypes.1">
+ <identities description="ID" tokens="//@typeDefinitions/@tokens.0"/>
+ </channelTypes>
+ <channelTypes description="This is the channel type StoreChannelType" name="StoreChannelType" referenceToken="//@typeDefinitions/@tokens.1" roleType="//@typeDefinitions/@roleTypes.2">
+ <identities description="ID" tokens="//@typeDefinitions/@tokens.0"/>
+ </channelTypes>
+ </typeDefinitions>
+ <choreographies description="Choreography flow for the PurchaseGoods process" name="PurchaseGoodsProcess" root="true">
+ <variableDefinitions description="Channel to facilitate interaction to CreditAgency" name="CreditAgencyChannel" type="//@typeDefinitions/@channelTypes.0"/>
+ <variableDefinitions description="Channel to facilitate interaction to Supplier" name="SupplierChannel" type="//@typeDefinitions/@channelTypes.1"/>
+ <variableDefinitions description="This is the variable buy" name="buy" type="//@typeDefinitions/@informationTypes.2"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="BuyRequest" operation="buy" channelVariable="//@choreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction BuyRequest" name="BuyRequestRequestExchange" type="//@typeDefinitions/@informationTypes.2"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheck" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction CreditCheck" name="CreditCheckRequestExchange" type="//@typeDefinitions/@informationTypes.5"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Choice" description="Is credit ok?">
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Credit Valid">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckOk" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckOk" name="CreditCheckOkRespondExchange" type="//@typeDefinitions/@informationTypes.4" action="Respond"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="BuyConfirmed" operation="buy" channelVariable="//@choreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction BuyConfirmed" name="BuyConfirmedRespondExchange" type="//@typeDefinitions/@informationTypes.0" action="Respond"/>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Credit Invalid">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckFailed" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckFailed" name="CreditCheckFailedRespondExchange" type="//@typeDefinitions/@informationTypes.3" action="Respond" faultName="CreditCheckFailed"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="BuyFailed" operation="buy" channelVariable="//@choreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction BuyFailed" name="BuyFailedRespondExchange" type="//@typeDefinitions/@informationTypes.1" action="Respond" faultName="BuyFailed"/>
+ </activities>
+ </activities>
+ </activities>
+ </choreographies>
+</org.pi4soa.cdl:Package>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/ReqRespFault.cdm
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/ReqRespFault.cdm (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/generator/testmodels/ReqRespFault.cdm 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<org.pi4soa.cdl:Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org.pi4soa.cdl="http:///org/pi4soa/cdl.ecore" description="The choreography description for ReqRespFault" name="ReqRespFault" author="gary" version="0.3" targetNamespace="http://www.pi4soa.org/ReqRespFault">
+ <typeDefinitions>
+ <nameSpaces description="Target Namespace for ReqRespFault" prefix="tns" uRI="http://www.pi4soa.org/ReqRespFault"/>
+ <nameSpaces description="XML Schema Namespace" prefix="xsd" uRI="http://www.w3.org/2001/XMLSchema"/>
+ <nameSpaces description="Target Namespace for ReqRespFault" prefix="byr" uRI="http://www.pi4soa.org/ReqRespFault/Buyer"/>
+ <nameSpaces description="Target Namespace for ReqRespFault" prefix="slr" uRI="http://www.pi4soa.org/ReqRespFault/Seller"/>
+ <informationTypes description="This is the information type CreditInformation" name="CreditInformation" elementName="CreditCheckRequest"/>
+ <informationTypes description="This is the information type CreditInvalid" name="CreditInvalid" elementName="CreditCheckInvalid"/>
+ <informationTypes description="This is the information type CreditValid" name="CreditValid" elementName="CreditCheckOk"/>
+ <informationTypes description="This is the information type URIType" name="URIType"/>
+ <tokens description="This is the token URI" name="URI" informationType="//@typeDefinitions/@informationTypes.3"/>
+ <roleTypes description="This is the role type Buyer" name="Buyer">
+ <behaviors description="This is the behavior BuyerBehavior" name="BuyerBehavior"/>
+ </roleTypes>
+ <roleTypes description="This is the role type Seller" name="Seller">
+ <behaviors description="This is the behavior SellerBehavior" name="SellerBehavior"/>
+ </roleTypes>
+ <relationshipTypes description="Relationship between Buyer and Seller" name="BuyerToSellerRel" firstRoleType="//@typeDefinitions/@roleTypes.0" secondRoleType="//@typeDefinitions/@roleTypes.1"/>
+ <participantTypes description="This is the participant type byr:Buyer" name="byr:Buyer" roleTypes="//@typeDefinitions/@roleTypes.0">
+ <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at Buyer" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type slr:Seller" name="slr:Seller" roleTypes="//@typeDefinitions/@roleTypes.1">
+ <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at Broker" name="conversationType"/>
+ </participantTypes>
+ <channelTypes description="This is the channel type SellerChannelType" name="SellerChannelType" referenceToken="//@typeDefinitions/@tokens.0" roleType="//@typeDefinitions/@roleTypes.1"/>
+ </typeDefinitions>
+ <choreographies description="Choreography flow for the ReqRespFault process" name="ReqRespFaultProcess" root="true">
+ <variableDefinitions description="Channel to facilitate interaction to Broker" name="BrokerChannel" type="//@typeDefinitions/@channelTypes.0" roleTypes="//@typeDefinitions/@roleTypes.1 //@typeDefinitions/@roleTypes.0"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheck" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction CreditCheck" name="CreditCheckRequestExchange" type="//@typeDefinitions/@informationTypes.0"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Choice">
+ <activities xsi:type="org.pi4soa.cdl:Sequence">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckValid" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckValid" name="CreditCheckValidRespondExchange" type="//@typeDefinitions/@informationTypes.2" action="Respond"/>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckInvalid" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckInvalid" name="CreditCheckInvalidRespondExchange" type="//@typeDefinitions/@informationTypes.1" action="Respond" faultName="insufficientCredit"/>
+ </activities>
+ </activities>
+ </activities>
+ </choreographies>
+</org.pi4soa.cdl:Package>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/ParserTest.java
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/ParserTest.java (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/ParserTest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,288 @@
+/*
+ * 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.bpel.parser;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.savara.bpel.model.BPELNotation;
+import org.scribble.conversation.model.ConversationModel;
+import org.scribble.lang.model.*;
+import org.scribble.conversation.model.ConversationNotation;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.ModelReference;
+import org.scribble.model.admin.Context;
+
+public class ParserTest extends TestCase {
+
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite("BPEL->Conversation Parser Tests");
+
+ suite.addTest(new BPELToConversationTest("ESBBrokerProcess_Broker", "ESBBroker at Broker"));
+ suite.addTest(new BPELToConversationTest("ESBBrokerProcess_Buyer", "ESBBroker at Buyer"));
+ suite.addTest(new BPELToConversationTest("ESBBrokerProcess_CreditAgency", "ESBBroker at CreditAgency"));
+ suite.addTest(new BPELToConversationTest("RequestForQuote_SupplierQuoteEngine", "ESBBroker at SupplierQuoteEngine"));
+ suite.addTest(new BPELToConversationTest("CompleteTransaction_SupplierTxnProcessor", "ESBBroker at SupplierTxnProcessor"));
+ suite.addTest(new BPELToConversationTest("PurchaseGoodsProcess_Buyer", "PurchaseGoods at Buyer"));
+ suite.addTest(new BPELToConversationTest("PurchaseGoodsProcess_CreditAgency", "PurchaseGoods at CreditAgency"));
+ suite.addTest(new BPELToConversationTest("PurchaseGoodsProcess_Store", "PurchaseGoods at Store"));
+ suite.addTest(new BPELToConversationTest("ReqRespFaultProcess_Buyer", "ReqRespFault at Buyer"));
+ suite.addTest(new BPELToConversationTest("ReqRespFaultProcess_Seller", "ReqRespFault at Seller"));
+
+ /**
+ * TODO: (SAVARA-150) Commenting out this test for now, as we now need the accompanying WSDL to be able to
+ * resolve the message type's underlying XSD element or type.
+ *
+ suite.addTest(new BPELToConversationTest("LoanApprovalService at Service", "LoanApprovalService at Service"));
+ */
+
+ return suite;
+ }
+
+ /**
+ * The test case for running the BPEL to Conversation test.
+ */
+ public static class BPELToConversationTest extends TestCase {
+
+ /**
+ * This constructor is initialized with the test
+ * name.
+ *
+ * @param name The test name
+ */
+ public BPELToConversationTest(String bpelName, String scvName) {
+ super(bpelName+"->"+scvName);
+ m_bpelName = bpelName;
+ m_scvName = scvName;
+ }
+
+ /**
+ * This method runs the test.
+ *
+ * @param result The test result
+ */
+ public void run(TestResult result) {
+ result.startTest(this);
+
+ String filename="testmodels/"+m_bpelName+".bpel";
+
+ java.io.InputStream is=
+ ParserTest.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(BPELNotation.NOTATION_CODE);
+ org.scribble.model.admin.DefaultModelListener l=
+ new org.scribble.model.admin.DefaultModelListener();
+
+ org.scribble.model.Model model=p.parse(ref, is, l, new ResourceLoaderContext());
+
+ if (model == null) {
+ result.addError(this, new Throwable("Model is null"));
+
+ } else if ((model instanceof LanguageModel) == false) {
+ result.addError(this, new Throwable("Model is null"));
+
+ } else if (l.getErrors().size() != 0) {
+ result.addError(this, new Throwable("Failed to parse CDM Model"));
+
+ for (int i=0; i < l.getErrors().size(); i++) {
+ System.err.println("ModelIssue: "+
+ l.getErrors().get(i).getMessage());
+ }
+ } else {
+ LanguageModel lm=(LanguageModel)model;
+ ConversationModel cm=new ConversationModel();
+
+ cm.setNamespace(lm.getNamespace());
+
+ if (lm.getConversations().size() == 1) {
+ cm.setConversation(lm.getConversations().get(0));
+ }
+
+ try {
+ 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);
+
+ exporter.export(new ModelReference(ConversationNotation.NOTATION_CODE),
+ cm, formatter);
+
+ String str=new String(os.toByteArray());
+
+ checkResults(result, str);
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ result.endTest(this);
+ }
+
+ /**
+ * This method checks the generated jboss-esb.xml against a
+ * previously stored correct version.
+ *
+ * @param result The test result
+ * @param conv The conversation
+ */
+ protected void checkResults(TestResult result, String conv) {
+ boolean f_valid=false;
+
+ String filename="results/"+m_scvName+".scv";
+
+ java.io.InputStream is=
+ ParserTest.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(conv) == false) {
+ result.addError(this,
+ new Throwable("Generated Conversation does not match stored version"));
+ } else {
+ f_valid = true;
+ }
+ } catch(Exception e) {
+ result.addError(this, e);
+ }
+ } else {
+ result.addError(this,
+ new Throwable("Resulting Conversation '"+filename+
+ "' not found for comparison"));
+ }
+
+ if (f_valid == false) {
+ String bpelfile="testmodels/"+m_bpelName+".bpel";
+
+ java.net.URL url=ParserTest.class.getResource(bpelfile);
+
+ 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_scvName+".expected");
+
+ if (resultFile.exists() == false) {
+ try {
+ java.io.FileOutputStream fos=new java.io.FileOutputStream(resultFile);
+
+ fos.write(conv.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 BPEL model source '"+
+ m_bpelName+"': "+url));
+ }
+ }
+ }
+ }
+
+ private String m_bpelName=null;
+ private String m_scvName=null;
+ }
+
+ public static class ResourceLoaderContext implements Context {
+
+ public ResourceLoaderContext() {
+ }
+
+ public InputStream getResource(ModelReference ref, String uri) {
+ String filename="testmodels/"+uri;
+
+ java.io.InputStream is=
+ ParserTest.class.getResourceAsStream(filename);
+
+ return(is);
+ }
+
+ public java.net.URI getResourceURI(ModelReference ref, String uri) {
+ String filename="testmodels/"+uri;
+
+ java.net.URI ret=null;
+
+ try {
+ ret = ParserTest.class.getResource(filename).toURI();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return(ret);
+ }
+
+ }
+}
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at Broker.scv
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at Broker.scv (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at Broker.scv 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,35 @@
+namespace null;
+
+conversation ESBBrokerProcess_Broker at Broker implements LoanBroker at Broker {
+ makeEnquiry(enquiry) from Buyer to Broker;
+ while {
+ getQuote(requestForQuote) from Broker to SupplierQuoteEngine;
+ getQuote(quote) from SupplierQuoteEngine to Broker;
+ }
+ ;
+ makeEnquiry(quoteList) from Broker to Buyer;
+ if {
+ buy(buy) from Buyer to Broker;
+ try {
+ checkCredit(CreditCheckRequest) from Broker to CreditAgency;
+ if {
+ checkCredit(CreditCheckOk) from CreditAgency to Broker;
+ } else if {
+ checkCredit(CreditCheckInvalid) from CreditAgency to Broker;
+ raise invalidCredit;
+ }
+ confirm(orderConfirmed) from Broker to SupplierTxnProcessor;
+ if {
+ confirm(bookingReference) from SupplierTxnProcessor to Broker;
+ } else if {
+ confirm(CreditCheckInvalid) from SupplierTxnProcessor to Broker;
+ raise invalidCredit;
+ }
+ buy(bookingReference) from Broker to Buyer;
+ } catch invalidCredit {
+ buy(orderRejected) from Broker to Buyer;
+ }
+ } else if {
+ cancel(cancel) from Buyer to Broker;
+ }
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at Buyer.scv
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at Buyer.scv (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at Buyer.scv 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,16 @@
+namespace null;
+
+conversation ESBBrokerProcess_Buyer at Buyer implements LoanBroker at Buyer {
+ makeEnquiry(enquiry) from Buyer to Broker;
+ makeEnquiry(quoteList) from Broker to Buyer;
+ if {
+ buy(buy) from Buyer to Broker;
+ if {
+ buy(bookingReference) from Broker to Buyer;
+ } else if {
+ buy(orderRejected) from Broker to Buyer;
+ }
+ } else if {
+ cancel(cancel) from Buyer to Broker;
+ }
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at CreditAgency.scv
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at CreditAgency.scv (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at CreditAgency.scv 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,12 @@
+namespace null;
+
+conversation ESBBrokerProcess_CreditAgency at CreditAgency implements Common at CreditAgency {
+ if {
+ checkCredit(CreditCheckRequest) from Broker to CreditAgency;
+ if {
+ checkCredit(CreditCheckOk) from CreditAgency to Broker;
+ } else if {
+ checkCredit(CreditCheckInvalid) from CreditAgency to Broker;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at SupplierQuoteEngine.scv
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at SupplierQuoteEngine.scv (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at SupplierQuoteEngine.scv 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,6 @@
+namespace null;
+
+conversation RequestForQuote_SupplierQuoteEngine at SupplierQuoteEngine implements LoanBroker at SupplierQuoteEngine {
+ getQuote(requestForQuote) from Broker to SupplierQuoteEngine;
+ getQuote(quote) from SupplierQuoteEngine to Broker;
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at SupplierTxnProcessor.scv
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at SupplierTxnProcessor.scv (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ESBBroker at SupplierTxnProcessor.scv 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,8 @@
+namespace null;
+
+conversation CompleteTransaction_SupplierTxnProcessor at SupplierTxnProcessor implements LoanBroker at SupplierTxnProcessor {
+ if {
+ confirm(orderConfirmed) from Broker to SupplierTxnProcessor;
+ confirm(bookingReference) from SupplierTxnProcessor to Broker;
+ }
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/LoanApprovalService at Service.scv
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/LoanApprovalService at Service.scv (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/LoanApprovalService at Service.scv 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,41 @@
+namespace null;
+
+conversation loanApprovalProcess {
+ try {
+ boolean receive-to-assess, receive-to-approval, approval-to-reply, assess-to-setMessage, setMessage-to-reply, assess-to-approval;
+ parallel {
+ request(creditInformationMessage) from customer;
+ receive-to-assess = xpath[true()];
+ receive-to-approval = xpath[true()];
+ } and {
+ when (xpath[$receive-to-assess]) {
+ check(creditInformationMessage) to assessor;
+ if {
+ check(riskAssessmentMessage) from assessor;
+ } else if {
+ check(errorMessage) from assessor;
+ raise lns:loanProcessFault;
+ }
+ assess-to-setMessage = xpath[true()];
+ assess-to-approval = xpath[true()];
+ }
+ } and {
+ when (xpath[$receive-to-approval and $assess-to-approval]) {
+ approve(creditInformationMessage) to approver;
+ if {
+ approve(approvalMessage) from approver;
+ } else if {
+ approve(errorMessage) from approver;
+ raise lns:loanProcessFault;
+ }
+ approval-to-reply = xpath[true()];
+ }
+ } and {
+ when (xpath[$setMessage-to-reply and $approval-to-reply]) {
+ request(approvalMessage) to customer;
+ }
+ }
+ } catch lns:loanProcessFault {
+ request(errorMessage) to customer;
+ }
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at Buyer.scv
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at Buyer.scv (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at Buyer.scv 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,10 @@
+namespace null;
+
+conversation PurchaseGoodsProcess_Buyer at Buyer implements Purchasing at Buyer {
+ buy(BuyRequest) from Buyer to Store;
+ if {
+ buy(BuyConfirmed) from Store to Buyer;
+ } else if {
+ buy(BuyFailed) from Store to Buyer;
+ }
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at CreditAgency.scv
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at CreditAgency.scv (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at CreditAgency.scv 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,10 @@
+namespace null;
+
+conversation PurchaseGoodsProcess_CreditAgency at CreditAgency implements Common at CreditAgency {
+ checkCredit(CreditCheckRequest) from Store to CreditAgency;
+ if {
+ checkCredit(CreditCheckOk) from CreditAgency to Store;
+ } else if {
+ checkCredit(CreditCheckInvalid) from CreditAgency to Store;
+ }
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at Store.scv
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at Store.scv (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/PurchaseGoods at Store.scv 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,13 @@
+namespace null;
+
+conversation PurchaseGoodsProcess_Store at Store implements Purchasing at Store {
+ buy(BuyRequest) from Buyer to Store;
+ checkCredit(CreditCheckRequest) from Store to CreditAgency;
+ if {
+ checkCredit(CreditCheckOk) from CreditAgency to Store;
+ buy(BuyConfirmed) from Store to Buyer;
+ } else if {
+ checkCredit(CreditCheckInvalid) from CreditAgency to Store;
+ buy(BuyFailed) from Store to Buyer;
+ }
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ReqRespFault at Buyer.scv
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ReqRespFault at Buyer.scv (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ReqRespFault at Buyer.scv 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,10 @@
+namespace null;
+
+conversation ReqRespFaultProcess_Buyer at Buyer implements LoanBroker at Buyer {
+ checkCredit(CreditCheckRequest) from Buyer to Seller;
+ if {
+ checkCredit(CreditCheckOk) from Seller to Buyer;
+ } else if {
+ checkCredit(CreditCheckInvalid) from Seller to Buyer;
+ }
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ReqRespFault at Seller.scv
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ReqRespFault at Seller.scv (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/results/ReqRespFault at Seller.scv 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,10 @@
+namespace null;
+
+conversation ReqRespFaultProcess_Seller at Seller implements ReqRespFaultProcess at Seller {
+ checkCredit(CreditCheckRequest) from Buyer to Seller;
+ if {
+ checkCredit(CreditCheckOk) from Seller to Buyer;
+ } else if {
+ checkCredit(CreditCheckInvalid) from Seller to Buyer;
+ }
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessor.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessor.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessor.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,20 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.LoanBroker at SupplierTxnProcessor" name="CompleteTransaction_SupplierTxnProcessor" targetNamespace="http://www.pi4soa.org/ESBBroker/Supplier" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="CompleteTransaction_SupplierTxnProcessor.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="CompleteTransaction_SupplierTxnProcessorArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <partnerLinks>
+ <partnerLink myRole="SupplierTxnProcessorService" name="BrokerToSupplierTxnProcessor" partnerLinkType="spr:BrokerToSupplierTxnProcessorServiceLT"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="spr:confirmRequest" name="confirmRequestVar"/>
+ <variable messageType="spr:confirmResponse" name="confirmResponseVar"/>
+ </variables>
+ <sequence>
+ <pick createInstance="yes">
+ <onMessage operation="confirm" partnerLink="BrokerToSupplierTxnProcessor" portType="spr:SupplierBehavior" variable="confirmRequestVar">
+ <sequence>
+ <reply name="Send_bookingReference" operation="confirm" partnerLink="BrokerToSupplierTxnProcessor" portType="spr:SupplierBehavior" variable="confirmResponseVar"/>
+ </sequence>
+ </onMessage>
+ </pick>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessor.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessor.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessor.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Supplier" targetNamespace="http://www.pi4soa.org/ESBBroker/Supplier">
+ <types xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"/>
+ </types>
+ <wsdl:message name="confirmRequest">
+ <wsdl:part element="orderConfirmed" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="confirmResponse">
+ <wsdl:part element="bookingReference" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getQuoteResponse">
+ <wsdl:part element="quote" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getQuoteRequest">
+ <wsdl:part element="requestForQuote" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="SupplierBehavior">
+ <wsdl:operation name="confirm">
+ <wsdl:input message="spr:confirmRequest">
+ </wsdl:input>
+ <wsdl:output message="spr:confirmResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getQuote">
+ <wsdl:input message="spr:getQuoteRequest">
+ </wsdl:input>
+ <wsdl:output message="spr:getQuoteResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="SupplierBehaviorBinding" type="spr:SupplierBehavior">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="confirm">
+ <soap:operation soapAction="http://www.pi4soa.org/ESBBroker/Supplier/confirm"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getQuote">
+ <soap:operation soapAction="http://www.pi4soa.org/ESBBroker/Supplier/getQuote"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="SupplierService">
+ <wsdl:port binding="spr:SupplierBehaviorBinding" name="SupplierBehaviorPort">
+ <soap:address location="http://localhost:8080/SupplierService/SupplierBehaviorPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessorArtifacts.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessorArtifacts.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/CompleteTransaction_SupplierTxnProcessorArtifacts.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" targetNamespace="http://www.pi4soa.org/ESBBroker/Supplier">
+ <wsdl:import location="CompleteTransaction_SupplierTxnProcessor.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <plnk:partnerLinkType name="BrokerToSupplierTxnProcessorServiceLT">
+ <plnk:role name="SupplierTxnProcessorService" portType="ns1:SupplierBehavior"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Broker.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Broker.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Broker.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,66 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.LoanBroker at Broker" name="ESBBrokerProcess_Broker" targetNamespace="http://www.pi4soa.org/ESBBroker/Broker" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_BrokerArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <partnerLinks>
+ <partnerLink myRole="BrokerBehavior" name="BuyerToBroker" partnerLinkType="brk:BuyerToBrokerServiceLT"/>
+ <partnerLink name="BrokerToSupplierQuoteEngine" partnerLinkType="brk:BrokerToSupplierQuoteEngineLT" partnerRole="SupplierQuoteEngineRequester"/>
+ <partnerLink name="BrokerToCreditAgency" partnerLinkType="brk:BrokerToCreditAgencyLT" partnerRole="CreditAgencyRequester"/>
+ <partnerLink name="BrokerToSupplierTxnProcessor" partnerLinkType="brk:BrokerToSupplierTxnProcessorLT" partnerRole="SupplierTxnProcessorRequester"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="brk:makeEnquiryRequest" name="makeEnquiryRequestVar"/>
+ <variable messageType="spr:getQuoteRequest" name="getQuoteRequestVar"/>
+ <variable messageType="spr:getQuoteResponse" name="getQuoteResponseVar"/>
+ <variable messageType="brk:makeEnquiryResponse" name="makeEnquiryResponseVar"/>
+ <variable messageType="brk:buyRequest" name="buyRequestVar"/>
+ <variable messageType="cay:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="cay:checkCreditResponse" name="checkCreditResponseVar"/>
+ <variable messageType="spr:confirmRequest" name="confirmRequestVar"/>
+ <variable messageType="spr:confirmResponse" name="confirmResponseVar"/>
+ <variable messageType="brk:buyResponse" name="buyResponseVar"/>
+ <variable messageType="brk:rejectedFault" name="rejectedFaultVar"/>
+ <variable messageType="brk:cancelRequest" name="cancelRequestVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_enquiry" operation="makeEnquiry" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="makeEnquiryRequestVar"/>
+ <while>
+ <sequence>
+ <scope>
+ <sequence>
+ <invoke inputVariable="getQuoteRequestVar" name="Send_requestForQuote" operation="getQuote" outputVariable="getQuoteResponseVar" partnerLink="BrokerToSupplierQuoteEngine" portType="spr:SupplierBehavior"/>
+ </sequence>
+ </scope>
+ </sequence>
+ </while>
+ <reply name="Send_quoteList" operation="makeEnquiry" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="makeEnquiryResponseVar"/>
+ <pick>
+ <onMessage operation="buy" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="buyRequestVar">
+ <sequence>
+ <scope>
+ <sequence>
+ <scope>
+ <faultHandlers>
+ <catch faultMessageType="cay:invalidCreditFault" faultName="cay:invalidCredit" faultVariable="invalidCreditFaultVar">
+ <sequence>
+ <reply faultName="brk:rejected" name="Send_orderRejected" operation="buy" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="rejectedFaultVar"/>
+ </sequence>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <invoke inputVariable="checkCreditRequestVar" name="Send_CreditCheckRequest" operation="checkCredit" outputVariable="checkCreditResponseVar" partnerLink="BrokerToCreditAgency" portType="cay:CreditAgencyBehavior"/>
+ <invoke inputVariable="confirmRequestVar" name="Send_orderConfirmed" operation="confirm" outputVariable="confirmResponseVar" partnerLink="BrokerToSupplierTxnProcessor" portType="spr:SupplierBehavior"/>
+ <reply name="Send_bookingReference" operation="buy" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="buyResponseVar"/>
+ </sequence>
+ </scope>
+ </sequence>
+ </scope>
+ </sequence>
+ </onMessage>
+ <onMessage operation="cancel" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="cancelRequestVar">
+ <sequence/>
+ </onMessage>
+ </pick>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Broker.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Broker.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Broker.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Broker" targetNamespace="http://www.pi4soa.org/ESBBroker/Broker">
+ <types xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"/>
+ </types>
+ <wsdl:message name="rejectedFault">
+ <wsdl:part element="orderRejected" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="makeEnquiryRequest">
+ <wsdl:part element="enquiry" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="buyResponse">
+ <wsdl:part element="bookingReference" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="makeEnquiryResponse">
+ <wsdl:part element="quoteList" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="buyRequest">
+ <wsdl:part element="buy" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="cancelRequest">
+ <wsdl:part element="cancel" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="BrokerBehavior">
+ <wsdl:operation name="buy">
+ <wsdl:input message="brk:buyRequest">
+ </wsdl:input>
+ <wsdl:output message="brk:buyResponse">
+ </wsdl:output>
+ <wsdl:fault message="brk:rejectedFault" name="rejected">
+ </wsdl:fault>
+ </wsdl:operation>
+ <wsdl:operation name="makeEnquiry">
+ <wsdl:input message="brk:makeEnquiryRequest">
+ </wsdl:input>
+ <wsdl:output message="brk:makeEnquiryResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="cancel">
+ <wsdl:input message="brk:cancelRequest">
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="BrokerBehaviorBinding" type="brk:BrokerBehavior">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="buy">
+ <soap:operation soapAction="http://www.pi4soa.org/ESBBroker/Broker/buy"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="rejected">
+ <soap:fault name="rejected" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ <wsdl:operation name="makeEnquiry">
+ <soap:operation soapAction="http://www.pi4soa.org/ESBBroker/Broker/makeEnquiry"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="cancel">
+ <soap:operation soapAction="http://www.pi4soa.org/ESBBroker/Broker/cancel"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="BrokerService">
+ <wsdl:port binding="brk:BrokerBehaviorBinding" name="BrokerBehaviorPort">
+ <soap:address location="http://localhost:8080/BrokerService/BrokerBehaviorPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_BrokerArtifacts.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_BrokerArtifacts.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_BrokerArtifacts.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.pi4soa.org/ESBBroker/Broker" xmlns:ns2="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:ns3="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" targetNamespace="http://www.pi4soa.org/ESBBroker/Broker">
+ <wsdl:import location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <wsdl:import location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <wsdl:import location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <plnk:partnerLinkType name="BuyerToBrokerServiceLT">
+ <plnk:role name="BrokerBehavior" portType="ns1:BrokerBehavior"/>
+ </plnk:partnerLinkType>
+ <plnk:partnerLinkType name="BrokerToSupplierQuoteEngineLT">
+ <plnk:role name="SupplierQuoteEngineRequester" portType="ns2:SupplierBehavior"/>
+ </plnk:partnerLinkType>
+ <plnk:partnerLinkType name="BrokerToCreditAgencyLT">
+ <plnk:role name="CreditAgencyRequester" portType="ns3:CreditAgencyBehavior"/>
+ </plnk:partnerLinkType>
+ <plnk:partnerLinkType name="BrokerToSupplierTxnProcessorLT">
+ <plnk:role name="SupplierTxnProcessorRequester" portType="ns2:SupplierBehavior"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Buyer.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Buyer.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Buyer.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,43 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.LoanBroker at Buyer" name="ESBBrokerProcess_Buyer" targetNamespace="http://www.pi4soa.org/ESBBroker/Buyer" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_BuyerArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Buyer"/>
+ <partnerLinks>
+ <partnerLink myRole="BrokerBehavior" name="BuyerToBroker" partnerLinkType="byr:BuyerToBrokerLT" partnerRole="BrokerRequester"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="brk:makeEnquiryRequest" name="makeEnquiryRequestVar"/>
+ <variable messageType="brk:makeEnquiryResponse" name="makeEnquiryResponseVar"/>
+ <variable messageType="brk:buyRequest" name="buyRequestVar"/>
+ <variable messageType="brk:buyResponse" name="buyResponseVar"/>
+ <variable messageType="brk:cancelRequest" name="cancelRequestVar"/>
+ </variables>
+ <sequence>
+ <invoke inputVariable="makeEnquiryRequestVar" name="Send_enquiry" operation="makeEnquiry" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior"/>
+ <receive name="Receive_quoteList" operation="makeEnquiry" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior" variable="makeEnquiryResponseVar"/>
+ <if>
+ <sequence>
+ <scope>
+ <sequence>
+ <scope>
+ <faultHandlers>
+ <catch faultMessageType="brk:rejectedFault" faultName="brk:rejected" faultVariable="rejectedFaultVar">
+ <sequence/>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <invoke inputVariable="buyRequestVar" name="Send_buy" operation="buy" outputVariable="buyResponseVar" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior"/>
+ </sequence>
+ </scope>
+ </sequence>
+ </scope>
+ </sequence>
+ <else>
+ <sequence>
+ <invoke inputVariable="cancelRequestVar" name="Send_cancel" operation="cancel" partnerLink="BuyerToBroker" portType="brk:BrokerBehavior"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_BuyerArtifacts.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_BuyerArtifacts.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_BuyerArtifacts.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.pi4soa.org/ESBBroker/Broker" xmlns:ns2="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" targetNamespace="http://www.pi4soa.org/ESBBroker/Buyer">
+ <wsdl:import location="ESBBrokerProcess_Buyer.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Buyer"/>
+ <wsdl:import location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <wsdl:import location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <wsdl:import location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <plnk:partnerLinkType name="BuyerToBrokerLT">
+ <plnk:role name="BrokerRequester" portType="ns1:BrokerBehavior"/>
+ <plnk:role name="BrokerBehavior" portType="ns2:BuyerBehavior"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgency.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgency.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgency.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,36 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.Common at CreditAgency" name="ESBBrokerProcess_CreditAgency" targetNamespace="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgencyArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <partnerLinks>
+ <partnerLink myRole="CreditAgencyService" name="BrokerToCreditAgency" partnerLinkType="cay:BrokerToCreditAgencyServiceLT"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="cay:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="cay:checkCreditResponse" name="checkCreditResponseVar"/>
+ <variable messageType="cay:invalidCreditFault" name="invalidCreditFaultVar"/>
+ </variables>
+ <sequence>
+ <pick>
+ <onMessage operation="checkCredit" partnerLink="BrokerToCreditAgency" portType="cay:CreditAgencyBehavior" variable="checkCreditRequestVar">
+ <sequence>
+ <scope>
+ <sequence>
+ <if>
+ <sequence>
+ <reply name="Send_CreditCheckOk" operation="checkCredit" partnerLink="BrokerToCreditAgency" portType="cay:CreditAgencyBehavior" variable="checkCreditResponseVar"/>
+ </sequence>
+ <else>
+ <sequence>
+ <reply faultName="cay:invalidCredit" name="Send_CreditCheckInvalid" operation="checkCredit" partnerLink="BrokerToCreditAgency" portType="cay:CreditAgencyBehavior" variable="invalidCreditFaultVar"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+ </scope>
+ </sequence>
+ </onMessage>
+ </pick>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgency.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgency.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgency.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CreditAgency" targetNamespace="http://www.pi4soa.org/ESBBroker/CreditAgency">
+ <types xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"/>
+ </types>
+ <wsdl:message name="checkCreditResponse">
+ <wsdl:part element="CreditCheckOk" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="checkCreditRequest">
+ <wsdl:part element="CreditCheckRequest" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="invalidCreditFault">
+ <wsdl:part element="CreditCheckInvalid" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="CreditAgencyBehavior">
+ <wsdl:operation name="checkCredit">
+ <wsdl:input message="cay:checkCreditRequest">
+ </wsdl:input>
+ <wsdl:output message="cay:checkCreditResponse">
+ </wsdl:output>
+ <wsdl:fault message="cay:invalidCreditFault" name="invalidCredit">
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CreditAgencyBehaviorBinding" type="cay:CreditAgencyBehavior">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="checkCredit">
+ <soap:operation soapAction="http://www.pi4soa.org/ESBBroker/CreditAgency/checkCredit"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="invalidCredit">
+ <soap:fault name="invalidCredit" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CreditAgencyService">
+ <wsdl:port binding="cay:CreditAgencyBehaviorBinding" name="CreditAgencyBehaviorPort">
+ <soap:address location="http://localhost:8080/CreditAgencyService/CreditAgencyBehaviorPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgencyArtifacts.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgencyArtifacts.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_CreditAgencyArtifacts.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" targetNamespace="http://www.pi4soa.org/ESBBroker/CreditAgency">
+ <wsdl:import location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+ <wsdl:import location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+ <wsdl:import location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <plnk:partnerLinkType name="BrokerToCreditAgencyServiceLT">
+ <plnk:role name="CreditAgencyService" portType="ns1:CreditAgencyBehavior"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Supplier.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Supplier.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ESBBrokerProcess_Supplier.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Supplier" targetNamespace="http://www.pi4soa.org/ESBBroker/Supplier">
+ <types xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"/>
+ </types>
+ <wsdl:message name="confirmRequest">
+ <wsdl:part element="orderConfirmed" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="confirmResponse">
+ <wsdl:part element="bookingReference" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getQuoteResponse">
+ <wsdl:part element="quote" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getQuoteRequest">
+ <wsdl:part element="requestForQuote" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="SupplierBehavior">
+ <wsdl:operation name="confirm">
+ <wsdl:input message="spr:confirmRequest">
+ </wsdl:input>
+ <wsdl:output message="spr:confirmResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getQuote">
+ <wsdl:input message="spr:getQuoteRequest">
+ </wsdl:input>
+ <wsdl:output message="spr:getQuoteResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="SupplierBehaviorBinding" type="spr:SupplierBehavior">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="confirm">
+ <soap:operation soapAction="http://www.pi4soa.org/ESBBroker/Supplier/confirm"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getQuote">
+ <soap:operation soapAction="http://www.pi4soa.org/ESBBroker/Supplier/getQuote"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="SupplierService">
+ <wsdl:port binding="spr:SupplierBehaviorBinding" name="SupplierBehaviorPort">
+ <soap:address location="http://localhost:8080/SupplierService/SupplierBehaviorPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/LoanApprovalService at Service.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/LoanApprovalService at Service.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/LoanApprovalService at Service.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,123 @@
+<process name="loanApprovalProcess"
+ targetNamespace="http://example.com/loan-approval/"
+ xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns:lns="http://example.com/loan-approval/wsdl/"
+ suppressJoinFailure="yes">
+ <import importType="http://schemas.xmlsoap.org/wsdl/"
+ location="loanServicePT.wsdl"
+ namespace="http://example.com/loan-approval/wsdl/" />
+ <partnerLinks>
+ <partnerLink name="customer"
+ partnerLinkType="lns:loanPartnerLT"
+ myRole="loanService" />
+ <partnerLink name="approver"
+ partnerLinkType="lns:loanApprovalLT"
+ partnerRole="approver" />
+ <partnerLink name="assessor"
+ partnerLinkType="lns:riskAssessmentLT"
+ partnerRole="assessor" />
+ </partnerLinks>
+ <variables>
+ <variable name="request"
+ messageType="lns:creditInformationMessage" />
+ <variable name="risk"
+ messageType="lns:riskAssessmentMessage" />
+ <variable name="approval"
+ messageType="lns:approvalMessage" />
+ </variables>
+ <faultHandlers>
+ <catch faultName="lns:loanProcessFault"
+ faultVariable="error"
+ faultMessageType="lns:errorMessage">
+ <reply partnerLink="customer"
+ portType="lns:loanServicePT"
+ operation="request" variable="error"
+ faultName="unableToHandleRequest" />
+ </catch>
+ </faultHandlers>
+ <flow>
+ <links>
+ <link name="receive-to-assess" />
+ <link name="receive-to-approval" />
+ <link name="approval-to-reply" />
+ <link name="assess-to-setMessage" />
+ <link name="setMessage-to-reply" />
+ <link name="assess-to-approval" />
+ </links>
+ <receive partnerLink="customer"
+ portType="lns:loanServicePT"
+ operation="request"
+ variable="request"
+ createInstance="yes">
+ <sources>
+ <source linkName="receive-to-assess">
+ <transitionCondition>
+ $request.amount < 10000
+ </transitionCondition>
+ </source>
+ <source linkName="receive-to-approval">
+ <transitionCondition>
+ $request.amount >= 10000
+ </transitionCondition>
+ </source>
+ </sources>
+ </receive>
+ <invoke partnerLink="assessor"
+ portType="lns:riskAssessmentPT"
+ operation="check"
+ inputVariable="request"
+ outputVariable="risk">
+ <targets>
+ <target linkName="receive-to-assess" />
+ </targets>
+ <sources>
+ <source linkName="assess-to-setMessage">
+ <transitionCondition>
+ $risk.level='low'
+ </transitionCondition>
+ </source>
+ <source linkName="assess-to-approval">
+ <transitionCondition>
+ $risk.level!='low'
+ </transitionCondition>
+ </source>
+ </sources>
+ </invoke>
+ <assign>
+ <targets>
+ <target linkName="assess-to-setMessage" />
+ </targets>
+ <sources>
+ <source linkName="setMessage-to-reply" />
+ </sources>
+ <copy>
+ <from>
+ <literal>yes</literal>
+ </from>
+ <to variable="approval" part="accept" />
+ </copy>
+ </assign>
+ <invoke partnerLink="approver"
+ portType="lns:loanApprovalPT"
+ operation="approve"
+ inputVariable="request"
+ outputVariable="approval">
+ <targets>
+ <target linkName="receive-to-approval" />
+ <target linkName="assess-to-approval" />
+ </targets>
+ <sources>
+ <source linkName="approval-to-reply" />
+ </sources>
+ </invoke>
+ <reply partnerLink="customer"
+ portType="lns:loanServicePT"
+ operation="request"
+ variable="approval">
+ <targets>
+ <target linkName="setMessage-to-reply" />
+ <target linkName="approval-to-reply" />
+ </targets>
+ </reply>
+ </flow>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Buyer.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Buyer.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Buyer.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,24 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:pur="java:org.jboss.savara.examples.purchasing" xmlns:sto="http://www.jboss.org/examples/store" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="savara.samples.Purchasing at Buyer" name="PurchaseGoodsProcess_Buyer" targetNamespace="http://www.jboss.org/savara/examples" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_BuyerArtifacts.wsdl" namespace="http://www.jboss.org/savara/examples"/>
+ <partnerLinks>
+ <partnerLink name="BuyerToStore" partnerLinkType="tns:BuyerToStoreLT" partnerRole="StoreRequester"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="sto:buyRequest" name="buyRequestVar"/>
+ <variable messageType="sto:buyResponse" name="buyResponseVar"/>
+ </variables>
+ <sequence>
+ <scope>
+ <faultHandlers>
+ <catch faultMessageType="sto:BuyFailedFault" faultName="sto:BuyFailed" faultVariable="BuyFailedFaultVar">
+ <sequence/>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <invoke inputVariable="buyRequestVar" name="Send_BuyRequest" operation="buy" outputVariable="buyResponseVar" partnerLink="BuyerToStore" portType="sto:StoreInterface"/>
+ </sequence>
+ </scope>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_BuyerArtifacts.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_BuyerArtifacts.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_BuyerArtifacts.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.jboss.org/examples/store" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" targetNamespace="http://www.jboss.org/savara/examples">
+ <wsdl:import location="PurchaseGoodsProcess_Buyer.wsdl" namespace="http://www.jboss.org/savara/examples"/>
+ <wsdl:import location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
+ <wsdl:import location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <plnk:partnerLinkType name="BuyerToStoreLT">
+ <plnk:role name="StoreRequester" portType="ns1:StoreInterface"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgency.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgency.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgency.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,26 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:pur="java:org.jboss.savara.examples.purchasing" xmlns:sto="http://www.jboss.org/examples/store" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="savara.samples.Common at CreditAgency" name="PurchaseGoodsProcess_CreditAgency" targetNamespace="java:org.jboss.savara.examples.purchasing" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgencyArtifacts.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
+ <partnerLinks>
+ <partnerLink myRole="CreditAgencyInterface" name="StoreToCreditAgency" partnerLinkType="pur:StoreToCreditAgencyServiceLT"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="pur:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="pur:checkCreditResponse" name="checkCreditResponseVar"/>
+ <variable messageType="pur:CreditCheckFailedFault" name="CreditCheckFailedFaultVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_CreditCheckRequest" operation="checkCredit" partnerLink="StoreToCreditAgency" portType="pur:CreditAgencyInterface" variable="checkCreditRequestVar"/>
+ <if>
+ <sequence>
+ <reply name="Send_CreditCheckOk" operation="checkCredit" partnerLink="StoreToCreditAgency" portType="pur:CreditAgencyInterface" variable="checkCreditResponseVar"/>
+ </sequence>
+ <else>
+ <sequence>
+ <reply faultName="pur:CreditCheckFailed" name="Send_CreditCheckInvalid" operation="checkCredit" partnerLink="StoreToCreditAgency" portType="pur:CreditAgencyInterface" variable="CreditCheckFailedFaultVar"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgency.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgency.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgency.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:pur="java:org.jboss.savara.examples.purchasing" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:sto="http://www.jboss.org/examples/store" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CreditAgency" targetNamespace="java:org.jboss.savara.examples.purchasing">
+ <types xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"/>
+ </types>
+ <wsdl:message name="checkCreditRequest">
+ <wsdl:part name="content" type="pur:CreditCheckRequest">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="CreditCheckFailedFault">
+ <wsdl:part name="content" type="pur:CreditCheckInvalid">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="checkCreditResponse">
+ <wsdl:part name="content" type="pur:CreditCheckOk">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="CreditAgencyInterface">
+ <wsdl:operation name="checkCredit">
+ <wsdl:input message="pur:checkCreditRequest">
+ </wsdl:input>
+ <wsdl:output message="pur:checkCreditResponse">
+ </wsdl:output>
+ <wsdl:fault message="pur:CreditCheckFailedFault" name="CreditCheckFailed">
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CreditAgencyInterfaceBinding" type="pur:CreditAgencyInterface">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="checkCredit">
+ <soap:operation soapAction="java:org.jboss.savara.examples.purchasing/checkCredit"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="CreditCheckFailed">
+ <soap:fault name="CreditCheckFailed" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CreditAgencyService">
+ <wsdl:port binding="pur:CreditAgencyInterfaceBinding" name="CreditAgencyInterfacePort">
+ <soap:address location="http://localhost:8080/CreditAgencyService/CreditAgencyInterfacePort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgencyArtifacts.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgencyArtifacts.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_CreditAgencyArtifacts.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="java:org.jboss.savara.examples.purchasing" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" targetNamespace="java:org.jboss.savara.examples.purchasing">
+ <wsdl:import location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
+ <wsdl:import location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <plnk:partnerLinkType name="StoreToCreditAgencyServiceLT">
+ <plnk:role name="CreditAgencyInterface" portType="ns1:CreditAgencyInterface"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Store.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Store.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Store.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,32 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:pur="java:org.jboss.savara.examples.purchasing" xmlns:sto="http://www.jboss.org/examples/store" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="savara.samples.Purchasing at Store" name="PurchaseGoodsProcess_Store" targetNamespace="http://www.jboss.org/examples/store" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_StoreArtifacts.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <partnerLinks>
+ <partnerLink myRole="StoreInterface" name="BuyerToStore" partnerLinkType="sto:BuyerToStoreServiceLT"/>
+ <partnerLink name="StoreToCreditAgency" partnerLinkType="sto:StoreToCreditAgencyLT" partnerRole="CreditAgencyRequester"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="sto:buyRequest" name="buyRequestVar"/>
+ <variable messageType="pur:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="pur:checkCreditResponse" name="checkCreditResponseVar"/>
+ <variable messageType="sto:buyResponse" name="buyResponseVar"/>
+ <variable messageType="sto:BuyFailedFault" name="BuyFailedFaultVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_BuyRequest" operation="buy" partnerLink="BuyerToStore" portType="sto:StoreInterface" variable="buyRequestVar"/>
+ <scope>
+ <faultHandlers>
+ <catch faultMessageType="pur:CreditCheckFailedFault" faultName="pur:CreditCheckFailed" faultVariable="CreditCheckFailedFaultVar">
+ <sequence>
+ <reply faultName="sto:BuyFailed" name="Send_BuyFailed" operation="buy" partnerLink="BuyerToStore" portType="sto:StoreInterface" variable="BuyFailedFaultVar"/>
+ </sequence>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <invoke inputVariable="checkCreditRequestVar" name="Send_CreditCheckRequest" operation="checkCredit" outputVariable="checkCreditResponseVar" partnerLink="StoreToCreditAgency" portType="pur:CreditAgencyInterface"/>
+ <reply name="Send_BuyConfirmed" operation="buy" partnerLink="BuyerToStore" portType="sto:StoreInterface" variable="buyResponseVar"/>
+ </sequence>
+ </scope>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Store.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Store.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_Store.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:pur="java:org.jboss.savara.examples.purchasing" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:sto="http://www.jboss.org/examples/store" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Store" targetNamespace="http://www.jboss.org/examples/store">
+ <types xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"/>
+ </types>
+ <wsdl:message name="BuyFailedFault">
+ <wsdl:part name="content" type="sto:BuyFailed">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="buyRequest">
+ <wsdl:part name="content" type="sto:BuyRequest">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="buyResponse">
+ <wsdl:part name="content" type="sto:BuyConfirmed">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="StoreInterface">
+ <wsdl:operation name="buy">
+ <wsdl:input message="sto:buyRequest">
+ </wsdl:input>
+ <wsdl:output message="sto:buyResponse">
+ </wsdl:output>
+ <wsdl:fault message="sto:BuyFailedFault" name="BuyFailed">
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="StoreInterfaceBinding" type="sto:StoreInterface">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="buy">
+ <soap:operation soapAction="http://www.jboss.org/examples/store/buy"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="BuyFailed">
+ <soap:fault name="BuyFailed" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="StoreService">
+ <wsdl:port binding="sto:StoreInterfaceBinding" name="StoreInterfacePort">
+ <soap:address location="http://localhost:8080/StoreService/StoreInterfacePort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_StoreArtifacts.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_StoreArtifacts.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/PurchaseGoodsProcess_StoreArtifacts.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.jboss.org/examples/store" xmlns:ns2="java:org.jboss.savara.examples.purchasing" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" targetNamespace="http://www.jboss.org/examples/store">
+ <wsdl:import location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+ <wsdl:import location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
+ <plnk:partnerLinkType name="BuyerToStoreServiceLT">
+ <plnk:role name="StoreInterface" portType="ns1:StoreInterface"/>
+ </plnk:partnerLinkType>
+ <plnk:partnerLinkType name="StoreToCreditAgencyLT">
+ <plnk:role name="CreditAgencyRequester" portType="ns2:CreditAgencyInterface"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Buyer.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Buyer.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Buyer.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,23 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:byr="http://www.pi4soa.org/ReqRespFault/Buyer" xmlns:slr="http://www.pi4soa.org/ReqRespFault/Seller" xmlns:tns="http://www.pi4soa.org/ReqRespFault" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.LoanBroker at Buyer" name="ReqRespFaultProcess_Buyer" targetNamespace="http://www.pi4soa.org/ReqRespFault/Buyer" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ReqRespFaultProcess_Seller.wsdl" namespace="http://www.pi4soa.org/ReqRespFault/Seller"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ReqRespFaultProcess_BuyerArtifacts.wsdl" namespace="http://www.pi4soa.org/ReqRespFault/Buyer"/>
+ <partnerLinks>
+ <partnerLink name="BuyerToSeller" partnerLinkType="byr:BuyerToSellerLT" partnerRole="SellerRequester"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="slr:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="slr:checkCreditResponse" name="checkCreditResponseVar"/>
+ </variables>
+ <sequence>
+ <scope>
+ <faultHandlers>
+ <catch faultMessageType="slr:insufficientCreditFault" faultName="slr:insufficientCredit" faultVariable="insufficientCreditFaultVar">
+ <sequence/>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <invoke inputVariable="checkCreditRequestVar" name="Send_CreditCheckRequest" operation="checkCredit" outputVariable="checkCreditResponseVar" partnerLink="BuyerToSeller" portType="slr:SellerBehavior"/>
+ </sequence>
+ </scope>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_BuyerArtifacts.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_BuyerArtifacts.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_BuyerArtifacts.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.pi4soa.org/ReqRespFault/Seller" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" targetNamespace="http://www.pi4soa.org/ReqRespFault/Buyer">
+ <wsdl:import location="ReqRespFaultProcess_Buyer.wsdl" namespace="http://www.pi4soa.org/ReqRespFault/Buyer"/>
+ <wsdl:import location="ReqRespFaultProcess_Seller.wsdl" namespace="http://www.pi4soa.org/ReqRespFault/Seller"/>
+ <plnk:partnerLinkType name="BuyerToSellerLT">
+ <plnk:role name="SellerRequester" portType="ns1:SellerBehavior"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Seller.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Seller.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Seller.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,25 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:byr="http://www.pi4soa.org/ReqRespFault/Buyer" xmlns:slr="http://www.pi4soa.org/ReqRespFault/Seller" xmlns:tns="http://www.pi4soa.org/ReqRespFault" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="org.pi4soa.reqrespfault.reqrespfault.ReqRespFaultProcess at Seller" name="ReqRespFaultProcess_Seller" targetNamespace="http://www.pi4soa.org/ReqRespFault/Seller" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ReqRespFaultProcess_Seller.wsdl" namespace="http://www.pi4soa.org/ReqRespFault/Seller"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="ReqRespFaultProcess_SellerArtifacts.wsdl" namespace="http://www.pi4soa.org/ReqRespFault/Seller"/>
+ <partnerLinks>
+ <partnerLink myRole="SellerBehavior" name="BuyerToSeller" partnerLinkType="slr:BuyerToSellerServiceLT"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="slr:checkCreditRequest" name="checkCreditRequestVar"/>
+ <variable messageType="slr:checkCreditResponse" name="checkCreditResponseVar"/>
+ <variable messageType="slr:insufficientCreditFault" name="insufficientCreditFaultVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_CreditCheckRequest" operation="checkCredit" partnerLink="BuyerToSeller" portType="slr:SellerBehavior" variable="checkCreditRequestVar"/>
+ <if>
+ <sequence>
+ <reply name="Send_CreditCheckOk" operation="checkCredit" partnerLink="BuyerToSeller" portType="slr:SellerBehavior" variable="checkCreditResponseVar"/>
+ </sequence>
+ <else>
+ <sequence>
+ <reply faultName="slr:insufficientCredit" name="Send_CreditCheckInvalid" operation="checkCredit" partnerLink="BuyerToSeller" portType="slr:SellerBehavior" variable="insufficientCreditFaultVar"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Seller.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Seller.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_Seller.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:byr="http://www.pi4soa.org/ReqRespFault/Buyer" xmlns:slr="http://www.pi4soa.org/ReqRespFault/Seller" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.pi4soa.org/ReqRespFault" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Seller" targetNamespace="http://www.pi4soa.org/ReqRespFault/Seller">
+ <types xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"/>
+ </types>
+ <wsdl:message name="checkCreditRequest">
+ <wsdl:part element="CreditCheckRequest" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="checkCreditResponse">
+ <wsdl:part element="CreditCheckOk" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="insufficientCreditFault">
+ <wsdl:part element="CreditCheckInvalid" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="SellerBehavior">
+ <wsdl:operation name="checkCredit">
+ <wsdl:input message="slr:checkCreditRequest">
+ </wsdl:input>
+ <wsdl:output message="slr:checkCreditResponse">
+ </wsdl:output>
+ <wsdl:fault message="slr:insufficientCreditFault" name="insufficientCredit">
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="SellerBehaviorBinding" type="slr:SellerBehavior">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="checkCredit">
+ <soap:operation soapAction="http://www.pi4soa.org/ReqRespFault/Seller/checkCredit"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="insufficientCredit">
+ <soap:fault name="insufficientCredit" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="SellerService">
+ <wsdl:port binding="slr:SellerBehaviorBinding" name="SellerBehaviorPort">
+ <soap:address location="http://localhost:8080/SellerService/SellerBehaviorPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_SellerArtifacts.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_SellerArtifacts.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/ReqRespFaultProcess_SellerArtifacts.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.pi4soa.org/ReqRespFault/Seller" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" targetNamespace="http://www.pi4soa.org/ReqRespFault/Seller">
+ <wsdl:import location="ReqRespFaultProcess_Seller.wsdl" namespace="http://www.pi4soa.org/ReqRespFault/Seller"/>
+ <plnk:partnerLinkType name="BuyerToSellerServiceLT">
+ <plnk:role name="SellerBehavior" portType="ns1:SellerBehavior"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngine.bpel
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngine.bpel (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngine.bpel 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,15 @@
+<process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="overlord.cdl.samples.LoanBroker at SupplierQuoteEngine" name="RequestForQuote_SupplierQuoteEngine" targetNamespace="http://www.pi4soa.org/ESBBroker/Supplier" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="RequestForQuote_SupplierQuoteEngine.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <import importType="http://schemas.xmlsoap.org/wsdl/" location="RequestForQuote_SupplierQuoteEngineArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <partnerLinks>
+ <partnerLink myRole="SupplierBehavior" name="BrokerToSupplierQuoteEngine" partnerLinkType="spr:BrokerToSupplierQuoteEngineServiceLT"/>
+ </partnerLinks>
+ <variables>
+ <variable messageType="spr:getQuoteRequest" name="getQuoteRequestVar"/>
+ <variable messageType="spr:getQuoteResponse" name="getQuoteResponseVar"/>
+ </variables>
+ <sequence>
+ <receive createInstance="yes" name="Receive_requestForQuote" operation="getQuote" partnerLink="BrokerToSupplierQuoteEngine" portType="spr:SupplierBehavior" variable="getQuoteRequestVar"/>
+ <reply name="Send_quote" operation="getQuote" partnerLink="BrokerToSupplierQuoteEngine" portType="spr:SupplierBehavior" variable="getQuoteResponseVar"/>
+ </sequence>
+</process>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngine.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngine.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngine.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Supplier" targetNamespace="http://www.pi4soa.org/ESBBroker/Supplier">
+ <types xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"/>
+ </types>
+ <wsdl:message name="confirmRequest">
+ <wsdl:part element="orderConfirmed" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="confirmResponse">
+ <wsdl:part element="bookingReference" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getQuoteResponse">
+ <wsdl:part element="quote" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getQuoteRequest">
+ <wsdl:part element="requestForQuote" name="content">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="SupplierBehavior">
+ <wsdl:operation name="confirm">
+ <wsdl:input message="spr:confirmRequest">
+ </wsdl:input>
+ <wsdl:output message="spr:confirmResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getQuote">
+ <wsdl:input message="spr:getQuoteRequest">
+ </wsdl:input>
+ <wsdl:output message="spr:getQuoteResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="SupplierBehaviorBinding" type="spr:SupplierBehavior">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="confirm">
+ <soap:operation soapAction="http://www.pi4soa.org/ESBBroker/Supplier/confirm"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getQuote">
+ <soap:operation soapAction="http://www.pi4soa.org/ESBBroker/Supplier/getQuote"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="SupplierService">
+ <wsdl:port binding="spr:SupplierBehaviorBinding" name="SupplierBehaviorPort">
+ <soap:address location="http://localhost:8080/SupplierService/SupplierBehaviorPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngineArtifacts.wsdl
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngineArtifacts.wsdl (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/parser/testmodels/RequestForQuote_SupplierQuoteEngineArtifacts.wsdl 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" targetNamespace="http://www.pi4soa.org/ESBBroker/Supplier">
+ <wsdl:import location="RequestForQuote_SupplierQuoteEngine.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
+ <plnk:partnerLinkType name="BrokerToSupplierQuoteEngineServiceLT">
+ <plnk:role name="SupplierBehavior" portType="ns1:SupplierBehavior"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/tests/AllTests.java
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/tests/AllTests.java (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/tests/AllTests.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,69 @@
+/*
+ * 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.bpel.tests;
+
+import org.savara.tools.bpel.generator.GeneratorTest.ChoreographyToBPELTester;
+import org.scribble.model.SubDefinitionPath;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+
+ suite.addTest(new ChoreographyToBPELTester("ESBBroker", "Broker"));
+ suite.addTest(new ChoreographyToBPELTester("ESBBroker", "Buyer"));
+ suite.addTest(new ChoreographyToBPELTester("ESBBroker", "CreditAgency"));
+ suite.addTest(new ChoreographyToBPELTester("ESBBroker",
+ new SubDefinitionPath(new String[]{"CompleteTransaction"}),
+ "SupplierTxnProcessor"));
+ suite.addTest(new ChoreographyToBPELTester("ESBBroker",
+ new SubDefinitionPath(new String[]{"RequestForQuote"}),
+ "SupplierQuoteEngine"));
+ suite.addTest(new ChoreographyToBPELTester("PurchaseGoods", "Buyer"));
+ suite.addTest(new ChoreographyToBPELTester("PurchaseGoods", "CreditAgency"));
+ suite.addTest(new ChoreographyToBPELTester("PurchaseGoods", "Store"));
+ suite.addTest(new ChoreographyToBPELTester("ReqRespFault", "Buyer"));
+ suite.addTest(new ChoreographyToBPELTester("ReqRespFault", "Seller"));
+
+ /* SAVARA-151 - need to uncomment tests and find a way to run from Tycho
+ *
+ suite.addTest(new BPELToConversationTest("ESBBrokerProcess_Broker", "ESBBroker at Broker"));
+ suite.addTest(new BPELToConversationTest("ESBBrokerProcess_Buyer", "ESBBroker at Buyer"));
+ suite.addTest(new BPELToConversationTest("ESBBrokerProcess_CreditAgency", "ESBBroker at CreditAgency"));
+ suite.addTest(new BPELToConversationTest("RequestForQuote_SupplierQuoteEngine", "ESBBroker at SupplierQuoteEngine"));
+ suite.addTest(new BPELToConversationTest("CompleteTransaction_SupplierTxnProcessor", "ESBBroker at SupplierTxnProcessor"));
+ suite.addTest(new BPELToConversationTest("PurchaseGoodsProcess_Buyer", "PurchaseGoods at Buyer"));
+ suite.addTest(new BPELToConversationTest("PurchaseGoodsProcess_CreditAgency", "PurchaseGoods at CreditAgency"));
+ suite.addTest(new BPELToConversationTest("PurchaseGoodsProcess_Store", "PurchaseGoods at Store"));
+ suite.addTest(new BPELToConversationTest("ReqRespFaultProcess_Buyer", "ReqRespFault at Buyer"));
+ suite.addTest(new BPELToConversationTest("ReqRespFaultProcess_Seller", "ReqRespFault at Seller"));
+ */
+
+ /**
+ * TODO: (SAVARA-150) Commenting out this test for now, as we now need the accompanying WSDL to be able to
+ * resolve the message type's underlying XSD element or type.
+ *
+ suite.addTest(new BPELToConversationTest("LoanApprovalService at Service", "LoanApprovalService at Service"));
+ */
+
+ return suite;
+ }
+}
\ No newline at end of file
Added: trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/tests/osgi/Activator.java
===================================================================
--- trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/tests/osgi/Activator.java (rev 0)
+++ trunk/tools/tests/org.savara.tools.bpel.tests/src/java/org/savara/tools/bpel/tests/osgi/Activator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,22 @@
+package org.savara.tools.bpel.tests.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/tools/tests/pom.xml
===================================================================
--- trunk/tools/tests/pom.xml (rev 0)
+++ trunk/tools/tests/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.tools</groupId>
+ <artifactId>tests</artifactId>
+ <packaging>pom</packaging>
+ <version>1.2.0-SNAPSHOT</version>
+ <name>Savara::Tools::Tests</name>
+
+ <parent>
+ <groupId>org.savara</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <modules>
+ <module>org.savara.protocol.contract.tests</module>
+ <!-- module>org.savara.tools.bpel.tests</module -->
+ </modules>
+
+</project>
+
Added: trunk/validators/jboss/common/pom.xml
===================================================================
--- trunk/validators/jboss/common/pom.xml (rev 0)
+++ trunk/validators/jboss/common/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,132 @@
+<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.validators</groupId>
+ <artifactId>savara-validator-jboss</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Savara::Validators::JBoss::Common</name>
+
+ <parent>
+ <groupId>org.savara.validators</groupId>
+ <artifactId>jboss</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.pi4soa</groupId>
+ <artifactId>org.pi4soa.common</artifactId>
+ <version>${pi4soa.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.pi4soa</groupId>
+ <artifactId>org.pi4soa.cdl</artifactId>
+ <version>${pi4soa.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.pi4soa</groupId>
+ <artifactId>org.pi4soa.service</artifactId>
+ <version>${pi4soa.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.savara.dependencies.eclipse</groupId>
+ <artifactId>emf-common</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.savara.dependencies.eclipse</groupId>
+ <artifactId>emf-ecore</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.savara.dependencies.eclipse</groupId>
+ <artifactId>emf-ecore-xmi</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <version>${jboss.version}</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>dist</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>savara-validator-jboss.sar</finalName>
+ <appendAssemblyId>true</appendAssemblyId>
+ <descriptors>
+ <descriptor>src/main/configs/common-assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-javadoc</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <doclet>org.jboss.apiviz.APIviz</doclet>
+ <docletArtifact>
+ <groupId>org.jboss.apiviz</groupId>
+ <artifactId>apiviz</artifactId>
+ <version>1.2.4.GA</version>
+ </docletArtifact>
+ <aggregate>true</aggregate>
+ <attach>false</attach>
+ <additionalparam>
+ -d ${project.build.directory}/javadoc
+ -charset UTF-8
+ -docencoding UTF-8
+ -version
+ -author
+ -breakiterator
+ -windowtitle "${project.name} ${project.version} API Reference"
+ -doctitle "${project.name} ${project.version} API Reference"
+ -bottom "Copyright © ${project.inceptionYear}-Present ${project.organization.name}. All Rights Reserved."
+ -link http://java.sun.com/javase/6/docs/api/
+ -sourceclasspath ${project.build.outputDirectory}
+ </additionalparam>
+ <encoding>UTF-8</encoding>
+ <locale>en_US</locale>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
Added: trunk/validators/jboss/common/src/main/configs/META-INF/jbm-queue-service.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/META-INF/jbm-queue-service.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/META-INF/jbm-queue-service.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+
+ <mbean code="org.jboss.jms.server.destination.TopicService"
+ name="jboss.messaging.destination:service=Topic,name=tracker"
+ xmbean-dd="xmdesc/Topic-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+
+</server>
Added: trunk/validators/jboss/common/src/main/configs/META-INF/jboss-beans.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/META-INF/jboss-beans.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/META-INF/jboss-beans.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean class="org.savara.validator.service.ServiceValidatorService"
+ name="ServiceValidator">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.savara:service=ServiceValidatorManager", exposedInterface=org.savara.validator.service.ServiceValidatorServiceMBean.class,registerDirectly=true)</annotation>
+ <property name="jndiName"><value>savara/ServiceValidatorManager</value></property>
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss.messaging.destination:service=Topic,name=tracker</depends>
+ </bean>
+
+</deployment>
Added: trunk/validators/jboss/common/src/main/configs/META-INF/jboss-scanning.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/META-INF/jboss-scanning.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/META-INF/jboss-scanning.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,3 @@
+<scanning xmlns="urn:jboss:scanning:1.0">
+ <!-- prevent scanning for annotations -->
+</scanning>
Added: trunk/validators/jboss/common/src/main/configs/META-INF/jboss-structure.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/META-INF/jboss-structure.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/META-INF/jboss-structure.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<structure>
+ <context>
+ <path name=""/>
+ <metaDataPath>
+ <path name="META-INF"/>
+ </metaDataPath>
+ <classpath>
+ <path name=""/>
+ <path name="" suffixes=".jar" />
+ <path name="lib" suffixes=".jar" />
+ </classpath>
+ </context>
+</structure>
Added: trunk/validators/jboss/common/src/main/configs/common-assembly.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/common-assembly.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/common-assembly.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,33 @@
+<assembly 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/xsd/assembly-1.1.0-SNAPSHOT.xsd">
+ <id>dist</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/configs</directory>
+ <outputDirectory>/</outputDirectory>
+ <excludes>
+ <exclude>common-assembly.xml</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>/lib</outputDirectory>
+ <includes>
+ <include>org.savara.validators:savara-validator-jboss</include>
+ <include>org.pi4soa:org.pi4soa.common</include>
+ <include>org.pi4soa:org.pi4soa.cdl</include>
+ <include>org.pi4soa:org.pi4soa.service</include>
+ <include>org.jboss.savara.dependencies.eclipse:emf-common</include>
+ <include>org.jboss.savara.dependencies.eclipse:emf-ecore</include>
+ <include>org.jboss.savara.dependencies.eclipse:emf-ecore-xmi</include>
+ </includes>
+ </dependencySet>
+ </dependencySets>
+
+</assembly>
Added: trunk/validators/jboss/common/src/main/configs/models/PurchaseGoods.cdm
===================================================================
--- trunk/validators/jboss/common/src/main/configs/models/PurchaseGoods.cdm (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/models/PurchaseGoods.cdm 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<org.pi4soa.cdl:Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org.pi4soa.cdl="http:///org/pi4soa/cdl.ecore" description="The choreography description for PurchaseGoods" name="PurchaseGoods" author="gary" version="0.1" targetNamespace="http://www.jboss.org/savara/examples">
+ <typeDefinitions>
+ <nameSpaces description="Target Namespace for PurchaseGoods" prefix="tns" uRI="http://www.jboss.org/savara/examples"/>
+ <nameSpaces description="XML Schema Namespace" prefix="xsd" uRI="http://www.w3.org/2001/XMLSchema"/>
+ <nameSpaces prefix="sto" uRI="http://www.jboss.org/examples/store" schemaLocation="store.xsd"/>
+ <nameSpaces prefix="ca" uRI="http://www.jboss.org/examples/creditAgency" schemaLocation="creditAgency.xsd"/>
+ <informationTypes description="This is the information type BuyConfirmed" name="BuyConfirmed" typeName="" elementName="sto:BuyConfirmed"/>
+ <informationTypes description="This is the information type BuyFailed" name="BuyFailed" typeName="" elementName="sto:BuyFailed"/>
+ <informationTypes description="This is the information type BuyRequest" name="BuyRequest" typeName="" elementName="sto:BuyRequest"/>
+ <informationTypes description="This is the information type CreditCheckInvalid" name="CreditCheckInvalid" typeName="" elementName="ca:CreditCheckInvalid"/>
+ <informationTypes description="This is the information type CreditCheckOk" name="CreditCheckOk" typeName="" elementName="ca:CreditCheckOk"/>
+ <informationTypes description="This is the information type CreditCheckRequest" name="CreditCheckRequest" typeName="" elementName="ca:CreditCheckRequest"/>
+ <informationTypes description="This is the information type IDType" name="IDType" typeName="xsd:string"/>
+ <informationTypes description="This is the information type URITokenType" name="URITokenType" typeName="xsd:anyURI"/>
+ <tokens description="This is the token ID" name="ID" informationType="//@typeDefinitions/@informationTypes.6"/>
+ <tokens description="This is the token URIToken" name="URIToken" informationType="//@typeDefinitions/@informationTypes.7"/>
+ <tokenLocators description="This is the token locator BuyFailedIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.1" query="//@id" name="BuyFailedIDLocator"/>
+ <tokenLocators description="This is the token locator BuyRequestIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.2" query="//@id" name="BuyRequestIDLocator"/>
+ <tokenLocators description="This is the token locator BuyResponseIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.0" query="//@id" name="BuyResponseIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckInvalidIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.3" query="//@id" name="CreditCheckInvalidIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckRequestIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.5" query="//@id" name="CreditCheckRequestIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckResponseIDLocator" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.4" query="//@id" name="CreditCheckResponseIDLocator"/>
+ <roleTypes description="This is the role type Buyer" name="Buyer">
+ <behaviors description="This is the behavior BuyerBehavior" name="BuyerBehavior"/>
+ </roleTypes>
+ <roleTypes description="This is the role type CreditAgency" name="CreditAgency">
+ <behaviors description="This is the behavior CreditAgencyBehavior" name="CreditAgencyBehavior" interface="ca:CreditAgencyInterface"/>
+ </roleTypes>
+ <roleTypes description="This is the role type Store" name="Store">
+ <behaviors description="This is the behavior StoreBehavior" name="StoreBehavior" interface="sto:StoreInterface"/>
+ </roleTypes>
+ <relationshipTypes description="Relationship between Buyer and Store" name="BuyerToStoreRel" firstRoleType="//@typeDefinitions/@roleTypes.0" secondRoleType="//@typeDefinitions/@roleTypes.2"/>
+ <relationshipTypes description="Relationship between Store and CreditAgency" name="StoreToCreditAgencyRel" firstRoleType="//@typeDefinitions/@roleTypes.2" secondRoleType="//@typeDefinitions/@roleTypes.1"/>
+ <participantTypes description="This is the participant type Buyer" name="Buyer" roleTypes="//@typeDefinitions/@roleTypes.0">
+ <semanticAnnotations annotation="savara.samples.Purchasing at Buyer" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type ca:CreditAgency" name="ca:CreditAgency" roleTypes="//@typeDefinitions/@roleTypes.1">
+ <semanticAnnotations annotation="savara.samples.Common at CreditAgency" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type sto:Store" name="sto:Store" roleTypes="//@typeDefinitions/@roleTypes.2">
+ <semanticAnnotations annotation="savara.samples.Purchasing at Store" name="conversationType"/>
+ </participantTypes>
+ <channelTypes description="This is the channel type CreditAgencyChannelType" name="CreditAgencyChannelType" referenceToken="//@typeDefinitions/@tokens.1" roleType="//@typeDefinitions/@roleTypes.1">
+ <identities description="ID" tokens="//@typeDefinitions/@tokens.0"/>
+ </channelTypes>
+ <channelTypes description="This is the channel type StoreChannelType" name="StoreChannelType" referenceToken="//@typeDefinitions/@tokens.1" roleType="//@typeDefinitions/@roleTypes.2">
+ <identities description="ID" tokens="//@typeDefinitions/@tokens.0"/>
+ </channelTypes>
+ </typeDefinitions>
+ <choreographies description="Choreography flow for the PurchaseGoods process" name="PurchaseGoodsProcess" root="true">
+ <variableDefinitions description="Channel to facilitate interaction to CreditAgency" name="CreditAgencyChannel" type="//@typeDefinitions/@channelTypes.0"/>
+ <variableDefinitions name="CreditCheckVar" type="//@typeDefinitions/@informationTypes.5"/>
+ <variableDefinitions description="Channel to facilitate interaction to Supplier" name="SupplierChannel" type="//@typeDefinitions/@channelTypes.1"/>
+ <variableDefinitions description="This is the variable buy" name="buy" type="//@typeDefinitions/@informationTypes.2"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="BuyRequest" operation="buy" channelVariable="//@choreographies.0/@variableDefinitions.2" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction BuyRequest" name="BuyRequestRequestExchange" type="//@typeDefinitions/@informationTypes.2">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/store}StoreService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheck" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction CreditCheck" name="CreditCheckRequestExchange" type="//@typeDefinitions/@informationTypes.5" receiveVariable="//@choreographies.0/@variableDefinitions.1">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAgencyService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Choice" description="Is credit ok?">
+ <activities xsi:type="org.pi4soa.cdl:Conditional" name="CreditValid" expression="cdl:getVariable('CreditCheckVar','','//@amount','CreditAgency') < 250">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckOk" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckOk" name="CreditCheckOkRespondExchange" type="//@typeDefinitions/@informationTypes.4" action="Respond">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAgencyService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="BuyConfirmed" operation="buy" channelVariable="//@choreographies.0/@variableDefinitions.2" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction BuyConfirmed" name="BuyConfirmedRespondExchange" type="//@typeDefinitions/@informationTypes.0" action="Respond">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/store}StoreService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Credit Invalid">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckFailed" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckFailed" name="CreditCheckFailedRespondExchange" type="//@typeDefinitions/@informationTypes.3" action="Respond" faultName="CreditCheckFailed">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAgencyService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="BuyFailed" operation="buy" channelVariable="//@choreographies.0/@variableDefinitions.2" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction BuyFailed" name="BuyFailedRespondExchange" type="//@typeDefinitions/@informationTypes.1" action="Respond" faultName="BuyFailed">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the destination;string;;{http://www.jboss.org/examples/store}StoreService}}"
		type="{{Type;The type of destination;enum;endpoint address,service name;service name}}" />
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </activities>
+ </activities>
+ </choreographies>
+</org.pi4soa.cdl:Package>
Added: trunk/validators/jboss/common/src/main/configs/models/TrailBlazer.cdm
===================================================================
--- trunk/validators/jboss/common/src/main/configs/models/TrailBlazer.cdm (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/models/TrailBlazer.cdm 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<org.pi4soa.cdl:Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org.pi4soa.cdl="http:///org/pi4soa/cdl.ecore" description="The choreography description for TrailBlazer" name="TrailBlazer" author="gary" version="0.1" targetNamespace="http://www.pi4soa.org/TrailBlazer">
+ <typeDefinitions>
+ <nameSpaces description="Target Namespace for TrailBlazer" prefix="tns" uRI="http://www.pi4soa.org/TrailBlazer"/>
+ <nameSpaces description="XML Schema Namespace" prefix="xsd" uRI="http://www.w3.org/2001/XMLSchema"/>
+ <informationTypes description="This is the information type CreditCheckReq" name="CreditCheckReq" elementName="creditCheck"/>
+ <informationTypes description="This is the information type CreditCheckResp" name="CreditCheckResp" elementName="creditCheckResult"/>
+ <informationTypes description="This is the information type InsufficientCredit" name="InsufficientCredit" elementName="insufficientCredit"/>
+ <informationTypes description="This is the information type Quote" name="Quote" elementName="quote"/>
+ <informationTypes description="This is the information type QuoteRefType" name="QuoteRefType" typeName="xsd:string"/>
+ <informationTypes description="This is the information type QuoteReq" name="QuoteReq" elementName="quoteRequest"/>
+ <informationTypes description="This is the information type SSNType" name="SSNType" typeName="xsd:string"/>
+ <informationTypes description="This is the information type URIType" name="URIType" typeName="xsd:anyURI"/>
+ <tokens description="This is the token QuoteRef" name="QuoteRef" informationType="//@typeDefinitions/@informationTypes.4"/>
+ <tokens description="This is the token SSN" name="SSN" informationType="//@typeDefinitions/@informationTypes.6"/>
+ <tokens description="This is the token URI" name="URI" informationType="//@typeDefinitions/@informationTypes.7"/>
+ <tokenLocators description="This is the token locator QuoteRef4InsufficientCredit" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.2" query="//ref/text()" name="QuoteRef4InsufficientCredit"/>
+ <tokenLocators description="This is the token locator QuoteRef4Quote" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.3" query="//ref/text()" name="QuoteRef4Quote"/>
+ <tokenLocators description="This is the token locator QuoteRef4QuoteReq" token="//@typeDefinitions/@tokens.0" informationType="//@typeDefinitions/@informationTypes.5" query="//@ref" name="QuoteRef4QuoteReq"/>
+ <tokenLocators description="This is the token locator SSN4CreditCheckReq" token="//@typeDefinitions/@tokens.1" informationType="//@typeDefinitions/@informationTypes.0" query="//@ssn" name="SSN4CreditCheckReq"/>
+ <tokenLocators description="This is the token locator SSN4CreditCheckResp" token="//@typeDefinitions/@tokens.1" informationType="//@typeDefinitions/@informationTypes.1" query="//@ssn" name="SSN4CreditCheckResp"/>
+ <tokenLocators description="This is the token locator SSN4InsufficientCredit" token="//@typeDefinitions/@tokens.1" informationType="//@typeDefinitions/@informationTypes.2" query="//customerUID/text()" name="SSN4InsufficientCredit"/>
+ <tokenLocators description="This is the token locator SSN4Quote" token="//@typeDefinitions/@tokens.1" informationType="//@typeDefinitions/@informationTypes.3" query="//customerUID/text()" name="SSN4Quote"/>
+ <tokenLocators description="This is the token locator SSN4QuoteReq" token="//@typeDefinitions/@tokens.1" informationType="//@typeDefinitions/@informationTypes.5" query="//@ssn" name="SSN4QuoteReq"/>
+ <roleTypes description="This is the role type Bank" name="Bank">
+ <behaviors description="This is the behavior BankBehavior" name="BankBehavior" interface="bank"/>
+ </roleTypes>
+ <roleTypes description="This is the role type CreditAgency" name="CreditAgency">
+ <behaviors description="This is the behavior CreditAgencyBehavior" name="CreditAgencyBehavior" interface="creditAgency"/>
+ </roleTypes>
+ <roleTypes description="This is the role type LoanBroker" name="LoanBroker">
+ <behaviors description="This is the behavior LoanBrokerBehavior" name="LoanBrokerBehavior" interface="loanBroker"/>
+ </roleTypes>
+ <roleTypes description="This is the role type Notifier" name="Notifier">
+ <behaviors description="This is the behavior NotifierBehavior" name="NotifierBehavior" interface="notifier"/>
+ </roleTypes>
+ <relationshipTypes description="Relationship between LoanBroker and Bank" name="LoanBrokerToBankRel" firstRoleType="//@typeDefinitions/@roleTypes.2" secondRoleType="//@typeDefinitions/@roleTypes.0"/>
+ <relationshipTypes description="Relationship between LoanBroker and CreditAgency" name="LoanBrokerToCreditAgencyRel" firstRoleType="//@typeDefinitions/@roleTypes.2" secondRoleType="//@typeDefinitions/@roleTypes.1"/>
+ <relationshipTypes description="Relationship between LoanBroker and Notifier" name="LoanBrokerToNotifierRel" firstRoleType="//@typeDefinitions/@roleTypes.2" secondRoleType="//@typeDefinitions/@roleTypes.3"/>
+ <participantTypes description="This is the participant type BankParticipant" name="BankParticipant" roleTypes="//@typeDefinitions/@roleTypes.0"/>
+ <participantTypes description="This is the participant type CreditAgencyParticipant" name="CreditAgencyParticipant" roleTypes="//@typeDefinitions/@roleTypes.1"/>
+ <participantTypes description="This is the participant type LoanBrokerParticipant" name="LoanBrokerParticipant" roleTypes="//@typeDefinitions/@roleTypes.2"/>
+ <participantTypes description="This is the participant type NotifierParticipant" name="NotifierParticipant" roleTypes="//@typeDefinitions/@roleTypes.3"/>
+ <channelTypes description="This is the channel type BankChannelType" name="BankChannelType" referenceToken="//@typeDefinitions/@tokens.2" roleType="//@typeDefinitions/@roleTypes.0">
+ <identities description="SSN Id and Quote Ref" tokens="//@typeDefinitions/@tokens.1 //@typeDefinitions/@tokens.0"/>
+ <identities description="SSN Id" type="Association" tokens="//@typeDefinitions/@tokens.1"/>
+ </channelTypes>
+ <channelTypes description="This is the channel type CreditAgencyChannelType" name="CreditAgencyChannelType" referenceToken="//@typeDefinitions/@tokens.2" roleType="//@typeDefinitions/@roleTypes.1">
+ <identities description="SSN Id" tokens="//@typeDefinitions/@tokens.1"/>
+ </channelTypes>
+ <channelTypes description="This is the channel type NotifierChannelType" name="NotifierChannelType" referenceToken="//@typeDefinitions/@tokens.2" roleType="//@typeDefinitions/@roleTypes.3">
+ <identities description="SSN Id" type="Association" tokens="//@typeDefinitions/@tokens.1"/>
+ <identities description="SSN Id and Quote Ref" tokens="//@typeDefinitions/@tokens.1 //@typeDefinitions/@tokens.0"/>
+ </channelTypes>
+ </typeDefinitions>
+ <choreographies description="Choreography flow for the TrailBlazer process" name="TrailBlazerProcess" root="true">
+ <enclosedChoreographies name="RequestQuote">
+ <variableDefinitions description="Channel to facilitate interaction to Bank" name="BankChannel" type="//@typeDefinitions/@channelTypes.0" roleTypes="//@typeDefinitions/@roleTypes.0 //@typeDefinitions/@roleTypes.2"/>
+ <variableDefinitions description="Channel to facilitate interaction to Notifier" name="NotifierChannel" type="//@typeDefinitions/@channelTypes.2" roleTypes="//@typeDefinitions/@roleTypes.2 //@typeDefinitions/@roleTypes.3"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="QuoteRequest" operation="requestQuote" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction QuoteRequest" name="QuoteRequestRequestExchange" type="//@typeDefinitions/@informationTypes.5">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-jmsBankRequestQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-fileBankRequestQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction QuoteRequest" name="QuoteRequestRespondExchange" type="//@typeDefinitions/@informationTypes.3" action="Respond">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-jmsBankResponseQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-fileBankResponseQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="NotifyCustomer" operation="notify" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction NotifyCustomer" name="NotifyCustomerRequestExchange" type="//@typeDefinitions/@informationTypes.3">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-customerNotifier}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </enclosedChoreographies>
+ <variableDefinitions description="Channel to facilitate interaction to CreditAgency" name="CreditAgencyChannel" type="//@typeDefinitions/@channelTypes.1" roleTypes="//@typeDefinitions/@roleTypes.1 //@typeDefinitions/@roleTypes.2"/>
+ <variableDefinitions description="This is the variable NotifierChannel" name="NotifierChannel" type="//@typeDefinitions/@channelTypes.2" roleTypes="//@typeDefinitions/@roleTypes.2 //@typeDefinitions/@roleTypes.3"/>
+ <variableDefinitions description="This is the variable creditCheckResult" name="creditCheckResult" type="//@typeDefinitions/@informationTypes.1" roleTypes="//@typeDefinitions/@roleTypes.2"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheck" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction CreditCheck" name="CreditCheckRequestExchange" type="//@typeDefinitions/@informationTypes.0">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-creditAgencyQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheck" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheck" name="CreditCheckRespondExchange" type="//@typeDefinitions/@informationTypes.1" action="Respond" receiveVariable="//@choreographies.0/@variableDefinitions.2">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-creditAgencyQueue_reply}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Choice">
+ <activities xsi:type="org.pi4soa.cdl:Conditional" description="Sufficient credit to request quotes" name="ValidCredit" expression="cdl:getVariable('creditCheckResult','','//@score') >= 4">
+ <activities xsi:type="org.pi4soa.cdl:Parallel">
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="First quote">
+ <activities xsi:type="org.pi4soa.cdl:Perform" choreography="//@choreographies.0/@enclosedChoreographies.0"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Second quote">
+ <activities xsi:type="org.pi4soa.cdl:Perform" choreography="//@choreographies.0/@enclosedChoreographies.0"/>
+ </activities>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Insufficient credit">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="NotifyCustomer" operation="notify" channelVariable="//@choreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction NotifyCustomer" name="NotifyCustomerRequestExchange" type="//@typeDefinitions/@informationTypes.2">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-customerNotifier}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </activities>
+ </activities>
+ </choreographies>
+</org.pi4soa.cdl:Package>
Added: trunk/validators/jboss/common/src/main/configs/pi4soa.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/pi4soa.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/pi4soa.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,31 @@
+<!--
+/*
+# * 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:
+# * 16, June 2008: Initial version created by gary
+# */
+-->
+
+<pi4soa>
+ <monitor>
+ <serviceTracker class="org.savara.validator.pi4soa.JMSServiceTracker" >
+ <jmsConnectionFactory>ConnectionFactory</jmsConnectionFactory>
+ <jmsDestination>topic/tracker</jmsDestination>
+ <recordMessagePayload>true</recordMessagePayload>
+ </serviceTracker>
+ </monitor>
+</pi4soa>
\ No newline at end of file
Added: trunk/validators/jboss/common/src/main/configs/validator-config.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/validator-config.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/validator-config.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,2 @@
+<validator mode="monitor" replyToTimeout="10000" >
+</validator>
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/AbstractServiceValidator.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/AbstractServiceValidator.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/AbstractServiceValidator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,70 @@
+/*
+ * 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.validator;
+
+/**
+ * Abstract base class representing the ServiceValidator.
+ */
+public abstract class AbstractServiceValidator implements ServiceValidator {
+
+ private static final String MODELS_PATH = "models/";
+
+ /**
+ * This is the constructor for the abstract
+ * service validator, initialised with the validator
+ * name.
+ *
+ * @param name The validator name
+ */
+ public AbstractServiceValidator(ValidatorName name) {
+ m_name = name;
+ }
+
+ /**
+ * This method returns the validator name.
+ *
+ * @return The validator name
+ */
+ public ValidatorName getValidatorName() {
+ return(m_name);
+ }
+
+ /**
+ * This method returns the input stream associated
+ * with the model. Once the input stream has been
+ * used, it is the caller's responsibility to close
+ * the stream.
+ *
+ * @return The model's input stream, or null if
+ * not found
+ */
+ protected java.io.InputStream getModel() {
+ String filePath=MODELS_PATH+getValidatorName().getModelName();
+
+ java.io.InputStream ret = AbstractServiceValidator.class.
+ getClassLoader().getResourceAsStream(filePath);
+
+ return(ret);
+ }
+
+ public String toString() {
+ return("ServiceValidator["+getValidatorName()+"]");
+ }
+
+ private ValidatorName m_name=null;
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/DefaultValidatorConfig.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/DefaultValidatorConfig.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/DefaultValidatorConfig.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.validator;
+
+/**
+ * This class represents a default configuration that will be used for
+ * validation against a stream of ESB based messages.
+ */
+public class DefaultValidatorConfig implements ValidatorConfig {
+
+ /**
+ * This is the constructor for the default validator model.
+ *
+ * @param modeType The model type
+ * @param config The configuration
+ */
+ public DefaultValidatorConfig(String modelType, org.w3c.dom.Element config) {
+ m_modelType = modelType;
+ m_configuration = config;
+ }
+
+ /**
+ * This method returns the type of the model associated
+ * with this validator configuration. This will
+ * general be based on the file extension of the model
+ * file.
+ *
+ * @return The model type
+ */
+ public String getModelType() {
+ return(m_modelType);
+ }
+
+ /**
+ * This method returns the validator configuration
+ * associated with the model.
+ *
+ * @return The validator model
+ */
+ public org.w3c.dom.Element getConfiguration() {
+ return(m_configuration);
+ }
+
+ private String m_modelType=null;
+ private org.w3c.dom.Element m_configuration=null;
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/Endpoint.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/Endpoint.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/Endpoint.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,87 @@
+/*
+ * 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.validator;
+
+/**
+ * This class represents an endpoint being monitored by one
+ * or more service validator.
+ */
+public class Endpoint {
+
+ /**
+ * This is the constructor for the endpoint, supplying
+ * the destination associated with the endpoint.
+ *
+ * @param destination The destination
+ */
+ public Endpoint(String destination) {
+ m_destination = destination;
+ }
+
+ /**
+ * This method returns the destination for the endpoint.
+ *
+ * @return The destination
+ */
+ public String getDestination() {
+ return(m_destination);
+ }
+
+ /**
+ * This method returns the list of service validators
+ * associated with this endpoint.
+ *
+ * @return The list of service validators for this endpoint
+ */
+ public java.util.List<ServiceValidator> getServiceValidators() {
+ return(m_validators);
+ }
+
+ public boolean equals(Object obj) {
+ boolean ret=false;
+
+ if (obj instanceof Endpoint) {
+ Endpoint ep=(Endpoint)obj;
+
+ if (ep.getDestination() != null &&
+ ep.getDestination().equals(m_destination)) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+
+ public int hashCode() {
+ int ret=0;
+
+ if (m_destination != null) {
+ ret = m_destination.hashCode();
+ }
+
+ return(ret);
+ }
+
+ public String toString() {
+ return("Endpoint["+m_destination+"]");
+ }
+
+ private String m_destination=null;
+ private java.util.List<ServiceValidator> m_validators=
+ new java.util.Vector<ServiceValidator>();
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidator.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidator.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,68 @@
+/*
+ * 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.validator;
+
+/**
+ * This interface represents a service validator responsible for
+ * validing a stream of ESB messages against a model.
+ */
+public interface ServiceValidator {
+
+ /**
+ * This method returns the validator name.
+ *
+ * @return The validator name
+ */
+ public ValidatorName getValidatorName();
+
+ /**
+ * This method processes a sent message against a service
+ * behavioural description.
+ *
+ * @param mesgType The optional message type
+ * @param msg The message
+ * @throws Exception Failed to process sent message
+ */
+ public void messageSent(String mesgType, java.io.Serializable msg) throws Exception;
+
+ /**
+ * This method processes a received message against a service
+ * behavioural description.
+ *
+ * @param mesgType The optional message type
+ * @param msg The message
+ * @throws Exception Failed to process received message
+ */
+ public void messageReceived(String mesgType, java.io.Serializable msg) throws Exception;
+
+ /**
+ * This method is called to update the model associated
+ * with the service validator.
+ *
+ * @throws Exception Failed to update the service validator
+ */
+ public void update() throws Exception;
+
+ /**
+ * This method closes the service validator.
+ *
+ * @throws Exception Failed to close the service validator
+ */
+ public void close() throws Exception;
+
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidatorFactory.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidatorFactory.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidatorFactory.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,71 @@
+/*
+ * 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.validator;
+
+import java.lang.reflect.Constructor;
+import org.apache.log4j.Logger;
+
+/**
+ * This class provides a factory for Service Validators.
+ */
+public class ServiceValidatorFactory {
+
+ /**
+ * This method returns the Service Validator appropriate
+ * for the supplied validator name.
+ *
+ * @param name The validator name
+ * @return The service validator
+ * @exception IOException Failed to create the service validator
+ */
+ public static ServiceValidator getServiceValidator(ValidatorName name)
+ throws Exception {
+ ServiceValidator ret=null;
+
+ String modelType=name.getModelType();
+
+ if (modelType != null &&
+ m_validatorClasses.containsKey(modelType)) {
+ Class<?> cls=m_validatorClasses.get(modelType);
+
+ Constructor<?> con=cls.getConstructor(
+ new Class[]{ValidatorName.class});
+
+ ret = (ServiceValidator)con.newInstance(new Object[]{name});
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Returning service validator for "+
+ name+": "+ret);
+ }
+
+ return(ret);
+ }
+
+ private static final Logger logger = Logger.getLogger(ServiceValidatorFactory.class);
+
+ private static java.util.Map<String,Class<?>> m_validatorClasses=
+ new java.util.HashMap<String,Class<?>>();
+
+ static {
+ m_validatorClasses.put(org.savara.validator.pi4soa.Pi4SOAServiceRecorder.getModelType(),
+ org.savara.validator.pi4soa.Pi4SOAServiceRecorder.class);
+ m_validatorClasses.put(org.savara.validator.pi4soa.Pi4SOAServiceValidator.getModelType(),
+ org.savara.validator.pi4soa.Pi4SOAServiceValidator.class);
+ }
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidatorManager.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidatorManager.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/ServiceValidatorManager.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,972 @@
+/*
+ * 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.validator;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.log4j.Logger;
+
+/**
+ * This class is responsible for managing the active
+ * service validators, the mapping of endpoints to the service
+ * validators and updating the configuration when changes
+ * are detected.
+ */
+public class ServiceValidatorManager {
+
+ /**
+ * Default constructor for the service validator manager.
+ */
+ public ServiceValidatorManager() {
+ initialize();
+ }
+
+ /**
+ * This method initializes the service validator manager on
+ * startup.
+ */
+ protected void initialize() {
+
+ java.net.URL url=
+ ServiceValidatorManager.class.getClassLoader().getResource(CONFIG_FILE);
+
+ if (url != null) {
+ m_validatorConfigFile = new java.io.File(url.getFile());
+
+ java.io.File[] files=m_validatorConfigFile.getParentFile().listFiles();
+
+ for (int i=0; m_modelsDir == null && i < files.length; i++) {
+ if (files[i].getName().equals("models") &&
+ files[i].isDirectory()) {
+ m_modelsDir = files[i];
+ }
+ }
+
+ if (m_modelsDir != null) {
+ ValidatorConfigChangeMonitor mon=
+ new ValidatorConfigChangeMonitor();
+
+ new Thread(mon).start();
+ }
+ }
+ }
+
+ /**
+ * This method closes the service validation manager.
+ */
+ public void close() {
+ }
+
+ /**
+ * This method returns the list of service validators associated
+ * with the supplied input endpoint.
+ *
+ * @param endpoint The input endpoint
+ * @return The list of service validators, or null if the endpoint
+ * is unknown
+ */
+ public java.util.List<ServiceValidator> getInputServiceValidators(Endpoint endpoint) {
+ java.util.List<ServiceValidator> ret=
+ m_inputValidators.get(endpoint);
+
+ if (ret == null) {
+ ret = m_replyToManager.getInputServiceValidators(endpoint);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Return input validators '"+endpoint+"': "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the supplied endpoint will be
+ * associated with a dynamic reply-to endpoint.
+ *
+ * @param endpoint The endpoint
+ * @return Whether the endpoint has a dynamic reply-to
+ */
+ public boolean isInputDynamicReplyTo(Endpoint endpoint) {
+ boolean ret=m_inputDynaReplyTos.contains(endpoint);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Is input endpoint '"+endpoint+
+ "' a dynamic reply-to: "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of service validators associated
+ * with the supplied output endpoint.
+ *
+ * @param endpoint The output endpoint
+ * @return The list of service validators, or null if the endpoint
+ * is unknown
+ */
+ public java.util.List<ServiceValidator> getOutputServiceValidators(Endpoint endpoint) {
+ java.util.List<ServiceValidator> ret=
+ m_outputValidators.get(endpoint);
+
+ if (ret == null) {
+ ret = m_replyToManager.getOutputServiceValidators(endpoint);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Return output validators '"+endpoint+"': "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the supplied endpoint will be
+ * associated with a dynamic reply-to endpoint.
+ *
+ * @param endpoint The endpoint
+ * @return Whether the endpoint has a dynamic reply-to
+ */
+ public boolean isOutputDynamicReplyTo(Endpoint endpoint) {
+ boolean ret=m_outputDynaReplyTos.contains(endpoint);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Is output endpoint '"+endpoint+
+ "' a dynamic reply-to: "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method registers a list of service validators against
+ * a dynamic 'reply-to' endpoint.
+ *
+ * @param endpoint The endpoint
+ * @param validators The list of service validators
+ */
+ public void registerInputReplyToValidators(Endpoint endpoint,
+ java.util.List<ServiceValidator> validators) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Register input reply-to '"+endpoint+"': "+validators);
+ }
+
+ m_replyToManager.registerInputDynamicReplyTo(endpoint, validators);
+ }
+
+ /**
+ * This method registers a list of service validators against
+ * a dynamic 'reply-to' endpoint.
+ *
+ * @param endpoint The endpoint
+ * @param validators The list of service validators
+ */
+ public void registerOutputReplyToValidators(Endpoint endpoint,
+ java.util.List<ServiceValidator> validators) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Register output reply-to '"+endpoint+"': "+validators);
+ }
+
+ m_replyToManager.registerOutputDynamicReplyTo(endpoint, validators);
+ }
+
+ /**
+ * This method returns a ServiceValidator associated with the
+ * supplied validator name.
+ *
+ * @param name The validator name
+ * @return The service validator
+ * @throws Exception Failed to create service validator
+ */
+ public ServiceValidator createServiceValidator(ValidatorName name)
+ throws Exception {
+ ServiceValidator ret=null;
+
+ synchronized(m_serviceValidators) {
+ ret = m_serviceValidators.get(name);
+
+ // If does not exist, then create, else update
+ // the existing service validator
+ if (ret == null) {
+ ret = ServiceValidatorFactory.getServiceValidator(name);
+
+ m_serviceValidators.put(name, ret);
+ } else {
+
+ // Update the description
+ ret.update();
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Created Service Validator '"+name+"': "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method removes the service validator associated with
+ * the supplied validator name.
+ *
+ * @param name The validator name
+ * @throws Exception Failed to remove the service validator
+ */
+ protected void removeServiceValidator(ValidatorName name)
+ throws Exception {
+ synchronized(m_serviceValidators) {
+ ServiceValidator validator=(ServiceValidator)
+ m_serviceValidators.remove(name);
+
+ // Check if validator should be removed from
+ // input/output endpoint mappings
+ java.util.Iterator<Endpoint> iter=m_inputValidators.keySet().iterator();
+
+ while (iter.hasNext()) {
+ Endpoint ep=iter.next();
+ java.util.List<ServiceValidator> list=
+ m_inputValidators.get(ep);
+
+ if (list.contains(validator)) {
+ list.remove(validator);
+
+ if (list.size() == 0) {
+ logger.error("Input validator list, associated with endpoint '"+
+ ep+"' contains no entries after removal of validator '"+
+ name+"' - this Endpoint should have previously been removed");
+ }
+ }
+ }
+
+ iter=m_outputValidators.keySet().iterator();
+
+ while (iter.hasNext()) {
+ Endpoint ep=iter.next();
+ java.util.List<ServiceValidator> list=
+ m_outputValidators.get(ep);
+
+ if (list.contains(validator)) {
+ list.remove(validator);
+
+ if (list.size() == 0) {
+ logger.error("Output validator list, associated with endpoint '"+
+ ep+"' contains no entries after removal of validator '"+
+ name+"' - this Endpoint should have previously been removed");
+ }
+ }
+ }
+
+ if (validator != null) {
+ validator.close();
+ }
+ }
+ }
+
+ /**
+ * This method returns the set of currently configured
+ * service validator names.
+ *
+ * @return The set of validator names
+ */
+ protected java.util.Set<ValidatorName> getServiceValidatorNames() {
+ java.util.Set<ValidatorName> ret=new java.util.HashSet<ValidatorName>();
+
+ ret.addAll(m_serviceValidators.keySet());
+
+ return(ret);
+ }
+
+ /**
+ * This method updates the configuration of the service
+ * validators and endpoint mappings.
+ */
+ protected void updateConfigurations() {
+ java.util.Set<ValidatorName> existingValidatorNames=
+ getServiceValidatorNames();
+
+ java.util.Set<Endpoint> existingInputEndpoints=
+ new java.util.HashSet<Endpoint>(m_inputValidators.keySet());
+
+ java.util.Set<Endpoint> existingOutputEndpoints=
+ new java.util.HashSet<Endpoint>(m_outputValidators.keySet());
+
+ java.util.Set<Endpoint> existingInputDynaReplyTos=
+ new java.util.HashSet<Endpoint>(m_inputDynaReplyTos);
+
+ java.util.Set<Endpoint> existingOutputDynaReplyTos=
+ new java.util.HashSet<Endpoint>(m_outputDynaReplyTos);
+
+ java.io.InputStream is=ServiceValidatorManager.class.getClassLoader().
+ getResourceAsStream(CONFIG_FILE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("ValidationFilter: config="+CONFIG_FILE+" is="+is);
+ }
+
+ try {
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=builder.parse(is);
+
+ org.w3c.dom.Element config=doc.getDocumentElement();
+
+ if (config.getNodeName().equals(VALIDATOR_NODE)) {
+
+ // Old 'active' attribute is now 'mode'
+ String active=config.getAttribute(ACTIVE_ATTR);
+
+ if (active != null && active.equalsIgnoreCase("true")) {
+ m_managedMode = true;
+ }
+
+ String mode=config.getAttribute(MODE_ATTR);
+
+ if (mode != null) {
+ if (mode.equals("manage")) {
+ m_managedMode = true;
+ } else if (mode.equals("monitor")) {
+ m_managedMode = false; // will override active=true
+ } else {
+ logger.error("Unknown mode '"+mode+"' - setting to 'monitor'");
+ m_managedMode = false;
+ }
+ }
+
+ if (m_managedMode) {
+ logger.debug("Setting validators in 'manage' mode");
+ } else {
+ logger.debug("Setting validators in 'monitor' mode");
+ }
+
+ // Check for dynamic replyTo endpoint timeout
+ String timeoutValue=config.getAttribute(REPLY_TO_TIMEOUT_ATTR);
+
+ if (timeoutValue != null) {
+ try {
+ long tv=Long.parseLong(timeoutValue);
+
+ m_replyToManager.setReplyToTimeout(tv);
+ } catch(Exception e) {
+ logger.error("Unable to set 'reply to' timeout", e);
+ }
+ }
+ }
+
+ updateConfiguration(config, existingValidatorNames,
+ existingInputEndpoints, existingOutputEndpoints,
+ existingInputDynaReplyTos, existingOutputDynaReplyTos);
+
+ // Work through choreography files in the models directory
+ java.io.File[] files=m_modelsDir.listFiles();
+
+ for (int i=0; i < files.length; i++) {
+
+ // Check if a ValidatorModel exists for the
+ // file
+ try {
+ ValidatorConfig vm=
+ ValidatorConfigFactory.getValidatorConfig(files[i]);
+
+ if (vm != null) {
+ org.w3c.dom.Element vConfig=vm.getConfiguration();
+
+ if (vConfig != null) {
+ updateConfiguration(vConfig,
+ existingValidatorNames,
+ existingInputEndpoints,
+ existingOutputEndpoints,
+ existingInputDynaReplyTos,
+ existingOutputDynaReplyTos);
+ } else {
+ logger.error("Failed to obtain configuration for model '"+
+ files[i].getName()+"'");
+ }
+ }
+ } catch(Exception e) {
+ logger.error("Failed to update configuration for model '"+
+ files[i].getName()+"'", e);
+ }
+ }
+
+ // Any remaining input keys need to be removed
+ java.util.Iterator<Endpoint> iter=
+ existingInputEndpoints.iterator();
+
+ while (iter.hasNext()) {
+ Endpoint key=iter.next();
+ m_inputValidators.remove(key);
+ }
+
+ iter = existingInputDynaReplyTos.iterator();
+
+ while (iter.hasNext()) {
+ Endpoint key=iter.next();
+ m_inputDynaReplyTos.remove(key);
+ }
+
+ // Any remaining output keys need to be removed
+ iter = existingOutputEndpoints.iterator();
+
+ while (iter.hasNext()) {
+ Endpoint key=iter.next();
+ m_outputValidators.remove(key);
+ }
+
+ iter = existingOutputDynaReplyTos.iterator();
+
+ while (iter.hasNext()) {
+ Endpoint key=iter.next();
+ m_outputDynaReplyTos.remove(key);
+ }
+
+ // Any remaining service description names need to
+ // have their associated monitors removed
+ java.util.Iterator<ValidatorName> sviter=
+ existingValidatorNames.iterator();
+
+ while (sviter.hasNext()) {
+ ValidatorName svkey=sviter.next();
+
+ try {
+ logger.debug("Removing service validator: "+svkey);
+ removeServiceValidator(svkey);
+ } catch(Exception e) {
+ logger.error(
+ "Failed to remove service validator: "+svkey, e);
+ }
+ }
+ } catch(Exception e) {
+ logger.error("Failed to update configuration from input stream", e);
+ }
+ }
+
+ /**
+ * This method performs the update of the configuration of
+ * service monitors, based on the information in the validator
+ * configuration XML file, and the choreographies defined in the
+ * models folder.
+ *
+ * @param config The configuration
+ * @param existingValidatorNames The list of validator names
+ * @param existingInputEndpoints The list of input endpoints
+ * @param existingOutputEndpoints The list of output endpoints
+ * @param existingInputDynaReplyTos The set of input dynamic replyTo endpoints
+ * @param existingOutputDynaReplyTos The set of output dynamic replyTo endpoints
+ */
+ protected void updateConfiguration(org.w3c.dom.Element config,
+ java.util.Set<ValidatorName> existingValidatorNames,
+ java.util.Set<Endpoint> existingInputEndpoints,
+ java.util.Set<Endpoint> existingOutputEndpoints,
+ java.util.Set<Endpoint> existingInputDynaReplyTos,
+ java.util.Set<Endpoint> existingOutputDynaReplyTos) {
+ logger.debug("Update Service Validator Configuration");
+
+ if (config != null) {
+ try {
+ if (config.getNodeName().equals(VALIDATOR_NODE)) {
+ String active=config.getAttribute(ACTIVE_ATTR);
+
+ if (active != null && active.equalsIgnoreCase("true")) {
+
+ logger.debug("Setting validator into active mode");
+ m_managedMode = true;
+ }
+ }
+
+ org.w3c.dom.NodeList services=config.getElementsByTagName(SERVICE_NODE);
+
+ if (logger.isDebugEnabled()) {
+ if (services != null) {
+ logger.debug("ServiceValidationManager: services="+services.getLength());
+ } else {
+ logger.debug("ServiceValidationManager: services null");
+ }
+ }
+
+ for (int i=0; i < services.getLength(); i++) {
+ ServiceValidator sm=null;
+
+ // Create service monitor for service
+ String modelName=
+ ((org.w3c.dom.Element)services.item(i)).getAttribute(MODEL_ATTR);
+ String role=
+ ((org.w3c.dom.Element)services.item(i)).getAttribute(ROLE_ATTR);
+ String validate=
+ ((org.w3c.dom.Element)services.item(i)).getAttribute(VALIDATE_ATTR);
+
+ // Check for old attribute names, for
+ // backward compatibility - only support
+ // for a limited time
+ if (role == null) {
+ role = ((org.w3c.dom.Element)services.item(i)).getAttribute("participantType");
+ }
+
+ if (modelName == null) {
+ modelName = ((org.w3c.dom.Element)services.item(i)).getAttribute("cdmFilePath");
+
+ if (modelName != null) {
+ // Remove path
+ int pos=modelName.lastIndexOf('/');
+ if (pos != -1) {
+ modelName = modelName.substring(pos+1);
+ }
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Initialize service validator for: model="+
+ modelName+" role="+role+" validate="+validate);
+ }
+
+ if (role != null) {
+ boolean f_validate=(validate != null && validate.equalsIgnoreCase("true"));
+
+ if (modelName != null ||
+ f_validate == false) {
+ ValidatorName name=null;
+
+ if (f_validate) {
+ name = new ValidatorName(modelName, role);
+ } else {
+ name = new ValidatorName(role);
+
+ }
+
+ try {
+ // Obtain the service container
+ sm = createServiceValidator(name);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Service validator for '"+modelName+
+ "' and role '"+role+"' = "+sm);
+ }
+
+ // Remove validator name from list
+ existingValidatorNames.remove(sm.getValidatorName());
+ } catch(Exception e) {
+ logger.error(
+ "Failed to create service validator '"+
+ name+"'", e);
+ }
+ } else {
+ logger.error("Model name must be specified in validation mode");
+ }
+ } else {
+ logger.error("Role must be specified");
+ }
+
+ if (sm != null) {
+ // Map inputs to service
+ org.w3c.dom.NodeList inputs=((org.w3c.dom.Element)services.item(i)).getElementsByTagName(INPUT_NODE);
+
+ for (int j=0; j < inputs.getLength(); j++) {
+ String epr=((org.w3c.dom.Element)inputs.item(j)).getAttribute(EPR_ATTR);
+
+ if (epr != null) {
+ Endpoint endpoint=new Endpoint(epr);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Storing input endpoint '"+
+ endpoint+"' against validator: "+sm);
+ }
+
+ // Check if existing list
+ java.util.List<ServiceValidator> svs=
+ m_inputValidators.get(endpoint);
+
+ if (svs == null) {
+ svs = new java.util.Vector<ServiceValidator>();
+ m_inputValidators.put(endpoint, svs);
+ }
+
+ if (svs.contains(sm) == false) {
+ svs.add(sm);
+ }
+
+ existingInputEndpoints.remove(endpoint);
+
+ // Check if dynamic replyTo
+ String dynamicReplyTo=((org.w3c.dom.Element)inputs.item(j)).
+ getAttribute(DYNAMIC_REPLY_TO_ATTR);
+
+ if (dynamicReplyTo != null && dynamicReplyTo.equalsIgnoreCase("true")) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Input endpoint '"+
+ endpoint+"' has dynamic replyTo destination");
+ }
+
+ m_inputDynaReplyTos.add(endpoint);
+
+ existingInputDynaReplyTos.remove(endpoint);
+ }
+ }
+ }
+
+ // Map outputs to service
+ org.w3c.dom.NodeList outputs=((org.w3c.dom.Element)services.item(i)).getElementsByTagName(OUTPUT_NODE);
+
+ for (int j=0; j < outputs.getLength(); j++) {
+ String epr=((org.w3c.dom.Element)outputs.item(j)).getAttribute(EPR_ATTR);
+
+ if (epr != null) {
+ Endpoint endpoint=new Endpoint(epr);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Storing output endpoint '"+
+ endpoint+"' against validator: "+sm);
+ }
+
+ // Check if existing list
+ java.util.List<ServiceValidator> svs=
+ m_outputValidators.get(endpoint);
+
+ if (svs == null) {
+ svs = new java.util.Vector<ServiceValidator>();
+ m_outputValidators.put(endpoint, svs);
+ }
+
+ if (svs.contains(sm) == false) {
+ svs.add(sm);
+ }
+
+ existingOutputEndpoints.remove(endpoint);
+
+ // Check if dynamic replyTo
+ String dynamicReplyTo=((org.w3c.dom.Element)outputs.item(j)).
+ getAttribute(DYNAMIC_REPLY_TO_ATTR);
+
+ if (dynamicReplyTo != null && dynamicReplyTo.equalsIgnoreCase("true")) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Output endpoint '"+
+ endpoint+"' has dynamic replyTo destination");
+ }
+
+ m_outputDynaReplyTos.add(endpoint);
+
+ existingOutputDynaReplyTos.remove(endpoint);
+ }
+ }
+ }
+ }
+ }
+ } catch(Exception e) {
+ logger.error("Failed to load validator config", e);
+ }
+ }
+ }
+
+ /**
+ * This method returns whether the service validator configuration
+ * is in 'manage' mode. If yes, then invalid messages will
+ * be blocked from being delivered to their destination.
+ *
+ * @return Whether the service validator is in 'manage' mode
+ */
+ public boolean isManagedMode() {
+ return(m_managedMode);
+ }
+
+ private static final Logger logger = Logger.getLogger(ServiceValidatorManager.class);
+
+ private static final String EPR_ATTR = "epr";
+ private static final String DYNAMIC_REPLY_TO_ATTR = "dynamicReplyTo";
+
+ private static final String OUTPUT_NODE = "output";
+ private static final String INPUT_NODE = "input";
+ private static final String SERVICE_NODE = "service";
+ private static final String ACTIVE_ATTR = "active";
+ private static final String MODE_ATTR = "mode";
+ private static final String REPLY_TO_TIMEOUT_ATTR = "replyToTimeout";
+ private static final String VALIDATOR_NODE = "validator";
+
+ private static final String CONFIG_FILE = "validator-config.xml";
+ private static final String MODEL_ATTR="model";
+ private static final String ROLE_ATTR="role";
+ private static final String VALIDATE_ATTR="validate";
+
+ private static ServiceValidatorManager m_instance=null;
+ private java.io.File m_validatorConfigFile=null;
+ private java.io.File m_modelsDir=null;
+ private java.util.Map<ValidatorName,ServiceValidator> m_serviceValidators=
+ new java.util.HashMap<ValidatorName,ServiceValidator>();
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_inputValidators=new java.util.Hashtable<Endpoint,java.util.List<ServiceValidator>>();
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_outputValidators=new java.util.Hashtable<Endpoint,java.util.List<ServiceValidator>>();
+ private java.util.Set<Endpoint> m_inputDynaReplyTos=new java.util.HashSet<Endpoint>();
+ private java.util.Set<Endpoint> m_outputDynaReplyTos=new java.util.HashSet<Endpoint>();
+ private boolean m_managedMode=false;
+ private DynamicReplyToEndpointManager m_replyToManager=new DynamicReplyToEndpointManager();
+
+ /**
+ * This class is responsible for monitoring the models folder,
+ * within the overlord validator ESB bundle, to determine when
+ * the configuration has changed.
+ */
+ public class ValidatorConfigChangeMonitor implements java.lang.Runnable {
+
+ public ValidatorConfigChangeMonitor() {
+ // Do initial check for updates, so monitors
+ // initialized before returning from construct,
+ // as remainder of checks will be in a separate
+ // thread - so we need to ensure that the monitors
+ // are configured before the first message is
+ // passed through the filter.
+ checkForUpdates();
+ }
+
+ public void run() {
+
+ while (true) {
+ checkForUpdates();
+
+ try {
+ synchronized(ValidatorConfigChangeMonitor.this) {
+ wait(30000);
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ protected void checkForUpdates() {
+ logger.debug("Checking for config updates");
+
+ // Get last update time
+ long lastUpdate=getLastUpdate();
+
+ if (lastUpdate > m_lastUpdate) {
+
+ updateConfigurations();
+
+ m_lastUpdate = lastUpdate;
+ }
+ }
+
+ protected long getLastUpdate() {
+ long ret=0;
+
+ if (m_validatorConfigFile != null) {
+ ret = m_validatorConfigFile.lastModified();
+ }
+
+ if (m_modelsDir != null) {
+ java.io.File[] files=m_modelsDir.listFiles();
+
+ for (int i=0; i < files.length; i++) {
+ if (files[i].getName().endsWith(".cdm") &&
+ ret < files[i].lastModified()) {
+ ret = files[i].lastModified();
+ }
+ }
+
+ if (ret < m_modelsDir.lastModified()) {
+ ret = m_modelsDir.lastModified();
+ }
+ }
+
+ return(ret);
+ }
+
+ private long m_lastUpdate=0;
+ }
+
+ public class DynamicReplyToEndpointManager extends Thread {
+
+ /**
+ * The default constructor
+ */
+ public DynamicReplyToEndpointManager() {
+ setDaemon(true);
+
+ start();
+ }
+
+ /**
+ * The run method is responsible for ensuring the dynamic
+ * 'reply-to' endpoints are cleaned up periodically.
+ */
+ public void run() {
+
+ while(true) {
+
+ try {
+ synchronized(this) {
+ wait(m_replyToTimeout);
+ }
+ } catch(Exception e) {
+ logger.error("Failed to wait");
+ }
+
+ // Shift main entries to an emptied 'pending delete'
+ // map
+ synchronized(m_inputs) {
+ if (logger.isDebugEnabled()) {
+ java.util.Iterator<Endpoint> iter=
+ m_inputsPendingDelete.keySet().iterator();
+ while (iter.hasNext()) {
+ Endpoint endpoint=iter.next();
+ java.util.List<ServiceValidator> validators=
+ m_inputsPendingDelete.get(endpoint);
+ logger.debug("Deleting input (reply-to) validators '"+
+ endpoint+"': "+validators);
+ }
+ }
+
+ m_inputsPendingDelete.clear();
+ m_inputsPendingDelete.putAll(m_inputs);
+ m_inputs.clear();
+ }
+
+ synchronized(m_outputs) {
+ if (logger.isDebugEnabled()) {
+ java.util.Iterator<Endpoint> iter=
+ m_outputsPendingDelete.keySet().iterator();
+ while (iter.hasNext()) {
+ Endpoint endpoint=iter.next();
+ java.util.List<ServiceValidator> validators=
+ m_outputsPendingDelete.get(endpoint);
+ logger.debug("Deleting output (reply-to) validators '"+
+ endpoint+"': "+validators);
+ }
+ }
+
+ m_outputsPendingDelete.clear();
+ m_outputsPendingDelete.putAll(m_outputs);
+ m_outputs.clear();
+ }
+ }
+ }
+
+ /**
+ * This method returns the list of service validators
+ * associated with the dynamic reply-to endpoint.
+ *
+ * @param endpoint The input endpoint
+ * @return The list of service validators, or null if
+ * not found
+ */
+ public java.util.List<ServiceValidator> getInputServiceValidators(Endpoint endpoint) {
+ java.util.List<ServiceValidator> ret=null;
+
+ synchronized(m_inputs) {
+ ret = m_inputs.get(endpoint);
+
+ if (ret == null) {
+ ret = m_inputsPendingDelete.get(endpoint);
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Return input (reply-to) validators '"+endpoint+"': "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of service validators
+ * associated with the dynamic reply-to endpoint.
+ *
+ * @param endpoint The output endpoint
+ * @return The list of service validators, or null if
+ * not found
+ */
+ public java.util.List<ServiceValidator> getOutputServiceValidators(Endpoint endpoint) {
+ java.util.List<ServiceValidator> ret=null;
+
+ synchronized(m_outputs) {
+ ret = m_outputs.get(endpoint);
+
+ if (ret == null) {
+ ret = m_outputsPendingDelete.get(endpoint);
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Return output (reply-to) validators '"+endpoint+"': "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method registers a list of service validators against
+ * a dynamic 'reply-to' endpoint.
+ *
+ * @param endpoint The endpoint
+ * @param validators The list of service validators
+ */
+ public void registerInputDynamicReplyTo(Endpoint endpoint,
+ java.util.List<ServiceValidator> validators) {
+
+ synchronized(m_inputs) {
+ m_inputs.put(endpoint, validators);
+
+ // May not be necessary, as entry would not be
+ // used - but could save memory?
+ m_inputsPendingDelete.remove(endpoint);
+ }
+ }
+
+ /**
+ * This method registers a list of service validators against
+ * a dynamic 'reply-to' endpoint.
+ *
+ * @param endpoint The endpoint
+ * @param validators The list of service validators
+ */
+ public void registerOutputDynamicReplyTo(Endpoint endpoint,
+ java.util.List<ServiceValidator> validators) {
+
+ synchronized(m_outputs) {
+ m_outputs.put(endpoint, validators);
+
+ // May not be necessary, as entry would not be
+ // used - but could save memory?
+ m_outputsPendingDelete.remove(endpoint);
+ }
+ }
+
+ /**
+ * This method sets the timeout period for purging the
+ * cache of reply-to endpoints.
+ *
+ * @param timeoutValue The timeout value
+ */
+ public void setReplyToTimeout(long timeoutValue) {
+ m_replyToTimeout = timeoutValue;
+ }
+
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_inputs=
+ new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_outputs=
+ new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_inputsPendingDelete=
+ new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_outputsPendingDelete=
+ new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
+ private long m_replyToTimeout=10000;
+ }
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfig.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfig.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfig.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,44 @@
+/*
+ * 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.validator;
+
+/**
+ * This interface represents a configuration that will be used for
+ * validation against a stream of ESB based messages.
+ */
+public interface ValidatorConfig {
+
+ /**
+ * This method returns the type of the model associated
+ * with this validator configuration. This will
+ * general be based on the file extension of the model
+ * file.
+ *
+ * @return The model type
+ */
+ public String getModelType();
+
+ /**
+ * This method returns the validator configuration
+ * associated with the model.
+ *
+ * @return The validator model
+ */
+ public org.w3c.dom.Element getConfiguration();
+
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfigFactory.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfigFactory.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfigFactory.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,97 @@
+/*
+ * 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.validator;
+
+import org.apache.log4j.Logger;
+
+/**
+ * This class provides a factory for ValidatorConfig objects
+ * based on supplied model file details.
+ */
+public class ValidatorConfigFactory {
+
+ /**
+ * This method retrieves a validator config associated with
+ * the supplied file. If the model associated with the
+ * file is not supported, then a null will be returned.
+ *
+ * @param file The file containing the model
+ * @return The validator config, or null if an unsupported type
+ * @exception IOException Failed to load supported model type
+ */
+ public static ValidatorConfig getValidatorConfig(java.io.File file)
+ throws java.io.IOException {
+ ValidatorConfig ret=null;
+
+ String modelType=null;
+
+ if (file != null && (modelType=getModelType(file.getName())) != null) {
+ ValidatorConfigLoader loader=null;
+
+ for (int i=0; loader == null &&
+ i < m_loaders.size(); i++) {
+
+ if (m_loaders.get(i).isSupported(modelType)) {
+ loader = m_loaders.get(i);
+ }
+ }
+
+ if (loader != null) {
+ java.io.FileInputStream fis=new java.io.FileInputStream(file);
+
+ ret = loader.loadValidatorConfig(fis, file.getName());
+
+ fis.close();
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Returning validator config for "+
+ file.getName()+": "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines the model type associated with the
+ * supplied model filename.
+ *
+ * @param name The model filename
+ * @return The model type, or null if not known
+ */
+ protected static String getModelType(String name) {
+ String ret=null;
+ int pos=name.lastIndexOf('.');
+
+ if (pos != -1) {
+ ret = name.substring(pos+1);
+ }
+
+ return(ret);
+ }
+
+ private static final Logger logger = Logger.getLogger(ValidatorConfigFactory.class);
+
+ private static java.util.List<ValidatorConfigLoader> m_loaders=
+ new java.util.Vector<ValidatorConfigLoader>();
+
+ static {
+ m_loaders.add(new org.savara.validator.pi4soa.Pi4SOAValidatorConfigLoader());
+ }
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfigLoader.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfigLoader.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorConfigLoader.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,48 @@
+/*
+ * 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.validator;
+
+/**
+ * This interface is implemented by model specific loaders, to
+ * load a ValidatorConfig for the particular model type.
+ */
+public interface ValidatorConfigLoader {
+
+ /**
+ * This method determines if the validator config loader
+ * implementation supports the supplied model type.
+ *
+ * @param modelType The model type
+ * @return Whether the loader supports the model type
+ */
+ public boolean isSupported(String modelType);
+
+ /**
+ * This method loads the validator config, contained within
+ * the supplied input stream representing a model of the
+ * supported type.
+ *
+ * @param is The input stream
+ * @param modelPath The path to the model file
+ * @return The validator config
+ * @throws java.io.IOException Failed to load validator config
+ */
+ public ValidatorConfig loadValidatorConfig(java.io.InputStream is,
+ String modelPath) throws java.io.IOException;
+
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorName.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorName.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/ValidatorName.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,134 @@
+/*
+ * 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.validator;
+
+/**
+ * This class represents a key for looking up a service validator.
+ */
+public class ValidatorName {
+
+ /**
+ * This constructor is initialized with the details used to
+ * identify the validator.
+ *
+ * @param role The role
+ */
+ public ValidatorName(String role) {
+ m_role = role;
+ m_validate = false;
+ }
+
+ /**
+ * This constructor is initialized with the details used to
+ * identify the validator.
+ *
+ * @param modelName The model name
+ * @param role The role
+ * @param validate Whether to validate, or simply record
+ */
+ public ValidatorName(String modelName, String role) {
+ m_modelName = modelName;
+ m_role = role;
+ m_validate = true;
+ }
+
+ /**
+ * This method returns the model name associated with the
+ * service validator.
+ *
+ * @return The model name
+ */
+ public String getModelName() {
+ return(m_modelName);
+ }
+
+ /**
+ * This method returns the type associated with the model.
+ * If no model has been defined for the validator name,
+ * as in the case of a validator in record mode, then
+ * this method will return ValidatorName.NO_MODEL_TYPE.
+ *
+ * @return The model type
+ */
+ public String getModelType() {
+ String ret=null;
+ int pos=0;
+
+ if (m_modelName != null &&
+ (pos=m_modelName.lastIndexOf('.')) != -1) {
+ ret = m_modelName.substring(pos+1);
+ } else {
+ ret = NO_MODEL_TYPE;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the role associated with the Service
+ * Validator.
+ *
+ * @return The role
+ */
+ public String getRole() {
+ return(m_role);
+ }
+
+ /**
+ * This method determines whether the associated service
+ * validator is in validation or record mode.
+ *
+ * @return Whether in validation or record mode
+ */
+ public boolean isValidate() {
+ return(m_validate);
+ }
+
+ public boolean equals(Object obj) {
+ boolean ret=false;
+
+ if (obj instanceof ValidatorName) {
+ ret = (obj.toString().equals(toString()) &&
+ ((ValidatorName)obj).m_validate == m_validate);
+ }
+
+ return(ret);
+ }
+
+ public int hashCode() {
+ return(toString().hashCode());
+ }
+
+ public String toString() {
+ String ret=null;
+
+ if (isValidate()) {
+ ret = m_modelName+":"+m_role;
+ } else {
+ ret = m_role;
+ }
+
+ return(ret);
+ }
+
+ public static final String NO_MODEL_TYPE="NoModelType";
+
+ private String m_modelName=null;
+ private String m_role=null;
+ private boolean m_validate=false;
+}
\ No newline at end of file
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/JMSServiceTracker.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/JMSServiceTracker.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/JMSServiceTracker.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,1196 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Sep 12, 2005 : Initial version created by gary
+ */
+
+// Original version copied from pi4soa service tracker, licensed under Apache version 2
+
+/*
+ * 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.validator.pi4soa;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jms.QueueConnectionFactory;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.XMLUtils;
+import org.pi4soa.service.Channel;
+import org.pi4soa.service.Identity;
+import org.pi4soa.service.Message;
+import org.pi4soa.service.ServiceException;
+import org.pi4soa.service.behavior.MessageClassification;
+import org.pi4soa.service.behavior.MessageDefinition;
+import org.pi4soa.service.behavior.Receive;
+import org.pi4soa.service.behavior.Send;
+import org.pi4soa.service.behavior.ServiceDescription;
+import org.pi4soa.service.session.Session;
+import org.pi4soa.service.tracker.PublishingServiceTracker;
+import org.pi4soa.service.tracker.ServiceTracker;
+import org.pi4soa.service.tracker.TrackerEvent;
+
+/**
+ * This class provides an implementation of the publishing service
+ * tracker that sends the monitoring information using the JMS
+ * API.
+ *
+ */
+public class JMSServiceTracker implements ServiceTracker {
+
+ private static final String SAVARA_SERVICE_TRACKER_NS = "http://www.savara.org/service/tracker";
+ /**
+ * This is the default constructor for the JMS service
+ * tracker implementation.
+ *
+ */
+ public JMSServiceTracker() {
+ }
+
+ /**
+ * This method is invoked to initialize the JMS connection, based
+ * on the established properties.
+ *
+ */
+ public void initialize() {
+
+ logger.info("Initializing Savara JMS Service Tracker");
+
+ javax.naming.Context ctx=null;
+
+ try {
+ if (NamesUtil.isSet(m_jndiInitialContextFactory)) {
+ java.util.Properties jndiProps = new java.util.Properties();
+ jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ m_jndiInitialContextFactory);
+ jndiProps.setProperty(Context.PROVIDER_URL,
+ m_jndiProviderURL);
+
+ if (m_jndiFactoryURLPackages != null) {
+ jndiProps.setProperty(Context.URL_PKG_PREFIXES,
+ m_jndiFactoryURLPackages);
+ }
+
+ ctx = new javax.naming.InitialContext(jndiProps);
+ } else {
+ if (logger.isLoggable(java.util.logging.Level.FINER)) {
+ logger.finer("Creating default initial context");
+ }
+ ctx = new javax.naming.InitialContext();
+ }
+ } catch(Exception e) {
+ logger.severe("Failed to create JNDI initial context: "+e);
+ }
+
+ // Get connection factory and destination topic
+ if (ctx != null) {
+
+ try {
+ try {
+ javax.jms.ConnectionFactory factory =
+ (javax.jms.ConnectionFactory)
+ ctx.lookup(m_jmsConnectionFactory);
+
+ m_connection = factory.createConnection();
+
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("Connection: "+m_connection);
+ }
+
+ } catch(java.lang.RuntimeException re) {
+ if (m_jmsConnectionFactoryAlternate != null) {
+ QueueConnectionFactory qcf = (QueueConnectionFactory)
+ ctx.lookup(m_jmsConnectionFactoryAlternate);
+ m_connection = qcf.createQueueConnection();
+
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("Alternate Connection: "+m_connection);
+ }
+
+ } else {
+ throw re;
+ }
+ }
+
+ javax.jms.Destination dest =
+ (javax.jms.Destination)ctx.lookup(m_jmsDestination);
+
+ m_session = m_connection.createSession(false,
+ javax.jms.Session.AUTO_ACKNOWLEDGE);
+
+ m_producer = m_session.createProducer(dest);
+
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(Thread.currentThread()+
+ ": Created JMS ServiceTracker connection");
+ }
+
+ } catch(Exception e) {
+ logger.severe("Failed to create JMS connection: "+e);
+ }
+ }
+ }
+
+ /**
+ * This method sets the JNDI initial context factory class name.
+ *
+ * @param factory The factory class name
+ */
+ public void setJNDIInitialContextFactory(String factory) {
+ m_jndiInitialContextFactory = factory;
+ }
+
+ /**
+ * This method sets the provider URL that is used when publishing
+ * the tracker events.
+ *
+ * @param url The provider url
+ */
+ public void setJNDIProviderURL(String url) {
+ m_jndiProviderURL = url;
+ }
+
+ /**
+ * This method sets the JNDI factory URL packages.
+ *
+ * @param pkgs The packages
+ */
+ public void setJNDIFactoryURLPackages(String pkgs) {
+ m_jndiFactoryURLPackages = pkgs;
+ }
+
+ /**
+ * This method sets the JMS connection factory name, to
+ * be looked up within JNDI.
+ *
+ * @param cf The connection factory
+ */
+ public void setJMSConnectionFactory(String cf) {
+ m_jmsConnectionFactory = cf;
+ }
+
+ /**
+ * This method sets the alternate JMS connection factory name, to
+ * be looked up within JNDI.
+ *
+ * @param cf The connection factory
+ */
+ public void setJMSConnectionFactoryAlternate(String cf) {
+ m_jmsConnectionFactoryAlternate = cf;
+ }
+
+ /**
+ * This method sets the JMS destination name, to
+ * be looked up within JNDI.
+ *
+ * @param dest The destination
+ */
+ public void setJMSDestination(String dest) {
+ m_jmsDestination = dest;
+ }
+
+ /**
+ * This method is used to publish the service tracker message.
+ *
+ * @param serviceName The service name
+ * @param session The session
+ * @param mesg The message
+ */
+ protected synchronized void publish(String serviceName, Session session,
+ String mesg) {
+
+ // Establish JMS connection and topic
+ if (m_initialized == false &&
+ m_jmsConnectionFactory != null &&
+ m_jmsDestination != null) {
+ initialize();
+
+ m_initialized = true;
+ }
+
+ if (m_producer != null) {
+
+ try {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(mesg);
+ }
+
+ TextMessage tm=m_session.createTextMessage(mesg);
+
+ if (logger.isLoggable(Level.FINEST)) {
+ logger.finest(Thread.currentThread()+
+ ": Sending JMS ServiceTracker record="+tm);
+ }
+
+ m_producer.send(tm);
+ } catch(Exception e) {
+ logger.severe("Failed to publish message: "+e);
+ }
+
+ } else {
+ logger.warning("Could not publish message: "+mesg);
+ }
+ }
+
+ /**
+ * This method closes the service tracker.
+ *
+ * @exception ServiceException Failed to close
+ */
+ public void close() throws ServiceException {
+
+ try {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(Thread.currentThread()+
+ ": Closing JMS ServiceTracker connection");
+ }
+
+ if (m_session != null) {
+ m_session.close();
+ m_session = null;
+ }
+
+ if (m_connection != null) {
+ m_connection.close();
+ m_connection = null;
+ }
+
+ } catch(Exception e) {
+ logger.severe("Failed to close JMS connection: "+e);
+
+ m_initialized = false;
+
+ throw new ServiceException("Failed to close JMS connection", e);
+ }
+
+ m_initialized = false;
+ }
+
+ /**
+ * This method sets whether the message payload should be
+ * recorded as part of the service tracker send and receive
+ * events.
+ *
+ * @param val Whether to record the message payload
+ */
+ public void setRecordMessagePayload(Boolean val) {
+ if (val != null) {
+ m_recordMessagePayload = val.booleanValue();
+ } else {
+ m_recordMessagePayload = false;
+ }
+ }
+
+ /**
+ * This method indicates that a new service instance
+ * has started.
+ *
+ * @param service The service
+ * @param session The session
+ */
+ public void serviceStarted(ServiceDescription service,
+ Session session) {
+ String version="";
+
+ if (service.getVersion() != null) {
+ version = VERSION_ATTR+"=\""+
+ service.getVersion()+"\" ";
+ }
+
+ String xml="<sd:"+TrackerEvent.SERVICE_STARTED+" "+
+ NAME_ATTR+"=\""+service.getFullyQualifiedName()+
+ "\" "+version+SERVICE_INSTANCE_ID_ATTR+"=\""+
+ getServiceInstanceId(session)+"\" "+
+ SESSION_ID_ATTR+"=\""+
+ getSessionId(session)+"\" "+TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" />";
+
+ //record(getServiceName(session), session, xml, INFO, null);
+ }
+
+ /**
+ * This method indicates that a service instance
+ * has finished.
+ *
+ * @param service The service
+ * @param session The session
+ */
+ public void serviceFinished(ServiceDescription service,
+ Session session) {
+ String version="";
+
+ if (service.getVersion() != null) {
+ version = VERSION_ATTR+"=\""+
+ service.getVersion()+"\" ";
+ }
+
+ String xml="<sd:"+TrackerEvent.SERVICE_FINISHED+
+ " "+NAME_ATTR+"=\""+service.getFullyQualifiedName()+
+ "\" "+version+SERVICE_INSTANCE_ID_ATTR+"=\""+
+ getServiceInstanceId(session)+"\" "+
+ SESSION_ID_ATTR+"=\""+
+ getSessionId(session)+"\" "+TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" />";
+
+ //record(getServiceName(session), session, xml, INFO, null);
+ }
+
+ /**
+ * This method indicates that a new sub session
+ * has started within an existing service instance.
+ *
+ * @param parent The parent session
+ * @param session The session
+ */
+ public void subSessionStarted(Session parent, Session session) {
+ String xml="<sd:"+TrackerEvent.SUB_SESSION_STARTED+
+ " "+SERVICE_INSTANCE_ID_ATTR+"=\""+
+ getServiceInstanceId(session)+"\" "+
+ PARENT_SESSION_ID_ATTR+"=\""+getSessionId(parent)+
+ "\" "+SESSION_ID_ATTR+"=\""+
+ getSessionId(session)+"\" "+TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" />";
+
+ //record(getServiceName(session), session, xml, INFO, null);
+ }
+
+ /**
+ * This method indicates that an existing
+ * sub session has finished.
+ *
+ * @param parent The parent session
+ * @param session The session
+ */
+ public void subSessionFinished(Session parent, Session session) {
+ String xml="<sd:"+TrackerEvent.SUB_SESSION_FINISHED+
+ " "+SERVICE_INSTANCE_ID_ATTR+"=\""+
+ getServiceInstanceId(session)+"\" "+
+ PARENT_SESSION_ID_ATTR+"=\""+getSessionId(parent)+
+ "\" "+SESSION_ID_ATTR+"=\""+
+ getSessionId(session)+"\" "+TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" />";
+
+ //record(getServiceName(session), session, xml, INFO, null);
+ }
+
+ /**
+ * This method registers the fact that a message has been
+ * sent from a stateful service.
+ *
+ * @param activity The behavioral activity
+ * @param session The session
+ * @param channel The channel
+ * @param mesg The message that has been handled
+ */
+ public void sentMessage(Send activity, Session session,
+ Channel channel, Message mesg) {
+ String channelText=getChannelText(channel);
+ String messageText=getMessageText(mesg,
+ activity.getMessageDefinition());
+
+ String xml="<sd:"+TrackerEvent.SENT_MESSAGE+
+ " "+SERVICE_INSTANCE_ID_ATTR+"=\""+
+ getServiceInstanceId(session)+"\" "+
+ SESSION_ID_ATTR+"=\""+
+ getSessionId(session)+"\" "+TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" >"+messageText+
+ channelText+"</sd:"+TrackerEvent.SENT_MESSAGE+">";
+
+ record(getServiceName(session), session, xml, INFO, null);
+ }
+
+ /**
+ * This method registers the fact that a message has been
+ * sent from a stateless service.
+ *
+ * @param defn The message definition
+ * @param mesg The message that has been handled
+ */
+ public void sentMessage(MessageDefinition defn, Message mesg) {
+ String messageText=getMessageText(mesg, defn);
+ String serviceName=getServiceName(defn);
+
+ String xml="<sd:"+TrackerEvent.SENT_MESSAGE+" "+
+ //SESSION_ID_ATTR+"=\""+serviceName+"\" "+
+ TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" >"+messageText+
+ "</sd:"+TrackerEvent.SENT_MESSAGE+">";
+
+ record(serviceName, null, xml, INFO, null);
+ }
+
+ /**
+ * This method registers the fact that a message has been
+ * received from a stateful service.
+ *
+ * @param activity The behavioral activity
+ * @param session The session
+ * @param channel The channel
+ * @param mesg The message that has been handled
+ */
+ public void receivedMessage(Receive activity, Session session,
+ Channel channel, Message mesg) {
+ String channelText=getChannelText(channel);
+ String messageText=getMessageText(mesg,
+ activity.getMessageDefinition());
+
+ String xml="<sd:"+TrackerEvent.RECEIVED_MESSAGE+
+ " "+SERVICE_INSTANCE_ID_ATTR+"=\""+
+ getServiceInstanceId(session)+"\" "+
+ SESSION_ID_ATTR+"=\""+
+ getSessionId(session)+"\" "+TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" >"+messageText+
+ channelText+"</sd:"+TrackerEvent.RECEIVED_MESSAGE+">";
+
+ record(getServiceName(session), session, xml, INFO, null);
+ }
+
+ /**
+ * This method registers the fact that a message has been
+ * received from a stateless service.
+ *
+ * @param defn The message definition
+ * @param mesg The message that has been handled
+ */
+ public void receivedMessage(MessageDefinition defn, Message mesg) {
+ String messageText=getMessageText(mesg, defn);
+ String serviceName=getServiceName(defn);
+
+ String xml="<sd:"+TrackerEvent.RECEIVED_MESSAGE+" "+
+ //SESSION_ID_ATTR+"=\""+serviceName+"\" "+
+ TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" >"+messageText+
+ "</sd:"+TrackerEvent.RECEIVED_MESSAGE+">";
+
+ record(serviceName, null, xml, INFO, null);
+ }
+
+ /**
+ * This method registers that a message was not expected.
+ *
+ * @param sdesc The service description, if known
+ * @param session The session, or null if a stateless service,
+ * or cannot be associated with a session
+ * @param mesg The message that was not expected
+ * @param reason The optional reason why the message was
+ * considered to be unexpected
+ */
+ public void unexpectedMessage(ServiceDescription sdesc,
+ Session session, Message mesg, String reason) {
+ String messageText=getMessageText(mesg, null);
+
+ // Process the reason field to ensure it has no
+ // character that would cause the XML a problem
+ reason = processAttributeContents(reason);
+
+ String xml="<sd:"+TrackerEvent.UNEXPECTED_MESSAGE+
+ " "+SERVICE_INSTANCE_ID_ATTR+"=\""+
+ getServiceInstanceId(session)+"\" "+
+ SESSION_ID_ATTR+"=\""+
+ getSessionId(session)+"\" "+TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" ><sd:"+DETAILS_NODE+">"+
+ reason+"</sd:"+DETAILS_NODE+">"+messageText+
+ "</sd:"+TrackerEvent.UNEXPECTED_MESSAGE+">";
+
+ String serviceName=null;
+
+ if (sdesc != null) {
+ serviceName = sdesc.getFullyQualifiedName();
+ } else {
+ serviceName = getServiceName(session);
+ }
+
+ String serviceVersion=null;
+
+ if (sdesc != null) {
+ serviceVersion = sdesc.getVersion();
+ }
+
+ record(serviceName, serviceVersion, session, mesg, xml, ERROR, null);
+ }
+
+ /**
+ * This method registers that an exception was not handled.
+ *
+ * @param session The session, or null if a stateless service
+ * @param excType The exception type
+ */
+ public void unhandledException(Session session, String excType) {
+
+ String xml="<sd:"+TrackerEvent.UNHANDLED_EXCEPTION+
+ " "+SERVICE_INSTANCE_ID_ATTR+"=\""+
+ getServiceInstanceId(session)+"\" "+
+ SESSION_ID_ATTR+"=\""+
+ getSessionId(session)+"\" "+TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" ><sd:"+DETAILS_NODE+">"+
+ excType+"</sd:"+DETAILS_NODE+"></sd:"+
+ TrackerEvent.UNHANDLED_EXCEPTION+">";
+
+ record(getServiceName(session), session, xml, ERROR, null);
+ }
+
+ /**
+ * This method reports information regarding the processing
+ * of a service session. The details can either be specified
+ * as a textual string (unstructured data),
+ * or as a structured XML fragment.<p>
+ *
+ * @param session The session, or null if a stateless service
+ * @param details The details
+ */
+ public void information(Session session, String details) {
+ String xml="<sd:"+TrackerEvent.INFORMATION+
+ " "+SERVICE_INSTANCE_ID_ATTR+"=\""+
+ getServiceInstanceId(session)+"\" "+
+ SESSION_ID_ATTR+"=\""+getSessionId(session)+
+ "\" "+TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" ><sd:"+DETAILS_NODE+">"+
+ XMLUtils.encodeXMLString(details)+
+ "</sd:"+DETAILS_NODE+"></sd:"+
+ TrackerEvent.INFORMATION+">";
+
+ record(getServiceName(session), session, xml, INFO, null);
+ }
+
+ /**
+ * This method reports information regarding the processing
+ * of a service session. The details can either be specified
+ * as a textual string (unstructured data),
+ * or as a structured XML fragment.<p>
+ *
+ * @param session The session, or null if a stateless service
+ * @param details The details
+ * @param exc The optional exception
+ */
+ public void warning(Session session, String details,
+ Throwable exc) {
+ String excText="";
+ if (exc != null) {
+ try {
+ java.io.StringWriter s=new java.io.StringWriter();
+ java.io.PrintWriter p=new java.io.PrintWriter(s);
+
+ exc.printStackTrace(p);
+
+ p.close();
+ s.close();
+
+ excText = "<sd:"+EXCEPTION_NODE+">"+s.toString()+"</sd:"+EXCEPTION_NODE+">";
+ } catch(Exception e) {
+ logger.severe("Failed to record exception stack trace: "+e);
+
+ excText = "<sd:"+EXCEPTION_NODE+">"+exc.getLocalizedMessage()+"</sd:"+EXCEPTION_NODE+">";
+ }
+ }
+
+ String xml="<sd:"+TrackerEvent.WARNING+
+ " "+SERVICE_INSTANCE_ID_ATTR+"=\""+
+ getServiceInstanceId(session)+"\" "+
+ SESSION_ID_ATTR+"=\""+getSessionId(session)+
+ "\" "+TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" ><sd:"+DETAILS_NODE+">"+
+ XMLUtils.encodeXMLString(details)+
+ "</sd:"+DETAILS_NODE+">"+excText+"</sd:"+
+ TrackerEvent.WARNING+">";
+
+ record(getServiceName(session), session, xml, WARNING, exc);
+ }
+
+ /**
+ * This method reports information regarding the processing
+ * of a service session. The details can either be specified
+ * as a textual string (unstructured data),
+ * or as a structured XML fragment.<p>
+ *
+ * @param session The session, or null if a stateless service
+ * @param details The details
+ * @param exc The optional exception
+ */
+ public void error(Session session, String details,
+ Throwable exc) {
+ String excText="";
+ if (exc != null) {
+ try {
+ java.io.StringWriter s=new java.io.StringWriter();
+ java.io.PrintWriter p=new java.io.PrintWriter(s);
+
+ exc.printStackTrace(p);
+
+ p.close();
+ s.close();
+
+ excText = "<sd:"+EXCEPTION_NODE+">"+s.toString()+"</sd:"+EXCEPTION_NODE+">";
+ } catch(Exception e) {
+ logger.severe("Failed to record exception stack trace: "+e);
+
+ excText = "<sd:"+EXCEPTION_NODE+">"+exc.getLocalizedMessage()+"</sd:"+EXCEPTION_NODE+">";
+ }
+ }
+
+
+ String xml="<sd:"+TrackerEvent.ERROR+
+ " "+SERVICE_INSTANCE_ID_ATTR+"=\""+
+ getServiceInstanceId(session)+"\" "+
+ SESSION_ID_ATTR+"=\""+getSessionId(session)+
+ "\" "+TIMESTAMP_ATTR+"=\""+
+ System.currentTimeMillis()+"\" ><sd:"+DETAILS_NODE+">"+
+ XMLUtils.encodeXMLString(details)+
+ "</sd:"+DETAILS_NODE+">"+excText+"</sd:"+
+ TrackerEvent.ERROR+">";
+
+ record(getServiceName(session), session, xml, ERROR, exc);
+ }
+
+ /**
+ * Check the format of the specified session id.
+ *
+ * @param session The initial session
+ * @return The reformatted session id
+ */
+ protected String getSessionId(Session session) {
+ String ret=null;
+
+ if (session != null) {
+ ret = session.getId().getSessionId();
+ }
+
+ if (ret == null) {
+ ret = "";
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether a long expanded form
+ * of id should be used for the service instance id.
+ *
+ * @return Whether the expanded form of id is used
+ */
+ protected boolean isIdExpanded() {
+ return(true);
+ }
+
+ /**
+ * This method returns the service instance id
+ * associated with the specified session.
+ *
+ * @param session The session
+ * @return The service instance id
+ */
+ protected String getServiceInstanceId(Session session) {
+ String ret=null;
+
+ if (session != null) {
+ if (isIdExpanded()) {
+ ret = session.getId().getServiceDescriptionName()+
+ "/"+session.getId().getServiceInstanceId();
+ } else {
+ ret = session.getId().getServiceInstanceId();
+ }
+ }
+
+ if (ret == null) {
+ ret = "";
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the service name associated with the
+ * supplied session.
+ *
+ * @param session The session
+ * @return The service name
+ */
+ protected String getServiceName(Session session) {
+ String ret="";
+
+ if (session != null && session.getId() != null) {
+ ret = session.getId().getServiceDescriptionName();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the service name associated with the
+ * supplied message definition.
+ *
+ * @param defn The message definition
+ * @return The service name
+ */
+ protected String getServiceName(MessageDefinition defn) {
+ String ret="";
+
+ if (defn != null && defn.getServiceDescription() != null) {
+ ret = defn.getServiceDescription().getFullyQualifiedName();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method constructs the session related information
+ * to be recorded.
+ *
+ * @param session The session
+ * @return The session text
+ */
+ protected String getSessionIdentityText(Session session) {
+ return(getSessionIdentityText(session, null));
+ }
+
+ /**
+ * This method constructs the session related information
+ * to be recorded.
+ *
+ * @param session The session
+ * @param mesg The optional message
+ * @return The session text
+ */
+ public String getSessionIdentityText(Session session, Message mesg) {
+ StringBuffer identities=new StringBuffer();
+
+ if (session != null && session.getSessionIdentity() != null) {
+ identities.append("<sd:"+SESSION_IDENTITY_NODE+">"+
+ "<sd:"+IDENTITY_NODE+" "+NAME_ATTR+"=\""+
+ session.getSessionIdentity().getName()+"\" >"+
+ XMLUtils.encodeXMLString(session.getSessionIdentity().getFullId())+
+ "</sd:"+IDENTITY_NODE+">"+
+ "</sd:"+SESSION_IDENTITY_NODE+">");
+ }
+
+ java.util.Iterator<Identity> ids=null;
+
+ if (session != null) {
+ ids = session.getPrimaryIdentities().iterator();
+ }
+
+ // If session has no identity information, but a
+ // message is supplied, then try getting identity
+ // from it.
+ if ((ids == null || ids.hasNext() == false) &&
+ mesg != null && mesg.getMessageIdentities() != null) {
+ ids = mesg.getMessageIdentities().iterator();
+ }
+
+ if (ids != null && ids.hasNext()) {
+ identities.append("<sd:"+PRIMARY_IDENTITIES_NODE+">");
+
+ while (ids.hasNext()) {
+ Identity cur=ids.next();
+
+ identities.append("<sd:"+IDENTITY_NODE+" "+NAME_ATTR+"=\""+
+ cur.getName()+"\" >");
+ identities.append(XMLUtils.encodeXMLString(cur.getFullId()));
+ identities.append("</sd:"+IDENTITY_NODE+">");
+ }
+
+ identities.append("</sd:"+PRIMARY_IDENTITIES_NODE+">");
+ }
+
+ return(identities.toString());
+ }
+
+ /**
+ * This method returns the XML text associated with the
+ * message.
+ *
+ * @param mesg The message
+ * @param defn The message definition from the description
+ * @return The message text
+ */
+ public String getMessageText(Message mesg, MessageDefinition defn) {
+ String type=null;
+
+ if (defn == null) {
+ type = (mesg.isRequest()?REQUEST_RPC_MESSAGE_TYPE:RESPONSE_RPC_MESSAGE_TYPE);
+
+ if (mesg.isRPCStyle() == false) {
+ type = MESSAGE_STYLE_MESSAGE_TYPE;
+ }
+ } else {
+ type = (defn.getClassification()==MessageClassification.REQUEST?
+ REQUEST_RPC_MESSAGE_TYPE:RESPONSE_RPC_MESSAGE_TYPE);
+ }
+
+ if (NamesUtil.isSet(mesg.getFaultName())) {
+ type = FAULT_RPC_MESSAGE_TYPE;
+ }
+
+ return(getMessageTextForType(mesg, type));
+ }
+
+ /**
+ * This method returns the XML text associated with the
+ * message.
+ *
+ * @param mesg The message
+ * @param type The message classification (request/response/message/fault)
+ * @return The message text
+ */
+ protected String getMessageTextForType(Message mesg, String type) {
+ String ret=null;
+ String fault="";
+ String messageType="";
+ String identities="";
+ String valueText=getMessagePayload(mesg);
+ String endpoint="";
+
+ if (NamesUtil.isSet(mesg.getFaultName())) {
+ fault = FAULT_ATTR+"=\""+mesg.getFaultName()+"\" ";
+ }
+
+ if (NamesUtil.isSet(mesg.getType())) {
+ messageType = MESSAGE_TYPE_ATTR+"=\""+mesg.getType()+"\" ";
+ }
+
+ if (mesg.getSessionIdentity() != null) {
+ identities = "<sd:"+SESSION_IDENTITY_NODE+">"+
+ "<sd:"+IDENTITY_NODE+" "+NAME_ATTR+"=\""+
+ mesg.getSessionIdentity().getName()+"\" >"+
+ mesg.getSessionIdentity().getFullId()+
+ "</sd:"+IDENTITY_NODE+">"+
+ "</sd:"+SESSION_IDENTITY_NODE+">";
+
+ if (mesg.getChannelIdentity() != null) {
+ identities += "<sd:"+CHANNEL_IDENTITY_NODE+">"+
+ "<sd:"+IDENTITY_NODE+" "+NAME_ATTR+"=\""+
+ mesg.getChannelIdentity().getName()+"\" >"+
+ mesg.getChannelIdentity().getFullId()+
+ "</sd:"+IDENTITY_NODE+">"+
+ "</sd:"+CHANNEL_IDENTITY_NODE+">";
+ }
+ } else if (mesg.getMessageIdentities() != null &&
+ mesg.getMessageIdentities().size() > 0) {
+
+ identities += "<sd:"+PRIMARY_IDENTITIES_NODE+">";
+
+ for (int i=0; i < mesg.getMessageIdentities().size(); i++) {
+ Identity id=(Identity)mesg.getMessageIdentities().get(i);
+
+ identities += "<sd:"+IDENTITY_NODE+" "+NAME_ATTR+"=\""+
+ id.getName()+"\" >";
+ identities += id.getFullId();
+ identities += "</sd:"+IDENTITY_NODE+">";
+ }
+
+ identities += "</sd:"+PRIMARY_IDENTITIES_NODE+">";
+ }
+
+ if (mesg.getServiceEndpoint() != null) {
+ endpoint = mesg.getServiceEndpoint().toText(null);
+ }
+
+ String serviceType=mesg.getServiceType();
+ if (serviceType == null) {
+ serviceType = "";
+ }
+
+ ret = "<sd:"+MESSAGE_NODE+" "+OPERATION_ATTR+"=\""+
+ (mesg.getOperationName()==null?"":mesg.getOperationName())+
+ "\" "+TYPE_ATTR+"=\""+type+"\" "+fault+
+ messageType+SERVICE_TYPE_ATTR+"=\""+
+ serviceType+"\" ><sd:"+ENDPOINT_NODE+">"+
+ endpoint+"</sd:"+ENDPOINT_NODE+">"+identities+
+ valueText+"</sd:"+MESSAGE_NODE+">";
+
+ return(ret);
+ }
+
+ /**
+ * This method constructs the message payload value for the
+ * send and receive tracker events. The information is only
+ * provided if the service tracker is configured to supply
+ * it, as the performance impact of transporting large
+ * message payloads in tracker messages would not be appropriate
+ * for production environments - however it may be useful
+ * in development and test environments. If the supplied
+ * message is a multi-part message containing a single part
+ * then the single part will be extracted and used. If a
+ * multi-part message with multiple parts, then the map
+ * textual representation will be provided. If the value is
+ * a DOM representation, then it will be converted to a
+ * string. All other situations will rely on the 'toString'
+ * representation of the value to be appropriate.
+ *
+ * @param mesg The message
+ * @return The payload
+ */
+ protected String getMessagePayload(Message mesg) {
+ String ret="";
+
+ if (m_recordMessagePayload) {
+ Object value=mesg.getValue();
+ if (mesg.isMultiPart() && ((java.util.Map)value).size() == 1) {
+ value = ((java.util.Map)value).values().iterator().next();
+ }
+
+ if (value instanceof org.w3c.dom.Node) {
+ try {
+ value = XMLUtils.getText((org.w3c.dom.Node)value);
+ } catch(Exception e) {
+ logger.severe("Failed to convert message DOM value" +
+ "to string: "+e);
+ value = "";
+ }
+ }
+
+ if (value != null) {
+ ret = "<sd:"+VALUE_NODE+">"+value.toString()+
+ "</sd:"+VALUE_NODE+">";
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the XML text associated with the
+ * channel.
+ *
+ * @param channel The channel
+ * @return The channel text
+ */
+ protected String getChannelText(Channel channel) {
+
+ if (channel == null) {
+ return("");
+ }
+
+ StringBuffer identities=new StringBuffer();
+
+ java.util.Set<Identity> ids=channel.getPrimaryIdentities();
+
+ if (ids != null && ids.size() > 0) {
+ identities.append("<sd:"+PRIMARY_IDENTITIES_NODE+">");
+
+ java.util.Iterator<Identity> iter=ids.iterator();
+ while (iter.hasNext()) {
+ Identity id=iter.next();
+
+ identities.append("<sd:"+IDENTITY_NODE+" "+NAME_ATTR+"=\""+
+ id.getName()+"\" >");
+ identities.append(XMLUtils.encodeXMLString(id.getFullId()));
+ identities.append("</sd:"+IDENTITY_NODE+">");
+ }
+
+ identities.append("</sd:"+PRIMARY_IDENTITIES_NODE+">");
+ }
+
+ return("<sd:"+CHANNEL_NODE+" "+NAME_ATTR+"=\""+
+ channel.getName()+"\" "+TYPE_ATTR+"=\""+
+ channel.getType()+"\" >"+
+ identities.toString()+"</sd:"+CHANNEL_NODE+">");
+ }
+
+ /**
+ * This method processes the supplied value to deal with any
+ * unwanted characters that would be inappropriate for an
+ * XML attribute value.
+ *
+ * @param value The value
+ * @return The processed value
+ */
+ protected String processAttributeContents(String value) {
+ String ret=value;
+
+ ret = ret.replaceAll("\"", "");
+
+ return(ret);
+ }
+
+ /**
+ * This method records the tracker information. This method
+ * also takes the optional 'message', used to derive session
+ * identity, if the session does not currently have any
+ * identity. This situation should only occur if the first
+ * message to a service is an unexpected message.
+ *
+ * @param serviceName The service name
+ * @param serviceVersion The optional service version
+ * @param session The session
+ * @param mesg The message
+ * @param xml The information to be recorded
+ * @param type The type of information (INFO, WARNING, ERROR)
+ * @param exc The optional exception
+ */
+ protected void record(String serviceName, String serviceVersion,
+ Session session, Message mesg, String xml, String type, Throwable exc) {
+
+ String message=build(serviceName, serviceVersion,
+ session, mesg, xml);
+
+ publish(serviceName, session, message);
+ }
+
+ /**
+ * This method records the tracker information.
+ *
+ * @param serviceName The service name
+ * @param session The session
+ * @param xml The information to be recorded
+ * @param type The type of information (INFO, WARNING, ERROR)
+ * @param exc The optional exception
+ */
+ protected void record(String serviceName, Session session,
+ String xml, String type, Throwable exc) {
+ record(serviceName, null, session, null, xml, type, exc);
+ }
+
+ /**
+ * This method constructs the service tracker message to be
+ * published.
+ *
+ * @param serviceName The service name
+ * @param serviceVersion The optional service version
+ * @param session The session
+ * @param mesg The optional message
+ * @param xml The XML for the current tracker event
+ * @return The message
+ */
+ protected String build(String serviceName, String serviceVersion,
+ Session session, Message mesg, String xml) {
+ StringBuffer ret=new StringBuffer();
+ String versionText="";
+ String nameText="";
+
+ if (serviceName != null) {
+ nameText = NAME_ATTR+"=\""+serviceName+"\" ";
+ }
+
+ if (serviceVersion != null) {
+ versionText=VERSION_ATTR+"=\""+serviceVersion+"\" ";
+
+ } else if (session != null && session.getId() != null &&
+ session.getId().getServiceDescriptionVersion() != null) {
+ versionText=VERSION_ATTR+"=\""+
+ session.getId().getServiceDescriptionVersion()+
+ "\" ";
+ }
+
+ ret.append("<sd:record xmlns:sd=\""+
+ SAVARA_SERVICE_TRACKER_NS+"\" "+nameText+versionText+">");
+
+ ret.append(getSessionIdentityText(session, mesg));
+
+ ret.append("<sd:events>");
+
+ ret.append(xml);
+
+ ret.append("</sd:events>");
+ ret.append("</sd:record>");
+
+ return(ret.toString());
+ }
+
+ /**
+ * This method determines whether message payload will be
+ * recorded.
+ *
+ * @param bool Whether the message payload is recorded
+ */
+ public void setRecordMessagePayload(String bool) {
+ logger.info("Record message payload: "+bool);
+
+ if (bool != null && bool.equalsIgnoreCase("true")) {
+ m_recordMessagePayload = true;
+ } else {
+ m_recordMessagePayload = false;
+ }
+ }
+
+ private static Logger logger = Logger.getLogger(JMSServiceTracker.class.getName());
+
+ private boolean m_recordMessagePayload=false;
+
+ public static final String RECORD_MESSAGE_PAYLOAD = "pi4soa.tracker.messagePayload";
+
+ public static final String INFO="info";
+ public static final String WARNING="warning";
+ public static final String ERROR="error";
+
+ public static final String MESSAGE_NODE="message";
+ public static final String DETAILS_NODE="details";
+ public static final String OPERATION_ATTR="operation";
+ public static final String FAULT_ATTR="fault";
+ public static final String NAME_ATTR="name";
+ public static final String TIMESTAMP_ATTR="timestamp";
+ public static final String TYPE_ATTR="type";
+ public static final String MESSAGE_TYPE_ATTR="messageType";
+ public static final String SERVICE_TYPE_ATTR="serviceType";
+ public static final String EXCEPTION_NODE="exception";
+ public static final String SERVICE_INSTANCE_ID_ATTR="serviceInstanceId";
+ public static final String SESSION_ID_ATTR="sessionId";
+ public static final String PARENT_SESSION_ID_ATTR="parentSessionId";
+
+ public static final String VERSION_ATTR = "version";
+ public static final String FAULT_RPC_MESSAGE_TYPE = "fault";
+ public static final String RESPONSE_RPC_MESSAGE_TYPE = "response";
+ public static final String REQUEST_RPC_MESSAGE_TYPE = "request";
+ public static final String MESSAGE_STYLE_MESSAGE_TYPE = "message";
+ public static final String SESSION_IDENTITY_NODE = "sessionIdentity";
+ public static final String CHANNEL_IDENTITY_NODE = "channelIdentity";
+ public static final String IDENTITY_NODE = "identity";
+ public static final String PRIMARY_IDENTITIES_NODE = "primaryIdentities";
+ public static final String ENDPOINT_NODE = "endpoint";
+ public static final String CHANNEL_NODE = "channel";
+ public static final String VALUE_NODE = "value";
+
+ protected static final String TRACKER_JNDI_INITIAL_CONTEXT_FACTORY_PROPERTY = "pi4soa.tracker.jndi.initialContextFactory";
+ protected static final String TRACKER_JNDI_PROVIDER_URL_PROPERTY = "pi4soa.tracker.jndi.providerURL";
+ protected static final String TRACKER_JNDI_FACTORY_URL_PACKAGES_PROPERTY = "pi4soa.tracker.jndi.factoryURLPackages";
+ protected static final String TRACKER_JMS_TOPIC_CONNECTION_FACTORY_PROPERTY = "pi4soa.tracker.jms.topicConnectionFactory";
+ protected static final String TRACKER_JMS_TOPIC_PROPERTY = "pi4soa.tracker.jms.topic";
+ protected static final String TRACKER_JMS_CONNECTION_FACTORY_PROPERTY = "pi4soa.tracker.jms.connectionFactory";
+ protected static final String TRACKER_JMS_CONNECTION_FACTORY_ALTERNATE_PROPERTY = "pi4soa.tracker.jms.connectionFactoryAlternate";
+ protected static final String TRACKER_JMS_DESTINATION_PROPERTY = "pi4soa.tracker.jms.destination";
+ protected static final String TRACKER_JMS_CLIENT_ID_PROPERTY = "pi4soa.tracker.jms.clientId";
+ protected static final String TRACKER_JMS_DURABLE_SUBSCRIPTION_PROPERTY = "pi4soa.tracker.jms.durableSubscription";
+
+ private boolean m_initialized=false;
+ private String m_jndiInitialContextFactory=null;
+ private String m_jndiProviderURL=null;
+ private String m_jndiFactoryURLPackages=null;
+ private String m_jmsConnectionFactory=null;
+ private String m_jmsConnectionFactoryAlternate=null;
+ private String m_jmsDestination=null;
+
+ private javax.jms.Connection m_connection=null;
+ private javax.jms.Session m_session=null;
+ private javax.jms.MessageProducer m_producer=null;
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceRecorder.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceRecorder.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceRecorder.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -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.validator.pi4soa;
+
+import org.apache.log4j.Logger;
+
+import org.savara.validator.AbstractServiceValidator;
+import org.savara.validator.ValidatorName;
+import org.pi4soa.common.util.MessageUtil;
+import org.pi4soa.service.ServiceException;
+import org.pi4soa.service.behavior.*;
+import org.pi4soa.service.monitor.*;
+
+/**
+ * This class implements the pi4soa service validator responsible for
+ * recording a stream of ESB messages.
+ */
+public class Pi4SOAServiceRecorder extends AbstractServiceValidator {
+
+ /**
+ * This is the constructor for the pi4soa service
+ * recorder implementation.
+ *
+ * @param name The validator name
+ */
+ public Pi4SOAServiceRecorder(ValidatorName name) {
+ super(name);
+
+ initialize();
+ }
+
+ /**
+ * This method initializes the service recorder.
+ */
+ protected void initialize() {
+ try {
+ // Use XML configuration, to enable alternative
+ // runtime configuration to be specified by
+ // including a pi4soa.xml file in the environment
+ DefaultMonitorConfiguration conf=
+ new XMLMonitorConfiguration();
+
+ conf.setValidateBehaviour(getValidatorName().isValidate());
+
+ m_monitor = ServiceMonitorFactory.getServiceMonitor(conf);
+
+ ServiceDescription sdesc=BehaviorFactory.eINSTANCE.createServiceDescription();
+ sdesc.setName(getValidatorName().getRole());
+
+ // Register service description
+ m_monitor.getConfiguration().getServiceRepository().
+ addServiceDescription(sdesc);
+
+ logger.debug("Created monitor for service description "+sdesc.getFullyQualifiedName());
+
+ } catch(Exception e) {
+ logger.error("Failed to initialize service monitor: "+e);
+ }
+ }
+
+ /**
+ * This method returns the model type associated with this
+ * service recorder.
+ *
+ * @return The model type
+ */
+ public static String getModelType() {
+ return(ValidatorName.NO_MODEL_TYPE);
+ }
+
+ /**
+ * This method is called to update the model associated
+ * with the service validator.
+ */
+ public void update() {
+ }
+
+ /**
+ * This method processes a sent message against a service
+ * behavioural description.
+ *
+ * @param mesgType The optional message type
+ * @param msg The message
+ * @throws Exception Failed to process sent message
+ */
+ public void messageSent(String mesgType, java.io.Serializable msg) throws Exception {
+
+ if (msg == null) {
+ throw new ServiceException("Failed to obtain value from message: "+msg);
+ }
+
+ if (mesgType == null) {
+ mesgType = MessageUtil.getMessageType(msg);
+ }
+
+ org.pi4soa.service.Message mesg=
+ m_monitor.createMessage(mesgType,
+ null, null, msg, null, null);
+
+ synchronized(m_monitor) {
+ m_monitor.messageSent(mesg);
+ }
+ }
+
+ /**
+ * This method processes a received message against a service
+ * behavioural description.
+ *
+ * @param mesgType The optional message type
+ * @param msg The message
+ * @throws Exception Failed to process received message
+ */
+ public void messageReceived(String mesgType, java.io.Serializable msg) throws Exception {
+
+ if (msg == null) {
+ throw new ServiceException("Failed to obtain value from message: "+msg);
+ }
+
+ if (mesgType == null) {
+ mesgType = MessageUtil.getMessageType(msg);
+ }
+
+ org.pi4soa.service.Message mesg=
+ m_monitor.createMessage(mesgType,
+ null, null, msg, null, null);
+
+ synchronized(m_monitor) {
+ m_monitor.messageReceived(mesg);
+ }
+ }
+
+ /**
+ * This method closes the service validator.
+ *
+ * @throws Exception Failed to close the service validator
+ */
+ public void close() throws Exception {
+ m_monitor.close();
+ }
+
+ private static final Logger logger = Logger.getLogger(Pi4SOAServiceRecorder.class);
+
+ private org.pi4soa.service.monitor.ServiceMonitor m_monitor=null;
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceValidator.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceValidator.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceValidator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,220 @@
+/*
+ * 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.validator.pi4soa;
+
+import org.apache.log4j.Logger;
+
+import org.savara.validator.AbstractServiceValidator;
+import org.savara.validator.ValidatorName;
+import org.pi4soa.common.util.MessageUtil;
+import org.pi4soa.service.ServiceException;
+import org.pi4soa.service.behavior.*;
+import org.pi4soa.service.monitor.*;
+
+/**
+ * This class implements the pi4soa service validator responsible for
+ * validating a stream of ESB messages against a choreography model.
+ */
+public class Pi4SOAServiceValidator extends AbstractServiceValidator {
+
+ private static final String CDM_MODEL_TYPE = "cdm";
+
+ /**
+ * This is the constructor for the pi4soa service
+ * validator implementation.
+ *
+ * @param name The validator name
+ * @throws Exception Failed to initialize service validator
+ */
+ public Pi4SOAServiceValidator(ValidatorName name)
+ throws Exception {
+ super(name);
+
+ update();
+ }
+
+ /**
+ * This method returns the model type associated with this
+ * service validator.
+ *
+ * @return The model type
+ */
+ public static String getModelType() {
+ return CDM_MODEL_TYPE;
+ }
+
+ /**
+ * This method is called to update the model associated
+ * with the service validator.
+ *
+ * @throws Exception Failed to update the service validator
+ */
+ public void update() throws Exception {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Update: "+getValidatorName());
+ }
+
+ java.io.InputStream is=getModel();
+
+ if (is != null) {
+ org.pi4soa.service.behavior.ServiceDescription sdesc=
+ org.pi4soa.service.util.DescriptionRetrievalUtil.instance().getServiceDescription(is,
+ getValidatorName().getRole());
+
+ try {
+ is.close();
+ } catch(Exception e) {
+ logger.error("Failed to close model '"+
+ getValidatorName()+"' input stream", e);
+ }
+
+ if (sdesc != null) {
+
+ if (m_monitor == null) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Service monitor for '"+
+ sdesc.getFullyQualifiedName()+
+ "' being created");
+ }
+
+ try {
+ // Use XML configuration, to enable alternative
+ // runtime configuration to be specified by
+ // including a pi4soa.xml file in the environment
+ DefaultMonitorConfiguration conf=
+ new XMLMonitorConfiguration();
+
+ conf.setValidateBehaviour(getValidatorName().isValidate());
+
+ m_monitor = ServiceMonitorFactory.getServiceMonitor(conf);
+
+ // Register service description
+ m_monitor.getConfiguration().getServiceRepository().
+ addServiceDescription(sdesc);
+
+ logger.debug("Created monitor for service description "+sdesc.getFullyQualifiedName());
+
+ } catch(Exception e) {
+ logger.error("Failed to initialize service monitor: "+e);
+ }
+ } else {
+
+ synchronized(m_monitor) {
+ // Service monitor already in use for the service
+ // description, so update description
+ try {
+ // Clear previous version of the service description
+ ServiceDescription[] sdescs=
+ m_monitor.getConfiguration().getServiceRepository().getServiceDescriptions();
+
+ for (int i=0; sdescs != null && i < sdescs.length; i++) {
+ m_monitor.getConfiguration().getServiceRepository().
+ removeServiceDescription(sdescs[i]);
+ }
+
+ logger.debug("Updating service description for "+sdesc.getFullyQualifiedName());
+
+ m_monitor.getConfiguration().getServiceRepository().addServiceDescription(sdesc);
+ } catch(Exception e) {
+ logger.error("Failed to update service description '"+
+ sdesc.getFullyQualifiedName()+"'", e);
+ }
+ }
+ }
+ } else {
+ logger.error("Unable to obtain service description for validator '"+
+ getValidatorName()+"'");
+ }
+ } else {
+ logger.error("Unable to obtain model for validator '"+
+ getValidatorName()+"'");
+
+ throw new java.io.IOException("Failed to locate model '"+
+ getValidatorName().getModelName()+"'");
+ }
+ }
+
+ /**
+ * This method processes a sent message against a service
+ * behavioural description.
+ *
+ * @param mesgType The optional message type
+ * @param msg The message
+ * @throws Exception Failed to process sent message
+ */
+ public void messageSent(String mesgType, java.io.Serializable msg) throws Exception {
+
+ if (msg == null) {
+ throw new ServiceException("Failed to obtain value from message: "+msg);
+ }
+
+ if (mesgType == null) {
+ mesgType = MessageUtil.getMessageType(msg);
+ }
+
+ org.pi4soa.service.Message mesg=
+ m_monitor.createMessage(mesgType,
+ null, null, msg, null, null);
+
+ synchronized(m_monitor) {
+ m_monitor.messageSent(mesg);
+ }
+ }
+
+ /**
+ * This method processes a received message against a service
+ * behavioural description.
+ *
+ * @param mesgType The optional message type
+ * @param msg The message
+ * @throws Exception Failed to process received message
+ */
+ public void messageReceived(String mesgType, java.io.Serializable msg) throws Exception {
+
+ if (msg == null) {
+ throw new ServiceException("Failed to obtain value from message: "+msg);
+ }
+
+ if (mesgType == null) {
+ mesgType = MessageUtil.getMessageType(msg);
+ }
+
+ org.pi4soa.service.Message mesg=
+ m_monitor.createMessage(mesgType,
+ null, null, msg, null, null);
+
+ synchronized(m_monitor) {
+ m_monitor.messageReceived(mesg);
+ }
+ }
+
+ /**
+ * This method closes the service validator.
+ *
+ * @throws Exception Failed to close the service validator
+ */
+ public void close() throws Exception {
+ m_monitor.close();
+ }
+
+ private static final Logger logger = Logger.getLogger(Pi4SOAServiceValidator.class);
+
+ private org.pi4soa.service.monitor.ServiceMonitor m_monitor=null;
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAValidatorConfigLoader.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAValidatorConfigLoader.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAValidatorConfigLoader.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,70 @@
+/*
+ * 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.validator.pi4soa;
+
+import org.savara.validator.DefaultValidatorConfig;
+import org.savara.validator.ValidatorConfig;
+import org.savara.validator.ValidatorConfigLoader;
+
+/**
+ * This class provides the pi4soa implementation of the
+ * validator config loader.
+ */
+public class Pi4SOAValidatorConfigLoader implements ValidatorConfigLoader {
+
+ public static final String PI4SOA_MODEL_TYPE="cdm";
+
+ /**
+ * This method determines if the validator config loader
+ * implementation supports the supplied model type.
+ *
+ * @param modelType The model type
+ * @return Whether the loader supports the model type
+ */
+ public boolean isSupported(String modelType) {
+ return(PI4SOA_MODEL_TYPE.equals(modelType));
+ }
+
+ /**
+ * This method loads the validator config, contained within
+ * the supplied input stream representing a model of the
+ * supported type.
+ *
+ * @param is The input stream
+ * @param modelPath The path to the model file
+ * @return The validator config
+ * @throws java.io.IOException Failed to load validator config
+ */
+ public ValidatorConfig loadValidatorConfig(java.io.InputStream is,
+ String modelPath) throws java.io.IOException {
+ ValidatorConfig ret=null;
+
+ org.pi4soa.cdl.Package cdlpack=
+ org.pi4soa.service.util.DescriptionRetrievalUtil.instance().getCDLPackage(is);
+
+ ValidatorConfigGenerator generator=new ValidatorConfigGenerator();
+
+ org.w3c.dom.Element validator=
+ generator.generate(cdlpack, modelPath);
+
+ ret = new DefaultValidatorConfig(PI4SOA_MODEL_TYPE,
+ validator);
+
+ return(ret);
+ }
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/ValidatorConfigGenerator.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/ValidatorConfigGenerator.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/pi4soa/ValidatorConfigGenerator.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,322 @@
+/*
+ * 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.validator.pi4soa;
+
+import java.util.Collections;
+import org.apache.log4j.Logger;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.util.xml.DOMWriter;
+import org.pi4soa.cdl.*;
+import org.pi4soa.common.annotations.*;
+import org.pi4soa.common.xml.XMLUtils;
+
+/**
+ * This class provides a generator for the JBossESB Validator
+ * configuration.
+ */
+public class ValidatorConfigGenerator {
+
+ private static final String VALIDATE_ATTR = "validate";
+ private static final String ROLE_ATTR = "role";
+ private static final String MODEL_ATTR = "model";
+ private static final String SERVICE_ELEMENT = "service";
+ private static final String VALIDATOR_ELEMENT = "validator";
+
+ public static void main(String[] args) {
+ if (args.length != 1) {
+ System.err.println("Usage: ValidatorConfigGenerator cdmPath");
+ System.exit(1);
+ }
+
+ try {
+ java.io.FileInputStream is=new java.io.FileInputStream(args[0]);
+
+ org.pi4soa.cdl.Package cdlpack=org.pi4soa.cdl.CDLManager.load(is);
+
+ is.close();
+
+ ValidatorConfigGenerator gen=new ValidatorConfigGenerator();
+
+ org.w3c.dom.Element config=gen.generate(cdlpack, args[0]);
+
+ System.out.println("CONFIG:\r\n"+XMLUtils.getText(config, true));
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * The default constructor.
+ */
+ public ValidatorConfigGenerator() {
+ }
+
+ /**
+ * This method generates the validator configuration associated
+ * with the supplied choreography.
+ *
+ * @param cdlpack The CDL package
+ * @param model The model (choreography file name)
+ * @return The validator config
+ */
+ public org.w3c.dom.Element generate(org.pi4soa.cdl.Package cdlpack,
+ String model) {
+ org.w3c.dom.Element ret=null;
+
+ try {
+ ret = createValidatorConfig();
+
+ // Create the new entries for the supplied choreography
+ if (cdlpack != null) {
+ createEntries(ret, model, cdlpack);
+ } else {
+ logger.error("Choreography not supplied for '"+model+"'");
+ }
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(DOMWriter.printNode(ret, true));
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method creates the initial template for the
+ * validator config.
+ *
+ * @return The initial validator config
+ * @throws Exception Failed to generate validator config
+ */
+ protected org.w3c.dom.Element createValidatorConfig()
+ throws Exception {
+ org.w3c.dom.Element ret=null;
+
+ org.w3c.dom.Document doc=
+ javax.xml.parsers.DocumentBuilderFactory.
+ newInstance().newDocumentBuilder().newDocument();
+
+ ret = doc.createElement(VALIDATOR_ELEMENT);
+
+ doc.appendChild(ret);
+
+ return(ret);
+ }
+
+ /**
+ * This method creates the entries in the validator config.
+ *
+ * @param validator The validator config
+ * @param model The model
+ * @param cdlpack The choreography description
+ */
+ protected void createEntries(org.w3c.dom.Element validator,
+ String model, org.pi4soa.cdl.Package cdlpack) {
+
+ for (int i=0; i < cdlpack.getTypeDefinitions().getParticipantTypes().size(); i++) {
+ org.pi4soa.cdl.ParticipantType ptype=
+ cdlpack.getTypeDefinitions().getParticipantTypes().get(i);
+
+ org.w3c.dom.Element service=
+ validator.getOwnerDocument().createElement(SERVICE_ELEMENT);
+
+ service.setAttribute(MODEL_ATTR, model);
+ service.setAttribute(ROLE_ATTR, ptype.getName());
+ service.setAttribute(VALIDATE_ATTR, Boolean.TRUE.toString());
+
+ cdlpack.visit(new InputOutputAnalyser(ptype, service));
+
+ if (service.getFirstChild() != null) {
+ validator.appendChild(service);
+ }
+ }
+ }
+
+ private static Logger logger = Logger.getLogger(ValidatorConfigGenerator.class);
+
+ public class InputOutputAnalyser extends DefaultCDLVisitor {
+
+ private static final String DESTINATION_TYPE_ENDPOINT_ADDRESS = "endpoint address";
+ private static final String TYPE_ATTR = "type";
+ private static final String DYNAMIC_REPLY_TO_ATTR = "dynamicReplyTo";
+ private static final String VALIDATOR_ANNOTATION = "validator";
+ private static final String VALIDATOR_ELEMENT = "validator";
+ private static final String DESTINATION_ELEMENT = "destination";
+ private static final String NAME_ATTR = "name";
+ private static final String EPR_ATTR = "epr";
+ private static final String INPUT_ELEMENT = "input";
+ private static final String OUTPUT_ELEMENT = "output";
+
+ public InputOutputAnalyser(org.pi4soa.cdl.ParticipantType ptype,
+ org.w3c.dom.Element service) {
+ m_participantType = ptype;
+ m_service = service;
+
+ m_templateProcessor =
+ org.pi4soa.common.annotations.AnnotationsManagerFactory.getAnnotationsManager().getTemplateProcessor(VALIDATOR_ANNOTATION);
+ }
+
+ /**
+ * This method inspects the supplied interaction.
+ *
+ */
+ public void interaction(Interaction interaction) {
+ if (m_participantType.getRoleTypes().contains(interaction.getFromRoleType()) ||
+ (interaction.getFromParticipant() != null &&
+ Collections.disjoint(m_participantType.getRoleTypes(),
+ interaction.getFromParticipant().getRoleTypes()) == false)) {
+
+ for (int i=0; i < interaction.getExchangeDetails().size(); i++) {
+ processExchangeDetails(interaction.getExchangeDetails().get(i), true);
+ }
+ } else if (m_participantType.getRoleTypes().contains(interaction.getToRoleType()) ||
+ (interaction.getToParticipant() != null &&
+ Collections.disjoint(m_participantType.getRoleTypes(),
+ interaction.getToParticipant().getRoleTypes()) == false)) {
+ for (int i=0; i < interaction.getExchangeDetails().size(); i++) {
+ processExchangeDetails(interaction.getExchangeDetails().get(i), false);
+ }
+ }
+ }
+
+ /**
+ * This method checks the supplied exchange details to determine
+ * if there is a 'jbossesb' annotation containing information
+ * about a destination to be validated.
+ *
+ * @param details The exchange details
+ * @param from Whether the 'from' details should be checked,
+ * otherwise the 'to' details will be checked
+ */
+ protected void processExchangeDetails(ExchangeDetails details, boolean from) {
+
+ for (int i=0; i < details.getSemanticAnnotations().size(); i++) {
+ SemanticAnnotation sa=details.getSemanticAnnotations().get(i);
+ org.w3c.dom.Element dest=null;
+
+ if (sa.getAnnotation() != null && sa.getName() != null &&
+ sa.getName().equals(VALIDATOR_ANNOTATION)) {
+ try {
+ // Transform the text representation to DOM
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=
+ builder.parse(new java.io.ByteArrayInputStream(
+ sa.getAnnotation().getBytes()));
+
+ if (doc.getDocumentElement() != null &&
+ doc.getDocumentElement().getNodeName().equals(
+ VALIDATOR_ELEMENT)) {
+ org.w3c.dom.NodeList nl=
+ doc.getDocumentElement().getElementsByTagName(DESTINATION_ELEMENT);
+
+ if (nl.getLength() == 1) {
+ dest = (org.w3c.dom.Element)nl.item(0);
+ } else if (nl.getLength() > 1) {
+ logger.error("Too many destination elements ("+
+ nl.getLength()+") found");
+ } else {
+ logger.error("No destinations found");
+ }
+ }
+
+ } catch(Exception e) {
+ logger.error("Failed to load validator annotation", e);
+ }
+ }
+
+ if (dest != null) {
+ processDestination(details, dest, from);
+ }
+ }
+ }
+
+ /**
+ * This method processes the destination information
+ * associated with the exchange details.
+ *
+ * @param details The exchange details
+ * @param dest The destination DOM element
+ * @param from Whether the 'from' or 'to' role should
+ * be considered
+ */
+ protected void processDestination(ExchangeDetails details,
+ org.w3c.dom.Element dest, boolean from) {
+ String elemName=null;
+
+ if (dest != null) {
+ if (from) {
+ if (details.getAction() == ExchangeActionType.REQUEST) {
+ elemName = OUTPUT_ELEMENT;
+ } else if (dest.getAttribute(TYPE_ATTR).trim().length() == 0 ||
+ dest.getAttribute(TYPE_ATTR).equals(DESTINATION_TYPE_ENDPOINT_ADDRESS)) {
+ elemName = INPUT_ELEMENT;
+ }
+ } else {
+ if (details.getAction() == ExchangeActionType.REQUEST) {
+ elemName = INPUT_ELEMENT;
+ } else if (dest.getAttribute(TYPE_ATTR).trim().length() == 0 ||
+ dest.getAttribute(TYPE_ATTR).equals(DESTINATION_TYPE_ENDPOINT_ADDRESS)) {
+ elemName = OUTPUT_ELEMENT;
+ }
+ }
+
+ if (elemName != null) {
+ org.w3c.dom.Element elem=m_service.getOwnerDocument().createElement(elemName);
+
+ // Parameter has been stored in a structured manner
+ // to support use of templates and presentations,
+ // so need to extract the value
+ java.util.List<TemplateParameter> params=
+ m_templateProcessor.getTemplateParameters(dest.getAttribute(NAME_ATTR));
+
+ if (params != null && params.size() > 0) {
+ elem.setAttribute(EPR_ATTR, params.get(0).getValue());
+ }
+
+ if (dest.hasAttribute(DYNAMIC_REPLY_TO_ATTR)) {
+ params=m_templateProcessor.getTemplateParameters(dest.getAttribute(DYNAMIC_REPLY_TO_ATTR));
+
+ if (params != null && params.size() > 0) {
+
+ if (params.get(0).getValue().equalsIgnoreCase("true")) {
+ elem.setAttribute(DYNAMIC_REPLY_TO_ATTR, "true");
+ }
+ }
+ }
+
+ if (elem.hasAttribute(EPR_ATTR)) {
+ m_service.appendChild(elem);
+ }
+ }
+ }
+ }
+
+ private ParticipantType m_participantType=null;
+ private org.w3c.dom.Element m_service=null;
+ private org.pi4soa.common.annotations.TemplateProcessor m_templateProcessor=null;
+ }
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorService.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorService.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorService.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.validator.service;
+
+import java.util.logging.Logger;
+
+import org.savara.validator.ServiceValidator;
+import org.savara.validator.ServiceValidatorManager;
+import org.jboss.util.naming.NonSerializableFactory;
+
+import javax.naming.*;
+
+/**
+ * This is the JBoss Savara Service Validator Service managing the Service Validator.
+ *
+ * @author gbrown
+ *
+ */
+public class ServiceValidatorService extends org.jboss.system.ServiceMBeanSupport implements ServiceValidatorServiceMBean {
+
+ private final static Logger logger = Logger.getLogger(ServiceValidatorService.class.getName());
+
+ private String m_jndiName=null;
+ private ServiceValidatorManager m_serviceValidatorManager=null;
+
+ /**
+ * The default constructor.
+ */
+ public ServiceValidatorService() {
+ }
+
+ /**
+ * This method starts the service, instantiating the
+ * Service Validation Manager and registering it with JNDI.
+ */
+ protected void startService() throws Exception {
+ logger.info("Starting Savara Service Validator Manager");
+
+ m_serviceValidatorManager = new ServiceValidatorManager();
+
+ rebind();
+ }
+
+ /**
+ * This method stops the service, closing the
+ * Service Validation Manager and unregistering it from JNDI.
+ */
+ protected void stopService() throws Exception {
+ logger.info("Stopping Savara Service Validator Manager");
+
+ unbind(m_jndiName);
+
+ m_serviceValidatorManager.close();
+
+ m_serviceValidatorManager = null;
+ }
+
+ /**
+ * This method returns the JNDI name used to register the
+ * Service Validation Manager.
+ */
+ public String getJndiName() {
+ return m_jndiName;
+ }
+
+ /**
+ * This method sets the JNDI name associated with the
+ * BPEL engine.
+ *
+ * @param jndiName The JNDI name
+ * @throws NamingException Failed to register BPEL engine against
+ * the JNDI name
+ */
+ public void setJndiName(String jndiName) throws NamingException {
+ String oldName = m_jndiName;
+ m_jndiName = jndiName;
+
+ if (super.getState() == STARTED) {
+ unbind(oldName);
+ try {
+ rebind();
+ } catch(Exception e) {
+ NamingException ne = new NamingException("Failed to update jndiName");
+ ne.setRootCause(e);
+ throw ne;
+ }
+ }
+ }
+
+ private void rebind() throws NamingException {
+ InitialContext rootCtx = new InitialContext();
+ Name fullName = rootCtx.getNameParser("").parse(m_jndiName);
+ logger.info("fullName="+fullName);
+ NonSerializableFactory.rebind(fullName, m_serviceValidatorManager, true);
+ }
+
+ private void unbind(String jndiName) {
+ try {
+ InitialContext rootCtx = new InitialContext();
+ rootCtx.unbind(jndiName);
+ NonSerializableFactory.unbind(jndiName);
+ } catch(NamingException e) {
+ logger.severe("Failed to unbind map: "+e);
+ }
+ }
+}
Added: trunk/validators/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorServiceMBean.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorServiceMBean.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorServiceMBean.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.validator.service;
+
+import javax.naming.NamingException;
+
+import org.jboss.system.ServiceMBean;
+
+/**
+ * The MBean for the Service Validator Service.
+ *
+ * @author gbrown
+ *
+ */
+public interface ServiceValidatorServiceMBean extends ServiceMBean {
+
+ /**
+ * This method returns the JNDI name used to register the
+ * Service Validator.
+ */
+ public String getJndiName();
+
+ /**
+ * This method sets the JNDI name associated with the
+ * Service Validator.
+ *
+ * @param jndiName The JNDI name
+ * @throws NamingException Failed to register Service Validator against
+ * the JNDI name
+ */
+ public void setJndiName(String jndiName) throws javax.naming.NamingException;
+
+}
Added: trunk/validators/jboss/esb/pom.xml
===================================================================
--- trunk/validators/jboss/esb/pom.xml (rev 0)
+++ trunk/validators/jboss/esb/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,106 @@
+<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.validators</groupId>
+ <artifactId>savara-validator-jbossesb</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Savara::Validators::JBoss::ESB</name>
+
+ <parent>
+ <groupId>org.savara.validators</groupId>
+ <artifactId>jboss</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.savara.validators</groupId>
+ <artifactId>savara-validator-jboss</artifactId>
+ <version>${savara.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.savara.dependencies.esb</groupId>
+ <artifactId>jbossesb-rosetta</artifactId>
+ <version>${rosetta.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>dist</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>savara-validator-jbossesb.esb</finalName>
+ <appendAssemblyId>true</appendAssemblyId>
+ <descriptors>
+ <descriptor>src/main/configs/esb-assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-javadoc</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <doclet>org.jboss.apiviz.APIviz</doclet>
+ <docletArtifact>
+ <groupId>org.jboss.apiviz</groupId>
+ <artifactId>apiviz</artifactId>
+ <version>1.2.4.GA</version>
+ </docletArtifact>
+ <aggregate>true</aggregate>
+ <attach>false</attach>
+ <additionalparam>
+ -d ${project.build.directory}/javadoc
+ -charset UTF-8
+ -docencoding UTF-8
+ -version
+ -author
+ -breakiterator
+ -windowtitle "${project.name} ${project.version} API Reference"
+ -doctitle "${project.name} ${project.version} API Reference"
+ -bottom "Copyright © ${project.inceptionYear}-Present ${project.organization.name}. All Rights Reserved."
+ -link http://java.sun.com/javase/6/docs/api/
+ -sourceclasspath ${project.build.outputDirectory}
+ </additionalparam>
+ <encoding>UTF-8</encoding>
+ <locale>en_US</locale>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
Added: trunk/validators/jboss/esb/src/main/configs/META-INF/deployment.xml
===================================================================
--- trunk/validators/jboss/esb/src/main/configs/META-INF/deployment.xml (rev 0)
+++ trunk/validators/jboss/esb/src/main/configs/META-INF/deployment.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbossesb-deployment>
+ <depends>jboss.esb:deployment=jbossesb.esb</depends>
+ <depends>jboss.savara:service=ServiceValidatorManager</depends>
+</jbossesb-deployment>
Added: trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-esb.xml
===================================================================
--- trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-esb.xml (rev 0)
+++ trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-esb.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,6 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">
+ <!--
+ jbossesb internal services
+ -->
+</jbossesb>
Added: trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-scanning.xml
===================================================================
--- trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-scanning.xml (rev 0)
+++ trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-scanning.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,3 @@
+<scanning xmlns="urn:jboss:scanning:1.0">
+ <!-- prevent scanning for annotations -->
+</scanning>
Added: trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-structure.xml
===================================================================
--- trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-structure.xml (rev 0)
+++ trunk/validators/jboss/esb/src/main/configs/META-INF/jboss-structure.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<structure>
+ <context>
+ <path name=""/>
+ <metaDataPath>
+ <path name="META-INF"/>
+ </metaDataPath>
+ <classpath>
+ <path name=""/>
+ <path name="" suffixes=".jar" />
+ <path name="lib" suffixes=".jar" />
+ </classpath>
+ </context>
+</structure>
Added: trunk/validators/jboss/esb/src/main/configs/esb-assembly.xml
===================================================================
--- trunk/validators/jboss/esb/src/main/configs/esb-assembly.xml (rev 0)
+++ trunk/validators/jboss/esb/src/main/configs/esb-assembly.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,27 @@
+<assembly 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/xsd/assembly-1.1.0-SNAPSHOT.xsd">
+ <id>dist</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/configs</directory>
+ <outputDirectory>/</outputDirectory>
+ <excludes>
+ <exclude>esb-assembly.xml</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>/lib</outputDirectory>
+ <includes>
+ <include>org.savara.validators:savara-validator-jbossesb</include>
+ </includes>
+ </dependencySet>
+ </dependencySets>
+
+</assembly>
Added: trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/ESBUtil.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/ESBUtil.java (rev 0)
+++ trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/ESBUtil.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,135 @@
+/*
+ * 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.validator.jbossesb;
+
+import org.apache.log4j.Logger;
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.NameSpaceUtil;
+import org.pi4soa.common.xml.XMLUtils;
+
+/**
+ * This class provides utility functions for processing
+ * ESB messages.
+ */
+public class ESBUtil {
+
+ public static final String SOAP_ENVELOPE = "http://schemas.xmlsoap.org/soap/envelope/";
+
+ /**
+ * This method returns the message content associated
+ * with the supplied JBoss ESB message.
+ *
+ * @param message The esb message
+ * @return The message content
+ */
+ public static java.io.Serializable getMessage(
+ org.jboss.soa.esb.message.Message message) {
+ java.io.Serializable ret=null;
+
+ ret = (java.io.Serializable)message.getBody().get();
+
+ // Check if should return a multipart message
+ if (ret == null) {
+
+ // Check if single or multipart message
+ if (message.getBody().getNames() != null &&
+ message.getBody().getNames().length == 1) {
+
+ Object mesg=message.getBody().get(message.getBody().getNames()[0]);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("MESSAGE("+
+ message.getBody().getNames()[0]+")="+mesg);
+ }
+
+ if (mesg instanceof java.io.Serializable) {
+ ret = (java.io.Serializable)mesg;
+ }
+
+ } else if (message.getBody().getNames() != null &&
+ message.getBody().getNames().length > 1) {
+
+ java.util.Hashtable<String,Object> multipart=
+ new java.util.Hashtable<String,Object>();
+
+ for (int i=0; i < message.getBody().getNames().length; i++) {
+ multipart.put(message.getBody().getNames()[i],
+ message.getBody().get(message.getBody().getNames()[i]));
+ }
+
+ ret = multipart;
+ }
+ }
+
+ if (ret instanceof byte[]) {
+ ret = new String((byte[])ret);
+ }
+
+ ret = getBody(ret);
+
+ return(ret);
+ }
+
+ public static java.io.Serializable getBody(java.io.Serializable value) {
+ java.io.Serializable ret=null;
+
+ if (value instanceof org.w3c.dom.Element &&
+ ((org.w3c.dom.Element)value).getLocalName().equals("Envelope") &&
+ ((org.w3c.dom.Element)value).getNamespaceURI().equals(
+ SOAP_ENVELOPE)) {
+
+ org.w3c.dom.NodeList bodylist=((org.w3c.dom.Element)value).
+ getElementsByTagNameNS(SOAP_ENVELOPE, "Body");
+
+ for (int i=0; ret == null && i < bodylist.getLength(); i++) {
+ if (bodylist.item(i) instanceof org.w3c.dom.Element &&
+ bodylist.item(i).getLocalName().equals("Body")) {
+ org.w3c.dom.NodeList children=((org.w3c.dom.Element)bodylist.item(i)).getChildNodes();
+
+ for (int j=0; ret == null && j < children.getLength(); j++) {
+ if (children.item(j) instanceof org.w3c.dom.Element) {
+ ret = (java.io.Serializable)children.item(j);
+ }
+ }
+ }
+ }
+ } else if (value instanceof String) {
+
+ try {
+ org.w3c.dom.Node node=XMLUtils.getNode((String)value);
+
+ ret = getBody((java.io.Serializable)node);
+
+ // Convert to string
+ if (ret instanceof org.w3c.dom.Node) {
+ ret = XMLUtils.getText((org.w3c.dom.Node)ret);
+ }
+
+ } catch(Exception e) {
+ logger.warn("Failed to obtain message body from value: "+value);
+ }
+
+ } else {
+ ret = value;
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger(ESBUtil.class);
+}
Added: trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/JBossESBInterceptor.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/JBossESBInterceptor.java (rev 0)
+++ trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/JBossESBInterceptor.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,285 @@
+/*
+ * 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.validator.jbossesb;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+
+import org.savara.validator.Endpoint;
+import org.savara.validator.ServiceValidator;
+import org.savara.validator.ServiceValidatorManager;
+import org.jboss.soa.esb.message.*;
+import org.jboss.soa.esb.couriers.*;
+
+/**
+ * This class represents the filter used to intercept ESB
+ * messages an apply them to relevant Service Validators.
+ */
+public class JBossESBInterceptor extends org.jboss.soa.esb.filter.InputOutputFilter {
+
+ private static final String TOPIC_PREFIX = "topic/";
+ private static final String QUEUE_PREFIX = "queue/";
+ private static final String JMS_PROTOCOL_PREFIX = "jms:";
+
+ private static final Logger logger = Logger.getLogger(JBossESBInterceptor.class);
+
+ private ServiceValidatorManager m_serviceValidatorManager=null;
+
+ /**
+ * The default constructor.
+ */
+ public JBossESBInterceptor() {
+ }
+
+ /**
+ * This method returns the service validator manager.
+ *
+ * @return The service validator manager
+ */
+ protected ServiceValidatorManager getServiceValidatorManager() {
+ if (m_serviceValidatorManager == null) {
+ try {
+ InitialContext ctx = new InitialContext();
+ m_serviceValidatorManager =
+ (ServiceValidatorManager)ctx.lookup("savara/ServiceValidatorManager");
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to locate Savara Service Validator Manager");
+ }
+ }
+
+ return(m_serviceValidatorManager);
+ }
+
+ /**
+ * This method is invoked when a message is sent by an
+ * ESB service.
+ *
+ * @param msg The ESB message
+ * @param params The parameters
+ * @throws CourierException Failed to validate message
+ */
+ public Message onOutput(Message msg, java.util.Map params)
+ throws CourierException {
+
+ Endpoint endpoint=getEndpoint(msg);
+
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getOutputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageSent(null, ESBUtil.getMessage(msg));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle sent message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid sent message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ throw new CourierException("Failed to handle sent message on endpoint '"+
+ endpoint+"' validated against: "+vnames, ex);
+ }
+ } else {
+
+ // Check whether a dynamic reply is expected
+ if (getServiceValidatorManager().isOutputDynamicReplyTo(endpoint)) {
+
+ // Register interest in the 'reply-to' endpoint
+ Endpoint replyTo=getReplyToEndpoint(msg);
+
+ if (replyTo != null) {
+ getServiceValidatorManager().registerInputReplyToValidators(replyTo,
+ validators);
+ } else {
+ logger.error("Unable to get 'reply-to' endpoint for message: "+msg);
+ }
+ }
+ }
+ }
+ }
+
+ return(msg);
+ }
+
+ /**
+ * This method is invoked when a message is received by an
+ * ESB service.
+ *
+ * @param msg The ESB message
+ * @param params The parameters
+ * @throws CourierException Failed to validate message
+ */
+ public Message onInput(Message msg, java.util.Map params)
+ throws CourierException {
+
+ Endpoint endpoint=getEndpoint(msg);
+
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getInputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageReceived(null, ESBUtil.getMessage(msg));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle received message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid received message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ throw new CourierException("Failed to handle received message on endpoint '"+
+ endpoint+"' validated against: "+vnames, ex);
+ }
+ } else {
+
+ // Check whether a dynamic reply is expected
+ if (getServiceValidatorManager().isInputDynamicReplyTo(endpoint)) {
+
+ // Register interest in the 'reply-to' endpoint
+ Endpoint replyTo=getReplyToEndpoint(msg);
+
+ if (replyTo != null) {
+ getServiceValidatorManager().registerOutputReplyToValidators(replyTo,
+ validators);
+ } else {
+ logger.error("Unable to get 'reply-to' endpoint for message: "+msg);
+ }
+ }
+ }
+ }
+ }
+
+ return(msg);
+ }
+
+ /**
+ * This method returns an endpoint associated with the 'to'
+ * destination of the supplied message.
+ *
+ * @param msg The message
+ * @return The endpoint, or null if not relevant
+ */
+ protected Endpoint getEndpoint(Message msg) {
+ Endpoint ret=null;
+
+ if (msg != null && msg.getHeader() != null &&
+ msg.getHeader().getCall() != null &&
+ msg.getHeader().getCall().getTo() != null &&
+ msg.getHeader().getCall().getTo().getAddr() != null) {
+
+ String key=msg.getHeader().getCall().getTo().getAddr().getAddress();
+ int ind=-1;
+
+ if (key.startsWith(JMS_PROTOCOL_PREFIX) &&
+ ((ind=key.indexOf(QUEUE_PREFIX)) != -1 ||
+ (ind=key.indexOf(TOPIC_PREFIX)) != -1)) {
+ ret = new Endpoint(JMS_PROTOCOL_PREFIX+key.substring(ind));
+ }
+ }
+
+ logger.debug("Destination for message '"+msg+"' is: "+ret);
+
+ return(ret);
+ }
+
+ /**
+ * This method returns an endpoint associated with the 'to'
+ * destination of the supplied message.
+ *
+ * @param msg The message
+ * @return The endpoint, or null if not relevant
+ */
+ protected Endpoint getReplyToEndpoint(Message msg) {
+ Endpoint ret=null;
+
+ if (msg != null && msg.getHeader() != null &&
+ msg.getHeader().getCall() != null &&
+ msg.getHeader().getCall().getReplyTo() != null &&
+ msg.getHeader().getCall().getReplyTo().getAddr() != null) {
+
+ String key=msg.getHeader().getCall().getReplyTo().getAddr().getAddress();
+ int ind=-1;
+
+ if (key.startsWith(JMS_PROTOCOL_PREFIX) &&
+ ((ind=key.indexOf(QUEUE_PREFIX)) != -1 ||
+ (ind=key.indexOf(TOPIC_PREFIX)) != -1)) {
+ ret = new Endpoint(JMS_PROTOCOL_PREFIX+key.substring(ind));
+ }
+ }
+
+ logger.debug("Reply-To Destination for message '"+msg+"' is: "+ret);
+
+ return(ret);
+ }
+}
Added: trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/ValidatorFilter.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/ValidatorFilter.java (rev 0)
+++ trunk/validators/jboss/esb/src/main/java/org/savara/validator/jbossesb/ValidatorFilter.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,36 @@
+/*
+ * 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.validator.jbossesb;
+
+/**
+ *
+ * @deprecated Use JBossESBInterceptor instead
+ */
+public class ValidatorFilter extends JBossESBInterceptor {
+
+ /**
+ * The default constructor.
+ */
+ public ValidatorFilter() {
+ }
+
+}
Added: trunk/validators/jboss/esb/src/test/java/org/savara/validator/jbossesb/ESBUtilTest.java
===================================================================
--- trunk/validators/jboss/esb/src/test/java/org/savara/validator/jbossesb/ESBUtilTest.java (rev 0)
+++ trunk/validators/jboss/esb/src/test/java/org/savara/validator/jbossesb/ESBUtilTest.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,76 @@
+package org.savara.validator.jbossesb;
+
+import static org.junit.Assert.*;
+
+import org.pi4soa.common.xml.XMLUtils;
+
+public class ESBUtilTest {
+
+ @org.junit.Test
+ public void testGetBodyText() {
+
+ String mesg="<soap:Envelope xmlns:soap=\""+ESBUtil.SOAP_ENVELOPE+"\" >"+
+ "<soap:Header>"+
+ "<m:Trans xmlns:m=\"http://www.w3schools.com/transaction/\" "+
+ "soap:mustUnderstand=\"1\">234</m:Trans>"+
+ "</soap:Header>"+
+ "<soap:Body>"+
+ "<m:GetPrice xmlns:m=\"http://www.w3schools.com/prices\">"+
+ "<m:Item>Apples</m:Item>"+
+ "</m:GetPrice>"+
+ "</soap:Body>"+
+ "</soap:Envelope>";
+
+ String expected="<m:GetPrice xmlns:m=\"http://www.w3schools.com/prices\">"+
+ "<m:Item>Apples</m:Item>"+
+ "</m:GetPrice>";
+
+ java.io.Serializable result=ESBUtil.getBody(mesg);
+
+ if ((result instanceof String) == false) {
+ fail("Result should be a string");
+ }
+
+ if (result.equals(expected) == false) {
+ fail("Failed to match body");
+ }
+ }
+
+ @org.junit.Test
+ public void testGetBodyXML() {
+
+ String mesg="<soap:Envelope xmlns:soap=\""+ESBUtil.SOAP_ENVELOPE+"\" >"+
+ "<soap:Header>"+
+ "<m:Trans xmlns:m=\"http://www.w3schools.com/transaction/\" "+
+ "soap:mustUnderstand=\"1\">234</m:Trans>"+
+ "</soap:Header>"+
+ "<soap:Body>"+
+ "<m:GetPrice xmlns:m=\"http://www.w3schools.com/prices\">"+
+ "<m:Item>Apples</m:Item>"+
+ "</m:GetPrice>"+
+ "</soap:Body>"+
+ "</soap:Envelope>";
+
+ try {
+ org.w3c.dom.Node mesgxml=XMLUtils.getNode(mesg);
+
+ String expected="<m:GetPrice xmlns:m=\"http://www.w3schools.com/prices\">"+
+ "<m:Item>Apples</m:Item>"+
+ "</m:GetPrice>";
+
+ java.io.Serializable result=ESBUtil.getBody((java.io.Serializable)mesgxml);
+
+ if ((result instanceof org.w3c.dom.Node) == false) {
+ fail("Result should be a DOM Node");
+ }
+
+ String resulttext=XMLUtils.getText((org.w3c.dom.Node)result);
+
+ if (resulttext.equals(expected) == false) {
+ fail("Failed to match body");
+ }
+ } catch(Exception e) {
+ fail("Failed to get body from XML: "+e);
+ }
+ }
+}
Added: trunk/validators/jboss/pom.xml
===================================================================
--- trunk/validators/jboss/pom.xml (rev 0)
+++ trunk/validators/jboss/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,25 @@
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.savara.validators</groupId>
+ <artifactId>jboss</artifactId>
+ <packaging>pom</packaging>
+ <name>Savara::Validators::JBoss</name>
+ <version>1.2.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.savara</groupId>
+ <artifactId>validators</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <modules>
+ <module>common</module>
+ <module>esb</module>
+ <module>wsnative</module>
+ </modules>
+
+</project>
Added: trunk/validators/jboss/wsnative/pom.xml
===================================================================
--- trunk/validators/jboss/wsnative/pom.xml (rev 0)
+++ trunk/validators/jboss/wsnative/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,119 @@
+<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.validators</groupId>
+ <artifactId>savara-validator-jbossws-native</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Savara::Validators::JBoss::WS-Native</name>
+
+ <parent>
+ <groupId>org.savara.validators</groupId>
+ <artifactId>jboss</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.savara.validators</groupId>
+ <artifactId>savara-validator-jboss</artifactId>
+ <version>${savara.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <version>${jboss.version}</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ws</groupId>
+ <artifactId>jbossws-framework</artifactId>
+ <version>${jbossws.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ws.native</groupId>
+ <artifactId>jbossws-native-core</artifactId>
+ <version>${jbossws.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>dist</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>savara-validator-jbossws-native.sar</finalName>
+ <appendAssemblyId>true</appendAssemblyId>
+ <descriptors>
+ <descriptor>src/main/configs/ws-native-assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-javadoc</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <doclet>org.jboss.apiviz.APIviz</doclet>
+ <docletArtifact>
+ <groupId>org.jboss.apiviz</groupId>
+ <artifactId>apiviz</artifactId>
+ <version>1.2.4.GA</version>
+ </docletArtifact>
+ <aggregate>true</aggregate>
+ <attach>false</attach>
+ <additionalparam>
+ -d ${project.build.directory}/javadoc
+ -charset UTF-8
+ -docencoding UTF-8
+ -version
+ -author
+ -breakiterator
+ -windowtitle "${project.name} ${project.version} API Reference"
+ -doctitle "${project.name} ${project.version} API Reference"
+ -bottom "Copyright © ${project.inceptionYear}-Present ${project.organization.name}. All Rights Reserved."
+ -link http://java.sun.com/javase/6/docs/api/
+ -sourceclasspath ${project.build.outputDirectory}
+ </additionalparam>
+ <encoding>UTF-8</encoding>
+ <locale>en_US</locale>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
Added: trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-beans.xml
===================================================================
--- trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-beans.xml (rev 0)
+++ trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-beans.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean class="org.savara.validator.jbosswsnative.service.JBossWSNativeServiceValidatorService"
+ name="JBossWSNativeServiceValidator">
+ <!--
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.savara:service=ServiceValidatorManager", exposedInterface=org.savara.validator.service.ServiceValidatorServiceMBean.class,registerDirectly=true)</annotation>
+ -->
+ <depends>jboss.savara:service=ServiceValidatorManager</depends>
+ </bean>
+
+</deployment>
Added: trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-scanning.xml
===================================================================
--- trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-scanning.xml (rev 0)
+++ trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-scanning.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,3 @@
+<scanning xmlns="urn:jboss:scanning:1.0">
+ <!-- prevent scanning for annotations -->
+</scanning>
Added: trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-structure.xml
===================================================================
--- trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-structure.xml (rev 0)
+++ trunk/validators/jboss/wsnative/src/main/configs/META-INF/jboss-structure.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<structure>
+ <context>
+ <path name=""/>
+ <metaDataPath>
+ <path name="META-INF"/>
+ </metaDataPath>
+ <classpath>
+ <path name=""/>
+ <path name="" suffixes=".jar" />
+ <path name="lib" suffixes=".jar" />
+ </classpath>
+ </context>
+</structure>
Added: trunk/validators/jboss/wsnative/src/main/configs/ws-native-assembly.xml
===================================================================
--- trunk/validators/jboss/wsnative/src/main/configs/ws-native-assembly.xml (rev 0)
+++ trunk/validators/jboss/wsnative/src/main/configs/ws-native-assembly.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,27 @@
+<assembly 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/xsd/assembly-1.1.0-SNAPSHOT.xsd">
+ <id>dist</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/configs</directory>
+ <outputDirectory>/</outputDirectory>
+ <excludes>
+ <exclude>ws-native-assembly.xml</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>/lib</outputDirectory>
+ <includes>
+ <include>org.savara.validators:savara-validator-jbossws-native</include>
+ </includes>
+ </dependencySet>
+ </dependencySets>
+
+</assembly>
Added: trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/AbstractJBossWSNativeInterceptor.java
===================================================================
--- trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/AbstractJBossWSNativeInterceptor.java (rev 0)
+++ trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/AbstractJBossWSNativeInterceptor.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,188 @@
+/*
+ * 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.validator.jbosswsnative;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.savara.validator.Endpoint;
+import org.savara.validator.ServiceValidatorManager;
+import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
+import org.jboss.ws.metadata.umdm.ParameterMetaData;
+import org.jboss.wsf.common.DOMWriter;
+import org.jboss.wsf.common.handler.GenericSOAPHandler;
+
+/**
+ * Common abstract base class for the client and server JBossWS
+ * native interceptors.
+ *
+ */
+public abstract class AbstractJBossWSNativeInterceptor extends GenericSOAPHandler {
+
+ private static Log logger = LogFactory.getLog(AbstractJBossWSNativeInterceptor.class);
+
+ private ServiceValidatorManager m_serviceValidatorManager=null;
+
+ /**
+ * This method returns the service validator manager.
+ *
+ * @return The service validator manager
+ */
+ protected ServiceValidatorManager getServiceValidatorManager() {
+ if (m_serviceValidatorManager == null) {
+ try {
+ InitialContext ctx = new InitialContext();
+ m_serviceValidatorManager =
+ (ServiceValidatorManager)ctx.lookup("savara/ServiceValidatorManager");
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to locate Savara Service Validator Manager");
+ }
+ }
+
+ return(m_serviceValidatorManager);
+ }
+
+ /**
+ * This method returns the message content.
+ *
+ * @param soapCtx The SOAP message context
+ * @return The message content
+ * @throws Exception Failed to get the message content
+ */
+ public static java.io.Serializable getMessage(SOAPMessageContext soapCtx) throws Exception {
+ java.io.Serializable ret=null;
+
+ SOAPElement elem = getMessageBody(soapCtx);
+ if (elem != null) {
+ ret = DOMWriter.printNode(elem, true);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines the message type associated with the supplied SOAP
+ * message context.
+ *
+ * @param soapCtx The SOAP message context
+ * @return The message type
+ * @throws SOAPException Failed to determine the message type
+ */
+ public static String getMessageType(SOAPMessageContext soapCtx, boolean request) throws SOAPException {
+ String ret=null;
+
+ if (soapCtx instanceof org.jboss.ws.core.jaxws.handler.MessageContextJAXWS) {
+ org.jboss.ws.core.jaxws.handler.MessageContextJAXWS mc=
+ (org.jboss.ws.core.jaxws.handler.MessageContextJAXWS)soapCtx;
+ org.jboss.ws.metadata.umdm.OperationMetaData opmetadata=mc.getOperationMetaData();
+
+ if (opmetadata != null) {
+ ParameterMetaData pmd=null;
+
+ if (request && opmetadata.getInputParameters().size() == 1) {
+ pmd = opmetadata.getInputParameters().get(0);
+ } else if (!request && opmetadata.getOutputParameters().size() == 1) {
+ pmd = opmetadata.getOutputParameters().get(0);
+ }
+
+ if (pmd != null) {
+ // TODO: Find out why 'genericParam' is generated when the parameter
+ // is a complex type
+ if (pmd.getXmlName().getLocalPart().equals("genericParam")) {
+
+ // Extract message value
+ SOAPElement elem=getMessageBody(soapCtx);
+
+ if (elem != null) {
+ ret = elem.getElementQName().toString();
+ }
+
+ } else {
+ ret = pmd.getXmlName().toString();
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ protected static SOAPElement getMessageBody(SOAPMessageContext soapCtx) throws SOAPException {
+ SOAPElement ret=null;
+
+ // Extract message value
+ SOAPBody soapBody = soapCtx.getMessage().getSOAPPart().getEnvelope().getBody();
+
+ java.util.Iterator<?> iter=soapBody.getChildElements();
+ while (ret == null && iter.hasNext()) {
+ Object body=iter.next();
+
+ if (body instanceof SOAPElement) {
+ ret = (SOAPElement)body;
+ }
+ }
+
+ if (ret instanceof SOAPFault) {
+ SOAPFault fault=(SOAPFault)ret;
+
+ ret = (SOAPElement)fault.getDetail().getChildElements().next();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the endpoint associated with the supplied SOAP
+ * message context.
+ *
+ * @param soapCtx The SOAP message context
+ * @return The endpoint
+ */
+ public static Endpoint getEndpoint(SOAPMessageContext soapCtx) {
+ QName service=(QName)soapCtx.get(MessageContext.WSDL_SERVICE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Service for endpoint = "+service);
+ }
+
+ if (service == null && soapCtx instanceof SOAPMessageContextJAXWS) {
+ SOAPMessageContextJAXWS smc=(SOAPMessageContextJAXWS)soapCtx;
+
+ if (smc.getEndpointMetaData() != null &&
+ smc.getEndpointMetaData().getServiceMetaData() != null) {
+ service = smc.getEndpointMetaData().getServiceMetaData().getServiceName();
+ }
+ }
+
+ return(service == null ? null : new Endpoint(service.toString()));
+ }
+}
Added: trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java
===================================================================
--- trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java (rev 0)
+++ trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.validator.jbosswsnative;
+
+import javax.xml.soap.SOAPException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.savara.validator.Endpoint;
+import org.savara.validator.ServiceValidator;
+
+public class JBossWSNativeClientInterceptor extends AbstractJBossWSNativeInterceptor {
+
+ private static Log logger = LogFactory.getLog(JBossWSNativeClientInterceptor.class);
+
+ public JBossWSNativeClientInterceptor() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("JBossWSNativeClientInterceptor created");
+ }
+ }
+
+ protected boolean handleInbound(MessageContext ctx) {
+ boolean ret=true;
+ SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
+
+ Endpoint endpoint=getEndpoint(soapCtx);
+
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getOutputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageReceived(getMessageType(soapCtx, false), getMessage(soapCtx));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle received message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid received message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ ret = false;
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ protected boolean handleOutbound(MessageContext ctx) {
+ boolean ret=true;
+ SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
+
+ Endpoint endpoint=getEndpoint(soapCtx);
+
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getOutputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageSent(getMessageType(soapCtx, true), getMessage(soapCtx));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle received message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid received message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ ret = false;
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ public boolean handleFault(MessageContext ctx) {
+ return handleOutbound(ctx);
+ }
+}
Added: trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java
===================================================================
--- trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java (rev 0)
+++ trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.validator.jbosswsnative;
+
+import javax.xml.soap.SOAPException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.savara.validator.Endpoint;
+import org.savara.validator.ServiceValidator;
+
+public class JBossWSNativeServerInterceptor extends AbstractJBossWSNativeInterceptor {
+
+ private static Log logger = LogFactory.getLog(JBossWSNativeServerInterceptor.class);
+
+ public JBossWSNativeServerInterceptor() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("JBossWSNativeServerInterceptor created");
+ }
+ }
+
+ protected boolean handleInbound(MessageContext ctx) {
+ boolean ret=true;
+ SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
+
+ Endpoint endpoint=getEndpoint(soapCtx);
+
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getInputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageReceived(getMessageType(soapCtx, true), getMessage(soapCtx));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle received message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid received message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ ret = false;
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ protected boolean handleOutbound(MessageContext ctx) {
+ boolean ret=true;
+ SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
+
+ Endpoint endpoint=getEndpoint(soapCtx);
+
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getInputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageSent(getMessageType(soapCtx, false), getMessage(soapCtx));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle received message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid received message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ ret = false;
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ public boolean handleFault(MessageContext ctx) {
+ return handleOutbound(ctx);
+ }
+}
Added: trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/service/JBossWSNativeServiceValidatorService.java
===================================================================
--- trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/service/JBossWSNativeServiceValidatorService.java (rev 0)
+++ trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/service/JBossWSNativeServiceValidatorService.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.validator.jbosswsnative.service;
+
+import java.util.logging.Logger;
+
+import javax.naming.*;
+
+/**
+ * This is the JBossWS Native Savara Service Validator Service managing the Service Validator.
+ *
+ * @author gbrown
+ *
+ */
+public class JBossWSNativeServiceValidatorService extends org.jboss.system.ServiceMBeanSupport implements JBossWSNativeServiceValidatorServiceMBean {
+
+ private final static Logger logger = Logger.getLogger(JBossWSNativeServiceValidatorService.class.getName());
+
+ /**
+ * The default constructor.
+ */
+ public JBossWSNativeServiceValidatorService() {
+ }
+
+ /**
+ * This method starts the service, instantiating the
+ * Service Validation Manager and registering it with JNDI.
+ */
+ protected void startService() throws Exception {
+ logger.info("Starting Savara JBossWS Native Service Validator Adapter");
+ }
+
+ /**
+ * This method stops the service, closing the
+ * Service Validation Manager and unregistering it from JNDI.
+ */
+ protected void stopService() throws Exception {
+ logger.info("Stopping Savara JBossWS Native Service Validator Adapter");
+ }
+
+}
Added: trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/service/JBossWSNativeServiceValidatorServiceMBean.java
===================================================================
--- trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/service/JBossWSNativeServiceValidatorServiceMBean.java (rev 0)
+++ trunk/validators/jboss/wsnative/src/main/java/org/savara/validator/jbosswsnative/service/JBossWSNativeServiceValidatorServiceMBean.java 2010-11-21 00:29:50 UTC (rev 496)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.validator.jbosswsnative.service;
+
+import javax.naming.NamingException;
+
+import org.jboss.system.ServiceMBean;
+
+/**
+ * The MBean for the JBossWS Native Service Validator Service.
+ *
+ * @author gbrown
+ *
+ */
+public interface JBossWSNativeServiceValidatorServiceMBean extends ServiceMBean {
+
+}
Added: trunk/validators/pom.xml
===================================================================
--- trunk/validators/pom.xml (rev 0)
+++ trunk/validators/pom.xml 2010-11-21 00:29:50 UTC (rev 496)
@@ -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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.savara</groupId>
+ <artifactId>validators</artifactId>
+ <packaging>pom</packaging>
+ <name>Savara::Validators</name>
+ <version>1.2.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org</groupId>
+ <artifactId>savara</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <modules>
+ <module>jboss</module>
+ </modules>
+
+</project>
More information about the savara-commits
mailing list