summaryrefslogtreecommitdiffstats
path: root/sandbox/sebastien/java/dynamic/modules/assembly
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-07-19 02:50:53 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-07-19 02:50:53 +0000
commitf59fca36e7538cafbd6032003c7b06d64862a2bf (patch)
treee5b1222e40a7abc8b945195df39ab97c5eb5729c /sandbox/sebastien/java/dynamic/modules/assembly
parent1a8707aa6ad5e22117a9f17e88322a6ee824aa44 (diff)
Branch to experiment with dynamic component interfaces and implementations.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@965346 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/LICENSE205
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/META-INF/MANIFEST.MF70
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/NOTICE6
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/pom.xml88
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java781
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java129
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java96
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java381
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java185
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java96
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java1134
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java108
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java158
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java257
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java132
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java151
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java28
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java242
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java132
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java128
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java171
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java64
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java292
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java27
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java65
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java250
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java65
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java424
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java27
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java74
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java572
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java294
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java72
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml242
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor29
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor22
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver21
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint17
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties32
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties24
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties50
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java108
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java88
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java151
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java192
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java85
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java130
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java151
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java103
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java143
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java82
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.java78
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java62
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java83
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java35
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java162
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java109
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java136
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java99
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java39
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java230
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java58
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java161
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java286
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java83
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite59
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType31
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorURISpaces.composite59
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite32
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite29
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite44
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite127
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite56
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite125
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml96
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite27
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml206
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml207
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite49
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml204
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/LICENSE338
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/META-INF/MANIFEST.MF13
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/NOTICE38
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/pom.xml31
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java140
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema19
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd402
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd204
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd195
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd108
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd137
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd141
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd35
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd117
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd318
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-1.1-cd05.xsd38
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd34
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd173
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd179
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd05.xsd20
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd35
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd18
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd05.xsd90
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd35
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd35
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd34
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd05.xsd478
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd05.xsd30
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd32
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd55
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd05.xsd26
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd63
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd02.xsd26
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd21
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd51
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd51
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd28
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd05.xsd28
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd52
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd03.xsd119
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd03.xml249
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-atom.xsd43
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd41
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd41
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jms.xsd128
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd41
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rest.xsd105
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd40
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rss.xsd43
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd53
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-script.xsd38
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-widget.xsd42
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd40
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/LICENSE205
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/META-INF/MANIFEST.MF60
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/NOTICE6
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/pom.xml45
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java78
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java151
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java43
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java28
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java167
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java45
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java114
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java53
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java142
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java89
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java113
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java59
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java90
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java132
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java44
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java57
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java62
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java111
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java41
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java139
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java165
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java45
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java66
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java36
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java50
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java29
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java33
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java40
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java71
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java30
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java35
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java42
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java85
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java31
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java54
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java107
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java149
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java51
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java45
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ContractBuilder.java37
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java479
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java50
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java31
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java84
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/WireBuilder.java39
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java112
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java46
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java36
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java138
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java45
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java122
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java77
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java186
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java97
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java119
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java71
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java176
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java185
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java63
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java62
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java95
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java88
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java283
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java233
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java49
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java62
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java89
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java59
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java135
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java40
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java148
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java106
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java105
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java32
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java84
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java34
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java43
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java31
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java307
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java73
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java108
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Compatibility.java29
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java120
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java63
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java69
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java116
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java100
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java230
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java40
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java35
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java43
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java43
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java204
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java46
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java220
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java142
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java619
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java329
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java282
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java115
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java83
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java144
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java101
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java204
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java153
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java27
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java30
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java82
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java27
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java161
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java49
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java31
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.java37
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java66
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java67
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java147
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java57
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java44
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java38
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java97
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java39
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java168
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java78
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java87
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java70
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java145
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java48
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java130
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory18
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory19
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint18
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory17
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper19
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory18
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties327
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties83
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties30
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties25
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java170
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java70
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java61
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java42
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java41
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java30
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java396
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java70
-rw-r--r--sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java55
285 files changed, 30915 insertions, 0 deletions
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/LICENSE b/sandbox/sebastien/java/dynamic/modules/assembly-xml/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/LICENSE
@@ -0,0 +1,205 @@
+
+ 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.
+
+
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/META-INF/MANIFEST.MF b/sandbox/sebastien/java/dynamic/modules/assembly-xml/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..57e693005b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/META-INF/MANIFEST.MF
@@ -0,0 +1,70 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.assembly.xml;version="2.0.0";
+ uses:="org.apache.tuscany.sca.assembly,
+ javax.xml.parsers,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.contribution,
+ org.apache.tuscany.sca.monitor,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.interfacedef,
+ org.w3c.dom,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor",
+ org.apache.tuscany.sca.definitions.xml;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.definitions,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.policy.xml;version="2.0.0";
+ uses:="javax.xml.xpath,
+ javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.monitor,
+ javax.xml.namespace"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA XML Assembly Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA XML Assembly Model
+Import-Package: javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.stream,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.stream,
+ javax.xml.validation;resolution:=optional,
+ javax.xml.xpath,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.xpath;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.java;version="2.0.0",
+ org.apache.tuscany.sca.contribution.namespace;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.definitions.xml;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.w3c.dom,
+ org.xml.sax;resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.assembly.xml
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/NOTICE b/sandbox/sebastien/java/dynamic/modules/assembly-xml/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/pom.xml b/sandbox/sebastien/java/dynamic/modules/assembly-xml/pom.xml
new file mode 100644
index 0000000000..8eb306f07c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/pom.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <name>Apache Tuscany SCA Assembly XML Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0-2</version>
+ </dependency>
+ -->
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
new file mode 100644
index 0000000000..641e523d2c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
@@ -0,0 +1,781 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+import static javax.xml.stream.XMLStreamConstants.CDATA;
+import static javax.xml.stream.XMLStreamConstants.CHARACTERS;
+import static javax.xml.stream.XMLStreamConstants.COMMENT;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MANY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MULTIPLICITY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MUST_SUPPLY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.NAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ONE_N;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ONE_ONE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SCA11_NS;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TARGET;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TYPE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.VALUE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.VALUE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ZERO_N;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ZERO_ONE;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.tuscany.sca.assembly.AbstractContract;
+import org.apache.tuscany.sca.assembly.AbstractProperty;
+import org.apache.tuscany.sca.assembly.AbstractReference;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A base class with utility methods for the other artifact processors in this module.
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
+
+ protected AssemblyFactory assemblyFactory;
+ protected PolicyFactory policyFactory;
+ protected StAXArtifactProcessor<Object> extensionProcessor;
+ protected PolicySubjectProcessor policyProcessor;
+ private DocumentBuilderFactory documentBuilderFactory;
+
+
+ /**
+ * Constructs a new BaseArtifactProcessor.
+ * @param assemblyFactory
+ * @param policyFactory
+ */
+ @SuppressWarnings("unchecked")
+ protected BaseAssemblyProcessor(AssemblyFactory assemblyFactory,
+ PolicyFactory policyFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ StAXArtifactProcessor extensionProcessor) {
+ this.assemblyFactory = assemblyFactory;
+ this.policyFactory = policyFactory;
+ this.documentBuilderFactory = documentBuilderFactory;
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ }
+
+ /**
+ * @param modelFactories
+ * @param staxProcessor
+ * @param monitor
+ */
+ protected BaseAssemblyProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor) {
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)staxProcessor;
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ }
+
+ /**
+ * Marshals warnings into the monitor
+ *
+ * @param message
+ * @param model
+ * @param messageParameters
+ */
+ protected void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.WARNING,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Marshals errors into the monitor
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Marshals exceptions into the monitor
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Start an element.
+ * @param writer
+ * @param name
+ * @param attrs
+ * @throws XMLStreamException
+ */
+ protected void writeStart(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
+ super.writeStart(writer, SCA11_NS, name, attrs);
+ }
+
+ /**
+ * Start a document.
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void writeStartDocument(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
+ super.writeStartDocument(writer, SCA11_NS, name, attrs);
+ }
+
+ /**
+ * Read list of reference targets
+ * @param reference
+ * @param reader
+ */
+ protected void readTargets(Reference reference, XMLStreamReader reader) {
+ String value = getString(reader, TARGET);
+ ComponentService target = null;
+ if (value != null) {
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ target = assemblyFactory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(tokens.nextToken());
+ reference.getTargets().add(target);
+ }
+ }
+ }
+
+ /**
+ * Write a list of targets into an attribute
+ * @param reference
+ * @return
+ */
+ protected XAttr writeTargets(Reference reference) {
+ List<String> targets = new ArrayList<String>();
+ for (Service target : reference.getTargets()) {
+ targets.add(target.getName());
+ }
+ return new XAttr(TARGET, targets);
+ }
+
+ /**
+ * Read a multiplicity attribute.
+ * @param reference
+ * @param reader
+ */
+ protected void readMultiplicity(AbstractReference reference, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, MULTIPLICITY);
+ if (ZERO_ONE.equals(value)) {
+ reference.setMultiplicity(Multiplicity.ZERO_ONE);
+ } else if (ONE_N.equals(value)) {
+ reference.setMultiplicity(Multiplicity.ONE_N);
+ } else if (ZERO_N.equals(value)) {
+ reference.setMultiplicity(Multiplicity.ZERO_N);
+ } else if (ONE_ONE.equals(value)) {
+ reference.setMultiplicity(Multiplicity.ONE_ONE);
+ }
+ }
+
+ protected XAttr writeMultiplicity(AbstractReference reference) {
+ Multiplicity multiplicity = reference.getMultiplicity();
+ if (multiplicity != null) {
+ String value = null;
+ if (Multiplicity.ZERO_ONE.equals(multiplicity)) {
+ value = ZERO_ONE;
+ } else if (Multiplicity.ONE_N.equals(multiplicity)) {
+ value = ONE_N;
+ } else if (Multiplicity.ZERO_N.equals(multiplicity)) {
+ value = ZERO_N;
+ } else if (Multiplicity.ONE_ONE.equals(multiplicity)) {
+ value = ONE_ONE;
+ return null;
+ }
+ return new XAttr(MULTIPLICITY, value);
+ }
+ return null;
+ }
+
+
+ /**
+ * Reads an abstract property element.
+ * @param property
+ * @param reader
+ * @param context TODO
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ */
+ protected void readAbstractProperty(AbstractProperty property, XMLStreamReader reader, ProcessorContext context) throws XMLStreamException,
+ ContributionReadException {
+
+ property.setName(getString(reader, NAME));
+ property.setMany(getBoolean(reader, MANY));
+ property.setMustSupply(getBoolean(reader, MUST_SUPPLY));
+ property.setXSDElement(getQName(reader, ELEMENT));
+ property.setXSDType(getQName(reader, TYPE));
+ // MJE added 14/05/2009 - check for both @element and @type being present - disallowed by OASIS Assembly spec
+ if( property.getXSDElement() != null && property.getXSDType() != null ) {
+ ContributionReadException ce = new ContributionReadException("[ASM40010,ASM60040] Error: property has both @type and @element attribute values - " +
+ property.getName());
+ error(context.getMonitor(), "ContributionReadException", property, ce);
+ } // end if
+
+ }
+
+ /**
+ * Resolve an implementation.
+ * @param implementation
+ * @param resolver
+ * @param context
+ * @return
+ * @throws ContributionResolveException
+ */
+ protected Implementation resolveImplementation(Implementation implementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (implementation != null) {
+ if (implementation.isUnresolved()) {
+ implementation = resolver.resolveModel(Implementation.class, implementation, context);
+
+ // Lazily resolve implementations
+ if (implementation.isUnresolved()) {
+ extensionProcessor.resolve(implementation, resolver, context);
+ if (!implementation.isUnresolved()) {
+ resolver.addModel(implementation, context);
+ }
+ }
+ }
+ }
+ return implementation;
+ }
+
+ /**
+ * Resolve interface, callback interface and bindings on a list of contracts.
+ * @param contracts the list of contracts
+ * @param resolver the resolver to use to resolve models
+ * @param context TODO
+ */
+ protected <C extends Contract> void resolveContracts(List<C> contracts, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ resolveContracts(null, contracts, resolver, context);
+ }
+
+ /**
+ * Resolve interface, callback interface and bindings on a list of contracts.
+ * @param parent element for the contracts
+ * @param contracts the list of contracts
+ * @param resolver the resolver to use to resolve models
+ * @param context TODO
+ */
+ protected <C extends Contract> void resolveContracts(Base parent, List<C> contracts, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+
+ String parentName =
+ (parent instanceof Composite) ? ((Composite)parent).getName().toString() : (parent instanceof Component)
+ ? ((Component)parent).getName() : "UNKNOWN";
+
+ for (Contract contract : contracts) {
+ // Resolve the interface contract
+ InterfaceContract interfaceContract = contract.getInterfaceContract();
+ if (interfaceContract != null) {
+ extensionProcessor.resolve(interfaceContract, resolver, context);
+ }
+
+ // Resolve bindings
+ for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
+ Binding binding = contract.getBindings().get(i);
+ extensionProcessor.resolve(binding, resolver, context);
+
+ }
+
+ // Resolve callback bindings
+ if (contract.getCallback() != null) {
+
+ for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
+ Binding binding = contract.getCallback().getBindings().get(i);
+ extensionProcessor.resolve(binding, resolver, context);
+ }
+ }
+ }
+ }
+
+ /**
+ * Resolve interface and callback interface on a list of abstract contracts.
+ * @param contracts the list of contracts
+ * @param resolver the resolver to use to resolve models
+ * @param context TODO
+ */
+ protected <C extends AbstractContract> void resolveAbstractContracts(List<C> contracts, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ for (AbstractContract contract : contracts) {
+
+ // Resolve the interface contract
+ InterfaceContract interfaceContract = contract.getInterfaceContract();
+ if (interfaceContract != null) {
+ extensionProcessor.resolve(interfaceContract, resolver, context);
+ }
+ }
+ }
+
+ /**
+ * Read a property value into a DOM document.
+ * @param element
+ * @param type
+ * @param reader
+ * @param context TODO
+ * @return
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ * @throws ParserConfigurationException
+ */
+ protected Document readPropertyValue(QName element, QName type, boolean isMany, XMLStreamReader reader, ProcessorContext context) throws XMLStreamException,
+ ContributionReadException {
+ Document document;
+ try {
+ if (documentBuilderFactory == null) {
+ documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ }
+ document = documentBuilderFactory.newDocumentBuilder().newDocument();
+ } catch (ParserConfigurationException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(context.getMonitor(), "ContributionReadException", documentBuilderFactory, ce);
+ throw ce;
+ }
+
+ // Collect the property values as <value> elements under the <property>
+ Element root = document.createElementNS(SCA11_NS, "sca:" + PROPERTY);
+ String nameAttr = getString(reader, NAME);
+ if (nameAttr != null) {
+ root.setAttributeNS(SCA11_NS, "sca:" + NAME, nameAttr);
+ }
+ declareNamespace(root, "sca", SCA11_NS);
+ if (type != null) {
+ org.w3c.dom.Attr xsi = document.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi");
+ xsi.setValue(W3C_XML_SCHEMA_INSTANCE_NS_URI);
+ root.setAttributeNodeNS(xsi);
+
+ String prefix = type.getPrefix();
+ if (prefix == null || prefix.length() == 0) {
+ prefix = "ns";
+ }
+
+ declareNamespace(root, prefix, type.getNamespaceURI());
+
+ org.w3c.dom.Attr xsiType = document.createAttributeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type");
+ xsiType.setValue(prefix + ":" + type.getLocalPart());
+ root.setAttributeNodeNS(xsiType);
+ }
+ document.appendChild(root);
+
+ // Start to parse the property
+ QName name = reader.getName(); // Should be sca:property
+
+ // SCA 1.1 supports the @value for simple types
+ String valueAttr = getString(reader, VALUE);
+ if (valueAttr != null) {
+ Element valueElement = document.createElementNS(SCA11_NS, VALUE);
+ root.appendChild(valueElement);
+ valueElement.setTextContent(valueAttr);
+ }
+
+ boolean gotOneValue = false;
+ boolean isTextForProperty = true;
+ StringBuffer text = new StringBuffer();
+
+ int event = reader.getEventType();
+ while (true) {
+ switch (event) {
+ case START_ELEMENT:
+ name = reader.getName();
+ if (PROPERTY_QNAME.equals(name)) {
+ isTextForProperty = true;
+ break;
+ }
+ isTextForProperty = false;
+
+ // CONFORMANCE: ASM50033
+ // A property <value/> subelement MUST NOT be used when the @value attribute is used
+ // to specify the value for that property.
+ if (valueAttr != null) {
+ error(context.getMonitor(), "ASM50033: value attribute exists for the property element", name, name);
+ }
+ // Read <value>
+ if (VALUE_QNAME.equals(name)) {
+ if (gotOneValue && !isMany) {
+ // TODO: TUSCANY-3231 this should be error not warning but that breaks OASIS tests
+ // [rfeng] We should not issue warning here as the component property many inherit @many from the componentType property
+ // warning(context.getMonitor(), "ASM50032: multiple value elements for single-valued property", name, name);
+ }
+ loadElement(reader, root);
+ gotOneValue = true;
+ } else {
+ // Global elements
+ loadElement(reader, root);
+ }
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ case XMLStreamConstants.CDATA:
+ if (isTextForProperty) {
+ text.append(reader.getText());
+ }
+ break;
+ case END_ELEMENT:
+ name = reader.getName();
+ if (PROPERTY_QNAME.equals(name)) {
+
+ if (root.getChildNodes().getLength() == 0) {
+ // Add an text as an <value>
+ if (isTextForProperty){
+ if (text.length() > 0) {
+ Element valueElement = document.createElementNS(SCA11_NS, VALUE);
+ root.appendChild(valueElement);
+ valueElement.setTextContent(text.toString());
+ }
+ }
+ }
+ return document;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ break;
+ }
+ }
+ return document;
+ }
+
+ /**
+ * Create a DOM element
+ * @param document
+ * @param name
+ * @return
+ */
+ private Element createElement(Document document, QName name) {
+ String prefix = name.getPrefix();
+ String qname =
+ (prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name.getLocalPart();
+ return document.createElementNS(name.getNamespaceURI(), qname);
+ }
+
+ /**
+ * Declare a namespace.
+ * @param element
+ * @param prefix
+ * @param ns
+ */
+ private void declareNamespace(Element element, String prefix, String ns) {
+ if (ns == null) {
+ ns = "";
+ }
+ if (prefix == null) {
+ prefix = "";
+ }
+ String qname = null;
+ if ("".equals(prefix)) {
+ qname = "xmlns";
+ } else {
+ qname = "xmlns:" + prefix;
+ }
+ Node node = element;
+ boolean declared = false;
+ while (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
+ NamedNodeMap attrs = node.getAttributes();
+ if (attrs == null) {
+ break;
+ }
+ Node attr = attrs.getNamedItem(qname);
+ if (attr != null) {
+ declared = ns.equals(attr.getNodeValue());
+ break;
+ }
+ node = node.getParentNode();
+ }
+ if (!declared) {
+ org.w3c.dom.Attr attr = element.getOwnerDocument().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, qname);
+ attr.setValue(ns);
+ element.setAttributeNodeNS(attr);
+ }
+ }
+
+ /**
+ * Load a property value specification from an StAX stream into a DOM
+ * Document. Only elements, text and attributes are processed; all comments
+ * and other whitespace are ignored.
+ *
+ * @param reader the stream to read from
+ * @param root the DOM node to load
+ * @throws javax.xml.stream.XMLStreamException
+ */
+ private void loadElement(XMLStreamReader reader, Element root) throws XMLStreamException {
+ Document document = root.getOwnerDocument();
+ Node current = root;
+ while (true) {
+ switch (reader.getEventType()) {
+ case START_ELEMENT:
+ QName name = reader.getName();
+ Element child = createElement(document, name);
+
+ // push the new element and make it the current one
+ current.appendChild(child);
+ current = child;
+
+ int count = reader.getNamespaceCount();
+ for (int i = 0; i < count; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String ns = reader.getNamespaceURI(i);
+ declareNamespace(child, prefix, ns);
+ }
+
+ if (!"".equals(name.getNamespaceURI())) {
+ declareNamespace(child, name.getPrefix(), name.getNamespaceURI());
+ }
+
+ // add the attributes for this element
+ count = reader.getAttributeCount();
+ for (int i = 0; i < count; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+ if (prefix != null && prefix.length() != 0) {
+ qname = prefix + ":" + qname;
+ }
+ child.setAttributeNS(ns, qname, value);
+ if (ns != null) {
+ declareNamespace(child, prefix, ns);
+ }
+ }
+
+ break;
+ case CDATA:
+ current.appendChild(document.createCDATASection(reader.getText()));
+ break;
+ case CHARACTERS:
+ current.appendChild(document.createTextNode(reader.getText()));
+ break;
+ case COMMENT:
+ current.appendChild(document.createComment(reader.getText()));
+ break;
+ case END_ELEMENT:
+ // pop the element off the stack
+ current = current.getParentNode();
+ // if we are back at the root then we are done
+ if (current == root) {
+ return;
+ }
+
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ return;
+ }
+ }
+ }
+
+ /**
+ * Write the value of a property
+ * @param document
+ * @param element
+ * @param type
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void writePropertyValue(Object propertyValue, QName element, QName type, XMLStreamWriter writer)
+ throws XMLStreamException {
+
+ if (propertyValue instanceof Document) {
+ Document document = (Document)propertyValue;
+ NodeList nodeList = document.getDocumentElement().getChildNodes();
+
+ for (int item = 0; item < nodeList.getLength(); ++item) {
+ Node node = nodeList.item(item);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(node));
+
+ while (reader.hasNext()) {
+ switch (reader.next()) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ writer.writeStartElement(name.getPrefix(), name.getLocalPart(), name.getNamespaceURI());
+
+ int namespaces = reader.getNamespaceCount();
+ for (int i = 0; i < namespaces; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String ns = reader.getNamespaceURI(i);
+ writer.writeNamespace(prefix, ns);
+ }
+
+ if (!"".equals(name.getNamespaceURI())) {
+ writer.writeNamespace(name.getPrefix(), name.getNamespaceURI());
+ }
+
+ // add the attributes for this element
+ namespaces = reader.getAttributeCount();
+ for (int i = 0; i < namespaces; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+
+ writer.writeAttribute(prefix, ns, qname, value);
+ }
+
+ break;
+ case XMLStreamConstants.CDATA:
+ writer.writeCData(reader.getText());
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ writer.writeCharacters(reader.getText());
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ writer.writeEndElement();
+ break;
+ }
+ }
+ } else {
+ writer.writeCharacters(node.getTextContent());
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param reader
+ * @param elementName
+ * @param extensionAttributeProcessor
+ * @param context TODO
+ * @param estensibleElement
+ * @throws ContributionReadException
+ * @throws XMLStreamException
+ */
+ protected void readExtendedAttributes(XMLStreamReader reader,
+ QName elementName,
+ Extensible extensible,
+ StAXAttributeProcessor extensionAttributeProcessor,
+ ProcessorContext context) throws ContributionReadException,
+ XMLStreamException {
+ super.readExtendedAttributes(reader, extensible, extensionAttributeProcessor, assemblyFactory, context);
+ }
+
+
+ /*protected void validatePolicySets(PolicySubject policySetAttachPoint)
+ throws ContributionResolveException {
+ validatePolicySets(policySetAttachPoint, policySetAttachPoint.getApplicablePolicySets());
+ }
+
+
+ protected void validatePolicySets(PolicySubject policySetAttachPoint,
+ List<PolicySet> applicablePolicySets) throws ContributionResolveException {
+ //Since the applicablePolicySets in a policySetAttachPoint will already have the
+ //list of policysets that might ever be applicable to this attachPoint, just check
+ //if the defined policysets feature in the list of applicable policysets
+ ExtensionType attachPointType = policySetAttachPoint.getType();
+ for ( PolicySet definedPolicySet : policySetAttachPoint.getPolicySets() ) {
+ if ( !definedPolicySet.isUnresolved() ) {
+ if ( !applicablePolicySets.contains(definedPolicySet)) {
+ throw new ContributionResolveException("Policy Set '" + definedPolicySet.getName()
+ + "' does not apply to binding type "
+ + attachPointType.getName());
+ }
+ } else {
+ throw new ContributionResolveException("Policy Set '" + definedPolicySet.getName()
+ + "' is not defined in this domain ");
+
+
+ }
+ }
+ }*/
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java
new file mode 100644
index 0000000000..b5fe005812
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A componentType processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<ComponentType> {
+ private ValidatingXMLInputFactory inputFactory;
+
+ /**
+ * Constructs a new componentType processor.
+ * @param modelFactories
+ * @param staxProcessor
+ */
+ public ComponentTypeDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor) {
+ super(modelFactories, staxProcessor);
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ }
+
+ public ComponentType read(URL contributionURL, URI uri, URL url, ProcessorContext context) throws ContributionReadException {
+ InputStream urlStream = null;
+ Monitor monitor = context.getMonitor();
+ try {
+
+ // Create a stream reader
+ urlStream = IOHelper.openStream(url);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
+ ValidatingXMLInputFactory.setMonitor(reader, monitor);
+ reader.nextTag();
+
+ // Reader the componentType model
+ ComponentType componentType = (ComponentType)extensionProcessor.read(reader, context);
+ if (componentType != null) {
+ componentType.setURI(uri.toString());
+ }
+
+ // For debugging purposes, write it back to XML
+// if (componentType != null) {
+// try {
+// ByteArrayOutputStream bos = new ByteArrayOutputStream();
+// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+// extensionProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos));
+// Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray()));
+// OutputFormat format = new OutputFormat();
+// format.setIndenting(true);
+// format.setIndent(2);
+// XMLSerializer serializer = new XMLSerializer(System.out, format);
+// serializer.serialize(document);
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
+
+ return componentType;
+
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", inputFactory, ce);
+ throw ce;
+ } catch (IOException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", inputFactory, ce);
+ throw ce;
+ } finally {
+ try {
+ if (urlStream != null) {
+ urlStream.close();
+ urlStream = null;
+ }
+ } catch (IOException ioe) {
+ //ignore
+ }
+ }
+ }
+
+ public void resolve(ComponentType componentType, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ extensionProcessor.resolve(componentType, resolver, context);
+ }
+
+ public String getArtifactType() {
+ return ".componentType";
+ }
+
+ public Class<ComponentType> getModelType() {
+ return ComponentType.class;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java
new file mode 100644
index 0000000000..9a4a0dc035
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * A Model Resolver for ComponentType models.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeModelResolver implements ModelResolver {
+ private Contribution contribution;
+ private Map<String, ComponentType> map = new HashMap<String, ComponentType>();
+
+ public ComponentTypeModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ ComponentType componentType = (ComponentType)resolved;
+ map.put(componentType.getURI(), componentType);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(((ComponentType)resolved).getURI());
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+
+ //get componentType artifact URI
+ String uri = ((ComponentType)unresolved).getURI();
+ if (uri == null) {
+ return (T)unresolved;
+ }
+
+ //lookup the componentType
+ ComponentType resolved = (ComponentType) map.get(uri);
+ if (resolved != null) {
+ return modelClass.cast(resolved);
+ }
+
+ //If not found, delegate the resolution to the imports (in this case based on the java imports)
+ //compute the package name from the componentType URI
+ if (unresolved instanceof ComponentType) {
+ //FIXME The core assembly model now depends on java imports to
+ // resolve componentTypes of all kinds, this is not right at all!!!
+ int s = uri.lastIndexOf('/');
+ if (s != -1) {
+ String packageName = uri.substring(0, uri.lastIndexOf("/"));
+ for (Import import_ : this.contribution.getImports()) {
+ if (import_ instanceof JavaImport) {
+ JavaImport javaImport = (JavaImport)import_;
+ //check the import location against the computed package name from the componentType URI
+ if (javaImport.getPackage().equals(packageName)) {
+ // Delegate the resolution to the import resolver
+ resolved = javaImport.getModelResolver().resolveModel(ComponentType.class, (ComponentType)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return (T)unresolved;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
new file mode 100644
index 0000000000..b402b6e3a3
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
@@ -0,0 +1,381 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.CALLBACK;
+import static org.apache.tuscany.sca.assembly.xml.Constants.CALLBACK_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPONENT_TYPE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPONENT_TYPE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.IMPLEMENTATION;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MANY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MUST_SUPPLY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.NAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.OPERATION_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REFERENCE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REFERENCE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SERVICE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SERVICE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TYPE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.EXTENSION;
+import static org.apache.tuscany.sca.assembly.xml.Constants.EXTENSION_QNAME;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.w3c.dom.Document;
+
+/**
+ * A componentType processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<ComponentType> {
+
+ /**
+ * Constructs a new componentType processor.
+ *
+ * @param modelFactories
+ * @param extensionProcessor
+ * @param extensionAttributeProcessor
+ * @param monitor
+ */
+ public ComponentTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+ super(modelFactories, extensionProcessor);
+ }
+
+ public ComponentType read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
+ ComponentType componentType = null;
+ Service service = null;
+ Reference reference = null;
+ Contract contract = null;
+ Property property = null;
+ Callback callback = null;
+ QName name = null;
+
+ try {
+ // Read the componentType document
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ name = reader.getName();
+
+ if (Constants.COMPONENT_TYPE_QNAME.equals(name)) {
+
+ // Read a <componentType>
+ componentType = assemblyFactory.createComponentType();
+
+ } else if (Constants.SERVICE_QNAME.equals(name)) {
+
+ // Read a <service>
+ service = assemblyFactory.createService();
+ contract = service;
+ service.setName(getString(reader, Constants.NAME));
+ componentType.getServices().add(service);
+ policyProcessor.readPolicies(service, reader);
+
+ } else if (Constants.REFERENCE_QNAME.equals(name)) {
+
+ // Read a <reference>
+ reference = assemblyFactory.createReference();
+ contract = reference;
+ reference.setName(getString(reader, Constants.NAME));
+ reference.setWiredByImpl(getBoolean(reader, Constants.WIRED_BY_IMPL));
+ readMultiplicity(reference, reader);
+ readTargets(reference, reader);
+ componentType.getReferences().add(reference);
+ policyProcessor.readPolicies(reference, reader);
+
+ } else if (Constants.PROPERTY_QNAME.equals(name)) {
+
+ // Read a <property>
+ property = assemblyFactory.createProperty();
+ readAbstractProperty(property, reader, context);
+ policyProcessor.readPolicies(property, reader);
+
+ // Read the property value
+ Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), property.isMany(), reader, context);
+ property.setValue(value);
+
+ componentType.getProperties().add(property);
+
+ } else if (Constants.IMPLEMENTATION_QNAME.equals(name)) {
+
+ // Read an <implementation> element
+ policyProcessor.readPolicies(componentType, reader);
+
+ } else if (Constants.CALLBACK_QNAME.equals(name)) {
+
+ // Read a <callback>
+ callback = assemblyFactory.createCallback();
+ contract.setCallback(callback);
+ policyProcessor.readPolicies(callback, reader);
+
+ } else if (OPERATION_QNAME.equals(name)) {
+
+ // Read an <operation>
+ Operation operation = new OperationImpl();
+ operation.setName(getString(reader, NAME));
+ operation.setUnresolved(true);
+ if (callback != null) {
+ policyProcessor.readPolicies(callback, operation, reader);
+ } else {
+ policyProcessor.readPolicies(contract, operation, reader);
+ }
+ } else if(EXTENSION_QNAME.equals(name)) {
+ // Handle <extension>
+ //ignore element as this is a wrapper for extensibility
+ break;
+ } else {
+
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof InterfaceContract) {
+
+ // <service><interface> and <reference><interface>
+ contract.setInterfaceContract((InterfaceContract)extension);
+
+ } else if (extension instanceof Binding) {
+
+ // <service><binding> and <reference><binding>
+ if (callback != null) {
+ callback.getBindings().add((Binding)extension);
+ } else {
+ contract.getBindings().add((Binding)extension);
+ }
+ } else {
+
+ // Add the extension element to the current element
+ if (callback != null) {
+ callback.getExtensions().add(extension);
+ } else if (contract != null) {
+ contract.getExtensions().add(extension);
+ } else if (property != null) {
+ property.getExtensions().add(extension);
+ } else {
+ if (componentType instanceof Extensible) {
+ ((Extensible)componentType).getExtensions().add(extension);
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case END_ELEMENT:
+ name = reader.getName();
+
+ // Clear current state when reading reaching end element
+ if (SERVICE_QNAME.equals(name)) {
+ service = null;
+ contract = null;
+ } else if (REFERENCE_QNAME.equals(name)) {
+ reference = null;
+ contract = null;
+ } else if (PROPERTY_QNAME.equals(name)) {
+ property = null;
+ } else if (CALLBACK_QNAME.equals(name)) {
+ callback = null;
+ }
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ }
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error(context.getMonitor(), "XMLStreamException", reader, ex);
+ }
+
+ return componentType;
+ }
+
+ public void write(ComponentType componentType, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write <componentType> element
+ writeStartDocument(writer, COMPONENT_TYPE);
+
+ // Write <service> elements
+ for (Service service : componentType.getServices()) {
+ writeStart(writer, SERVICE, new XAttr(NAME, service.getName()),
+ policyProcessor.writePolicies(service));
+
+ if (service.getInterfaceContract() != null) {
+ extensionProcessor.write(service.getInterfaceContract(), writer, context);
+ }
+
+ for (Binding binding: service.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ if (service.getCallback() != null) {
+ Callback callback = service.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ for (Binding binding: callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+ for (Object extension: callback.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ this.writeExtendedElements(writer, service, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <reference> elements
+ for (Reference reference : componentType.getReferences()) {
+
+ writeStart(writer, REFERENCE,
+ new XAttr(NAME, reference.getName()),
+ writeMultiplicity(reference),
+ writeTargets(reference),
+ policyProcessor.writePolicies(reference));
+
+ extensionProcessor.write(reference.getInterfaceContract(), writer, context);
+
+ for (Binding binding: reference.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK,
+ policyProcessor.writePolicies(callback));
+
+ for (Binding binding: callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+ for (Object extension: callback.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ this.writeExtendedElements(writer, reference, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <property> elements
+ for (Property property : componentType.getProperties()) {
+ writeStart(writer,
+ PROPERTY,
+ new XAttr(NAME, property.getName()),
+ new XAttr(MUST_SUPPLY, property.isMustSupply()),
+ new XAttr(MANY, property.isMany()),
+ new XAttr(TYPE, property.getXSDType()),
+ new XAttr(ELEMENT, property.getXSDElement()),
+ policyProcessor.writePolicies(property));
+
+ // Write property value
+ writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : property.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extension elements
+ if (componentType instanceof Extensible) {
+ for (Object extension: ((Extensible)componentType).getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+ }
+
+ // Write <implementation> elements if the componentType has
+ // any intents or policySets
+ boolean writeImplementation = false;
+ if (componentType instanceof PolicySubject) {
+ if (!((PolicySubject)componentType).getRequiredIntents().isEmpty()) {
+ writeImplementation = true;
+ }
+ }
+ if (componentType instanceof PolicySubject) {
+ if (!((PolicySubject)componentType).getPolicySets().isEmpty()) {
+ writeImplementation = true;
+ }
+ }
+ if (writeImplementation) {
+ writeStart(writer, IMPLEMENTATION,
+ policyProcessor.writePolicies(componentType));
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(ComponentType componentType, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // Resolve component type services and references
+ resolveContracts(componentType.getServices(), resolver, context);
+ resolveContracts(componentType.getReferences(), resolver, context);
+ }
+
+ public QName getArtifactType() {
+ return COMPONENT_TYPE_QNAME;
+ }
+
+ public Class<ComponentType> getModelType() {
+ return ComponentType.class;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
new file mode 100644
index 0000000000..5ba42a0dec
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.xml.sax.SAXException;
+
+/**
+ * A composite processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<Composite>,
+ XMLStreamConstants {
+ private ValidatingXMLInputFactory inputFactory;
+
+
+ /**
+ * Constructs a composite document processor
+ * @param modelFactories
+ * @param staxProcessor
+ * @param monitor
+ */
+ public CompositeDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<?> staxProcessor) {
+ super(modelFactories, staxProcessor);
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ }
+
+ /**
+ * Reads the contents of a Composite document and returns a Composite object
+ * @param contributionURL - the URL of the contribution containing the Composite - can be null
+ * @param uri - the URI of the composite document
+ * @param url - the URL of the composite document
+ * @return a Composite object built from the supplied Composite document
+ */
+ public Composite read(URL contributionURL, URI uri, URL url, ProcessorContext context) throws ContributionReadException {
+ if( uri == null || url == null ) {
+ throw new ContributionReadException("Request to read composite with uri or url NULL");
+ } // end if
+ InputStream scdlStream = null;
+
+ try {
+ scdlStream = IOHelper.openStream(url);
+ } catch (IOException e) {
+ ContributionReadException ce = new ContributionReadException("Exception reading " + uri, e);
+ error(context.getMonitor(), "ContributionReadException", url, ce);
+ throw ce;
+ }
+ return read(uri, url, scdlStream, context);
+ }
+
+ public Composite read(URI uri, URL url, InputStream scdlStream, ProcessorContext context) throws ContributionReadException {
+ try {
+
+ Composite composite = null;
+ Monitor monitor = context.getMonitor();
+ // Tag the monitor with the name of the composite artifact
+ if( monitor != null ) {
+ monitor.setArtifactName(uri.toString());
+ } //end if
+
+ // Set up a StreamSource for the composite file, since this has an associated URL that
+ // can be used by the parser to find references to other files such as DTDs
+ StreamSource scdlSource = new StreamSource( scdlStream, url.toString() );
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(scdlSource);
+
+ // set the monitor on the input factory as the standard XMLInputFactory
+ // methods used for creating readers don't allow for the context to
+ // be passed in
+ ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor());
+
+ // Read the header (i.e. text before the <composite> element, if any
+ readCompositeFileHeader( reader );
+
+ // Read the composite model
+ composite = (Composite)extensionProcessor.read(reader, context);
+ if (composite != null) {
+ composite.setURI(uri.toString());
+ }
+
+ return composite;
+
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException("Exception reading " + uri, e);
+ error(context.getMonitor(), "ContributionReadException", inputFactory, ce);
+ throw ce;
+ } finally {
+ try {
+ if (scdlStream != null) {
+ scdlStream.close();
+ scdlStream = null;
+ }
+ } catch (IOException ioe) {
+ //ignore
+ }
+ }
+ }
+
+ /**
+ * Reads the header portion of a composite file - i.e. the section of the file before the
+ * <composite> start tag
+ * In particular handle any DTD declarations
+ * @param reader - an XMLStreamReader which is reading the composite file
+ * @throws XMLStreamException
+ */
+ private void readCompositeFileHeader( XMLStreamReader reader ) throws XMLStreamException {
+
+ while (true) {
+ int event = reader.next();
+
+ if ( event == CHARACTERS
+ || event == CDATA
+ || event == SPACE
+ || event == PROCESSING_INSTRUCTION
+ || event == COMMENT
+ || event == DTD
+ || event == ENTITY_DECLARATION ) {
+ continue;
+ } // end if
+
+ // The first start (or end) element terminates the header scan
+ if (event == START_ELEMENT || event == END_ELEMENT) {
+ return;
+ } // end if
+ } // end while
+ } // end method readCompositeFileHeader
+
+ public void resolve(Composite composite, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ try {
+ if (composite != null)
+ extensionProcessor.resolve(composite, resolver, context);
+ } catch (Throwable e ) {
+ // Add information about which composite was being processed when the exception occurred
+ String newMessage = "Processing composite " + composite.getName() + ": " + e.getMessage();
+ throw new ContributionResolveException( newMessage, e );
+ } // end try
+ }
+
+ public String getArtifactType() {
+ return ".composite";
+ }
+
+ public Class<Composite> getModelType() {
+ return Composite.class;
+ }
+
+} // end class
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java
new file mode 100644
index 0000000000..7a396fe100
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A Model Resolver for Composite models.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeModelResolver implements ModelResolver {
+
+ private Contribution contribution;
+ private Map<QName, Composite> map = new HashMap<QName, Composite>();
+
+ public CompositeModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ Composite composite = (Composite)resolved;
+ Composite old = map.put(composite.getName(), composite);
+ if (old != null) {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.RESOURCE_BUNDLE,
+ "DuplicateCompositeName",
+ composite.getName().toString(),
+ contribution.getLocation());
+ }
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(((Composite)resolved).getName());
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+
+ // Lookup a definition for the given namespace
+ QName qname = ((Composite)unresolved).getName();
+ Composite resolved = null;
+
+ // Delegate the resolution to the imports
+ for (Import import_ : this.contribution.getImports()) {
+ if (import_ instanceof NamespaceImport) {
+ NamespaceImport namespaceImport = (NamespaceImport)import_;
+ if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) {
+
+ // Delegate the resolution to the import resolver
+ resolved = namespaceImport.getModelResolver().resolveModel(Composite.class, (Composite)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+ }
+
+ // No definition found, search within the current contribution
+ resolved = (Composite) map.get(qname);
+ if (resolved != null) {
+ return modelClass.cast(resolved);
+ }
+
+ return (T)unresolved;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
new file mode 100644
index 0000000000..22879c2beb
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
@@ -0,0 +1,1134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.AUTOWIRE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.CALLBACK;
+import static org.apache.tuscany.sca.assembly.xml.Constants.CALLBACK_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPONENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPONENT_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPOSITE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPOSITE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.EXTENSION_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.FILE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.IMPLEMENTATION_COMPOSITE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.IMPLEMENTATION_COMPOSITE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.INCLUDE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.INCLUDE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.INTENTS;
+import static org.apache.tuscany.sca.assembly.xml.Constants.LOCAL;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MANY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MUST_SUPPLY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.NAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.NONOVERRIDABLE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.POLICY_SET_ATTACHMENT_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROMOTE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REFERENCE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REFERENCE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REPLACE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REQUIRES_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SCA11_NS;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SERVICE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SERVICE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SOURCE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TARGET;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TARGET_NAMESPACE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TYPE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.URI;
+import static org.apache.tuscany.sca.assembly.xml.Constants.WIRE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.WIRED_BY_IMPL;
+import static org.apache.tuscany.sca.assembly.xml.Constants.WIRE_QNAME;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Wire;
+import org.apache.tuscany.sca.common.xml.xpath.XPathHelper;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ResolverExtension;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.w3c.dom.Document;
+
+/**
+ * A composite processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<Composite> {
+ private XPathHelper xpathHelper;
+ private PolicyFactory intentAttachPointTypeFactory;
+ private StAXAttributeProcessor<Object> extensionAttributeProcessor;
+ private ContributionFactory contributionFactory;
+ private XSDFactory xsdFactory;
+
+ /**
+ * Construct a new composite processor
+ *
+ * @param extensionPoints
+ * @param extensionProcessor
+ */
+ public CompositeProcessor(ExtensionPointRegistry extensionPoints,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+
+ this(modelFactories(extensionPoints), extensionProcessor, extensionAttributeProcessor);
+
+ this.xpathHelper = XPathHelper.getInstance(extensionPoints);
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
+
+ this.xsdFactory = extensionPoints.getExtensionPoint(XSDFactory.class);
+ }
+
+ /**
+ * Constructs a new composite processor
+ *
+ * @param modelFactories
+ * @param extensionProcessor
+ * @param monitor
+ */
+ private CompositeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+
+ super(modelFactories, extensionProcessor);
+ this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
+
+ this.xsdFactory = modelFactories.getFactory(XSDFactory.class);
+ }
+
+ public Composite read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
+ Composite composite = null;
+ Composite include = null;
+ Component component = null;
+ Property property = null;
+ ComponentService componentService = null;
+ ComponentReference componentReference = null;
+ ComponentProperty componentProperty = null;
+ CompositeService compositeService = null;
+ CompositeReference compositeReference = null;
+ Contract contract = null;
+ Wire wire = null;
+ Callback callback = null;
+ QName name = null;
+ Monitor monitor = context.getMonitor();
+ try {
+ // Read the composite document
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ name = reader.getName();
+
+ if (COMPOSITE_QNAME.equals(name)) {
+
+ // Read a <composite>
+ composite = assemblyFactory.createComposite();
+ composite.setSpecVersion(Constants.SCA11_NS);
+
+ composite.setName(new QName(getURIString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
+
+ if (!isSet(reader, TARGET_NAMESPACE)) {
+ // spec says that a composite must have a namespace
+ warning(monitor, "NoCompositeNamespace", composite, composite.getName().toString());
+ }
+
+ if (isSet(reader, AUTOWIRE)) {
+ composite.setAutowire(getBoolean(reader, AUTOWIRE));
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, composite, extensionAttributeProcessor, context);
+
+ composite.setLocal(getBoolean(reader, LOCAL));
+ policyProcessor.readPolicies(composite, reader);
+
+ } else if (INCLUDE_QNAME.equals(name)) {
+
+ // Read an <include>
+ include = assemblyFactory.createComposite();
+ include.setName(getQName(reader, NAME));
+ include.setURI(getURIString(reader, URI));
+ include.setUnresolved(true);
+ composite.getIncludes().add(include);
+
+ } else if (SERVICE_QNAME.equals(name)) {
+ if (component != null) {
+
+ // Read a <component><service>
+ componentService = assemblyFactory.createComponentService();
+ contract = componentService;
+ componentService.setName(getString(reader, NAME));
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, componentService, extensionAttributeProcessor, context);
+
+ component.getServices().add(componentService);
+ policyProcessor.readPolicies(contract, reader);
+ } else {
+
+ // Read a <composite><service>
+ compositeService = assemblyFactory.createCompositeService();
+ contract = compositeService;
+ compositeService.setName(getString(reader, NAME));
+
+ String promoted = getURIString(reader, PROMOTE);
+ if (promoted != null) {
+ String promotedComponentName;
+ String promotedServiceName;
+ int s = promoted.indexOf('/');
+ if (s == -1) {
+ promotedComponentName = promoted;
+ promotedServiceName = null;
+ } else {
+ promotedComponentName = promoted.substring(0, s);
+ promotedServiceName = promoted.substring(s + 1);
+ }
+
+ Component promotedComponent = assemblyFactory.createComponent();
+ promotedComponent.setUnresolved(true);
+ promotedComponent.setName(promotedComponentName);
+ compositeService.setPromotedComponent(promotedComponent);
+
+ ComponentService promotedService = assemblyFactory.createComponentService();
+ promotedService.setUnresolved(true);
+ promotedService.setName(promotedServiceName);
+ compositeService.setPromotedService(promotedService);
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, compositeService, extensionAttributeProcessor, context);
+
+ composite.getServices().add(compositeService);
+ policyProcessor.readPolicies(contract, reader);
+ }
+
+ // set the parent model so that binding processing can
+ // detect it they're being read as part of a reference
+ // or a service
+ context.setParentModel(contract);
+
+ } else if (REFERENCE_QNAME.equals(name)) {
+ if (component != null) {
+ // Read a <component><reference>
+ componentReference = assemblyFactory.createComponentReference();
+ contract = componentReference;
+ componentReference.setName(getString(reader, NAME));
+ readMultiplicity(componentReference, reader);
+ if (isSet(reader, AUTOWIRE)) {
+ componentReference.setAutowire(getBoolean(reader, AUTOWIRE));
+ }
+ // Read @nonOverridable
+ String nonOverridable = reader.getAttributeValue(null, NONOVERRIDABLE);
+ if (nonOverridable != null) {
+ componentReference.setNonOverridable(Boolean.parseBoolean(nonOverridable));
+ }
+ readTargets(componentReference, reader);
+ componentReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader,
+ name,
+ componentReference,
+ extensionAttributeProcessor, context);
+
+ component.getReferences().add(componentReference);
+ policyProcessor.readPolicies(contract, reader);
+ } else {
+ // Read a <composite><reference>
+ compositeReference = assemblyFactory.createCompositeReference();
+ contract = compositeReference;
+ compositeReference.setName(getString(reader, NAME));
+ readMultiplicity(compositeReference, reader);
+ readTargets(compositeReference, reader);
+ String promote = getString(reader, Constants.PROMOTE);
+ if (promote != null) {
+ for (StringTokenizer tokens = new StringTokenizer(promote); tokens.hasMoreTokens();) {
+ String refName = tokens.nextToken();
+ Component promotedComponent = assemblyFactory.createComponent();
+ int index = refName.indexOf('/');
+ if (index == -1) {
+ error(monitor, "Invalid reference name", compositeReference, refName);
+ }
+ String promotedComponentName = refName.substring(0, index);
+ promotedComponent.setName(promotedComponentName);
+ promotedComponent.setUnresolved(true);
+ compositeReference.getPromotedComponents().add(promotedComponent);
+ ComponentReference promotedReference =
+ assemblyFactory.createComponentReference();
+ promotedReference.setUnresolved(true);
+ promotedReference.setName(refName);
+ compositeReference.getPromotedReferences().add(promotedReference);
+ }
+ }
+ compositeReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader,
+ name,
+ compositeReference,
+ extensionAttributeProcessor, context);
+
+ composite.getReferences().add(compositeReference);
+ policyProcessor.readPolicies(contract, reader);
+ }
+
+ // set the parent model so that binding processing can
+ // detect it they're being read as part of a reference
+ // or a service
+ context.setParentModel(contract);
+
+ } else if (PROPERTY_QNAME.equals(name)) {
+ if (component != null) {
+
+ // Read a <component><property>
+ componentProperty = assemblyFactory.createComponentProperty();
+ property = componentProperty;
+ String source = getURIString(reader, SOURCE);
+ if (source != null) {
+ source = source.trim();
+ }
+ componentProperty.setSource(source);
+ if (source != null) {
+ // $<name>/...
+ if (source.charAt(0) == '$') {
+ int index = source.indexOf('/');
+ if (index == -1) {
+ // Tolerating $prop
+ source = "";
+ } else {
+ source = source.substring(index + 1);
+ }
+ if ("".equals(source)) {
+ source = ".";
+ }
+ }
+
+ try {
+ componentProperty.setSourceXPathExpression(xpathHelper.compile(reader
+ .getNamespaceContext(), source));
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", source, ce);
+ //throw ce;
+ }
+ }
+ componentProperty.setFile(getURIString(reader, FILE));
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader,
+ name,
+ componentProperty,
+ extensionAttributeProcessor, context);
+
+ policyProcessor.readPolicies(property, reader);
+ readAbstractProperty(componentProperty, reader, context);
+
+ // Read the property value
+ Document value =
+ readPropertyValue(property.getXSDElement(), property.getXSDType(), property
+ .isMany(), reader, context);
+ property.setValue(value);
+
+ component.getProperties().add(componentProperty);
+ } else {
+
+ // Read a <composite><property>
+ property = assemblyFactory.createProperty();
+ policyProcessor.readPolicies(property, reader);
+ readAbstractProperty(property, reader, context);
+
+ // Read the property value
+ Document value =
+ readPropertyValue(property.getXSDElement(), property.getXSDType(), property
+ .isMany(), reader, context);
+ property.setValue(value);
+
+ composite.getProperties().add(property);
+ }
+
+ // TUSCANY-1949
+ // If the property doesn't have a value, the END_ELEMENT event is read by the readPropertyValue
+ if (reader.getEventType() == END_ELEMENT && PROPERTY_QNAME.equals(reader.getName())) {
+ property = null;
+ componentProperty = null;
+ }
+
+ } else if (COMPONENT_QNAME.equals(name)) {
+
+ // Read a <component>
+ component = assemblyFactory.createComponent();
+ component.setName(getString(reader, NAME));
+ if (isSet(reader, AUTOWIRE)) {
+ component.setAutowire(getBoolean(reader, AUTOWIRE));
+ }
+ if (isSet(reader, URI)) {
+ component.setURI(getURIString(reader, URI));
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, component, extensionAttributeProcessor, context);
+
+ composite.getComponents().add(component);
+ policyProcessor.readPolicies(component, reader);
+
+ } else if (WIRE_QNAME.equals(name)) {
+
+ // Read a <wire>
+ wire = assemblyFactory.createWire();
+ ComponentReference source = assemblyFactory.createComponentReference();
+ source.setUnresolved(true);
+ source.setName(getURIString(reader, SOURCE));
+ wire.setSource(source);
+
+ ComponentService target = assemblyFactory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(getURIString(reader, TARGET));
+ wire.setTarget(target);
+
+ // Read @replace
+ String replace = reader.getAttributeValue(null, REPLACE);
+ if (replace != null) {
+ wire.setReplace(Boolean.parseBoolean(replace));
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, wire, extensionAttributeProcessor, context);
+
+ composite.getWires().add(wire);
+ policyProcessor.readPolicies(wire, reader);
+
+ } else if (CALLBACK_QNAME.equals(name)) {
+
+ // Read a <callback>
+ callback = assemblyFactory.createCallback();
+ contract.setCallback(callback);
+ callback.setParentContract(contract);
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, callback, extensionAttributeProcessor, context);
+
+ policyProcessor.readPolicies(callback, reader);
+
+ // set the parent model so that binding processing can
+ // detect it they're being read as part of a callback
+ context.setParentModel(callback);
+
+ } else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) {
+
+ // Read an implementation.composite
+ Composite implementation = assemblyFactory.createComposite();
+ implementation.setName(getQName(reader, NAME));
+ implementation.setUnresolved(true);
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, implementation, extensionAttributeProcessor, context);
+
+ component.setImplementation(implementation);
+ policyProcessor.readPolicies(implementation, reader);
+ } else if (REQUIRES_QNAME.equals(name)) {
+ List<QName> intents = getQNames(reader, INTENTS);
+ for (QName i : intents) {
+ Intent intent = policyFactory.createIntent();
+ intent.setName(i);
+ if (composite != null) {
+ composite.getRequiredIntents().add(intent);
+ } else if (component != null) {
+ component.getRequiredIntents().add(intent);
+ } else if (contract != null) {
+ contract.getRequiredIntents().add(intent);
+ } else if (callback != null) {
+ callback.getRequiredIntents().add(intent);
+ }
+ }
+ } else if (POLICY_SET_ATTACHMENT_QNAME.equals(name)) {
+ QName ps = getQName(reader, NAME);
+ if (ps != null) {
+ PolicySet policySet = policyFactory.createPolicySet();
+ policySet.setName(ps);
+ if (composite != null) {
+ composite.getPolicySets().add(policySet);
+ } else if (component != null) {
+ component.getPolicySets().add(policySet);
+ } else if (contract != null) {
+ contract.getPolicySets().add(policySet);
+ } else if (callback != null) {
+ callback.getPolicySets().add(policySet);
+ }
+ }
+ } else if(EXTENSION_QNAME.equals(name)) {
+ // Handle <extension>
+ //ignore element as this is a wrapper for extensibility
+ break;
+ } else {
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof InterfaceContract) {
+
+ // <service><interface> and
+ // <reference><interface>
+ if (contract != null) {
+ contract.setInterfaceContract((InterfaceContract)extension);
+ } else {
+ if (name.getNamespaceURI().equals(SCA11_NS)) {
+ error(monitor, "UnexpectedInterfaceElement", extension);
+ //throw new ContributionReadException("Unexpected <interface> element found. It should appear inside a <service> or <reference> element");
+ } else {
+ composite.getExtensions().add(extension);
+ }
+ }
+ } else if (extension instanceof Binding) {
+ if (extension instanceof PolicySubject) {
+ ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType();
+ bindingType.setType(name);
+ bindingType.setUnresolved(true);
+ ((PolicySubject)extension).setExtensionType(bindingType);
+ }
+ // <service><binding> and
+ // <reference><binding>
+ if (callback != null) {
+ callback.getBindings().add((Binding)extension);
+ } else {
+ if (contract != null) {
+ contract.getBindings().add((Binding)extension);
+ } else {
+ if (name.getNamespaceURI().equals(SCA11_NS)) {
+ error(monitor, "UnexpectedBindingElement", extension);
+ //throw new ContributionReadException("Unexpected <binding> element found. It should appear inside a <service> or <reference> element");
+ } else {
+ composite.getExtensions().add(extension);
+ }
+ }
+ }
+
+ } else if (extension instanceof Implementation) {
+ if (extension instanceof PolicySubject) {
+ ExtensionType implType =
+ intentAttachPointTypeFactory.createImplementationType();
+ implType.setType(name);
+ implType.setUnresolved(true);
+ ((PolicySubject)extension).setExtensionType(implType);
+ }
+ // <component><implementation>
+ if (component != null) {
+ component.setImplementation((Implementation)extension);
+ } else {
+ if (name.getNamespaceURI().equals(SCA11_NS)) {
+ error(monitor, "UnexpectedImplementationElement", extension);
+ //throw new ContributionReadException("Unexpected <implementation> element found. It should appear inside a <component> element");
+ } else {
+ composite.getExtensions().add(extension);
+ }
+ }
+ } else {
+
+ // Add the extension element to the current
+ // element
+ if (callback != null) {
+ callback.getExtensions().add(extension);
+ } else if (contract != null) {
+ contract.getExtensions().add(extension);
+ } else if (property != null) {
+ property.getExtensions().add(extension);
+ } else if (component != null) {
+ component.getExtensions().add(extension);
+ } else {
+ composite.getExtensions().add(extension);
+ }
+ }
+ }
+ }
+ break;
+
+ case XMLStreamConstants.CHARACTERS:
+ break;
+
+ case END_ELEMENT:
+ name = reader.getName();
+
+ // Clear current state when reading reaching end element
+ if (SERVICE_QNAME.equals(name)) {
+ componentService = null;
+ compositeService = null;
+ contract = null;
+ } else if (INCLUDE_QNAME.equals(name)) {
+ include = null;
+ } else if (REFERENCE_QNAME.equals(name)) {
+ componentReference = null;
+ compositeReference = null;
+ contract = null;
+ } else if (PROPERTY_QNAME.equals(name)) {
+ componentProperty = null;
+ property = null;
+ } else if (COMPONENT_QNAME.equals(name)) {
+ component = null;
+ } else if (WIRE_QNAME.equals(name)) {
+ wire = null;
+ } else if (CALLBACK_QNAME.equals(name)) {
+ callback = null;
+ }
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ } catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error(monitor, "XMLStreamException", reader, ex);
+ }
+
+ return composite;
+ }
+
+ public void write(Composite composite, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+
+ // Write <composite> element
+ writeStartDocument(writer,
+ COMPOSITE,
+ new XAttr(TARGET_NAMESPACE, composite.getName().getNamespaceURI()),
+ new XAttr(NAME, composite.getName().getLocalPart()),
+ new XAttr(LOCAL, composite.isLocal() ? Boolean.TRUE : null),
+ new XAttr(AUTOWIRE, composite.getAutowire()),
+ policyProcessor.writePolicies(composite));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, composite, extensionAttributeProcessor, context);
+
+ // Write <include> elements
+ for (Composite include : composite.getIncludes()) {
+ String uri = include.isUnresolved() ? include.getURI() : null;
+ writeStart(writer, INCLUDE, new XAttr(NAME, include.getName()), new XAttr(URI, uri));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, include, extensionAttributeProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <service> elements
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ Component promotedComponent = compositeService.getPromotedComponent();
+ ComponentService promotedService = compositeService.getPromotedService();
+ String promote;
+ if (promotedService != null) {
+ if (promotedService.getName() != null) {
+ promote = promotedComponent.getName() + '/' + promotedService.getName();
+ } else {
+ promote = promotedComponent.getName();
+ }
+ } else {
+ promote = null;
+ }
+ writeStart(writer,
+ SERVICE,
+ new XAttr(NAME, service.getName()),
+ new XAttr(PROMOTE, promote),
+ policyProcessor.writePolicies(service));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, service, extensionAttributeProcessor, context);
+
+ // Write service interface
+ extensionProcessor.write(service.getInterfaceContract(), writer, context);
+
+ // Write bindings
+ for (Binding binding : service.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write <callback> element
+ if (service.getCallback() != null) {
+ Callback callback = service.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor, context);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, service, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, service, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <component> elements
+ for (Component component : composite.getComponents()) {
+ writeStart(writer,
+ COMPONENT,
+ new XAttr(NAME, component.getName()),
+ new XAttr(URI, component.getURI()),
+ new XAttr(AUTOWIRE, component.getAutowire()),
+ policyProcessor.writePolicies(component));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, component, extensionAttributeProcessor, context);
+
+ // Write the component implementation
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ writeStart(writer, IMPLEMENTATION_COMPOSITE, new XAttr(NAME, ((Composite)implementation).getName()));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, (Composite)implementation, extensionAttributeProcessor, context);
+
+ writeEnd(writer);
+ } else {
+ extensionProcessor.write(component.getImplementation(), writer, context);
+ }
+
+ for (Object extension : component.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ // Write <service> elements
+ for (ComponentService service : component.getServices()) {
+ writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), policyProcessor.writePolicies(service));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, service, extensionAttributeProcessor, context);
+
+ // Write service interface
+ extensionProcessor.write(service.getInterfaceContract(), writer, context);
+
+ // Write bindings
+ for (Binding binding : service.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write <callback> element
+ if (service.getCallback() != null) {
+ Callback callback = service.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor, context);
+
+ // Write bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, callback, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, service, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <reference> elements
+ for (ComponentReference reference : component.getReferences()) {
+ writeStart(writer,
+ REFERENCE,
+ new XAttr(NAME, reference.getName()),
+ new XAttr(AUTOWIRE, reference.getAutowire()),
+ (reference.isNonOverridable() ? new XAttr(NONOVERRIDABLE, true) : null),
+ writeMultiplicity(reference),
+ writeTargets(reference),
+ policyProcessor.writePolicies(reference));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, reference, extensionAttributeProcessor, context);
+
+ // Write reference interface
+ extensionProcessor.write(reference.getInterfaceContract(), writer, context);
+
+ // Write bindings
+ for (Binding binding : reference.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write callback
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor, context);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, callback, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, reference, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <property> elements
+ for (ComponentProperty property : component.getProperties()) {
+ writeStart(writer,
+ PROPERTY,
+ new XAttr(NAME, property.getName()),
+ new XAttr(MUST_SUPPLY, property.isMustSupply()),
+ new XAttr(MANY, property.isMany()),
+ new XAttr(TYPE, property.getXSDType()),
+ new XAttr(ELEMENT, property.getXSDElement()),
+ new XAttr(SOURCE, property.getSource()),
+ new XAttr(FILE, property.getFile()),
+ policyProcessor.writePolicies(property));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, property, extensionAttributeProcessor, context);
+
+ // Write property value
+ writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : property.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write <reference> elements
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+
+ // Write list of promoted references
+ List<String> promote = new ArrayList<String>();
+ for (ComponentReference promoted : compositeReference.getPromotedReferences()) {
+ promote.add(promoted.getName());
+ }
+
+ // Write <reference> element
+ writeStart(writer,
+ REFERENCE,
+ new XAttr(NAME, reference.getName()),
+ new XAttr(PROMOTE, promote),
+ writeMultiplicity(reference),
+ policyProcessor.writePolicies(reference));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, reference, extensionAttributeProcessor, context);
+
+ // Write reference interface
+ extensionProcessor.write(reference.getInterfaceContract(), writer, context);
+
+ // Write bindings
+ for (Binding binding : reference.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write <callback> element
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK);
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor, context);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, callback, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, reference, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <property> elements
+ for (Property property : composite.getProperties()) {
+ writeStart(writer,
+ PROPERTY,
+ new XAttr(NAME, property.getName()),
+ new XAttr(MUST_SUPPLY, property.isMustSupply()),
+ new XAttr(MANY, property.isMany()),
+ new XAttr(TYPE, property.getXSDType()),
+ new XAttr(ELEMENT, property.getXSDElement()),
+ policyProcessor.writePolicies(property));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, property, extensionAttributeProcessor, context);
+
+ // Write property value
+ writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : property.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write <wire> elements
+ for (Wire wire : composite.getWires()) {
+ writeStart(writer, WIRE, new XAttr(SOURCE, wire.getSource().getName()), new XAttr(TARGET, wire.getTarget()
+ .getName()), wire.isReplace() ? new XAttr(Constants.REPLACE, true) : null);
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, wire, extensionAttributeProcessor, context);
+
+ // Write extensions
+ for (Object extension : wire.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+ writeEnd(writer);
+ }
+
+ for (Object extension : composite.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(Composite composite, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ Monitor monitor = context.getMonitor();
+ try {
+ monitor.pushContext("Composite: " + composite.getName());
+
+ // Resolve includes in the composite
+ for (int i = 0, n = composite.getIncludes().size(); i < n; i++) {
+ Composite include = composite.getIncludes().get(i);
+ if (include != null) {
+ Composite resolved = resolver.resolveModel(Composite.class, include, context);
+ if (!resolved.isUnresolved()) {
+ if ((composite.isLocal() && resolved.isLocal()) || (!composite.isLocal() && !resolved.isLocal())) {
+ composite.getIncludes().set(i, resolved);
+ } else {
+ ContributionResolveException ce =
+ new ContributionResolveException("[ASM60041] Error: Composite " + composite.getName()
+ + " can only include another composite with the identical @local attribute value");
+ error(monitor, "ContributionResolveException", include, ce);
+ }
+ } else {
+ ContributionResolveException ce =
+ new ContributionResolveException("[ASM60042] Error: Composite " + include.getName()
+ + " is not a valid composite within the domain");
+ error(monitor, "ContributionResolveException", include, ce);
+ }
+ }
+ }
+
+ // Resolve extensions
+ for (Object extension : composite.getExtensions()) {
+ if (extension != null) {
+ extensionProcessor.resolve(extension, resolver, context);
+ }
+ }
+
+ //Resolve composite services and references
+ resolveContracts(composite, composite.getServices(), resolver, context);
+ resolveContracts(composite, composite.getReferences(), resolver, context);
+
+ for (Property property : composite.getProperties()){
+ resolvePropertyType("composite " + composite.getName().toString(),
+ property,
+ context.getContribution(), context);
+ }
+
+ // Resolve component implementations, services and references
+ for (Component component : composite.getComponents()) {
+
+ //resolve component services and references
+ resolveContracts(component, component.getServices(), resolver, context);
+ resolveContracts(component, component.getReferences(), resolver, context);
+
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ // resolve a reference to a property file
+ if (componentProperty.getFile() != null) {
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(componentProperty.getFile());
+ artifact = resolver.resolveModel(Artifact.class, artifact, context);
+ if (artifact.getLocation() != null) {
+ componentProperty.setFile(artifact.getLocation());
+ }
+ }
+
+ // resolve the reference to a complex property
+ resolvePropertyType("component " + component.getName(),
+ componentProperty,
+ context.getContribution(), context);
+ }
+
+ //resolve component implementation
+ Implementation implementation = component.getImplementation();
+ if (implementation != null) {
+ //now resolve the implementation so that even if there is a shared instance
+ //for this that is resolved, the specified intents and policysets are safe in the
+ //component and not lost
+ implementation = resolveImplementation(implementation, resolver, context);
+
+ component.setImplementation(implementation);
+ }
+
+ //add model resolver to component
+ if (component instanceof ResolverExtension) {
+ ((ResolverExtension)component).setModelResolver(resolver);
+ }
+ }
+
+ // Add model resolver to promoted components
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ Component promotedComponent = compositeService.getPromotedComponent();
+ if (promotedComponent instanceof ResolverExtension) {
+ ((ResolverExtension)promotedComponent).setModelResolver(resolver);
+ }
+ } // end for
+
+ } finally {
+ // Pop context
+ monitor.popContext();
+ } // end try
+ }
+
+ public QName getArtifactType() {
+ return COMPOSITE_QNAME;
+ }
+
+ public Class<Composite> getModelType() {
+ return Composite.class;
+ }
+
+ /**
+ * Returns the model factory extension point to use.
+ *
+ * @param extensionPoints
+ * @return
+ */
+ private static FactoryExtensionPoint modelFactories(ExtensionPointRegistry extensionPoints) {
+ return extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ }
+
+ /**
+ * Property elements can have XSD types attributes so, in the case of a complex type, we need to find
+ * the XSD definition that defines that type in the contribution while we still have access to the
+ * contribution. Later, in the builder, we use this XSD definition to ensure that the property value
+ * is of the correct type
+ *
+ * @param property
+ * @param contribution
+ */
+ private void resolvePropertyType(String parentName, Property property, Contribution contribution, ProcessorContext context){
+ // resolve the reference to a complex property
+ // we ignore any types in the schema namespace
+ if (property.getXSDType() != null &&
+ property.getXSDType().getNamespaceURI().equals("http://www.w3.org/2001/XMLSchema") != true){
+ XSDefinition xsdDefinition = xsdFactory.createXSDefinition();
+ xsdDefinition.setUnresolved(true);
+ xsdDefinition.setNamespace(property.getXSDType().getNamespaceURI());
+ // some unit tests don't set up contribution and model resolvers properly
+ if (contribution != null && contribution.getModelResolver() != null) {
+ XSDefinition resolved = contribution.getModelResolver().resolveModel(XSDefinition.class, xsdDefinition, context);
+ if (resolved == null || resolved.isUnresolved()){
+ // raise an error
+ // [rfeng] The XSD might be not available if we use JAXB annotated classes, report it as a warning for now
+ warning(context.getMonitor(), "PropertyTypeNotFound", property, property.getXSDType().toString(), property.getName(), parentName);
+ } else {
+ // store the schema in the property
+ property.setXSDDefinition(resolved);
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java
new file mode 100644
index 0000000000..9930096a26
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Processor for dealing with 'operation' elements from composite definitions
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ConfiguredOperationProcessor implements StAXArtifactProcessor<ConfiguredOperation>, Constants{
+
+ private AssemblyFactory assemblyFactory;
+ private PolicySubjectProcessor policyProcessor;
+ private PolicyFactory policyFactory;
+
+
+ public ConfiguredOperationProcessor(FactoryExtensionPoint modelFactories) {
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ }
+
+ public ConfiguredOperation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ ConfiguredOperation configuredOp = assemblyFactory.createConfiguredOperation();
+
+ //Read an <operation>
+ configuredOp.setName(reader.getAttributeValue(null, NAME));
+ configuredOp.setContractName(reader.getAttributeValue(null, SERVICE));
+ configuredOp.setUnresolved(true);
+
+ // Read policies
+ policyProcessor.readPolicies(configuredOp, reader);
+
+ //Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && OPERATION_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ return configuredOp;
+ }
+
+ public void write(ConfiguredOperation configuredOperation, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ // Write an <operation>
+ writer.writeStartElement(Constants.SCA11_NS, OPERATION);
+ policyProcessor.writePolicyAttributes(configuredOperation, writer);
+
+ writer.writeAttribute(NAME, configuredOperation.getName());
+ if ( configuredOperation.getContractName() != null ) {
+ writer.writeAttribute(SERVICE, configuredOperation.getContractName());
+ }
+ writer.writeEndElement();
+ }
+
+ public void resolve(ConfiguredOperation configuredOperation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ }
+
+ public QName getArtifactType() {
+ return OPERATION_QNAME;
+ }
+
+ public Class<ConfiguredOperation> getModelType() {
+ return ConfiguredOperation.class;
+ }
+
+}
+
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java
new file mode 100644
index 0000000000..7965002304
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Constants used in SCA assembly XML files.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension
+ */
+public interface Constants {
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ String COMPONENT_TYPE = "componentType";
+ QName COMPONENT_TYPE_QNAME = new QName(SCA11_NS, COMPONENT_TYPE);
+
+ String SERVICE = "service";
+ QName SERVICE_QNAME = new QName(SCA11_NS, SERVICE);
+
+ String REFERENCE = "reference";
+ QName REFERENCE_QNAME = new QName(SCA11_NS, REFERENCE);
+
+ String PROPERTY = "property";
+ QName PROPERTY_QNAME = new QName(SCA11_NS, PROPERTY);
+
+ String COMPOSITE = "composite";
+ QName COMPOSITE_QNAME = new QName(SCA11_NS, COMPOSITE);
+
+ String INCLUDE = "include";
+ QName INCLUDE_QNAME = new QName(SCA11_NS, INCLUDE);
+
+ String COMPONENT = "component";
+ QName COMPONENT_QNAME = new QName(SCA11_NS, COMPONENT);
+
+ String WIRE = "wire";
+ QName WIRE_QNAME = new QName(SCA11_NS, WIRE);
+
+ String OPERATION = "operation";
+ QName OPERATION_QNAME = new QName(SCA11_NS, OPERATION);
+
+ String CALLBACK = "callback";
+ QName CALLBACK_QNAME = new QName(SCA11_NS, CALLBACK);
+
+ String IMPLEMENTATION_COMPOSITE = "implementation.composite";
+ QName IMPLEMENTATION_COMPOSITE_QNAME = new QName(SCA11_NS, IMPLEMENTATION_COMPOSITE);
+
+ String IMPLEMENTATION = "implementation";
+ QName IMPLEMENTATION_QNAME = new QName(SCA11_NS, IMPLEMENTATION);
+
+ String BINDING_SCA = "binding.sca";
+ QName BINDING_SCA_QNAME = new QName(Constants.SCA11_NS, BINDING_SCA);
+
+ String EXTENSION = "extensions";
+ QName EXTENSION_QNAME = new QName(Constants.SCA11_NS, EXTENSION);
+
+ String NAME = "name";
+ String VALUE = "value";
+ QName VALUE_QNAME = new QName(SCA11_NS, VALUE);
+
+ String POLICY_SET_ATTACHMENT = "policySetAttachment";
+ QName POLICY_SET_ATTACHMENT_QNAME = new QName(SCA11_NS, POLICY_SET_ATTACHMENT);
+
+ String TARGET_NAMESPACE = "targetNamespace";
+ String LOCAL = "local";
+ String AUTOWIRE = "autowire";
+ String NONOVERRIDABLE = "nonOverridable";
+ String REPLACE = "replace";
+ String REQUIRES = "requires";
+ QName REQUIRES_QNAME = new QName(SCA11_NS, REQUIRES);
+ String INTENTS = "intents";
+
+ String POLICY_SETS = "policySets";
+ String PROMOTE = "promote";
+ String TARGET = "target";
+ String WIRED_BY_IMPL = "wiredByImpl";
+ String MULTIPLICITY = "multiplicity";
+ String TYPE = "type";
+ String ELEMENT = "element";
+ String MANY = "many";
+ String MUST_SUPPLY = "mustSupply";
+ String SOURCE = "source";
+ String FILE = "file";
+ String URI = "uri";
+ String ZERO_ONE = "0..1";
+ String ZERO_N = "0..n";
+ String ONE_ONE = "1..1";
+ String ONE_N = "1..n";
+
+ String SERVER_AUTHENTICATION = "serverAuthentication";
+ QName SERVER_AUTHENTICATION_INTENT = new QName(SCA11_NS, SERVER_AUTHENTICATION);
+ String SERVER_AUTHENTICATION_TRANSPORT = "serverAuthentication.transport";
+ QName SERVER_AUTHENTICATION_TRANSPORT_INTENT = new QName(SCA11_NS, SERVER_AUTHENTICATION_TRANSPORT);
+ String SERVER_AUTHENTICATION_MESSAGE = "serverAuthentication.message";
+ QName SERVER_AUTHENTICATION_MESSAGE_INTENT = new QName(SCA11_NS, SERVER_AUTHENTICATION_MESSAGE);
+
+ String CLIENT_AUTHENTICATION = "clientAuthentication";
+ QName CLIENT_AUTHENTICATION_INTENT = new QName(SCA11_NS, CLIENT_AUTHENTICATION);
+ String CLIENT_AUTHENTICATION_TRANSPORT = "clientAuthentication.transport";
+ QName CLIENT_AUTHENTICATION_TRANSPORT_INTENT = new QName(SCA11_NS, CLIENT_AUTHENTICATION_TRANSPORT);
+ String CLIENT_AUTHENTICATION_MESSAGE = "clientAuthentication.message";
+ QName CLIENT_AUTHENTICATION_MESSAGE_INTENT = new QName(SCA11_NS, CLIENT_AUTHENTICATION_MESSAGE);
+
+ String AUTHENTICATION = "authentication";
+ QName AUTHENTICATION_INTENT = new QName(SCA11_NS, AUTHENTICATION);
+
+ String MUTUAL_AUTHENTICATION = "mutualAuthentication";
+ QName MUTUAL_AUTHENTICATION_INTENT = new QName(SCA11_NS, MUTUAL_AUTHENTICATION);
+
+ String CONFIDENTIALITY = "confidentiality";
+ QName CONFIDENTIALITY_INTENT = new QName(SCA11_NS, CONFIDENTIALITY);
+ String CONFIDENTIALITY_TRANSPORT = "confidentiality.transport";
+ QName CONFIDENTIALITY_TRANSPORT_INTENT = new QName(SCA11_NS, CONFIDENTIALITY_TRANSPORT);
+ String CONFIDENTIALITY_MESSAGE = "confidentiality.message";
+ QName CONFIDENTIALITY_MESSAGE_INTENT = new QName(SCA11_NS, CONFIDENTIALITY_MESSAGE);
+
+ String INTEGRITY = "integrity";
+ QName INTEGRITY_INTENT = new QName(SCA11_NS, "INTEGRITY");
+ String INTEGRITY_TRANSPORT = "integrity.transport";
+ QName INTEGRITY_TRANSPORT_INTENT = new QName(SCA11_NS, INTEGRITY_TRANSPORT);
+ String INTEGRITY_MESSAGE = "integrity.message";
+ QName INTEGRITY_MESSAGE_INTENT = new QName(SCA11_NS, INTEGRITY_MESSAGE);
+
+ String AUTHORIZATION = "authorization";
+ QName AUTHORIZATION_INTENT = new QName(SCA11_NS, "INTEGRITY");
+ String AUTHORIZATION_FINE_GRAIN = "authorization.fineGrain";
+ QName AUTHORIZATION_FINE_GRAIN_INTENT = new QName(SCA11_NS, AUTHORIZATION_FINE_GRAIN);
+
+ // TODO - add transaction intent constants
+ String NOLISTENER = "noListener";
+ QName NOLISTENER_INTENT = new QName(SCA11_NS, NOLISTENER);
+
+ String SOAP = "SOAP";
+ QName SOAP_INTENT = new QName(SCA11_NS, SOAP);
+ String SOAP11 = "SOAP.v1_1";
+ QName SOAP11_INTENT = new QName(SCA11_NS, SOAP11);
+ String SOAP12 = "SOAP.v1_2";
+ QName SOAP12_INTENT = new QName(SCA11_NS, SOAP12);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java
new file mode 100644
index 0000000000..e6e172a44b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Default Model Processor for beans.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultBeanModelProcessor<T> extends BaseAssemblyProcessor implements StAXArtifactProcessor<T> {
+
+ private QName artifactType;
+ private Class<T> modelClass;
+ private Object modelFactory;
+ private Method factoryMethod;
+ private Map<String, Method> setterMethods = new HashMap<String, Method>();
+ private Map<String, Method> getterMethods = new HashMap<String, Method>();
+
+ public DefaultBeanModelProcessor(FactoryExtensionPoint modeFactories,
+ QName artifactType,
+ Class<T> modelClass,
+ Object modelFactory) {
+ super(modeFactories, null);
+ this.artifactType = artifactType;
+ this.modelClass = modelClass;
+ this.modelFactory = modelFactory;
+
+ // Introspect the factory class and bean model class
+ if (modelFactory != null) {
+
+ // Find the model create method
+ for (Method method: modelFactory.getClass().getMethods()) {
+ if (method.getName().startsWith("create") && method.getReturnType() == modelClass) {
+ factoryMethod = method;
+ break;
+ }
+ }
+ }
+
+ // Index the bean's setter methods
+ for (Method method: modelClass.getMethods()) {
+ Method getter;
+ String name = method.getName();
+ if (name.startsWith("set") && name.length() > 3) {
+
+ // Get the corresponding getter method
+ try {
+ getter = modelClass.getMethod("get" + name.substring(3));
+ } catch (Exception e) {
+ getter = null;
+ continue;
+ }
+
+ // Get the property name
+ name = name.substring(3);
+ if (name.length() > 1) {
+ if (!name.toUpperCase().equals(name)) {
+ name = name.substring(0, 1).toLowerCase() + name.substring(1);
+ }
+ }
+ } else {
+ continue;
+ }
+
+ // Map an uppercase property name to a lowercase attribute name
+ if (name.toUpperCase().equals(name)) {
+ name = name.toLowerCase();
+ }
+
+ // Trim trailing _ from property names
+ if (name.endsWith("_")) {
+ name = name.substring(0, name.length()-1);
+ }
+ setterMethods.put(name, method);
+ getterMethods.put(name, getter);
+ }
+ }
+
+ public T read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+
+ // Read an element
+ try {
+
+ // Create a new instance of the model
+ Object model;
+ if (modelFactory != null) {
+ // Invoke the factory create method
+ model = factoryMethod.invoke(modelFactory);
+ } else {
+ // Invoke the model bean class default constructor
+ model = modelClass.newInstance();
+ }
+
+ // Initialize the bean properties with the attributes found in the
+ // XML element
+ for (int i = 0, n = reader.getAttributeCount(); i < n; i++) {
+ String attributeName = reader.getAttributeLocalName(i);
+ Method setter = setterMethods.get(attributeName);
+ if (setter != null) {
+ String value = null;
+ if (attributeName.equals("uri")){
+ value = getURIString(reader, "uri");
+ } else {
+ value = reader.getAttributeValue(i);
+ }
+ setter.invoke(model, value);
+ }
+ }
+
+ // Read policies
+ policyProcessor.readPolicies(model, reader);
+
+ // FIXME read extension elements
+
+ // By default mark the model object unresolved
+ if (model instanceof Base) {
+ ((Base)model).setUnresolved(true);
+ }
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && artifactType.equals(reader.getName())) {
+ break;
+ }
+ }
+ return (T) model;
+
+ } catch (Exception e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(context.getMonitor(), "ContributionReadException", reader, ce);
+ throw ce;
+ }
+ }
+
+ public void write(T bean, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ try {
+ // Write the bean properties as attributes
+ List<XAttr> attrs = new ArrayList<XAttr>();
+ for (Map.Entry<String, Method> entry: getterMethods.entrySet()) {
+ if (entry.getValue().getReturnType() == String.class) {
+ String value = (String)entry.getValue().invoke(bean);
+ attrs.add(new XAttr(entry.getKey(), value));
+ }
+ }
+
+ // Write element
+ writeStart(writer, artifactType.getNamespaceURI(), artifactType.getLocalPart(),
+ policyProcessor.writePolicies(bean), new XAttr(null, attrs));
+
+ writeEnd(writer);
+
+ } catch (Exception e) {
+ ContributionWriteException ce = new ContributionWriteException(e);
+ error(context.getMonitor(), "ContributionWriteException", writer, ce);
+ throw ce;
+ }
+ }
+
+ public void resolve(T bean, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // Resolve and merge the component type associated with an
+ // implementation model
+ if (bean instanceof Implementation) {
+ Implementation implementation = (Implementation)bean;
+ String uri = implementation.getURI();
+ if (uri != null) {
+ int d = uri.lastIndexOf('.');
+ if (d != -1) {
+ uri = uri.substring(0, d) + ".componentType";
+
+ // Resolve the component type
+ ComponentType componentType = assemblyFactory.createComponentType();
+ componentType.setURI(uri);
+ componentType.setUnresolved(true);
+
+ componentType = resolver.resolveModel(ComponentType.class, componentType, context);
+ if (componentType != null && !componentType.isUnresolved()) {
+
+ // We found a component type, merge it into the implementation model
+ implementation.getServices().addAll(componentType.getServices());
+ implementation.getReferences().addAll(componentType.getReferences());
+ implementation.getProperties().addAll(componentType.getProperties());
+
+ if (implementation instanceof PolicySubject &&
+ componentType instanceof PolicySubject ) {
+ PolicySubject policiedImpl = (PolicySubject)implementation;
+ PolicySubject policiedCompType = (PolicySubject)componentType;
+
+ if ( policiedImpl.getPolicySets() != null) {
+ policiedImpl.getPolicySets().addAll(policiedCompType.getPolicySets());
+ }
+ if (policiedImpl.getRequiredIntents() != null) {
+ policiedImpl.getRequiredIntents().addAll(policiedCompType.getRequiredIntents());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Mark the model resolved
+ if (bean instanceof Base) {
+ ((Base)bean).setUnresolved(false);
+ }
+ }
+
+ public QName getArtifactType() {
+ return artifactType;
+ }
+
+ public Class<T> getModelType() {
+ return modelClass;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java
new file mode 100644
index 0000000000..d128897df0
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ */
+public class EndpointProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<Endpoint> {
+ private final static String ENDPOINT = "endpoint";
+ private final static QName ENDPOINT_QNAME = new QName(Constants.SCA11_TUSCANY_NS, ENDPOINT);
+
+ private ExtensionPointRegistry registry;
+
+ public EndpointProcessor(ExtensionPointRegistry registry,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+
+ super(modelFactories(registry), extensionProcessor);
+ this.registry = registry;
+ }
+
+ /**
+ * Returns the model factory extension point to use.
+ *
+ * @param extensionPoints
+ * @return
+ */
+ private static FactoryExtensionPoint modelFactories(ExtensionPointRegistry extensionPoints) {
+ return extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ }
+
+ public QName getArtifactType() {
+ return ENDPOINT_QNAME;
+ }
+
+ public Endpoint read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ Endpoint endpoint = assemblyFactory.createEndpoint();
+ if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) {
+ reader.nextTag();
+ }
+ Object model = extensionProcessor.read(reader, context);
+ if (model instanceof Composite) {
+ Composite composite = (Composite)model;
+ Component component = composite.getComponents().get(0);
+ ComponentService service = component.getServices().get(0);
+ Binding binding = service.getBindings().get(0);
+ endpoint.setComponent(component);
+ endpoint.setService(service);
+ endpoint.setBinding(binding);
+ }
+ return endpoint;
+ }
+
+ public void write(Endpoint model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ // writeStart(writer, ENDPOINT_QNAME);
+ extensionProcessor.write(wrap(model), writer, context);
+ // writeEnd(writer);
+ }
+
+ private Composite wrap(Endpoint endpoint) {
+ try {
+ Composite composite = assemblyFactory.createComposite();
+ composite.setName(ENDPOINT_QNAME);
+ composite.setLocal(false);
+ if (endpoint.getComponent() != null) {
+ Component component = (Component)endpoint.getComponent().clone();
+ component.setImplementation(null);
+ composite.getComponents().add(component);
+ component.getReferences().clear();
+ component.getServices().clear();
+ if (endpoint.getService() != null) {
+ ComponentService service = (ComponentService)endpoint.getService().clone();
+ component.getServices().add(service);
+ service.getBindings().clear();
+ service.setInterfaceContract(endpoint.getComponentServiceInterfaceContract());
+ if (endpoint.getBinding() != null) {
+ Binding binding = (Binding)endpoint.getBinding().clone();
+ service.getBindings().add(binding);
+ }
+ }
+ }
+ return composite;
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
+
+ public Class<Endpoint> getModelType() {
+ return Endpoint.class;
+ }
+
+ public void resolve(Endpoint model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java
new file mode 100644
index 0000000000..eda90c9d44
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ */
+public class EndpointReferenceProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<EndpointReference> {
+ private final static String ENDPOINT_REFERENCE = "endpointReference";
+ private final static QName ENDPOINT_REFERENCE_QNAME = new QName(Constants.SCA11_TUSCANY_NS, ENDPOINT_REFERENCE);
+
+ private ExtensionPointRegistry registry;
+
+ public EndpointReferenceProcessor(ExtensionPointRegistry registry,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+
+ super(modelFactories(registry), extensionProcessor);
+ this.registry = registry;
+ }
+
+ /**
+ * Returns the model factory extension point to use.
+ *
+ * @param extensionPoints
+ * @return
+ */
+ private static FactoryExtensionPoint modelFactories(ExtensionPointRegistry extensionPoints) {
+ return extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ }
+
+ public QName getArtifactType() {
+ return ENDPOINT_REFERENCE_QNAME;
+ }
+
+ public EndpointReference read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ EndpointReference endpointReference = assemblyFactory.createEndpointReference();
+ if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) {
+ reader.nextTag();
+ }
+ Object model = extensionProcessor.read(reader, context);
+ if (model instanceof Composite) {
+ Composite composite = (Composite)model;
+ Component component = composite.getComponents().get(0);
+ ComponentReference reference = component.getReferences().get(0);
+ Binding binding = reference.getBindings().get(0);
+ endpointReference.setComponent(component);
+ endpointReference.setReference(reference);
+ reference.getEndpointReferences().add(endpointReference);
+ endpointReference.setBinding(binding);
+
+ // set up the EPR so that resolution will happen
+ // at wire creation time if needs be
+ Endpoint endpoint = assemblyFactory.createEndpoint();
+ endpointReference.setTargetEndpoint(endpoint);
+
+ if (reference.getTargets().size() > 0){
+ // create a dummy endpoint with the URI set so that
+ // the endpoint registry will be consulted
+ endpoint.setUnresolved(true);
+ endpoint.setURI(reference.getTargets().get(0).getName());
+ endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND);
+ endpointReference.setUnresolved(true);
+ } else {
+ endpoint.setUnresolved(false);
+ endpoint.setBinding(reference.getBindings().get(0));
+ endpointReference.setStatus(EndpointReference.Status.RESOLVED_BINDING);
+ endpointReference.setUnresolved(false);
+ }
+ }
+ return endpointReference;
+ }
+
+ public void write(EndpointReference model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ extensionProcessor.write(wrap(model), writer, context);
+ }
+
+ private Composite wrap(EndpointReference endpointReference) {
+ try {
+ Composite composite = assemblyFactory.createComposite();
+ composite.setName(ENDPOINT_REFERENCE_QNAME);
+ composite.setLocal(false);
+ Component component = (Component)endpointReference.getComponent().clone();
+ composite.getComponents().add(component);
+ component.getReferences().clear();
+ component.getServices().clear();
+ ComponentReference reference = (ComponentReference)endpointReference.getReference().clone();
+ component.getReferences().add(reference);
+ reference.getBindings().clear();
+ Binding binding = (Binding)endpointReference.getBinding().clone();
+ reference.getBindings().add(binding);
+ //reference.setInterfaceContract(endpointReference.getInterfaceContract());
+ if (endpointReference.getStatus() != EndpointReference.Status.RESOLVED_BINDING){
+ ComponentService service = assemblyFactory.createComponentService();
+ service.setName(endpointReference.getTargetEndpoint().getURI());
+ reference.getTargets().clear();
+ reference.getTargets().add(service);
+ }
+ return composite;
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
+
+ public Class<EndpointReference> getModelType() {
+ return EndpointReference.class;
+ }
+
+ public void resolve(EndpointReference model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java
new file mode 100644
index 0000000000..0391acc676
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+/**
+ * Constants for resource bundle names
+ * @tuscany.spi.extension
+ */
+public interface Messages {
+ String RESOURCE_BUNDLE = "org.apache.tuscany.sca.assembly.xml.assembly-xml-validation-messages";
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
new file mode 100644
index 0000000000..286f109f44
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.apache.tuscany.sca.assembly.xml.Constants.POLICY_SETS;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REQUIRES;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * A Policy Attach Point processor.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class PolicySubjectProcessor extends BaseStAXArtifactProcessor {
+
+ private PolicyFactory policyFactory;
+
+ public PolicySubjectProcessor(PolicyFactory policyFactory) {
+ this.policyFactory = policyFactory;
+ }
+
+ public PolicySubjectProcessor(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
+ }
+
+ /**
+ * Read policy intents associated with an operation.
+ * @param subject
+ * @param operation
+ * @param reader
+ */
+ private void readIntents(Object subject, Operation operation, XMLStreamReader reader) {
+ if (!(subject instanceof PolicySubject))
+ return;
+ PolicySubject intentAttachPoint = (PolicySubject)subject;
+ String value = reader.getAttributeValue(null, REQUIRES);
+ if (value != null) {
+ List<Intent> requiredIntents = intentAttachPoint.getRequiredIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ if (operation != null) {
+ //FIXME Don't we need to handle intent specification
+ // on an operation basis?
+ //intent.getOperations().add(operation);
+ }
+ requiredIntents.add(intent);
+ }
+ }
+ }
+
+ /**
+ * Reads policy intents and policy sets associated with an operation.
+ * @param subject
+ * @param operation
+ * @param reader
+ */
+ public void readPolicies(Object subject, Operation operation, XMLStreamReader reader) {
+ readIntents(subject, operation, reader);
+ readPolicySets(subject, operation, reader);
+ }
+
+ /**
+ * Reads policy intents and policy sets.
+ * @param subject
+ * @param reader
+ */
+ public void readPolicies(Object subject, XMLStreamReader reader) {
+ readPolicies(subject, null, reader);
+ }
+
+ /**
+ * Reads policy sets associated with an operation.
+ * @param subject
+ * @param operation
+ * @param reader
+ */
+ private void readPolicySets(Object subject, Operation operation, XMLStreamReader reader) {
+ if (!(subject instanceof PolicySubject)) {
+ return;
+ }
+ PolicySubject policySubject = (PolicySubject)subject;
+ String value = reader.getAttributeValue(null, POLICY_SETS);
+ if (value != null) {
+ List<PolicySet> policySets = policySubject.getPolicySets();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ PolicySet policySet = policyFactory.createPolicySet();
+ policySet.setName(qname);
+ if (operation != null) {
+ //FIXME Don't we need to handle policySet specification
+ // on an operation basis?
+ //policySet.getOperations().add(operation);
+ }
+ policySets.add(policySet);
+ }
+ }
+ }
+
+ /**
+ * Write policies
+ * @param subject
+ * @return
+ */
+ XAttr writePolicies(Object subject) throws XMLStreamException {
+ return writePolicies(subject, (Operation)null);
+ }
+
+ /**
+ * Write policies
+ * @param subject
+ * @return
+ */
+ public void writePolicyAttributes(Object subject, XMLStreamWriter writer) throws XMLStreamException {
+ writePolicyAttributes(subject, (Operation)null, writer);
+ }
+
+ /**
+ * Write policies associated with an operation
+ * @param subject
+ * @param operation
+ * @return
+ */
+ XAttr writePolicies(Object subject, Operation operation) {
+ List<XAttr> attrs =new ArrayList<XAttr>();
+ attrs.add(writeIntents(subject, operation));
+ attrs.add(writePolicySets(subject, operation));
+ return new XAttr(null, attrs);
+ }
+
+ /**
+ * Write policies
+ * @param subject
+ * @return
+ */
+ public void writePolicyAttributes(Object subject, Operation operation, XMLStreamWriter writer) throws XMLStreamException {
+ XAttr attr = writePolicies(subject, operation);
+ attr.write(writer);
+ }
+
+ /**
+ * Write policy intents associated with an operation.
+ * @param subject
+ * @param operation
+ */
+ private XAttr writeIntents(Object subject, Operation operation) {
+ if (!(subject instanceof PolicySubject)) {
+ return null;
+ }
+ PolicySubject intentAttachPoint = (PolicySubject)subject;
+ List<QName> qnames = new ArrayList<QName>();
+ for (Intent intent: intentAttachPoint.getRequiredIntents()) {
+ qnames.add(intent.getName());
+ }
+ return new XAttr(Constants.REQUIRES, qnames);
+ }
+
+ /**
+ * Write policy sets associated with an operation.
+ * @param subject
+ * @param operation
+ */
+ private XAttr writePolicySets(Object subject, Operation operation) {
+ if (!(subject instanceof PolicySubject)) {
+ return null;
+ }
+ PolicySubject policySetAttachPoint = (PolicySubject)subject;
+ List<QName> qnames = new ArrayList<QName>();
+ for (PolicySet policySet: policySetAttachPoint.getPolicySets()) {
+ qnames.add(policySet.getName());
+ }
+ return new XAttr(Constants.POLICY_SETS, qnames);
+ }
+
+ public void resolvePolicies(Object subject, ModelResolver resolver, ProcessorContext context) {
+ if ( subject instanceof PolicySubject ) {
+ PolicySubject policySetAttachPoint = (PolicySubject)subject;
+
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ Intent resolvedIntent = null;
+
+ if ( policySetAttachPoint.getRequiredIntents() != null && policySetAttachPoint.getRequiredIntents().size() > 0 ) {
+ for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) {
+ resolvedIntent = resolver.resolveModel(Intent.class, intent, context);
+ requiredIntents.add(resolvedIntent);
+ }
+ policySetAttachPoint.getRequiredIntents().clear();
+ policySetAttachPoint.getRequiredIntents().addAll(requiredIntents);
+ }
+
+ if ( policySetAttachPoint.getPolicySets() != null && policySetAttachPoint.getPolicySets().size() > 0 ) {
+ List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
+ PolicySet resolvedPolicySet = null;
+ for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
+ resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet, context);
+ resolvedPolicySets.add(resolvedPolicySet);
+ }
+ policySetAttachPoint.getPolicySets().clear();
+ policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java
new file mode 100644
index 0000000000..28f4f9fb25
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * A processor to read the XML that describes the SCA binding.
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class SCABindingProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<SCABinding> {
+ private static final String NAME = "name";
+ private static final String URI = "uri";
+
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ private static final String BINDING_SCA = "binding.sca";
+ private static final QName BINDING_SCA_QNAME = new QName(SCA11_NS, BINDING_SCA);
+
+ private PolicyFactory policyFactory;
+ private SCABindingFactory scaBindingFactory;
+ private PolicySubjectProcessor policyProcessor;
+ private PolicyFactory intentAttachPointTypeFactory;
+
+
+ public SCABindingProcessor(FactoryExtensionPoint modelFactories) {
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
+ policyProcessor = new PolicySubjectProcessor(policyFactory);
+ this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class);
+ }
+
+ public QName getArtifactType() {
+ return BINDING_SCA_QNAME;
+ }
+
+ public Class<SCABinding> getModelType() {
+ return SCABinding.class;
+ }
+
+ public SCABinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ SCABinding scaBinding = scaBindingFactory.createSCABinding();
+ ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType();
+ bindingType.setType(getArtifactType());
+ bindingType.setUnresolved(true);
+ ((PolicySubject)scaBinding).setExtensionType(bindingType);
+
+ // Read policies
+ policyProcessor.readPolicies(scaBinding, reader);
+
+ // Read binding name
+ String name = reader.getAttributeValue(null, NAME);
+ if (name != null) {
+ scaBinding.setName(name);
+ }
+
+ // Read binding URI
+ String uri = getURIString(reader, URI);
+ if (uri != null) {
+ scaBinding.setURI(uri);
+ }
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && BINDING_SCA_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+ return scaBinding;
+ }
+
+ public void resolve(SCABinding model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ policyProcessor.resolvePolicies(model, resolver, context);
+ }
+
+ public void write(SCABinding scaBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write <binding.sca>
+ writer.writeStartElement(SCA11_NS, BINDING_SCA);
+ policyProcessor.writePolicyAttributes(scaBinding, writer);
+
+ // Write binding name
+ if (scaBinding.getName() != null) {
+ writer.writeAttribute(NAME, scaBinding.getName());
+ }
+
+ // Write binding URI
+ if (scaBinding.getURI() != null) {
+ writer.writeAttribute(URI, scaBinding.getURI());
+ }
+
+ writer.writeEndElement();
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
new file mode 100644
index 0000000000..af59324c7c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.definitions.xml;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+
+/**
+ * Default implementation of an extension point for XML definitionss.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultDefinitionsExtensionPoint implements DefinitionsExtensionPoint {
+ private static final Logger logger = Logger.getLogger(DefaultDefinitionsExtensionPoint.class.getName());
+ private static final URI DEFINITIONS_URI = URI.create("META-INF/definitions.xml");
+ private ExtensionPointRegistry registry;
+ private MonitorFactory monitorFactory;
+ private Set<URL> documents = new HashSet<URL>();
+ private List<Definitions> definitions = new ArrayList<Definitions>();
+ private boolean documentsLoaded;
+ private boolean loaded;
+
+ public DefaultDefinitionsExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ this.monitorFactory = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(MonitorFactory.class);
+ }
+
+ public void addDefinitionsDocument(URL url) {
+ documents.add(url);
+ }
+
+ public void removeDefinitionsDocument(URL url) {
+ documents.remove(url);
+ }
+
+ /**
+ * Load definitions declarations from META-INF/services/
+ * org.apache.tuscany.sca.contribution.processor.Definitions files
+ */
+ private synchronized void loadDefinitionsDocuments() {
+ if (documentsLoaded)
+ return;
+
+ // Get the definitions declarations
+ Collection<ServiceDeclaration> definitionsDeclarations;
+ try {
+ definitionsDeclarations = registry.getServiceDiscovery().getServiceDeclarations(DEFINITIONS_FILE);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ // Find each definitions
+ for (ServiceDeclaration definitionsDeclaration : definitionsDeclarations) {
+ URL url = definitionsDeclaration.getResource(definitionsDeclaration.getClassName());
+ if (url == null) {
+ throw new IllegalArgumentException(definitionsDeclaration.getClassName() + " cannot be found");
+ }
+ documents.add(url);
+ }
+
+ documentsLoaded = true;
+ }
+
+ public synchronized List<Definitions> getDefinitions() {
+ if (!loaded) {
+ loadDefinitionsDocuments();
+ URLArtifactProcessorExtensionPoint processors =
+ registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ URLArtifactProcessor<Definitions> processor = processors.getProcessor(Definitions.class);
+ ProcessorContext context = new ProcessorContext(monitorFactory.createMonitor());
+ for (URL url : documents) {
+ Definitions def;
+ try {
+ def = processor.read(null, DEFINITIONS_URI, url, context);
+ definitions.add(def);
+ } catch (ContributionReadException e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+ loaded = true;
+ }
+ return definitions;
+ }
+
+ public void addDefinitions(Definitions def) {
+ this.definitions.add(def);
+ }
+
+ public void removeDefinitions(Definitions def) {
+ this.definitions.remove(def);
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java
new file mode 100644
index 0000000000..d0a42be34e
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.definitions.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.definitions.DefinitionsFactory;
+import org.apache.tuscany.sca.definitions.util.DefinitionsUtil;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * A SCA Definitions Document processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsDocumentProcessor implements URLArtifactProcessor<Definitions> {
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private XMLInputFactory inputFactory;
+ private DefinitionsFactory definitionsFactory;
+
+
+
+ /**
+ * Constructs a new SCADefinitions processor.
+ *
+ * @param modelFactories
+ * @param staxProcessor
+ */
+ public DefinitionsDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> staxProcessor) {
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)staxProcessor;
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ this.definitionsFactory = modelFactories.getFactory(DefinitionsFactory.class);
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public Definitions read(URL contributionURL, final URI uri, final URL url, ProcessorContext context) throws ContributionReadException {
+ InputStream urlStream = null;
+ Monitor monitor = context.getMonitor();
+ monitor.pushContext("Definitions: " + url);
+ try {
+ // Allow privileged access to open URL stream. Add FilePermission to added to security
+ // policy file.
+ try {
+ urlStream = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>() {
+ public InputStream run() throws IOException {
+ return IOHelper.openStream(url);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ error(monitor, "PrivilegedActionException", url, (IOException)e.getException());
+ throw (IOException)e.getException();
+ }
+
+ //urlStream = createInputStream(url);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
+ ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor());
+ Definitions definitions = definitionsFactory.createDefinitions();
+ int event = reader.getEventType();
+ while (reader.hasNext()) {
+ event = reader.next();
+
+ // We only deal with the root element
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ // QName name = reader.getName();
+ Object model = extensionProcessor.read(reader, context);
+ if (model instanceof Definitions) {
+ DefinitionsUtil.aggregate((Definitions)model, definitions, monitor);
+ return definitions;
+ } else {
+ error(monitor, "ContributionReadException", model, null);
+ }
+ }
+ }
+
+ return definitions;
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", inputFactory, ce);
+ throw ce;
+ } catch (IOException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", inputFactory, ce);
+ throw ce;
+ } finally {
+
+ try {
+ if (urlStream != null) {
+ urlStream.close();
+ urlStream = null;
+ }
+ } catch (IOException ioe) {
+ //ignore
+ }
+
+ monitor.popContext();
+ }
+ }
+
+ public void resolve(Definitions scaDefinitions, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ extensionProcessor.resolve(scaDefinitions, resolver, context);
+ }
+
+ public String getArtifactType() {
+ return "/META-INF/definitions.xml";
+ }
+
+ public Class<Definitions> getModelType() {
+ return Definitions.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java
new file mode 100644
index 0000000000..3058b1f5b6
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.definitions.xml;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.definitions.Definitions;
+
+/**
+ * An extension point for built-in SCA intent/policySet definition files
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DefinitionsExtensionPoint {
+ String DEFINITIONS_FILE = "org.apache.tuscany.sca.definitions.xml.Definitions";
+
+ /**
+ * Add a definitions document
+ *
+ * @param url the URL of the definitions
+ */
+ void addDefinitionsDocument(URL url);
+
+ /**
+ * Remove a definitions document
+ *
+ * @param url the URL of the definitions
+ */
+ void removeDefinitionsDocument(URL url);
+
+ /**
+ * @param definitions
+ */
+ void addDefinitions(Definitions definitions);
+ /**
+ * @param definitions
+ */
+ void removeDefinitions(Definitions definitions);
+
+ /**
+ * Get the list of definitions
+ * @return A list of definitions
+ */
+ List<Definitions> getDefinitions();
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java
new file mode 100644
index 0000000000..006b80ee31
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java
@@ -0,0 +1,292 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.definitions.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.definitions.DefinitionsFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+/**
+ * Processor for SCA Definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Definitions> {
+ private ExtensionPointRegistry registry;
+ private StAXArtifactProcessorExtensionPoint processors;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private DefinitionsFactory definitionsFactory;
+ private PolicyFactory policyFactory;
+
+ public static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ public static final String BINDING = "binding";
+ public static final String IMPLEMENTATION = "implementation";
+ public static final String DEFINITIONS = "definitions";
+ public static final QName DEFINITIONS_QNAME = new QName(SCA11_NS, DEFINITIONS);
+ public static final String TARGET_NAMESPACE = "targetNamespace";
+ public static final String NAME = "name";
+
+ public DefinitionsProcessor(ExtensionPointRegistry registry,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ this.registry = registry;
+ this.extensionProcessor = extensionProcessor;
+ this.processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.definitionsFactory = factoryExtensionPoint.getFactory(DefinitionsFactory.class);
+ this.policyFactory = factoryExtensionPoint.getFactory(PolicyFactory.class);
+ }
+
+ public Definitions read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ QName name = null;
+ Definitions definitions = null;
+ String targetNamespace = null;
+
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (DEFINITIONS_QNAME.equals(name)) {
+ definitions = definitionsFactory.createDefinitions();
+ targetNamespace = getURIString(reader, TARGET_NAMESPACE);
+ definitions.setTargetNamespace(targetNamespace);
+ } else {
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof Intent) {
+ Intent intent = (Intent)extension;
+ intent.setName(new QName(targetNamespace, intent.getName().getLocalPart()));
+ definitions.getIntents().add(intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ i.setName(new QName(targetNamespace, i.getName().getLocalPart()));
+ }
+ } else if (extension instanceof PolicySet) {
+ PolicySet policySet = (PolicySet)extension;
+ policySet.setName(new QName(targetNamespace, policySet.getName().getLocalPart()));
+ definitions.getPolicySets().add(policySet);
+ } else if (extension instanceof Binding) {
+ Binding binding = (Binding)extension;
+ definitions.getBindings().add(binding);
+ } else if (extension instanceof BindingType) {
+ definitions.getBindingTypes().add((BindingType)extension);
+ } else if (extension instanceof ImplementationType) {
+ definitions.getImplementationTypes().add((ImplementationType)extension);
+ }
+ }
+ break;
+ }
+ }
+
+ case XMLStreamConstants.CHARACTERS:
+ break;
+
+ case END_ELEMENT:
+ name = reader.getName();
+ if (DEFINITIONS_QNAME.equals(name)) {
+ return definitions;
+ }
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ return definitions;
+ }
+
+ public void write(Definitions definitions, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+
+ writeStartDocument(writer, SCA11_NS, DEFINITIONS, new XAttr(TARGET_NAMESPACE, definitions.getTargetNamespace()));
+
+ for (Intent policyIntent : definitions.getIntents()) {
+ extensionProcessor.write(policyIntent, writer, context);
+ }
+
+ for (PolicySet policySet : definitions.getPolicySets()) {
+ extensionProcessor.write(policySet, writer, context);
+ }
+
+ for (Binding binding : definitions.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ for (BindingType bindingType : definitions.getBindingTypes()) {
+ extensionProcessor.write(bindingType, writer, context);
+ }
+
+ for (ImplementationType implType : definitions.getImplementationTypes()) {
+ extensionProcessor.write(implType, writer, context);
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(Definitions scaDefns, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // start by adding all of the top level artifacts into the resolver as there
+ // are many cross artifact references in a definitions file and we don't want
+ // to be dependent on the order things appear
+
+ List<Intent> intents = new ArrayList<Intent>();
+ List<PolicySet> policySets = new ArrayList<PolicySet>();
+ List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
+
+ for (Intent intent : scaDefns.getIntents()) {
+ intents.add(intent);
+ resolver.addModel(intent, context);
+ for (Intent i : intent.getQualifiedIntents()) {
+ intents.add(i);
+ resolver.addModel(i, context);
+ }
+ }
+
+ for (PolicySet policySet : scaDefns.getPolicySets()) {
+ if (policySet.getReferencedPolicySets().isEmpty()) {
+ policySets.add(policySet);
+ } else {
+ referredPolicySets.add(policySet);
+ }
+
+ resolver.addModel(policySet, context);
+ }
+
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
+ resolver.addModel(bindingType, context);
+ }
+
+ for (ImplementationType implType : scaDefns.getImplementationTypes()) {
+ resolver.addModel(implType, context);
+ }
+
+ // now resolve everything to ensure that any references between
+ // artifacts are satisfied
+
+ for (Intent policyIntent : intents)
+ extensionProcessor.resolve(policyIntent, resolver, context);
+
+ for (PolicySet policySet : policySets)
+ extensionProcessor.resolve(policySet, resolver, context);
+
+ for (PolicySet policySet : referredPolicySets)
+ extensionProcessor.resolve(policySet, resolver, context);
+
+ for (Binding binding : scaDefns.getBindings()) {
+ extensionProcessor.resolve(binding, resolver, context);
+ }
+
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
+ extensionProcessor.resolve(bindingType, resolver, context);
+ if (processors.getProcessor(bindingType.getType()) == null){
+ Monitor.error(context.getMonitor(),
+ this,
+ "org.apache.tuscany.sca.definitions.xml.definitions-xml-validation-messages",
+ "BindingTypeNotFound",
+ bindingType.getType().toString());
+ }
+ }
+
+ for (ImplementationType implementationType : scaDefns.getImplementationTypes()) {
+ extensionProcessor.resolve(implementationType, resolver, context);
+ if (processors.getProcessor(implementationType.getType()) == null){
+ Monitor.error(context.getMonitor(),
+ this,
+ "org.apache.tuscany.sca.definitions.xml.definitions-xml-validation-messages",
+ "ImplementationTypeNotFound",
+ implementationType.getType().toString());
+ }
+ }
+
+
+ // Flat intentMap structure by creating a policySet for each one
+ List<PolicySet> copy = new ArrayList<PolicySet>(scaDefns.getPolicySets());
+ for (PolicySet policySet : copy) {
+ //[lresende] Do we need to remove the current policySet and just include the flat one based on qualifiers ?
+ //If we don't, the policy is being resolved to the one that has intentMap and no direct concrete policies
+ boolean remove = false;
+
+ //process intent maps
+ for(IntentMap intentMap : policySet.getIntentMaps()) {
+ for(Qualifier qualifier : intentMap.getQualifiers()) {
+ remove = true;
+
+ PolicySet qualifiedPolicySet = policyFactory.createPolicySet();
+ qualifiedPolicySet.setAppliesTo(policySet.getAppliesTo());
+ qualifiedPolicySet.setAppliesToXPathExpression(policySet.getAttachToXPathExpression());
+ qualifiedPolicySet.setAttachTo(policySet.getAttachTo());
+ qualifiedPolicySet.setAttachToXPathExpression(policySet.getAttachToXPathExpression());
+
+ qualifiedPolicySet.setName(qualifier.getIntent().getName());
+ qualifiedPolicySet.getProvidedIntents().clear();
+ qualifiedPolicySet.getProvidedIntents().add(qualifier.getIntent());
+ qualifiedPolicySet.getPolicies().clear();
+ qualifiedPolicySet.getPolicies().addAll(qualifier.getPolicies());
+
+ scaDefns.getPolicySets().add(qualifiedPolicySet);
+ }
+ }
+
+ if(remove) {
+ scaDefns.getPolicySets().remove(policySet);
+ }
+ }
+ }
+
+ public QName getArtifactType() {
+ return DEFINITIONS_QNAME;
+ }
+
+ public Class<Definitions> getModelType() {
+ return Definitions.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java
new file mode 100644
index 0000000000..38cc4a9de2
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.definitions.xml;
+
+/**
+ * Constants for resource bundle names
+ */
+public interface Messages {
+ String RESOURCE_BUNDLE = "org.apache.tuscany.sca.definitions.xml.definitions-xml-validation-messages";
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
new file mode 100644
index 0000000000..70c71c5f1f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Processor for handling XML models of BindingType meta data definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class BindingTypeProcessor extends ExtensionTypeProcessor {
+
+ public BindingTypeProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ super(policyFactory, extensionProcessor);
+ }
+
+ public BindingTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ super(modelFactories.getFactory(PolicyFactory.class), extensionProcessor);
+ }
+
+ public QName getArtifactType() {
+ return BINDING_TYPE_QNAME;
+ }
+
+ @Override
+ protected ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (extnType instanceof BindingType) {
+ BindingType bindingType = (BindingType)extnType;
+ return resolver.resolveModel(BindingType.class, bindingType, context);
+ } else {
+ return extnType;
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
new file mode 100644
index 0000000000..95d8e67bf7
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Processor for handling XML models of ExtensionType meta data definitions
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class ExtensionTypeProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<ExtensionType>, PolicyConstants {
+
+ private PolicyFactory policyFactory;
+
+
+ protected abstract ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException;
+
+ public ExtensionTypeProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ this.policyFactory = policyFactory;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public ExtensionType read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ QName extType = getArtifactType();
+ QName type = getQName(reader, "type");
+
+ if (type != null) {
+ ExtensionType extensionType = null;
+ if (BINDING_TYPE_QNAME.equals(extType)) {
+ extensionType = policyFactory.createBindingType();
+ } else if (IMPLEMENTATION_TYPE_QNAME.equals(extType)) {
+ extensionType = policyFactory.createImplementationType();
+ } else {
+ error(context.getMonitor(), "UnrecognizedExtensionType", reader, type);
+ return null;
+ //throw new ContributionReadException("Unrecognized ExtensionType - " + type);
+ }
+ extensionType.setType(type);
+ extensionType.setUnresolved(true);
+
+ readAlwaysProvidedIntents(extensionType, reader);
+ readMayProvideIntents(extensionType, reader);
+ return extensionType;
+
+ } else {
+ error(context.getMonitor(), "RequiredAttributeMissing", reader, extType);
+ //throw new ContributionReadException("Required attribute '" + TYPE +
+ //"' missing from BindingType Definition");
+ }
+ return null;
+ }
+
+ private void readAlwaysProvidedIntents(ExtensionType extnType, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, ALWAYS_PROVIDES);
+ if (value != null) {
+ List<Intent> alwaysProvided = extnType.getAlwaysProvidedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ alwaysProvided.add(intent);
+ }
+ }
+ }
+
+ private void readMayProvideIntents(ExtensionType extnType, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, MAY_PROVIDE);
+ if (value != null) {
+ List<Intent> mayProvide = extnType.getMayProvidedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ mayProvide.add(intent);
+ }
+ }
+ }
+
+ public void write(ExtensionType extnType, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+
+ // Write an <sca:bindingType or sca:implementationType>
+ if (extnType instanceof BindingType) {
+ writer.writeStartElement(SCA11_NS, BINDING_TYPE);
+ } else if (extnType instanceof ImplementationType) {
+ writer.writeStartElement(SCA11_NS, IMPLEMENTATION_TYPE);
+ }
+
+ writeAlwaysProvidesIntentsAttribute(extnType, writer);
+ writeMayProvideIntentsAttribute(extnType, writer);
+
+ writer.writeEndElement();
+ }
+
+ private void writeMayProvideIntentsAttribute(ExtensionType extnType, XMLStreamWriter writer)
+ throws XMLStreamException {
+ StringBuffer sb = new StringBuffer();
+ for (Intent intent : extnType.getMayProvidedIntents()) {
+ writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
+ sb.append(intent.getName().getPrefix() + COLON + intent.getName().getLocalPart());
+ sb.append(WHITE_SPACE);
+ }
+
+ if (sb.length() > 0) {
+ writer.writeAttribute(MAY_PROVIDE, sb.toString());
+ }
+ }
+
+ private void writeAlwaysProvidesIntentsAttribute(ExtensionType extnType, XMLStreamWriter writer)
+ throws XMLStreamException {
+ StringBuffer sb = new StringBuffer();
+ for (Intent intent : extnType.getAlwaysProvidedIntents()) {
+ writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
+ sb.append(intent.getName().getPrefix() + COLON + intent.getName().getLocalPart());
+ sb.append(WHITE_SPACE);
+ }
+
+ if (sb.length() > 0) {
+ writer.writeAttribute(ALWAYS_PROVIDES, sb.toString());
+
+ }
+ }
+
+ public void resolve(ExtensionType extnType, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if (extnType != null && extnType.isUnresolved()) {
+ resolveAlwaysProvidedIntents(extnType, resolver, context);
+ resolveMayProvideIntents(extnType, resolver, context);
+ extnType.setUnresolved(false);
+ //resolveExtensionType(extnType, resolver);
+ }
+ }
+
+ private void resolveAlwaysProvidedIntents(ExtensionType extensionType, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> alwaysProvided = new ArrayList<Intent>();
+ for (Intent providedIntent : extensionType.getAlwaysProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ providedIntent = resolver.resolveModel(Intent.class, providedIntent, context);
+ if (!providedIntent.isUnresolved()) {
+ alwaysProvided.add(providedIntent);
+ } else {
+ error(context.getMonitor(), "AlwaysProvidedIntentNotFound", resolver, providedIntent, extensionType);
+ //throw new ContributionResolveException("Always Provided Intent - " + providedIntent
+ //+ " not found for ExtensionType "
+ //+ extensionType);
+ }
+ } else {
+ alwaysProvided.add(providedIntent);
+ }
+ }
+ extensionType.getAlwaysProvidedIntents().clear();
+ extensionType.getAlwaysProvidedIntents().addAll(alwaysProvided);
+ }
+ }
+
+ private void resolveMayProvideIntents(ExtensionType extensionType, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> mayProvide = new ArrayList<Intent>();
+ for (Intent providedIntent : extensionType.getMayProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ providedIntent = resolver.resolveModel(Intent.class, providedIntent, context);
+ if (!providedIntent.isUnresolved()) {
+ mayProvide.add(providedIntent);
+ } else {
+ error(context.getMonitor(), "MayProvideIntentNotFound", resolver, providedIntent, extensionType);
+ //throw new ContributionResolveException("May Provide Intent - " + providedIntent
+ //+ " not found for ExtensionType "
+ //+ extensionType);
+ }
+ } else {
+ mayProvide.add(providedIntent);
+ }
+ }
+ extensionType.getMayProvidedIntents().clear();
+ extensionType.getMayProvidedIntents().addAll(mayProvide);
+ }
+ }
+
+ public Class<ExtensionType> getModelType() {
+ return ExtensionType.class;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
new file mode 100644
index 0000000000..ec4e17385f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Processor for handling XML models of ImplementationType meta data definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImplementationTypeProcessor extends ExtensionTypeProcessor {
+
+ public ImplementationTypeProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ super(policyFactory, extensionProcessor);
+ }
+
+ public ImplementationTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ super(modelFactories.getFactory(PolicyFactory.class), extensionProcessor);
+ }
+
+ public QName getArtifactType() {
+ return IMPLEMENTATION_TYPE_QNAME;
+ }
+
+ @Override
+ protected ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (extnType instanceof ImplementationType) {
+ ImplementationType implType = (ImplementationType)extnType;
+ return resolver.resolveModel(ImplementationType.class, implType, context);
+ } else {
+ return extnType;
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java
new file mode 100644
index 0000000000..296677d8b8
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.Intent.Type;
+
+/**
+ * Processor for handling XML models of PolicyIntent definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntentProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Intent>,
+ PolicyConstants {
+
+ private PolicyFactory policyFactory;
+
+
+ public IntentProcessor(FactoryExtensionPoint modelFactories) {
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ }
+
+ public IntentProcessor(PolicyFactory policyFactory) {
+ this.policyFactory = policyFactory;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ private void warn(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.WARNING,
+ model,
+ message,
+ messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public Intent read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ Intent intent = null;
+ String intentLocalName = reader.getAttributeValue(null, NAME);
+ if (intentLocalName == null) {
+ error(context.getMonitor(), "IntentNameMissing", reader);
+ return null;
+ }
+
+ String intentType = reader.getAttributeValue(null, INTENT_TYPE);
+ if (intentType == null) {
+ intentType = Intent.Type.interaction.name();
+ }
+
+ intent = policyFactory.createIntent();
+
+ // [rfeng] the target namespace is not available, set the local part for now
+ // This will be changed in the definitions processor
+ intent.setName(new QName(intentLocalName));
+ intent.setType(Type.valueOf(intentType));
+
+ readRequiredIntents(intent, reader, context);
+ readExcludedIntents(intent, reader);
+
+ readConstrainedTypes(intent, reader);
+
+ Intent current = intent;
+ int event = reader.getEventType();
+ QName name = null;
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (DESCRIPTION_QNAME.equals(name)) {
+ String text = reader.getElementText();
+ if (text != null) {
+ text = text.trim();
+ }
+ current.setDescription(text);
+ } else if (INTENT_QUALIFIER_QNAME.equals(name)) {
+ String qualifierName = reader.getAttributeValue(null, NAME);
+ String defaultQ = reader.getAttributeValue(null, DEFAULT);
+ boolean isDefault = defaultQ == null ? false : Boolean.parseBoolean(defaultQ);
+ String qualifiedIntentName = intentLocalName + QUALIFIER + qualifierName;
+ Intent qualified = policyFactory.createIntent();
+ qualified.setType(intent.getType());
+ qualified.setName(new QName(qualifiedIntentName));
+ if (isDefault) {
+ if (intent.getDefaultQualifiedIntent() == null){
+ intent.setDefaultQualifiedIntent(qualified);
+ } else {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.RESOURCE_BUNDLE,
+ "MultipleDefaultQualifiers",
+ intent.getName().toString());
+ }
+ }
+
+ // check that the qualifier is unique
+ if ( !intent.getQualifiedIntents().contains(qualified)){
+ intent.getQualifiedIntents().add(qualified);
+ } else {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.RESOURCE_BUNDLE,
+ "QualifierIsNotUnique",
+ intent.getName().toString(),
+ qualifierName);
+ }
+
+ qualified.setQualifiableIntent(intent);
+ current = qualified;
+ }
+ break;
+ }
+ case END_ELEMENT: {
+ name = reader.getName();
+ if (INTENT_QUALIFIER_QNAME.equals(name)) {
+ current = intent;
+ }
+ break;
+ }
+ }
+ if (event == END_ELEMENT && POLICY_INTENT_QNAME.equals(reader.getName())) {
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ // REVIEW: [rfeng] What's going to happen if there is only one qualified intent
+ if (intent.getQualifiedIntents().size() == 1) {
+ intent.setDefaultQualifiedIntent(intent.getQualifiedIntents().get(0));
+ }
+ return intent;
+ }
+
+ public void write(Intent intent, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ // Write an <sca:intent>
+ writer.writeStartElement(PolicyConstants.SCA11_NS, INTENT);
+ writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
+ writer.writeAttribute(PolicyConstants.NAME, intent.getName().getPrefix() + COLON
+ + intent.getName().getLocalPart());
+ if (intent.getRequiredIntents() != null && intent.getRequiredIntents().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent requiredIntents : intent.getRequiredIntents()) {
+ sb.append(requiredIntents.getName());
+ sb.append(" ");
+ }
+ writer.writeAttribute(PolicyConstants.REQUIRES, sb.toString());
+ }
+
+ if (intent.getExcludedIntents() != null && intent.getExcludedIntents().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent excludedIntents : intent.getExcludedIntents()) {
+ sb.append(excludedIntents.getName());
+ sb.append(" ");
+ }
+ writer.writeAttribute(PolicyConstants.EXCLUDES, sb.toString());
+ }
+
+ if (intent.getConstrainedTypes() != null && intent.getConstrainedTypes().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (ExtensionType contrainedArtifact : intent.getConstrainedTypes()) {
+ sb.append(contrainedArtifact.getType().getPrefix());
+ sb.append(':').append(contrainedArtifact.getType().getLocalPart());
+ sb.append(" ");
+ }
+ writer.writeAttribute(CONSTRAINS, sb.toString());
+ }
+
+ if (intent.getDescription() != null && intent.getDescription().length() > 0) {
+ writer.writeStartElement(PolicyConstants.SCA11_NS, DESCRIPTION);
+ writer.writeCData(intent.getDescription());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ private void resolveContrainedTypes(Intent intent, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ Collection<ExtensionType> resolvedTypes = new HashSet<ExtensionType>();
+ for (ExtensionType extensionType : intent.getConstrainedTypes()) {
+ if (ExtensionType.BINDING_BASE.equals(extensionType.getType()) || ExtensionType.IMPLEMENTATION_BASE
+ .equals(extensionType.getType())) {
+ // HACK: Mark sca:binding and sca:implementation as resolved
+ extensionType.setUnresolved(false);
+ resolvedTypes.add(extensionType);
+ } else {
+ ExtensionType resolved = resolver.resolveModel(ExtensionType.class, extensionType, context);
+ if (!resolved.isUnresolved() || resolved != extensionType) {
+ resolvedTypes.add(resolved);
+ } else {
+ warn(context.getMonitor(), "ConstrainedTypeNotFound", intent, extensionType, intent);
+ }
+ }
+ }
+ intent.getConstrainedTypes().clear();
+ intent.getConstrainedTypes().addAll(resolvedTypes);
+ }
+
+ private void resolveProfileIntent(Intent intent, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ Monitor monitor = context.getMonitor();
+ // FIXME: Need to check for cyclic references first i.e an A requiring B
+ // and then B requiring A...
+ if (intent != null && !intent.getRequiredIntents().isEmpty()) {
+ // resolve all required intents
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ for (Intent required : intent.getRequiredIntents()) {
+ if (required.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, required, context);
+ // At this point, when the required intent is not resolved, it does not mean
+ // its undeclared, chances are that their dependency are not resolved yet.
+ // Lets try to resolve them first.
+ if (resolved.isUnresolved()) {
+ if (((resolved).getRequiredIntents()).contains(intent)) {
+ error(monitor, "CyclicReferenceFound", resolver, required, intent);
+ return;
+ }
+ }
+
+ if (!resolved.isUnresolved() || resolved != required) {
+ requiredIntents.add(resolved);
+ } else {
+ error(monitor, "RequiredIntentNotFound", resolver, required, intent);
+ return;
+ //throw new ContributionResolveException("Required Intent - " + requiredIntent
+ //+ " not found for Intent " + policyIntent);
+ }
+ } else {
+ requiredIntents.add(required);
+ }
+ }
+ intent.getRequiredIntents().clear();
+ intent.getRequiredIntents().addAll(requiredIntents);
+ }
+ }
+
+ private void resolveQualifiedIntent(Intent qualifed, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ if (qualifed != null) {
+ //resolve the qualifiable intent
+ Intent parent = qualifed.getQualifiableIntent();
+ if (parent == null) {
+ return;
+ }
+ if (parent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, parent, context);
+ // At this point, when the qualifiable intent is not resolved, it does not mean
+ // its undeclared, chances are that their dependency are not resolved yet.
+ // Lets try to resolve them first.
+
+ if (!resolved.isUnresolved() || resolved != qualifed) {
+ qualifed.setQualifiableIntent(resolved);
+ } else {
+ error(context.getMonitor(), "QualifiableIntentNotFound", resolver, parent, qualifed);
+ //throw new ContributionResolveException("Qualifiable Intent - " + qualifiableIntent
+ //+ " not found for Intent " + policyIntent);
+ }
+ }
+ }
+ }
+
+ public void resolve(Intent intent, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ if (intent != null && intent.isUnresolved()) {
+ resolveProfileIntent(intent, resolver, context);
+ resolveExcludedIntents(intent, resolver, context);
+ resolveQualifiedIntent(intent, resolver, context);
+ resolveContrainedTypes(intent, resolver, context);
+ intent.setUnresolved(false);
+ }
+ }
+
+ public QName getArtifactType() {
+ return POLICY_INTENT_QNAME;
+ }
+
+ private void readConstrainedTypes(Intent policyIntent, XMLStreamReader reader) throws ContributionReadException {
+ String value = reader.getAttributeValue(null, CONSTRAINS);
+ if (value != null) {
+ List<ExtensionType> constrainedTypes = policyIntent.getConstrainedTypes();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ ExtensionType extensionType = policyFactory.createExtensionType();
+ extensionType.setType(qname);
+ constrainedTypes.add(extensionType);
+ }
+ }
+ }
+
+ private void readRequiredIntents(Intent intent, XMLStreamReader reader, ProcessorContext context) {
+ String value = reader.getAttributeValue(null, REQUIRES);
+ if (value != null) {
+ List<Intent> requiredIntents = intent.getRequiredIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent required = policyFactory.createIntent();
+ required.setName(qname);
+ required.setUnresolved(true);
+ requiredIntents.add(required);
+ }
+
+ // Check that a profile intent does not have "." in its name
+ if (requiredIntents.size() > 0) {
+ if (intent.getName().getLocalPart().contains(".")){
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.RESOURCE_BUNDLE,
+ "ProfileIntentNameWithPeriod",
+ intent.getName().toString());
+ }
+ }
+ }
+ }
+
+ private void readExcludedIntents(Intent intent, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, EXCLUDES);
+ if (value != null) {
+ List<Intent> excludedIntents = intent.getExcludedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent excluded = policyFactory.createIntent();
+ excluded.setName(qname);
+ excluded.setUnresolved(true);
+ excludedIntents.add(excluded);
+ }
+ }
+ }
+
+ private void resolveExcludedIntents(Intent policyIntent, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (policyIntent != null) {
+ // resolve all excluded intents
+ List<Intent> excludedIntents = new ArrayList<Intent>();
+ for (Intent excludedIntent : policyIntent.getExcludedIntents()) {
+ if (excludedIntent.isUnresolved()) {
+ Intent resolvedExcludedIntent = resolver.resolveModel(Intent.class, excludedIntent, context);
+ if (!resolvedExcludedIntent.isUnresolved() || resolvedExcludedIntent != excludedIntent) {
+ excludedIntents.add(resolvedExcludedIntent);
+ } else {
+ error(context.getMonitor(), "ExcludedIntentNotFound", resolver, excludedIntent, policyIntent);
+ return;
+ //throw new ContributionResolveException("Excluded Intent " + excludedIntent
+ //+ " not found for intent " + policyIntent);
+ }
+ } else {
+ excludedIntents.add(excludedIntent);
+ }
+ }
+ policyIntent.getExcludedIntents().clear();
+ policyIntent.getExcludedIntents().addAll(excludedIntents);
+ }
+ }
+
+ public Class<Intent> getModelType() {
+ return Intent.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java
new file mode 100644
index 0000000000..ee8b5274cc
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+/**
+ * Constants for resource bundle names
+ */
+public interface Messages {
+ String RESOURCE_BUNDLE = "org.apache.tuscany.sca.policy.xml.policy-xml-validation-messages";
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
new file mode 100644
index 0000000000..69c5a11e9b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * constants related to policy framework
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PolicyConstants {
+ String WHITE_SPACE = " ";
+ String COLON = ":";
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ String TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ String INTENT = "intent";
+ String POLICY_SET = "policySet";
+ String POLICY_SET_REFERENCE = "policySetReference";
+ String INTENT_MAP = "intentMap";
+ String NAME = "name";
+ String TARGET_NAMESPACE = "targetNamespace";
+ String SCA_DEFINITIONS = "definitions";
+ String CONSTRAINS = "constrains";
+ String DESCRIPTION = "description";
+ String PROVIDES = "provides";
+ String APPLIES_TO = "appliesTo";
+ String ATTACH_TO = "attachTo";
+ String ALWAYS_APPLIES_TO = "alwaysAppliesTo";
+ String QUALIFIER = ".";
+ String INTENT_QUALIFIER = "qualifier";
+ String INTENT_MAP_QUALIFIER = "qualifier";
+ String REQUIRES = "requires";
+ String EXCLUDES = "excludes";
+ String DEFAULT = "default";
+
+ String ALWAYS_PROVIDES = "alwaysProvides";
+ String MAY_PROVIDE = "mayProvide";
+ String INTENT_TYPE = "intentType";
+ String IMPLEMENTATION_TYPE = "implementationType";
+ String BINDING_TYPE = "bindingType";
+ QName IMPLEMENTATION_TYPE_QNAME = new QName(SCA11_NS, IMPLEMENTATION_TYPE);
+ QName BINDING_TYPE_QNAME = new QName(SCA11_NS, BINDING_TYPE);
+ String BINDING = "binding";
+ String IMPLEMENTATION = "implementation";
+
+ QName POLICY_INTENT_QNAME = new QName(SCA11_NS, INTENT);
+ QName POLICY_SET_QNAME = new QName(SCA11_NS, POLICY_SET);
+ QName POLICY_INTENT_MAP_QNAME = new QName(SCA11_NS, INTENT_MAP);
+ QName SCA_DEFINITIONS_QNAME = new QName(SCA11_NS, SCA_DEFINITIONS);
+ QName DESCRIPTION_QNAME = new QName(SCA11_NS, DESCRIPTION);
+ QName POLICY_INTENT_MAP_QUALIFIER_QNAME = new QName(SCA11_NS, INTENT_MAP_QUALIFIER);
+ QName POLICY_SET_REFERENCE_QNAME = new QName(SCA11_NS, POLICY_SET_REFERENCE);
+ QName INTENT_QUALIFIER_QNAME = new QName(SCA11_NS, INTENT_QUALIFIER);
+
+ String QUALIFIED_INTENT_CONSTRAINS_ERROR = " - Qualified Intents must not specify 'constrains' attribute";
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
new file mode 100644
index 0000000000..68475a208b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
@@ -0,0 +1,572 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.policy.xml.PolicyConstants.SCA11_NS;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.apache.tuscany.sca.common.xml.xpath.XPathHelper;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+/**
+ * Processor for handling XML models of PolicySet definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<PolicySet>,
+ PolicyConstants {
+
+ private PolicyFactory policyFactory;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private XPathHelper xpathHelper;
+
+ // private XPathFactory xpathFactory;
+
+ public PolicySetProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor<Object> extensionProcessor) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.extensionProcessor = extensionProcessor;
+ this.xpathHelper = XPathHelper.getInstance(registry);
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public PolicySet read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException,
+ XMLStreamException {
+ PolicySet policySet = null;
+ Monitor monitor = context.getMonitor();
+ String policySetName = reader.getAttributeValue(null, NAME);
+ String appliesTo = reader.getAttributeValue(null, APPLIES_TO);
+ if (policySetName == null || appliesTo == null) {
+ if (policySetName == null)
+ error(monitor, "PolicySetNameMissing", reader);
+ if (appliesTo == null)
+ error(monitor, "PolicySetAppliesToMissing", reader);
+ return policySet;
+ }
+
+ policySet = policyFactory.createPolicySet();
+ policySet.setName(new QName(policySetName));
+
+ //TODO: with 1.0 version of specs the applies to xpath is given related to the immediate
+ //parent whereas the runtime evaluates the xpath aginst the composite element. What the runtime
+ //is doing is what the future version of the specs could be tending towards. When that happens
+ //this 'if' must be deleted
+ if (appliesTo != null && !appliesTo.startsWith("/")) {
+ appliesTo = "//" + appliesTo;
+ }
+
+ policySet.setAppliesTo(appliesTo);
+
+ if (appliesTo != null) {
+ try {
+ XPath path = xpathHelper.newXPath();
+ NamespaceContext nsContext = xpathHelper.getNamespaceContext(appliesTo, reader.getNamespaceContext());
+ // path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(context));
+ XPathExpression expression = xpathHelper.compile(path, nsContext, appliesTo);
+ policySet.setAppliesToXPathExpression(expression);
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", policySet, ce);
+ //throw ce;
+ }
+ }
+
+ String attachTo = reader.getAttributeValue(null, ATTACH_TO);
+ if (attachTo != null) {
+ try {
+ XPath path = xpathHelper.newXPath();
+ NamespaceContext nsContext = xpathHelper.getNamespaceContext(attachTo, reader.getNamespaceContext());
+ path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(nsContext));
+
+ attachTo = PolicyXPathFunction.normalize(attachTo,getSCAPrefix(nsContext));
+ XPathExpression expression = xpathHelper.compile(path, nsContext, attachTo);
+ policySet.setAttachTo(attachTo);
+ policySet.setAttachToXPathExpression(expression);
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", policySet, ce);
+ //throw ce;
+ }
+
+ }
+
+ readProvidedIntents(policySet, reader);
+
+ int event = reader.getEventType();
+ QName name = null;
+ reader.next();
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (POLICY_INTENT_MAP_QNAME.equals(name)) {
+ Intent mappedIntent = policyFactory.createIntent();
+ String provides = reader.getAttributeValue(null, PROVIDES);
+ if (provides != null) {
+ mappedIntent.setName(getQName(reader, PROVIDES));
+ if (policySet.getProvidedIntents().contains(mappedIntent)) {
+ readIntentMap(reader, policySet, mappedIntent, context);
+ } else {
+ error(monitor, "IntentNotSpecified", policySet, policySetName);
+ }
+ } else {
+ error(monitor, "IntentMapProvidesMissing", reader, policySetName);
+ }
+ } else if (POLICY_SET_REFERENCE_QNAME.equals(name)) {
+ PolicySet referredPolicySet = policyFactory.createPolicySet();
+ String referencename = reader.getAttributeValue(null, NAME);
+ if (referencename != null) {
+ referredPolicySet.setName(getQName(reader, NAME));
+ policySet.getReferencedPolicySets().add(referredPolicySet);
+ } else {
+ error(monitor, "PolicySetReferenceNameMissing", reader, policySetName);
+ }
+ } /*else if ( WS_POLICY_QNAME.equals(name) ) {
+ OMElement policyElement = loadElement(reader);
+ org.apache.neethi.Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
+ policySet.getPolicies().add(wsPolicy);
+ } */else {
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ PolicyExpression exp = policyFactory.createPolicyExpression();
+ exp.setName(name);
+ exp.setPolicy(extension);
+ // check that all the policies in the policy set are
+ // expressed in the same language. Compare against the
+ // first expression we added
+ if ((policySet.getPolicies().size() > 0) && (!policySet.getPolicies().get(0).getName()
+ .equals(name))) {
+ error(monitor, "PolicyLanguageMissmatch", reader, policySet.getName(), policySet
+ .getPolicies().get(0).getName(), name);
+ } else {
+ policySet.getPolicies().add(exp);
+ }
+ }
+ }
+ break;
+ }
+ }
+ if (event == END_ELEMENT) {
+ if (POLICY_SET_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ return policySet;
+ }
+
+ private String getSCAPrefix(NamespaceContext nsContext) {
+
+ Iterator<String> iter = nsContext.getPrefixes(SCA11_NS);
+ while (iter.hasNext()) {
+ String prefix = iter.next();
+ if (!prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
+ return prefix;
+ }
+ }
+
+ return "__sca";
+ }
+
+ public void readIntentMap(XMLStreamReader reader, PolicySet policySet, Intent mappedIntent, ProcessorContext context)
+ throws ContributionReadException {
+ Monitor monitor = context.getMonitor();
+ QName name = reader.getName();
+ if (POLICY_INTENT_MAP_QNAME.equals(name)) {
+
+ IntentMap intentMap = policyFactory.createIntentMap();
+ QName intentName = getQName(reader, INTENT_MAP);
+ intentMap.setProvidedIntent(mappedIntent);
+
+ if (!policySet.getIntentMaps().contains(intentMap)) {
+ policySet.getIntentMaps().add(intentMap);
+ } else {
+ Monitor.error(context.getMonitor(), this, Messages.RESOURCE_BUNDLE, "IntentMapIsNotUnique", policySet
+ .getName().toString(), mappedIntent.getName().getLocalPart());
+ }
+
+ String qualifierName = null;
+ String qualfiedIntentName = null;
+ Intent qualifiedIntent = null;
+
+ Qualifier qualifier = null;
+
+ int event = reader.getEventType();
+ try {
+ reader.next();
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (POLICY_INTENT_MAP_QUALIFIER_QNAME.equals(name)) {
+ qualifierName = getString(reader, NAME);
+ if (qualifierName != null) {
+ qualfiedIntentName =
+ mappedIntent.getName().getLocalPart() + QUALIFIER + qualifierName;
+ qualifiedIntent = policyFactory.createIntent();
+ qualifiedIntent.setName(new QName(mappedIntent.getName().getNamespaceURI(),
+ qualfiedIntentName));
+ qualifier = policyFactory.createQualifier();
+ qualifier.setIntent(qualifiedIntent);
+ intentMap.getQualifiers().add(qualifier);
+
+ } else {
+ error(monitor, "QualifierNameMissing", reader, policySet.getName());
+ }
+ } else if (POLICY_INTENT_MAP_QNAME.equals(name)) {
+ QName providedIntent = getQName(reader, PROVIDES);
+ if (qualifierName.equals(providedIntent.getLocalPart())) {
+ readIntentMap(reader, policySet, qualifiedIntent, context);
+ } else {
+ error(monitor,
+ "IntentMapDoesNotMatch",
+ providedIntent,
+ providedIntent,
+ qualifierName,
+ policySet);
+ //throw new ContributionReadException("Intent provided by IntentMap " +
+ //providedIntent + " does not match parent qualifier " + qualifierName +
+ //" in policyset - " + policySet);
+ }
+ } else {
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null && qualifier != null) {
+ PolicyExpression exp = policyFactory.createPolicyExpression();
+ exp.setName(name);
+ exp.setPolicy(extension);
+ qualifier.getPolicies().add(exp);
+ }
+ }
+ break;
+ }
+ }
+ if (event == END_ELEMENT && POLICY_INTENT_MAP_QNAME.equals(reader.getName())) {
+ break;
+ }
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", reader, ce);
+ throw ce;
+ }
+ }
+ }
+
+ public void write(PolicySet policySet, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ // Write an <sca:policySet>
+ writer.writeStartElement(SCA11_NS, POLICY_SET);
+ writer.writeNamespace(policySet.getName().getPrefix(), policySet.getName().getNamespaceURI());
+ writer.writeAttribute(NAME, policySet.getName().getPrefix() + COLON + policySet.getName().getLocalPart());
+ writer.writeAttribute(APPLIES_TO, policySet.getAppliesTo());
+ writer.writeAttribute(ATTACH_TO, policySet.getAttachTo());
+
+ writeProvidedIntents(policySet, writer);
+
+ writer.writeEndElement();
+ }
+
+ private void readProvidedIntents(PolicySet policySet, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, PROVIDES);
+ if (value != null) {
+ List<Intent> providedIntents = policySet.getProvidedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ providedIntents.add(intent);
+ }
+ }
+ }
+
+ private void writeProvidedIntents(PolicySet policySet, XMLStreamWriter writer) throws XMLStreamException {
+ if (!policySet.getProvidedIntents().isEmpty()) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent providedIntents : policySet.getProvidedIntents()) {
+ sb.append(getQualifiedName(providedIntents.getName(), writer));
+ sb.append(" ");
+ }
+ // Remove the last space
+ sb.deleteCharAt(sb.length() - 1);
+ writer.writeAttribute(PolicyConstants.PROVIDES, sb.toString());
+ }
+ }
+
+ private String getQualifiedName(QName name, XMLStreamWriter writer) throws XMLStreamException {
+ String local = name.getLocalPart();
+ String prefix = writer.getPrefix(name.getNamespaceURI());
+ if (prefix != null && prefix.length() > 0) {
+ return prefix + ':' + local;
+ } else {
+ return local;
+ }
+ }
+
+ private void resolvePolicies(PolicySet policySet, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ boolean unresolved = false;
+ if (policySet != null) {
+ for (Object o : policySet.getPolicies()) {
+ extensionProcessor.resolve(o, resolver, context);
+ /*if ( o instanceof Policy && ((Policy)o).isUnresolved() ) {
+ unresolved = true;
+ }*/
+ }
+ policySet.setUnresolved(unresolved);
+ }
+ }
+
+ public QName getArtifactType() {
+ return POLICY_SET_QNAME;
+ }
+
+ public Class<PolicySet> getModelType() {
+ return PolicySet.class;
+ }
+
+ private void resolveProvidedIntents(PolicySet policySet, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (policySet != null) {
+ //resolve all provided intents
+ List<Intent> providedIntents = new ArrayList<Intent>();
+ for (Intent providedIntent : policySet.getProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, providedIntent, context);
+ if (!resolved.isUnresolved() || resolved != providedIntent) {
+ providedIntents.add(resolved);
+ } else {
+ error(context.getMonitor(), "ProvidedIntentNotFound", policySet, providedIntent, policySet);
+ return;
+ //throw new ContributionResolveException("Provided Intent - " + providedIntent
+ //+ " not found for PolicySet " + policySet);
+ }
+ } else {
+ providedIntents.add(providedIntent);
+ }
+ }
+ policySet.getProvidedIntents().clear();
+ policySet.getProvidedIntents().addAll(providedIntents);
+ }
+ }
+
+ private void resolveIntentsInMappedPolicies(PolicySet policySet, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ Monitor monitor = context.getMonitor();
+ for (IntentMap intentMap : policySet.getIntentMaps()) {
+ Intent intent = intentMap.getProvidedIntent();
+ if (intent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, intent, context);
+ if (!resolved.isUnresolved() || resolved != intent) {
+ intentMap.setProvidedIntent(resolved);
+ } else {
+ error(monitor, "MappedIntentNotFound", policySet, intent, policySet);
+ return;
+ //throw new ContributionResolveException("Mapped Intent - " + mappedIntent
+ //+ " not found for PolicySet " + policySet);
+ }
+ }
+ for (Qualifier qualifier : intentMap.getQualifiers()) {
+ intent = qualifier.getIntent();
+ if (intent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, intent, context);
+ if (!resolved.isUnresolved() || resolved != intent) {
+ qualifier.setIntent(resolved);
+ } else {
+ error(monitor, "MappedIntentNotFound", policySet, intent, policySet);
+ return;
+ //throw new ContributionResolveException("Mapped Intent - " + mappedIntent
+ //+ " not found for PolicySet " + policySet);
+ }
+ }
+ for (PolicyExpression exp : qualifier.getPolicies()) {
+ // FIXME: How to resolve the policies?
+ }
+ }
+ // validate that the intent map has a qualifier for each
+ // intent qualifier. The above code has already checked that the
+ // qualifiers that are there are resolved
+ Intent providedIntent = intentMap.getProvidedIntent();
+ if (intentMap.getQualifiers().size() != providedIntent.getQualifiedIntents().size()) {
+ String missingQualifiers = "";
+ for (Intent loopQualifiedIntent : providedIntent.getQualifiedIntents()) {
+ boolean found = false;
+ for (Qualifier loopQualifier : intentMap.getQualifiers()) {
+ if (loopQualifier.getIntent().getName().equals(loopQualifiedIntent.getName())) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ missingQualifiers += loopQualifiedIntent.getName().getLocalPart() + " ";
+ }
+ }
+ if (missingQualifiers.length() > 0) {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.RESOURCE_BUNDLE,
+ "IntentMapMissingQualifiers",
+ policySet.getName().toString(),
+ providedIntent.getName().getLocalPart(),
+ missingQualifiers);
+ }
+ }
+ }
+
+ }
+
+ private void resolveReferredPolicySets(PolicySet policySet, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+
+ List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
+ for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+ if (referredPolicySet.isUnresolved()) {
+ PolicySet resolved = resolver.resolveModel(PolicySet.class, referredPolicySet, context);
+ if (!resolved.isUnresolved() || resolved != referredPolicySet) {
+ referredPolicySets.add(resolved);
+ } else {
+ error(context.getMonitor(), "ReferredPolicySetNotFound", policySet, referredPolicySet, policySet);
+ return;
+ //throw new ContributionResolveException("Referred PolicySet - " + referredPolicySet
+ //+ "not found for PolicySet - " + policySet);
+ }
+ } else {
+ referredPolicySets.add(referredPolicySet);
+ }
+ }
+ policySet.getReferencedPolicySets().clear();
+ policySet.getReferencedPolicySets().addAll(referredPolicySets);
+ }
+
+ private void includeReferredPolicySets(PolicySet policySet, PolicySet referredPolicySet) {
+ for (PolicySet furtherReferredPolicySet : referredPolicySet.getReferencedPolicySets()) {
+ includeReferredPolicySets(referredPolicySet, furtherReferredPolicySet);
+ }
+ policySet.getPolicies().addAll(referredPolicySet.getPolicies());
+ policySet.getIntentMaps().addAll(referredPolicySet.getIntentMaps());
+ }
+
+ public void resolve(PolicySet policySet, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (policySet != null && policySet.isUnresolved()) {
+ resolveProvidedIntents(policySet, resolver, context);
+ resolveIntentsInMappedPolicies(policySet, resolver, context);
+ resolveReferredPolicySets(policySet, resolver, context);
+
+ for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+ includeReferredPolicySets(policySet, referredPolicySet);
+ }
+
+ if (policySet.isUnresolved()) {
+ //resolve the policy attachments
+ resolvePolicies(policySet, resolver, context);
+
+ /*if ( !policySet.isUnresolved() ) {
+ resolver.addModel(policySet);
+ }*/
+ }
+
+ policySet.setUnresolved(false);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java
new file mode 100644
index 0000000000..d0b45b2d7d
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java
@@ -0,0 +1,294 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * The SCA-defined XPath function
+ */
+public class PolicyXPathFunction implements XPathFunction {
+ private static Logger logger = Logger.getLogger(PolicyXPathFunction.class.getName());
+
+ static final QName InterfaceRef = new QName(PolicyConstants.SCA11_NS, "InterfaceRef");
+ static final QName OperationRef = new QName(PolicyConstants.SCA11_NS, "OperationRef");
+ static final QName MessageRef = new QName(PolicyConstants.SCA11_NS, "MessageRef");
+ static final QName IntentRefs = new QName(PolicyConstants.SCA11_NS, "IntentRefs");
+ static final QName URIRef = new QName(PolicyConstants.SCA11_NS, "URIRef");
+
+ static final Set<QName> functions =
+ new HashSet<QName>(Arrays.asList(InterfaceRef, OperationRef, MessageRef, IntentRefs, URIRef));
+
+ private NamespaceContext namespaceContext;
+ private final QName functionName;
+
+ public PolicyXPathFunction(NamespaceContext namespaceContext, QName functionName) {
+ super();
+ this.namespaceContext = namespaceContext;
+ this.functionName = functionName;
+ }
+
+ private Node getContextNode(List args) {
+ if (args.size() >= 2) {
+ NodeList nodeList = (NodeList)args.get(1);
+ if (nodeList.getLength() > 0) {
+ return nodeList.item(0);
+ }
+ }
+ return null;
+ }
+
+ public Object evaluate(List args) throws XPathFunctionException {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(functionName + "(" + args + ")");
+ }
+
+ String arg = (String)args.get(0);
+ Node node = getContextNode(args);
+ /**
+ * If the xpath expression that contains the function does not select any nodes
+ * (eg IntentRefs('someIntent')), the context node passed in will be a Document.
+ * In this case we need to iterate over every Node in the Document and evaluate it.
+ *
+ * If the xpath expression does select nodes (eg //sca:component[IntentRefs('someIntent')])
+ * then xpath will call evaluate for each node and we only need to return the result for that
+ * node.
+ */
+ if ( node instanceof Document )
+ return evaluateDocument(arg, (Document)node);
+ else
+ return evaluateNode(arg, node);
+ }
+
+ public Object evaluateNode(String arg, Node node) {
+ if (InterfaceRef.equals(functionName)) {
+ return evaluateInterface(arg, node);
+ } else if (OperationRef.equals(functionName)) {
+ String[] params = arg.split("/");
+ if (params.length != 2) {
+ throw new IllegalArgumentException("Invalid argument: " + arg);
+ }
+ String interfaceName = params[0];
+ String operationName = params[1];
+ return evaluateOperation(interfaceName, operationName, node);
+ } else if (MessageRef.equals(functionName)) {
+ String[] params = arg.split("/");
+ if (params.length != 3) {
+ throw new IllegalArgumentException("Invalid argument: " + arg);
+ }
+ String interfaceName = params[0];
+ String operationName = params[1];
+ String messageName = params[2];
+ return evaluateMessage(interfaceName, operationName, messageName, node);
+ } else if (URIRef.equals(functionName)) {
+ return evaluateURI(arg, node);
+ } else if (IntentRefs.equals(functionName)) {
+ String[] intents = arg.split("(\\s)+");
+ return evaluateIntents(intents, node);
+ } else {
+ return Boolean.FALSE;
+ }
+ }
+
+ private class NodeListImpl implements NodeList {
+
+ private ArrayList<Node> list;
+
+ public NodeListImpl() {
+ this.list = new ArrayList<Node>();
+ }
+ public int getLength() {
+ return this.list.size();
+ }
+
+ public Node item(int index) {
+ return this.list.get(index);
+ }
+ public boolean add(Node node) {
+ return this.list.add(node);
+
+ }
+
+ }
+ private Object evaluateDocument(String arg, Document doc) {
+ NodeListImpl retList = new NodeListImpl();
+ NodeList elements = doc.getElementsByTagName("*");
+ for ( int i=0; i < elements.getLength(); i++) {
+ Object node = evaluateNode(arg, elements.item(i));
+ if ( node != null )
+ retList.add((Node)node);
+ }
+ return retList;
+ }
+
+ private Boolean evaluateInterface(String interfaceName, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private Boolean evaluateOperation(String interfaceName, String operationName, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private Boolean evaluateMessage(String interfaceName, String operationName, String messageName, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private Boolean evaluateURI(String uri, Node node) {
+ return Boolean.FALSE;
+ }
+
+ /**
+ * Evaluates a single node for the given intents.
+ * @param intents
+ * @param node
+ * @return
+ */
+ private Object evaluateIntents(String[] intents, Node node) {
+ if ( node == null )
+ return false;
+
+ if ( node.getAttributes() != null ) {
+ for ( int i=0; i < node.getAttributes().getLength(); i++) {
+ Node attr = node.getAttributes().item(i);
+
+ if ( "requires".equalsIgnoreCase(attr.getNodeName())) {
+
+ for ( int j = 0; j < intents.length; j++ ) {
+ // Check negative intents
+ if ( intents[j].startsWith("!")) {
+ if ( matchIntent(intents[j].substring(1), attr, node.getNamespaceURI()))
+ return null;
+ } else if ( !matchIntent(intents[j], attr, node.getNamespaceURI())){
+ return null;
+ }
+ }
+ return node;
+ }
+
+ }
+ }
+
+ return null;
+ }
+
+
+
+ /**
+ * Determine whether the given intent is present in the "requires" attribute
+ * @param intent
+ * @param node
+ * @param namespaceURI
+ * @return
+ */
+ private boolean matchIntent(String intent, Node node, String namespaceURI) {
+ String[] requires = node.getNodeValue().split("(\\s)+");
+ QName intentName = getStringAsQName(intent);
+
+
+ for ( int i=0; i < requires.length; i++ ) {
+ QName nodeName = null;
+ int idx = requires[i].indexOf(':');
+
+ // No prefix specified
+ if ( idx == -1 ) {
+ nodeName = new QName(namespaceURI, requires[i]);
+ } else {
+ String prefix = requires[i].substring(0, idx);
+ String name = requires[i].substring(idx + 1);
+ String ns = node.lookupNamespaceURI(prefix);
+ nodeName = new QName(ns, name, prefix);
+ }
+ if ( intentName.equals(nodeName))
+ return true;
+ }
+ return false;
+ }
+
+
+ private QName getStringAsQName(String intent) {
+ int idx = intent.indexOf(':');
+ if (idx == -1)
+ return new QName(intent);
+
+ String prefix = intent.substring(0, idx);
+ intent = intent.substring(idx + 1);
+
+ return new QName(namespaceContext.getNamespaceURI(prefix), intent, prefix);
+
+ }
+
+
+ private static Pattern FUNCTION;
+ static {
+ String functionPattern = "(URIRef|InterfaceRef|OperationRef|MessageRef|IntentRefs)\\s*\\(([^\\)]*)\\)";
+ FUNCTION = Pattern.compile(functionPattern);
+ }
+
+ /** Adds the node as an argument to the XPath function.
+ * Required in order to have access to the NodeList within the function
+ */
+ public static String normalize(String attachTo, String scaPrefix) {
+ // Get rid of any whitespace
+ attachTo = attachTo.trim();
+
+ Matcher matcher = FUNCTION.matcher(attachTo);
+ boolean result = matcher.find();
+ if (result) {
+ StringBuffer sb = new StringBuffer();
+ do {
+ String function = matcher.group(1);
+ String args = matcher.group(2);
+ if ( (matcher.start() == 0) || (attachTo.charAt( matcher.start() -1) != ':' )) {
+ function = scaPrefix + ":" + function;
+ }
+ String replacement = null;
+ if (args.trim().length() > 0) {
+ replacement = function + "(" + args + "," + "self::node())";
+ } else {
+ replacement = function + "(self::node())";
+ }
+ matcher.appendReplacement(sb, replacement);
+ result = matcher.find();
+ } while (result);
+
+ matcher.appendTail(sb);
+ return sb.toString();
+ }
+ return attachTo;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java
new file mode 100644
index 0000000000..ca44667903
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionResolver;
+
+/**
+ * A resolver that handles SCA-defined XPath functions
+ *
+ * Interface Related Functions
+ * <ul>
+ * <li>InterfaceRef( InterfaceName )
+ * <li>OperationRef( InterfaceName/OperationName )
+ * <li>MessageRef( InterfaceName/OperationName/MessageName )
+ * </ul>
+ *
+ * Intent Related Functions
+ * <ul>
+ * <li>IntentRefs( IntentList )
+ * </ul>
+ *
+ * URI Based Function
+ * <ul>
+ * <li>URIRef( URI )
+ * </ul>
+ */
+public class PolicyXPathFunctionResolver implements XPathFunctionResolver {
+ private NamespaceContext namespaceContext;
+
+ public PolicyXPathFunctionResolver(NamespaceContext namespaceContext) {
+ super();
+ this.namespaceContext = namespaceContext;
+ }
+
+ public XPathFunction resolveFunction(QName functionName, int arity) {
+ if (functionName == null) {
+ throw new NullPointerException("Function name is null");
+ }
+ if (PolicyXPathFunction.functions.contains(functionName)) {
+ if (arity >= 1) {
+ // We are relaxing the arity here so that we can pass in the context node
+ // by modifying the original xpath so that sca functions take self::node()
+ // as the 2nd argument
+ return new PolicyXPathFunction(namespaceContext, functionName);
+ } else {
+ throw new IllegalArgumentException("Invalid number of arguments: " + arity);
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml
new file mode 100644
index 0000000000..7d50cd0ae4
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<sca:definitions xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- Security related intents -->
+ <sca:intent name="serverAuthentication" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding requires that the
+ server is authenticated by the client
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="clientAuthentication" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding requires that the
+ client is authenticated by the server
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="authentication" requires="sca:clientAuthentication">
+ <sca:description>
+ A convenience intent to help migration
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="mutualAuthentication"
+ requires="sca:clientAuthentication sca:serverAuthentication">
+ <sca:description>
+ Communication through the binding requires that the
+ client and server to authenticate each other
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="confidentiality" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding prevents unauthorized
+ users from reading the messages
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="integrity" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding prevents tampering
+ with the messages sent between the client and the service.
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="authorization" constrains="sca:implementation"
+ intentType="implementation">
+ <sca:description>
+ Ensures clients are authorized to use services.
+ </sca:description>
+ <sca:qualifier name="fineGrain" default="true"/>
+ </sca:intent>
+
+
+ <!-- Reliable messaging related intents -->
+ <sca:intent name="atLeastOnce" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that a message sent
+ by a client is always delivered to the component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="atMostOnce" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that a message that was
+ successfully sent by a client is not delivered more than
+ once to the component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="exactlyOnce" requires="sca:atLeastOnce sca:atMostOnce"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ This profile intent is used to indicate that a message sent
+ by a client is always delivered to the component. It also
+ indicates that duplicate messages are not delivered to the
+ component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="ordered" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that all the messages are
+ delivered to the component in the order they were sent by
+ the client.
+ </sca:description>
+ </sca:intent>
+
+ <!-- Transaction related intents -->
+ <sca:intent name="managedTransaction" excludes="sca:noManagedTransaction"
+ mutuallyExclusive="true" constrains="sca:implementation"
+ intentType="implementation">
+ <sca:description>
+ A managed transaction environment is necessary in order to
+ run the component. The specific type of managed transaction
+ needed is not constrained.
+ </sca:description>
+ <sca:qualifier name="global" default="true">
+ <sca:description>
+ For a component marked with managedTransaction.global
+ a global transaction needs to be present before dispatching
+ any method on the component - using any transaction
+ propagated from the client or else beginning and completing
+ a new transaction.
+ </sca:description>
+ </sca:qualifier>
+ <sca:qualifier name="local">
+ <sca:description>
+ A component marked with managedTransaction.local needs to
+ run within a local transaction containment (LTC) that
+ is started and ended by the SCA runtime.
+ </sca:description>
+ </sca:qualifier>
+ </sca:intent>
+
+ <sca:intent name="noManagedTransaction" excludes="sca:managedTransaction"
+ constrains="sca:implementation" intentType="implementation">
+ <sca:description>
+ A component marked with noManagedTransaction needs to run without
+ a managed transaction, under neither a global transaction nor
+ an LTC. A transaction propagated to the hosting SCA runtime
+ is not joined by the hosting runtime on behalf of a
+ component marked with noManagedtransaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="transactedOneWay" excludes="sca:immediateOneWay"
+ constrains="sca:binding" intentType="implementation">
+ <sca:description>
+ For a reference marked as transactedOneWay any OneWay invocation
+ messages are transacted as part of a client global
+ transaction.
+ For a service marked as transactedOneWay any OneWay invocation
+ message are received from the transport binding in a
+ transacted fashion, under the service’s global transaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="immediateOneWay" excludes="sca:transactedOneWay"
+ constrains="sca:binding" intentType="implementation">
+ <sca:description>
+ For a reference indicates that any OneWay invocation messages
+ are sent immediately regardless of any client transaction.
+ For a service indicates that any OneWay invocation is
+ received immediately regardless of any target service
+ transaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="propagatesTransaction" excludes="sca:suspendsTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ A service marked with propagatesTransaction is dispatched
+ under any propagated (client) transaction and the service binding
+ needs to be capable of receiving a transaction context.
+ A reference marked with propagatesTransaction propagates any
+ transaction context under which the client runs when the
+ reference is used for a request-response interaction and the
+ binding of a reference marked with propagatesTransaction needs to
+ be capable of propagating a transaction context.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="suspendsTransaction" excludes="sca:propagatesTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ A service marked with suspendsTransaction is not dispatched
+ under any propagated (client) transaction.
+ A reference marked with suspendsTransaction does not propagate
+ any transaction context under which the client runs when the
+ reference is used.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="managedSharedTransaction"
+ requires="sca:managedTransaction.global sca:propagatesTransaction">
+ <sca:description>
+ Used to indicate that the component requires both the
+ managedTransaction.global and the propagatesTransactions
+ intents
+ </sca:description>
+ </sca:intent>
+
+ <!-- Miscellaneous intents -->
+ <sca:intent name="asyncInvocation" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Indicates that request/response operations for the
+ interface of this wire are "long running" and must be
+ treated as two separate message transmissions
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="SOAP" constrains="sca:binding" intentType="interaction" mutuallyExclusive="true">
+ <sca:description>
+ Specifies that the SOAP messaging model is used for delivering
+ messages.
+ </sca:description>
+ <sca:qualifier name="v1_1" default="true"/>
+ <sca:qualifier name="v1_2"/>
+ </sca:intent>
+
+ <sca:intent name="JMS" constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ Requires that the messages are delivered and received via the
+ JMS API.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="noListener" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent can only be used on a reference. Indicates that the
+ client is not able to handle new inbound connections. The binding
+ and callback binding are configured so that any
+ response or callback comes either through a back channel of the
+ connection from the client to the server or by having the client
+ poll the server for messages.
+ </sca:description>
+ </sca:intent>
+
+</sca:definitions>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..7982dc123c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.ComponentTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#componentType,model=org.apache.tuscany.sca.assembly.ComponentType
+org.apache.tuscany.sca.assembly.xml.CompositeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#composite,model=org.apache.tuscany.sca.assembly.Composite
+org.apache.tuscany.sca.assembly.xml.SCABindingProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#binding.sca,model=org.apache.tuscany.sca.assembly.SCABinding
+org.apache.tuscany.sca.assembly.xml.EndpointProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#endpoint,model=org.apache.tuscany.sca.assembly.Endpoint
+org.apache.tuscany.sca.assembly.xml.EndpointReferenceProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#endpointReference,model=org.apache.tuscany.sca.assembly.EndpointReference
+org.apache.tuscany.sca.definitions.xml.DefinitionsProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#definitions,model=org.apache.tuscany.sca.definitions.Definitions
+org.apache.tuscany.sca.policy.xml.BindingTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#bindingType,model=org.apache.tuscany.sca.policy.BindingType
+org.apache.tuscany.sca.policy.xml.ImplementationTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#implementationType,model=org.apache.tuscany.sca.policy.ImplementationType
+org.apache.tuscany.sca.policy.xml.IntentProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#intent,model=org.apache.tuscany.sca.policy.Intent
+org.apache.tuscany.sca.policy.xml.PolicySetProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#policySet,model=org.apache.tuscany.sca.policy.PolicySet
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
new file mode 100644
index 0000000000..f8d1e11ef3
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.ComponentTypeDocumentProcessor;type=.componentType,model=org.apache.tuscany.sca.assembly.ComponentType
+org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor;type=.composite,model=org.apache.tuscany.sca.assembly.Composite
+org.apache.tuscany.sca.definitions.xml.DefinitionsDocumentProcessor;type=/META-INF/definitions.xml,model=org.apache.tuscany.sca.definitions.Definitions
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..f8e4d5bbd4
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.assembly.xml.CompositeModelResolver;model=org.apache.tuscany.sca.assembly.Composite
+org.apache.tuscany.sca.assembly.xml.ComponentTypeModelResolver;model=org.apache.tuscany.sca.assembly.ComponentType
+org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;model=org.apache.tuscany.sca.policy.Intent
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..381c0ba23b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+META-INF/sca-policy-1.1-intents-definitions-cd03.xml
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint
new file mode 100644
index 0000000000..45b3512614
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org.apache.tuscany.sca.definitions.xml.DefaultDefinitionsExtensionPoint
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
new file mode 100644
index 0000000000..8ad5f88892
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
@@ -0,0 +1,32 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+NoCompositeNamespace = No namespace found: Composite = {0}
+UnexpectedInterfaceElement = Unexpected <interface> element found. It should appear inside a <service> or <reference> element.
+UnexpectedBindingElement = Unexpected <binding> element found. It should appear inside a <service> or <reference> element.
+UnexpectedImplementationElement = Unexpected <implementation> element found. It should appear inside a <component> element.
+PolicyImplValidationException = PolicyValidation exception when processing implementation of component {0} due to {1}.
+PolicyServiceValidationException = PolicyValidation exceptions when processing service/reference {0} in {1}. Error is {2}
+ContributionReadException = ContributionReadException occured due to : {0}
+ContributionResolveException = ContributionResolveException occured due to : {0}
+ContributionWriteException = ContributionWriteException occured due to : {0}
+XMLStreamException = XMLStreamException occured due to : {0}
+DuplicateCompositeName = [ASM_6001] More than one composite with the same name {0} found in contribution {1}
+PropertyTypeNotFound = The type {0} specified on property {1} of {2} can't be found in any loaded contribution (makes sure the .xsd file is in a contribution, that the contribution is being loaded and that contribution imports and exports are correct)
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties
new file mode 100644
index 0000000000..de27c0bd31
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties
@@ -0,0 +1,24 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+ContributionReadException = ContributionReadException occured due to :
+PrivilegedActionException = Privileged Action Exception occured due to FilePermission in security policy file:
+ImplementationTypeNotFound = [POL50001] An extension to support the implementation type {0} can't be found in the domain
+BindingTypeNotFound = An extension to support the binding type {0} can't be found in the domain \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties
new file mode 100644
index 0000000000..08ef6bb5e9
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties
@@ -0,0 +1,50 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+ReferredPolicySetNotFound = Referred PolicySet - {0} not found for PolicySet - {1}
+MappedIntentNotFound = Mapped Intent - {0} not found for PolicySet {1}
+ProvidedIntentNotFound = Provided Intent - {0} not found for PolicySet {1}
+UnableToMapPolicies = Unable to map policies for default qualifier in IntentMap for - {0} in policy set - {1}
+IntentMapDoesNotMatch = Intent provided by IntentMap {0} does not match parent qualifier {1} in policyset - {2}
+IntentNotSpecified = [POL30021] Intent Map provides for Intent not specified as provided by parent PolicySet - {0}
+ContrainsAttributeMissing = Constrains attribute missing from Policy Intent Definition {0}
+RequiredIntentNotFound = [POL30015] Required Intent - {0} not found for ProfileIntent {1}
+QualifiableIntentNotFound = Qualifiable Intent - {0} not found for QualifiedIntent {1}
+ErrorInPolicyIntentDefinition = Error in PolicyIntent Definition - {0} {1}
+ExcludedIntentNotFound = [POL30016] Excluded Intent {0} not found for intent {1}
+UnrecognizedIntentAttachPointType = Unrecognized IntentAttachPointType - {0}
+RequiredAttributeMissing = Required attribute {0} missing from extension type definition
+AlwaysProvidedIntentNotFound = Always Provided Intent - {0} not found for ExtensionType {1}
+MayProvideIntentNotFound = May Provide Intent - {0} not found for ExtensionType {1}
+ContributionReadException = ContributionReadException occurred due to: {0}
+CyclicReferenceFound = Cyclic reference detected in required attributes of ProfileIntents {0} and {1}
+IntentNameMissing = Required attribute "name" missing for Intent Definition
+PolicySetReferenceNameMissing = Required attribute "name" missing for PolicySetReference in PolicySet : {0}
+PolicySetNameMissing = Required attribute "name" missing for PolicySet Definition
+PolicySetAppliesToMissing = Required attribute "appliesTo" missing for PolicySet Definition
+IntentMapProvidesMissing = Required attribute "provides" missing for IntentMap in PolicySet : {0}
+QualifierNameMissing = Required attribute "name" missing for qualifier definition in PolicySet : {0}
+ConstrainedTypeNotFound = Unable to find the extension type {0} constrained by intent: {1}
+MultipleDefaultQualifiers = [POL30004] Intent {0} has more than one qualifier marked as the default qualifier
+QualifierIsNotUnique = [POL30005] The intent {0} has more than one qualifier with the name {1}
+ProfileIntentNameWithPeriod = [POL30006] The profile intent name {0} must not have the character "." in it
+IntentMapIsNotUnique = [POL30010] The policy set {0} has more than one intent map with the name {1}
+IntentMapMissingQualifiers = [POL30020] The policy set {0} intent map {1} has missing qualifiers: {2} The intent map qualifiers must match the provided intent qualifiers.
+PolicyLanguageMissmatch = Policy set {0} contains policy expressions from more than on language, languages {1} and {2} found
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java
new file mode 100644
index 0000000000..3f4a74ba03
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CompositeProcessorTestCase {
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ private static final String OASIS_COMPOSITE =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?> "
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" "
+ + "xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\" "
+ + "targetNamespace=\"http://store\" "
+ + "name=\"store\">"
+ + "<component name=\"Catalog\">"
+ + " <implementation.java class=\"services.FruitsCatalogImpl\"/>"
+ + "</component>"
+ + "</composite>";
+
+ private static final String OSOA_COMPOSITE =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" "
+ + "xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" "
+ + "targetNamespace=\"http://store\" "
+ + "name=\"store\">"
+ + "<component name=\"Catalog\">"
+ + " <implementation.java class=\"services.FruitsCatalogImpl\"/>"
+ + "</component>"
+ + "</composite>";
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static Monitor monitor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ monitor = context.getMonitor();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ @Test
+ public void testReadOASISSpecVersion() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OASIS_COMPOSITE));
+ Object result = staxProcessor.read(reader, context);
+ assertNotNull(result);
+ if( result instanceof Composite) {
+ Composite composite = (Composite) result;
+ assertEquals(SCA11_NS, composite.getSpecVersion());
+ }
+ reader.close();
+ }
+
+ @Test
+ public void testReadOSOASpecVersion() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OSOA_COMPOSITE));
+ Object result = staxProcessor.read(reader, context);
+ assertNotNull(result);
+ if( result instanceof Composite) {
+ throw new Exception("Error, unsupported OSOA namespace being parsed as valid !");
+ }
+ reader.close();
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java
new file mode 100644
index 0000000000..0d5e69bd61
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test writing SCA XML assemblies.
+ *
+ * TUSCANY-2662
+ *
+ * @version $Rev$ $Date$
+ */
+public class MultiplicityReadWriteTestCase {
+ private XMLInputFactory inputFactory;
+ private XMLOutputFactory outputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+ private ProcessorContext context;
+
+ @Before
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Multiplicity.composite");
+ Composite composite = staxProcessor.read(is, Composite.class, context);
+
+ verifyComposite(composite);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+ bos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ composite = staxProcessor.read(bis, Composite.class, context);
+
+ verifyComposite(composite);
+
+ }
+
+
+ private void verifyComposite(Composite composite) {
+ assertEquals(composite.getComponents().get(0).getReferences().get(0).getMultiplicity(), Multiplicity.ZERO_N);
+ assertEquals(composite.getReferences().get(0).getMultiplicity(), Multiplicity.ONE_N);
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
new file mode 100644
index 0000000000..155c0c5a47
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadAllTestCase {
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static XMLInputFactory inputFactory;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(composite);
+ assertEquals(composite.getName(), new QName("http://calc", "TestAllCalculator"));
+ assertTrue(composite.isLocal());
+ assertFalse(composite.getAutowire() == Boolean.TRUE);
+ assertEquals(((PolicySubject)composite).getRequiredIntents().get(0).getName(), new QName("http://test",
+ "confidentiality"));
+ assertEquals(((PolicySubject)composite).getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+
+ Composite include = composite.getIncludes().get(0);
+ assertEquals(include.getName(), new QName("http://calc", "TestAllDivide"));
+
+ CompositeService calcCompositeService = (CompositeService)composite.getServices().get(0);
+ assertEquals(calcCompositeService.getName(), "CalculatorService");
+ assertTrue(calcCompositeService.getPromotedService().isUnresolved());
+ assertEquals(calcCompositeService.getPromotedService().getName(),
+ "CalculatorService");
+ assertEquals(calcCompositeService.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcCompositeService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+ Callback calcServiceCallback = calcCompositeService.getCallback();
+ assertNotNull(calcServiceCallback);
+ assertEquals(calcServiceCallback.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcServiceCallback.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+
+ Component calcComponent = composite.getComponents().get(0);
+ assertEquals(calcComponent.getName(), "CalculatorServiceComponent");
+ assertEquals(calcComponent.getAutowire(), Boolean.FALSE);
+ assertEquals(calcComponent.getRequiredIntents().get(0).getName(), new QName("http://test",
+ "confidentiality"));
+ assertEquals(calcComponent.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+
+ ComponentService calcComponentService = calcComponent.getServices().get(0);
+ assertEquals(calcComponentService.getName(), "CalculatorService");
+ assertEquals(calcComponentService.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcComponentService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+
+ ComponentReference calcComponentReference = calcComponent.getReferences().get(0);
+ assertEquals(calcComponentReference.getName(), "addService");
+ assertEquals(calcComponentReference.getAutowire(), Boolean.FALSE);
+ assertEquals(calcComponentReference.isWiredByImpl(), false);
+ assertEquals(calcComponentReference.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcComponentReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+
+ Property property = calcComponent.getProperties().get(0);
+ assertEquals(property.getName(), "round");
+ Document doc = (Document) property.getValue();
+ Element element = doc.getDocumentElement();
+ String value = element.getTextContent();
+ assertEquals(value, "true");
+ assertEquals(property.getXSDType(), new QName("http://www.w3.org/2001/XMLSchema", "boolean"));
+ assertEquals(property.isMany(), false);
+
+ CompositeReference calcCompositeReference = (CompositeReference)composite.getReferences().get(0);
+ assertEquals(calcCompositeReference.getName(), "MultiplyService");
+ assertTrue(calcCompositeReference.getPromotedReferences().get(0).isUnresolved());
+ assertEquals(calcCompositeReference.getPromotedReferences().get(0).getName(),
+ "CalculatorServiceComponent/multiplyService");
+ assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+ Callback calcCallback = calcCompositeReference.getCallback();
+ assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ assertNotNull(calcCallback);
+ // TODO test operations
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..473e483d31
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.HashMap;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.ValidatorHandler;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.processor.DefaultValidationSchemaExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadDocumentTestCase {
+ private static final String TUSCANY_11_XSD = "tuscany-sca-1.1.xsd";
+
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static ModelResolver resolver;
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ValidatorHandler handler;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ URLArtifactProcessorExtensionPoint documentProcessors =
+ extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+
+ resolver = new DefaultModelResolver();
+ handler = getValidationHandler();
+
+ }
+
+ @Test
+ public void testValidateAssembly() throws Exception {
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ URL url = getClass().getResource("Calculator.composite");
+ XMLReader reader = parserFactory.newSAXParser().getXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(url.openStream()));
+
+ }
+
+ private static ValidatorHandler getValidationHandler() throws SAXException {
+ SchemaFactory schemaFactory;
+ try {
+ schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ schemaFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ } catch (Error e) {
+ // Some old JDKs don't support XMLSchema validation
+ return null;
+ } catch (Exception e) {
+ // Some old JDKs don't support XMLSchema validation
+ return null;
+ }
+ Schema schema = schemaFactory.newSchema(ReadDocumentTestCase.class.getClassLoader().getResource(TUSCANY_11_XSD));
+ ValidatorHandler handler = schema.newValidatorHandler();
+ return handler;
+ }
+
+ @Test
+ public void testValidateImplementation() throws Exception {
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ URL url = getClass().getResource("Calculator.composite");
+ XMLReader reader = parserFactory.newSAXParser().getXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(url.openStream()));
+ }
+
+ @Test
+ public void testReadImplementation() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(registry, new HashMap<String, String>());
+ schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString());
+ XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas);
+ DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(registry);
+ factories.addFactory(validatingInputFactory);
+
+ CompositeDocumentProcessor compositeDocumentProcessor =
+ new CompositeDocumentProcessor(factories, staxProcessor);
+
+ URL url = getClass().getResource("Calculator.composite");
+ URI uri = URI.create("Calculator.composite");
+ Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url, context);
+ assertNotNull(composite);
+ }
+
+ @Test
+ public void testValidateBinding() throws Exception {
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ URL url = getClass().getResource("RMIBindingTest.composite");
+ XMLReader reader = parserFactory.newSAXParser().getXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(url.openStream()));
+ }
+
+ @Test
+ public void testReadBinding() throws Exception {
+
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(registry, new HashMap<String, String>());
+ schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString());
+ XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas);
+ DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(registry);
+ factories.addFactory(validatingInputFactory);
+ CompositeDocumentProcessor compositeDocumentProcessor =
+ new CompositeDocumentProcessor(factories, staxProcessor);
+
+ URL url = getClass().getResource("RMIBindingTest.composite");
+ URI uri = URI.create("RMIBindingTest.composite");
+ Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url, context);
+ assertNotNull(composite);
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ URL url = getClass().getResource("Calculator.composite");
+ URI uri = URI.create("Calculator.composite");
+ Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url, context);
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite, context);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url, context);
+
+ documentProcessor.resolve(composite, resolver, context);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java
new file mode 100644
index 0000000000..05d320b211
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance());
+ }
+
+
+ @Test
+ public void testReadComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader, context));
+ is.close();
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader, context));
+ is.close();
+
+ }
+
+ @Test
+ public void testReadCompositeAndWireIt() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader, context));
+ is.close();
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java
new file mode 100644
index 0000000000..28a2bb6851
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadWriteAnyAttributeTestCase {
+
+ private static final String XML = "<?xml version='1.0' encoding='UTF-8'?>"+
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" " +
+ "targetNamespace=\"http://calc\" " +
+ "name=\"Calculator\">"+
+ "<component name=\"AddServiceComponent\" xmlns:test=\"http://test\" test:customAttribute=\"customValue\">"+
+ "<implementation.java class=\"calculator.AddServiceImpl\" />"+
+ "</component>"+
+ "</composite>";
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+ private ProcessorContext context;
+
+ /**
+ * Initialize the test environment
+ * This takes care to register attribute processors when provided
+ *
+ * @param attributeProcessor
+ * @throws Exception
+ */
+ private void init(StAXAttributeProcessor<?> attributeProcessor) throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+ if(attributeProcessor != null) {
+ StAXAttributeProcessorExtensionPoint staxAttributeProcessors = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
+ staxAttributeProcessors.addArtifactProcessor(attributeProcessor);
+ }
+
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance());
+ }
+
+ /**
+ * Read and Write a composite that has a extended attribute
+ * and a particular attribute processor
+ * @throws Exception
+ */
+ @Test
+ public void testReadWriteCompositeWithAttributeProcessor() throws Exception {
+ init(new TestAttributeProcessor());
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML));
+ Composite composite = (Composite) staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+
+ // used for debug comparison
+ // System.out.println(XML);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML, bos.toString());
+ }
+
+ /**
+ * Read and Write a composite that has a extended attribute
+ * but no particular processor for it
+ * @throws Exception
+ */
+ @Test
+ public void testDefaultReadWriteComposite() throws Exception {
+ init(null);
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML));
+ Composite composite = (Composite) staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+
+ // used for debug comparison
+ // System.out.println(XML);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML, bos.toString());
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java
new file mode 100644
index 0000000000..7a36c1d97d
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class ReadWriteAnyElementTestCase {
+ private static final String XML_RECURSIVE_EXTENDED_ELEMENT =
+ "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://temp\" name=\"RecursiveExtendedElement\">" +
+ "<unknownElement>" +
+ "<subUnknownElement1 attribute=\"anyAttribute\" />" +
+ "<subUnknownElement2 />" +
+ "</unknownElement>" +
+ "</composite>";
+
+ private static final String XML_UNKNOWN_IMPL =
+ "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://temp\" name=\"aaaa\" autowire=\"false\">" +
+ "<component name=\"unknownImpl\">" +
+ "<implementation.unknown class=\"raymond\" />" +
+ "<service name=\"service\">" +
+ "<binding.ws />" +
+ "</service>" +
+ "</component>" +
+ "</composite>";
+
+ private static final String XML_UNKNOWN_IMPL_WITH_INVALID_ATTRIBUTE =
+ "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://temp\" name=\"aaaa\" autowire=\"false\">" +
+ "<component name=\"unknownImpl\">" +
+ "<implementation.unknown class=\"raymond\" />" +
+ "<service name=\"service\" requires=\"\">" +
+ "<binding.ws />" +
+ "</service>" +
+ "</component>" +
+ "</composite>";
+
+
+ private ValidatingXMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+ private ProcessorContext context;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, XMLOutputFactory.newInstance());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testReadWriteExtendedRecursiveElement() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_RECURSIVE_EXTENDED_ELEMENT));
+ ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor());
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+
+ // used for debug comparison
+ // System.out.println(XML_RECURSIVE_EXTENDED_ELEMENT);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML_RECURSIVE_EXTENDED_ELEMENT, bos.toString());
+ bos.close();
+ }
+
+ @Test
+ public void testReadWriteUnknwonImpl() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_UNKNOWN_IMPL));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+
+ // used for debug comparison
+ // System.out.println(XML_UNKNOWN_IMPL);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML_UNKNOWN_IMPL, bos.toString());
+ bos.close();
+ }
+
+ // @Test
+ @Ignore()
+ public void testReadWriteInvalidAttribute() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_UNKNOWN_IMPL_WITH_INVALID_ATTRIBUTE));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+
+ // used for debug comparison
+ // System.out.println(XML_UNKNOWN_IMPL);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML_UNKNOWN_IMPL, bos.toString());
+ bos.close();
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java
new file mode 100644
index 0000000000..fc675dcdce
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadWriteLocalCompositeTestCase {
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+ private ProcessorContext context;
+
+ private static final String LOCAL_COMPOSITE_XML = "<?xml version='1.0' encoding='UTF-8'?>"+
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://localcalc\" name=\"LocalCalculator\" local=\"true\">"+
+ "</composite>";
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+ StAXAttributeProcessorExtensionPoint staxAttributeProcessors = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
+ staxAttributeProcessors.addArtifactProcessor(new TestAttributeProcessor());
+
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("local.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite) staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ assertTrue(composite.isLocal());
+ is.close();
+ }
+
+ @Test
+ public void testWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("local.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite) staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ assertTrue(composite.isLocal());
+ is.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+ System.out.println(bos.toString());
+
+ assertEquals(LOCAL_COMPOSITE_XML, bos.toString());
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
new file mode 100644
index 0000000000..df588e3504
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ResolvePolicyTestCase {
+
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static ModelResolver resolver;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ resolver = new DefaultModelResolver();
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ // Create StAX processors
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+ }
+
+ private void preResolvePolicyTests(Composite composite) {
+ assertNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription());
+ assertTrue(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
+
+ assertNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+
+ assertNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+
+ assertNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+ }
+
+ private void postResolvePolicyTests(Composite composite) {
+ assertNotNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription());
+ assertFalse(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+ assertNotNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+ assertNotNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+ assertNotNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ URL url = getClass().getResource("Calculator.composite");
+ URI uri = URI.create("Calculator.composite");
+ Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url, context);
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite, context);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url, context);
+
+ documentProcessor.resolve(composite, resolver, context);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java
new file mode 100644
index 0000000000..28e679da4a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Test resolving SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ResolveTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessorExtensionPoint staxProcessors;
+ private static ModelResolver resolver;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ resolver = new DefaultModelResolver();
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ StAXArtifactProcessor<Composite> compositeReader = staxProcessors.getProcessor(Composite.class);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite nestedComposite = compositeReader.read(reader, context);
+ is.close();
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite, context);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeReader.read(reader, context);
+ is.close();
+
+ compositeReader.resolve(composite, resolver, context);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.java
new file mode 100644
index 0000000000..8d9bc72389
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class StripURISpacesTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance());
+ }
+
+
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorURISpaces.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ is.close();
+
+ CompositeService compositeService = (CompositeService)composite.getServices().get(0);
+ assertNotNull(compositeService);
+
+ // Promoted component name with leading and training spaces removed
+ assertEquals("CalculatorServiceComponent", compositeService.getPromotedComponent().getName());
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java
new file mode 100644
index 0000000000..b6f4c11ac2
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A Policy Processor used for testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestAttributeProcessor extends BaseStAXArtifactProcessor implements StAXAttributeProcessor<String> {
+ private static final QName ATTRIBUTE = new QName("http://test", "customAttribute");
+
+ public QName getArtifactType() {
+ return ATTRIBUTE;
+ }
+
+ public String read(QName attributeName, XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ return reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart());
+ }
+
+ public void write(String value, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ writer.setPrefix(ATTRIBUTE.getPrefix(), ATTRIBUTE.getNamespaceURI());
+ writer.writeAttribute(ATTRIBUTE.getLocalPart(), value);
+ }
+
+ public Class<String> getModelType() {
+ return String.class;
+ }
+
+ public void resolve(String arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..cfec8dee7a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+
+/**
+ * A PolicyExpression Processor used for testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<PolicyExpression> {
+
+ public QName getArtifactType() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public PolicyExpression read(XMLStreamReader arg0, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ return new MockPolicyImplOne();
+ }
+
+ public void write(PolicyExpression arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ }
+
+ public Class<PolicyExpression> getModelType() {
+ return PolicyExpression.class;
+ }
+
+ public void resolve(PolicyExpression arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+ }
+
+ public class MockPolicyImplOne implements PolicyExpression {
+ public <T> T getPolicy() {
+ return null;
+ }
+
+ public void setName(QName name) {
+ }
+
+ public <T> void setPolicy(T policy) {
+ }
+
+ public QName getName() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java
new file mode 100644
index 0000000000..5e3fa15b69
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+
+/**
+ * A factory for the SCA binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestSCABindingFactoryImpl implements SCABindingFactory {
+ public SCABinding createSCABinding() {
+ return new TestSCABindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
new file mode 100644
index 0000000000..f83a2ebd14
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.xml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * A test cheel for the SCA binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestSCABindingImpl implements SCABinding, PolicySubject {
+ private String name;
+ private String uri;
+ private List<Object> extensions = new ArrayList<Object>();
+
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private ExtensionType bindingType = new TestSCABindingType();
+
+ /**
+ * Constructs a new SCA binding.
+ */
+ protected TestSCABindingImpl() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public List<PolicySet> getPolicySets() {
+ // TODO Auto-generated method stub
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ // TODO Auto-generated method stub
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ // TODO Auto-generated method stub
+ return bindingType;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.bindingType = type;
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ private class TestSCABindingType implements ExtensionType {
+ private QName name = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912","binding");
+ public QName getBaseType() {
+ return BINDING_BASE;
+ }
+
+ public QName getType() {
+ return name;
+ }
+
+ public void setType(QName type) {
+ }
+
+ public List<Intent> getAlwaysProvidedIntents() {
+ return Collections.emptyList();
+ }
+
+ public List<Intent> getMayProvidedIntents() {
+ return Collections.emptyList();
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java
new file mode 100644
index 0000000000..543aaf9893
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test the wiring of SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ModelResolver resolver;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ resolver = new DefaultModelResolver();
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ Composite nestedComposite = readComposite("Calculator.composite");
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite, context);
+
+ Composite composite = readComposite("TestAllCalculator.composite");
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url, context);
+ assertNotNull(scaDefns);
+
+ policyDefinitionsProcessor.resolve(scaDefns, resolver, context);
+
+ staxProcessor.resolve(composite, resolver, context);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+ private Composite readComposite(String resource) throws XMLStreamException, ContributionReadException, IOException {
+ InputStream is = getClass().getResourceAsStream(resource);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ is.close();
+ return composite;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
new file mode 100644
index 0000000000..a19ce79490
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test writing SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WriteAllTestCase {
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static ExtensibleStAXArtifactProcessor staxProcessor;
+ private static ModelResolver resolver;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ resolver = new DefaultModelResolver();
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = staxProcessor.read(is, Composite.class, context);
+
+ verifyComposite(composite);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+ bos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ composite = staxProcessor.read(bis, Composite.class, context);
+
+ verifyComposite(composite);
+
+ }
+
+ @Test
+ public void testReadWireWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = staxProcessor.read(is, Composite.class, context);
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url, context);
+ assertNotNull(scaDefns);
+ policyDefinitionsProcessor.resolve(scaDefns, resolver, context);
+
+ staxProcessor.resolve(composite, resolver, context);
+ // compositeBuilder.build(composite, null, monitor);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+ }
+
+ @Test
+ public void testReadWriteComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ ComponentType componentType = staxProcessor.read(is, ComponentType.class, context);
+ staxProcessor.resolve(componentType, resolver, context);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(componentType, bos, context);
+ }
+
+
+ private void verifyComposite(Composite composite) {
+ assertEquals(composite.getProperties().get(0).getName(),"prop1");
+ assertEquals(composite.getProperties().get(0).isMany(), true);
+ assertEquals(composite.getProperties().get(1).getName(),"prop2");
+ assertEquals(composite.getProperties().get(1).isMustSupply(), true);
+ assertEquals(composite.getProperties().get(0).getXSDType(), new QName("http://foo", "MyComplexType"));
+ assertEquals(composite.getProperties().get(1).getXSDElement(), new QName("http://foo", "MyComplexPropertyValue1"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java
new file mode 100644
index 0000000000..f50cd5811f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test writing SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WriteNamespacesTestCase {
+ private static StAXArtifactProcessor<Composite> compositeProcessor;
+ private static XMLOutputFactory outputFactory;
+ private static XMLInputFactory inputFactory;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+ //outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+
+ StAXArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ compositeProcessor = artifactProcessors.getProcessor(Composite.class);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+
+ // Read
+ InputStream is = getClass().getResourceAsStream("NestedCalculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeProcessor.read(reader, context);
+ Component component = composite.getComponents().get(0);
+ Composite implementation = (Composite)component.getImplementation();
+ QName qname = implementation.getName();
+
+ // Write
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos);
+ compositeProcessor.write(composite, writer, context);
+ System.out.println(bos);
+
+ // Read again
+ is = new ByteArrayInputStream(bos.toByteArray());
+ reader = inputFactory.createXMLStreamReader(is);
+ composite = compositeProcessor.read(reader, context);
+
+ // Compare
+ component = composite.getComponents().get(0);
+ implementation = (Composite)component.getImplementation();
+
+ assertEquals(qname, implementation.getName());
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java
new file mode 100644
index 0000000000..58e6e534b9
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.definitions.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Mocked Policy
+ */
+public class MockPolicy {
+ public QName getName() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..f99b81f73f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.definitions.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadDocumentTestCase {
+
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor = null;
+ private static Definitions definitions;
+ private static Map<QName, Intent> intentTable = new Hashtable<QName, Intent>();
+ private static Map<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
+ private static Map<QName, BindingType> bindingTypesTable = new Hashtable<QName, BindingType>();
+ private static Map<QName, ImplementationType> implTypesTable = new Hashtable<QName, ImplementationType>();
+ public static final String scaNamespace = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ public static final String namespace = "http://test";
+
+ private static final QName secureWsPolicy = new QName(namespace, "SecureWSPolicy");
+ private static final QName confidentiality = new QName(namespace, "confidentiality");
+ private static final QName integrity = new QName(namespace, "integrity");
+ private static final QName messageProtection = new QName(namespace, "messageProtection");
+ private static final QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ private static final QName confidentiality_message = new QName(namespace, "confidentiality.message");
+ private static final QName secureReliablePolicy = new QName(namespace, "SecureReliablePolicy");
+ private static final QName secureMessagingPolicies = new QName(namespace, "SecureMessagingPolicies");
+ private static final QName securityPolicy = new QName(namespace, "SecurityPolicy");
+ private static final QName basicAuthMsgProtSecurity = new QName(namespace, "BasicAuthMsgProtSecurity");
+ private static final QName wsBinding = new QName(scaNamespace, "binding.ws");
+ private static final QName javaImpl = new QName(scaNamespace, "implementation.java");
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+
+ // Create StAX processors
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+
+ URLArtifactProcessorExtensionPoint documentProcessors =
+ extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ URL url = ReadDocumentTestCase.class.getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ definitions = policyDefinitionsProcessor.read(null, uri, url, context);
+
+ for (Intent intent : definitions.getIntents()) {
+ intentTable.put(intent.getName(), intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ intentTable.put(i.getName(), i);
+ }
+ }
+
+ for (PolicySet policySet : definitions.getPolicySets()) {
+ policySetTable.put(policySet.getName(), policySet);
+ }
+
+ for (BindingType bindingType : definitions.getBindingTypes()) {
+ bindingTypesTable.put(bindingType.getType(), bindingType);
+ }
+
+ for (ImplementationType implType : definitions.getImplementationTypes()) {
+ implTypesTable.put(implType.getType(), implType);
+ }
+ }
+
+ @Test
+ public void testReadSCADefinitions() throws Exception {
+ assertNotNull(definitions);
+
+ assertNotNull(intentTable.get(confidentiality));
+ assertNotNull(intentTable.get(messageProtection));
+ assertNotNull(intentTable.get(confidentiality_transport));
+ assertTrue(intentTable.get(confidentiality).getDescription().length() > 0);
+
+ assertNotNull(policySetTable.get(secureReliablePolicy));
+ assertTrue(policySetTable.get(secureReliablePolicy).getProvidedIntents().size() == 2);
+ assertTrue(policySetTable.get(secureReliablePolicy).getPolicies().size() == 2);
+
+ assertNotNull(policySetTable.get(secureMessagingPolicies));
+ assertEquals(2, policySetTable.get(secureMessagingPolicies).getIntentMaps().get(0).getQualifiers().size());
+ //assertTrue(policySetTable.get(secureWsPolicy).getPolicies().get(0) instanceof org.apache.neethi.Policy);
+
+ assertEquals(bindingTypesTable.size(), 1);
+ assertNotNull(bindingTypesTable.get(wsBinding));
+ assertEquals(implTypesTable.size(), 1);
+ assertNotNull(implTypesTable.get(javaImpl));
+ }
+
+ private boolean isRealizedBy(PolicySet policySet, Intent intent) {
+ if (intent.getName().getLocalPart().indexOf('.') == -1) {
+ return policySet.getProvidedIntents().contains(intent);
+ }
+ for (IntentMap map : policySet.getIntentMaps()) {
+ for (Qualifier q : map.getQualifiers()) {
+ if (q.getIntent().equals(intent)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private int getNumberOfQualifiedPolicies(PolicySet policySet) {
+ int count = 0;
+ for(IntentMap intentMap: policySet.getIntentMaps()) {
+ for(Qualifier q: intentMap.getQualifiers()) {
+ count += q.getPolicies().size();
+ }
+ }
+ return count;
+ }
+
+ @Test
+ public void testResolveSCADefinitions() throws Exception {
+ Intent i1 = intentTable.get(messageProtection);
+ assertTrue(!i1.getRequiredIntents().isEmpty());
+ assertNull(i1.getRequiredIntents().get(0).getDescription());
+
+ QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ Intent i2 = intentTable.get(confidentiality_transport);
+ assertNotNull(i2.getQualifiableIntent());
+
+ PolicySet secureReliablePolicySet = policySetTable.get(secureReliablePolicy);
+ PolicySet secureMessagingPolicySet = policySetTable.get(secureMessagingPolicies);
+ PolicySet securityPolicySet = policySetTable.get(securityPolicy);
+
+ assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
+ assertNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
+ assertTrue(secureMessagingPolicySet.isUnresolved());
+ assertEquals(3, getNumberOfQualifiedPolicies(securityPolicySet));
+
+ //testing to ensure that inclusion of referred policy sets has not happened
+ PolicySet basicAuthMsgProtSecurityPolicySet = policySetTable.get(basicAuthMsgProtSecurity);
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());
+
+ BindingType wsBindingType = bindingTypesTable.get(wsBinding);
+ assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
+ ImplementationType javaImplType = implTypesTable.get(javaImpl);
+ assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+
+ ModelResolver resolver = new DefaultModelResolver();
+ policyDefinitionsProcessor.resolve(definitions, resolver, context);
+ //builder.build(scaDefinitions);
+
+ //testing if policy intents have been linked have property been linked up
+ assertNotNull(i1.getRequiredIntents().get(0).getDescription());
+ // assertNotNull(i2.getQualifiableIntent().getDescription());
+ assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
+ assertNotNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
+
+ //testing if policysets have been properly linked up with intents
+ assertFalse(secureMessagingPolicySet.isUnresolved());
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality_transport)));
+
+ //testing if intent maps have been properly mapped to policies
+ assertFalse(securityPolicySet.isUnresolved());
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality_message)));
+
+ //testing for inclusion of referred policysets
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getIntentMaps().get(0).getQualifiers().isEmpty());
+ assertTrue(isRealizedBy(basicAuthMsgProtSecurityPolicySet, intentTable.get(confidentiality_transport)));
+
+ assertNotNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNotNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
+ assertNotNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNotNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..a148e33029
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.definitions.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A PolicyProcessor used for testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<MockPolicy> {
+ public QName getArtifactType() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public MockPolicy read(XMLStreamReader arg0, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ return new MockPolicy();
+ }
+
+ public void write(MockPolicy arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ }
+
+ public Class<MockPolicy> getModelType() {
+ return MockPolicy.class;
+ }
+
+ public void resolve(MockPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
new file mode 100644
index 0000000000..d2b0775361
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import static org.apache.tuscany.sca.policy.xml.PolicyXPathFunction.normalize;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+/**
+ *
+ */
+public class PolicyXPathFunctionResolverTestCase {
+ private static XPath xpath;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ XPathFactory factory = XPathFactory.newInstance();
+ xpath = factory.newXPath();
+ xpath.setNamespaceContext(new NamespaceContextImpl());
+ xpath.setXPathFunctionResolver(new PolicyXPathFunctionResolver(xpath.getNamespaceContext()));
+ }
+
+ @Test
+ public void testIntentsRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ String str = "//sca:composite/sca:component[IntentRefs('sca:confidentiality')]";
+ str = normalize(str, "sca");
+ // Test the rewrite of xpath so that the self:node() is passed into the SCA function
+ XPathExpression exp = xpath.compile(str);
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testIntentsRef2() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ String str = " //sca:composite/sca:component[sca:IntentRefs('sca:confidentiality')]";
+ str = normalize(str, "sca");
+ // Test the rewrite of xpath so that the self:node() is passed into the SCA function
+ XPathExpression exp = xpath.compile(str);
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testIntentsRef3() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ String str = " IntentRefs('sca:confidentiality') ";
+ str = normalize(str, "sca");
+ // Test the rewrite of xpath so that the self:node() is passed into the SCA function
+ XPathExpression exp = xpath.compile(str);
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ Assert.assertEquals(1, nodes.getLength());
+ }
+ @Test
+ public void testURIRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ XPathExpression exp = xpath.compile(normalize("sca:composite/sca:component[sca:URIRef('AddServiceComponent')]","sca"));
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ // Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testInterfaceRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:service[sca:InterfaceRef('AddService')]","sca"));
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ // Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testOperationRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:reference[sca:OperationRef('AddService/add')]","sca"));
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ // Assert.assertEquals(1, nodes.getLength());
+ }
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ private static class NamespaceContextImpl implements NamespaceContext {
+
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ public String getNamespaceURI(String prefix) {
+ if ("sca".equals(prefix)) {
+ return SCA11_NS;
+ } else {
+ return null;
+ }
+ }
+
+ public String getPrefix(String namespaceURI) {
+ if (SCA11_NS.equals(namespaceURI)) {
+ return "sca";
+ }
+ return null;
+ }
+
+ public Iterator getPrefixes(String namespaceURI) {
+ if (SCA11_NS.equals(namespaceURI)) {
+ return Collections.singleton("sca").iterator();
+ }
+ return null;
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..231bdfd516
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadDocumentTestCase {
+
+ private ModelResolver resolver;
+ private StAXArtifactProcessor<Object> staxProcessor;
+ private ProcessorContext context;
+
+ private static final QName elementToProcess =
+ new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "implementationType");
+
+ private Map<QName, Intent> intentTable = new Hashtable<QName, Intent>();
+ private Map<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
+ private Map<QName, BindingType> bindingTypesTable = new Hashtable<QName, BindingType>();
+ private Map<QName, ImplementationType> implTypesTable = new Hashtable<QName, ImplementationType>();
+ private static final String scaNamespace = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ private static final String namespace = "http://test";
+
+ private static final QName confidentiality = new QName(namespace, "confidentiality");
+ private static final QName integrity = new QName(namespace, "integrity");
+ private static final QName messageProtection = new QName(namespace, "messageProtection");
+ private static final QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ private static final QName confidentiality_message = new QName(namespace, "confidentiality.message");
+ private static final QName secureReliablePolicy = new QName(namespace, "SecureReliablePolicy");
+ private static final QName secureMessagingPolicies = new QName(namespace, "SecureMessagingPolicies");
+ private static final QName securityPolicy = new QName(namespace, "SecurityPolicy");
+ private static final QName basicAuthMsgProtSecurity = new QName(namespace, "BasicAuthMsgProtSecurity");
+ private static final QName wsBinding = new QName(scaNamespace, "binding.ws");
+ private static final QName javaImpl = new QName(scaNamespace, "implementation.java");
+
+ @Before
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ resolver = new DefaultModelResolver();
+ context = new ProcessorContext(extensionPoints);
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+
+ URL url = getClass().getResource("test_definitions.xml");
+ InputStream urlStream = url.openStream();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+ reader.next();
+
+ //position on the right element qname to get processed
+ while (reader.hasNext()) {
+ reader.next();
+ int event = reader.getEventType();
+ if (event == START_ELEMENT && reader.getName().equals(elementToProcess)) {
+ break;
+ }
+ }
+ while (true) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ Object artifact = staxProcessor.read(reader, context);
+ if (artifact instanceof PolicySet) {
+ PolicySet policySet = (PolicySet)artifact;
+ policySet.setName(new QName(namespace, policySet.getName().getLocalPart()));
+ policySetTable.put(policySet.getName(), policySet);
+ } else if (artifact instanceof Intent) {
+ Intent intent = (Intent)artifact;
+ intent.setName(new QName(namespace, intent.getName().getLocalPart()));
+ intentTable.put(intent.getName(), intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ i.setName(new QName(namespace, i.getName().getLocalPart()));
+ intentTable.put(i.getName(), i);
+ resolver.addModel(i, context);
+ }
+ } else if (artifact instanceof BindingType) {
+ BindingType bindingType = (BindingType)artifact;
+ bindingTypesTable.put(bindingType.getType(), bindingType);
+ } else if (artifact instanceof ImplementationType) {
+ ImplementationType implType = (ImplementationType)artifact;
+ implTypesTable.put(implType.getType(), implType);
+ }
+
+ if (artifact != null) {
+ resolver.addModel(artifact, context);
+ }
+
+ break;
+ }
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+ urlStream.close();
+ }
+
+ @Test
+ public void testReadSCADefinitions() throws Exception {
+ assertNotNull(intentTable.get(confidentiality));
+ assertNotNull(intentTable.get(messageProtection));
+ assertNotNull(intentTable.get(confidentiality_transport));
+ assertTrue(intentTable.get(confidentiality).getDescription().length() > 0);
+
+ assertNotNull(policySetTable.get(secureReliablePolicy));
+ assertTrue(policySetTable.get(secureReliablePolicy).getProvidedIntents().size() == 2);
+ assertTrue(policySetTable.get(secureReliablePolicy).getPolicies().size() == 2);
+
+ assertNotNull(policySetTable.get(secureMessagingPolicies));
+ assertEquals(2, policySetTable.get(secureMessagingPolicies).getIntentMaps().get(0).getQualifiers().get(0).getPolicies().size());
+
+ assertEquals(bindingTypesTable.size(), 1);
+ assertNotNull(bindingTypesTable.get(wsBinding));
+ assertEquals(implTypesTable.size(), 1);
+ assertNotNull(implTypesTable.get(javaImpl));
+ }
+
+ private int getNumberOfQualifiedPolicies(PolicySet policySet) {
+ int count = 0;
+ for(IntentMap intentMap: policySet.getIntentMaps()) {
+ for(Qualifier q: intentMap.getQualifiers()) {
+ count += q.getPolicies().size();
+ }
+ }
+ return count;
+ }
+
+ @Test
+ public void testResolution() throws Exception {
+ assertTrue(!intentTable.get(messageProtection).getRequiredIntents().isEmpty());
+ Intent profileIntent = intentTable.get(new QName(namespace, "messageProtection"));
+ assertNull(profileIntent.getRequiredIntents().get(0).getDescription());
+
+ QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ assertTrue(intentTable.get(confidentiality_transport) instanceof Intent);
+ Intent qualifiedIntent = (Intent)intentTable.get(new QName(namespace, "confidentiality.transport"));
+ assertNull(qualifiedIntent.getDescription());
+ assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
+
+ PolicySet secureReliablePolicySet = policySetTable.get(secureReliablePolicy);
+ PolicySet secureMessagingPolicySet = policySetTable.get(secureMessagingPolicies);
+ PolicySet securityPolicySet = policySetTable.get(securityPolicy);
+
+ assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
+ assertNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
+ assertTrue(secureMessagingPolicySet.isUnresolved());
+ assertEquals(2, getNumberOfQualifiedPolicies(securityPolicySet));
+
+ //testing to ensure that inclusion of referred policy sets has not happened
+ PolicySet basicAuthMsgProtSecurityPolicySet = policySetTable.get(basicAuthMsgProtSecurity);
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());
+
+ ExtensionType wsBindingType = bindingTypesTable.get(wsBinding);
+ assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
+ ExtensionType javaImplType = implTypesTable.get(javaImpl);
+ assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+
+ List<Intent> intents = new ArrayList<Intent>(intentTable.values());
+
+ for (Intent intent : intents) {
+ staxProcessor.resolve(intent, resolver, context);
+ }
+
+ for (PolicySet policySet : policySetTable.values()) {
+ if (policySet.getReferencedPolicySets().isEmpty())
+ staxProcessor.resolve(policySet, resolver, context);
+ }
+
+ for (PolicySet policySet : policySetTable.values()) {
+ if (!policySet.getReferencedPolicySets().isEmpty())
+ staxProcessor.resolve(policySet, resolver, context);
+ }
+
+ for (ExtensionType bindingType : bindingTypesTable.values()) {
+ staxProcessor.resolve(bindingType, resolver, context);
+ }
+
+ for (ExtensionType implType : implTypesTable.values()) {
+ staxProcessor.resolve(implType, resolver, context);
+ }
+
+ //testing if policy intents have been linked have property been linked up
+ assertNotNull(profileIntent.getRequiredIntents().get(0).getDescription());
+ assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
+ assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
+ assertNotNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
+
+ //testing if policysets have been properly linked up with intents
+ assertFalse(secureMessagingPolicySet.isUnresolved());
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality_transport)));
+
+ //testing if intent maps have been properly mapped to policies
+ assertFalse(securityPolicySet.isUnresolved());
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality_message)));
+
+ //testing for inclusion of referred policysets
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());
+ assertTrue(isRealizedBy(basicAuthMsgProtSecurityPolicySet, intentTable.get(confidentiality_transport)));
+
+ assertNotNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNotNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
+ assertNotNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNotNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+ }
+
+ private boolean isRealizedBy(PolicySet policySet, Intent intent) {
+ if (intent.getName().getLocalPart().indexOf('.') == -1) {
+ return policySet.getProvidedIntents().contains(intent);
+ }
+ for (IntentMap map : policySet.getIntentMaps()) {
+ for (Qualifier q : map.getQualifiers()) {
+ if (q.getIntent().equals(intent)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..aea2c3adb8
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<PolicyExpression> {
+
+ public QName getArtifactType() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public PolicyExpression read(XMLStreamReader arg0, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ return new MockPolicyImplOne();
+ }
+
+ public void write(PolicyExpression arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ }
+
+ public Class<PolicyExpression> getModelType() {
+ // TODO Auto-generated method stub
+ return PolicyExpression.class;
+ }
+
+ public void resolve(PolicyExpression arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+ public class MockPolicyImplOne implements PolicyExpression {
+ public <T> T getPolicy() {
+ return null;
+ }
+
+ public void setName(QName name) {
+ }
+
+ public <T> void setPolicy(T policy) {
+ }
+
+ public QName getName() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
new file mode 100644
index 0000000000..be0c1eb737
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:x="http://x"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" multiplicity="0..1" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+ <x:unknownElement uknAttr="attribute1">
+ <y:subUnknownElement1 xmlns:y="http://y" uknAttr1="attribute2"/>
+ <x:subUnknownElement2 />
+ </x:unknownElement>
+
+</composite>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
new file mode 100644
index 0000000000..83fa64cef4
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService">
+ <interface.java interface="calculator.DivideService" />
+ </reference>
+
+</componentType>
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorURISpaces.composite b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorURISpaces.composite
new file mode 100644
index 0000000000..287810b156
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorURISpaces.composite
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:x="http://x"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="Calculator">
+
+ <service name="CalculatorService" promote=" CalculatorServiceComponent ">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" multiplicity="0..1" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+ <x:unknownElement uknAttr="attribute1">
+ <y:subUnknownElement1 xmlns:y="http://y" uknAttr1="attribute2"/>
+ <x:subUnknownElement2 />
+ </x:unknownElement>
+
+</composite>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite
new file mode 100644
index 0000000000..0d344ac937
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://temp"
+ name="composite1">
+ <component name="data7">
+ <implementation.java class="temp.EchoImpl"/>
+ <service name="Echo">
+ <interface.wsdl interface="http://echo.webservice#wsdl.interface(Echo)"/>
+ </service>
+ <reference multiplicity="0..n" name="reference" requires=""/>
+ </component>
+
+ <reference multiplicity="1..n" name="reference" promote="" requires=""/>
+</composite>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite
new file mode 100644
index 0000000000..5606e653bb
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.composite xmlns:n="http://inner" name="n:InnerCalculator"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite
new file mode 100644
index 0000000000..9140403fc4
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://helloWorldRMI"
+ name="HelloWorldRmiComposite">
+
+ <service name="HelloWorldRmiService" promote="HelloWorldServiceComponent">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteService" />
+ </service>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ </component>
+
+ <component name="HelloWorldRmiServiceComponent">
+ <implementation.java class="helloworld.HelloWorldRmiImpl"/>
+ <reference name="extService"></reference>
+ </component>
+
+ <reference name="HelloWorldRmiReference" promote="HelloWorldRmiServiceComponent/extService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteService" />
+ </reference>
+
+</composite>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
new file mode 100644
index 0000000000..195dfcf106
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<composite autowire="false" local="true" name="TestAllCalculator" policySets="sns:SecureReliablePolicy"
+ requires="cns:confidentiality" targetNamespace="http://calc" xmlns:tns="http://calc"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200912 http://docs.oasis-open.org/ns/opencsa/sca/200912 "
+ xmlns:ext="http://extension"
+ xmlns:cns="http://test" xmlns:sns="http://test">
+
+ <include name="tns:TestAllDivide"/>
+ <ext:testExtension/>
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent/CalculatorService" requires="cns:confidentiality"
+ policySets="sns:SecureReliablePolicy">
+ <ext:testExtension/>
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ <operation name="add" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
+
+ <binding.ws name="CalculatorWS" policySets="sns:SecureReliablePolicy" port="" requires="cns:confidentiality" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <ext:testExtension/>
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="" uri="http://calc/callback/ws">
+ </binding.ws>
+ </callback>
+ </service>
+
+ <component name="CalculatorServiceComponent" autowire="false"
+ policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <ext:testExtension/>
+ <service name="CalculatorService" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ </service>
+
+ <reference name="addService" target="AddServiceComponent/AddService" autowire="false" multiplicity="1..1"
+ policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" wiredByImpl="false">
+ <ext:testExtension/>
+ <interface.java interface="calculator.AddService" callbackInterface="calculator.AddCallback" />
+ </reference>
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" />
+ <reference name="divideService" target="DivideServiceComponent" />
+
+ <property name="round" type="xsd:boolean" many="false">true</property>
+
+ <implementation.java class="calculator.CalculatorServiceImpl" policySets="" requires="" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <service name="AddService">
+ <interface.java interface="calculator.AddService" />
+ </service>
+ <implementation.java class="calculator.AddServiceImpl" />
+ </component>
+
+ <component name="NestedCompositeComponent">
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+ <implementation.composite name="tns:Calculator" />
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl" />
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl" />
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl" />
+ </component>
+
+ <reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService" policySets="sns:SecureReliablePolicy"
+ requires="cns:confidentiality">
+ <interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback" />
+
+ <binding.ws name="MultiplyWS" port="" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <binding.ws name="MultiplyCallbackWS" port="" uri="http://calc/callback/ws" policySets="sns:SecureReliablePolicy"
+ requires="cns:confidentiality">
+ </binding.ws>
+ </callback>
+ </reference>
+
+ <property name="prop1" xmlns:foo="http://foo" many="true" type="foo:MyComplexType">
+ <value xsi:type="foo:MyComplexType" attr="bar">
+ <foo:a>AValue</foo:a>
+ <bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
+ </value>
+ <value xsi:type="foo:MyComplexType" attr="zing">
+ <foo:a>BValue</foo:a>
+ <bar:b xmlns:bar="http://bar">BoringURI</bar:b>
+ </value>
+ </property>
+
+ <property name="prop2" xmlns:foo="http://foo" mustSupply="true" element="foo:MyComplexPropertyValue1">
+ <foo:MyComplexPropertyValue1>123</foo:MyComplexPropertyValue1>
+ </property>
+ <property name="prop3" xmlns:foo="http://foo" mustSupply="true" value="123"/>
+ <property name="prop4">123</property>
+ <property name="prop5"><value>123</value></property>
+
+</composite>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite
new file mode 100644
index 0000000000..42e6c1c3ec
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite autowire="false"
+ local="true"
+ name="TestAllDivide"
+ policySets="" requires=""
+ targetNamespace="http://calc"
+ xmlns:tns="http://calc"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200912 http://docs.oasis-open.org/ns/opencsa/sca/200912 ">
+
+ <!--
+ <include name="tns:CompleteDivide"/>
+ -->
+ <service name="DivideService" policySets="" promote="CalculatorDivideComponent/DivideService" requires="">
+ <interface.java interface="calculator.DivideService" callbackInterface="calculator.DivideCallback"/>
+ <operation name="divide" policySets="" requires=""/>
+
+ <binding.ws name="CalculatorWS" policySets="" port="" requires="" uri="http://calc/ws">
+ <operation name="divide" policySets="" requires=""/>
+ </binding.ws>
+
+ <callback policySets="" requires="">
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="" uri="http://calc/callback/ws">
+ <operation name="divideCallback" policySets="" requires=""/>
+ </binding.ws>
+ </callback>
+ </service>
+
+ <component name="CalculatorDivideComponent" autowire="false" policySets="" requires="">
+ <service name="DivideService" policySets="" requires="">
+ <interface.java interface="calculator.DivideService" callbackInterface="calculator.DivideCallback"/>
+ </service>
+ <implementation.java class="calculator.DivideImpl" policySets="" requires=""/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
new file mode 100644
index 0000000000..424cec3e8a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<composite autowire="false" local="true" name="TestAllCalculator"
+ requires="cns:tuscanyIntent_1" targetNamespace="http://calc" xmlns:tns="http://calc"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200912 http://docs.oasis-open.org/ns/opencsa/sca/200912 "
+ xmlns:ext="http://extension"
+ xmlns:cns="http://test" xmlns:sns="http://test">
+
+ <include name="tns:TestAllDivide"/>
+ <ext:testExtension/>
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent/CalculatorService" requires="cns:tuscanyIntent_2 cns:tuscanyIntent_1">
+ <ext:testExtension/>
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ <operation name="add" requires="cns:tuscanyIntent_6"/>
+
+ <binding.ws name="CalculatorWS" port="" requires="cns:tuscanyIntent_3" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback requires="cns:tuscanyIntent_4">
+ <ext:testExtension/>
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="cns:tuscanyIntent_5" uri="http://calc/callback/ws">
+ </binding.ws>
+ </callback>
+ </service>
+
+ <component name="CalculatorServiceComponent" autowire="false"
+ requires="cns:tuscanyIntent_2 cns:tuscanyIntent_3">
+ <ext:testExtension/>
+ <service name="CalculatorService" requires="cns:tuscanyIntent_3">
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="cns:tuscanyIntent_4" uri="http://calc/callback/ws">
+ </binding.ws>
+ <callback>
+ </callback>
+ </service>
+
+ <reference name="addService" target="AddServiceComponent/AddService" autowire="false" multiplicity="1..1"
+ requires="cns:tuscanyIntent_3 cns:tuscanyIntent_2.qualified" wiredByImpl="false">
+ <ext:testExtension/>
+ <interface.java interface="calculator.AddService" callbackInterface="calculator.AddCallback" />
+ <binding.ws name="addServiceWSRef" policySets="" port="" requires="cns:tuscanyIntent_4" uri="http://calc/callback/ws">
+ </binding.ws>
+ </reference>
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" />
+ <reference name="divideService" target="DivideServiceComponent" />
+
+ <property name="round" type="xsd:boolean" many="false">true</property>
+
+ <implementation.java class="calculator.CalculatorServiceImpl" policySets="" requires="cns:tuscanyIntent_4" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <service name="AddService">
+ <interface.java interface="calculator.AddService" />
+ </service>
+ <implementation.java class="calculator.AddServiceImpl" />
+ </component>
+
+ <component name="NestedCompositeComponent">
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+ <implementation.composite name="tns:Calculator" />
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl" />
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl" />
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl" />
+ </component>
+
+ <reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService"
+ requires="cns:tuscanyIntent_2">
+ <interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback" />
+
+ <binding.ws name="MultiplyWS" port="" requires="cns:tuscanyIntent_3" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback policySets="sns:SecureReliablePolicy" requires="cns:tuscanyIntent_3">
+ <binding.ws name="MultiplyCallbackWS" port="" uri="http://calc/callback/ws"
+ requires="cns:tuscanyIntent_4">
+ </binding.ws>
+ </callback>
+ </reference>
+
+ <property name="prop1" xmlns:foo="http://foo">
+ <value xsi:type="foo:MyComplexType" attr="bar">
+ <foo:a>AValue</foo:a>
+ <bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
+ </value>
+ <value xsi:type="foo:MyComplexType" attr="zing">
+ <foo:a>BValue</foo:a>
+ <bar:b xmlns:bar="http://bar">BoringURI</bar:b>
+ </value>
+ </property>
+
+</composite>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml
new file mode 100644
index 0000000000..489d6abed1
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<sca:definitions xmlns="http://test"
+ targetNamespace="http://test"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+<!-- simple intent -->
+ <sca:intent name="tuscanyIntent_1"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ <sca:qualifier name="qualified" default="true"/>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_2"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ <sca:qualifier name="qualified" default="true"/>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_3"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_4"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+<sca:intent name="tuscanyIntent_5"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_6"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_7"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_8"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_9"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_10"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+</sca:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite
new file mode 100644
index 0000000000..279f7d534e
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:calc="http://localcalc"
+ xmlns:test="http://testlocal"
+ targetNamespace="http://localcalc"
+ name="LocalCalculator"
+ local="true">
+
+</composite>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml
new file mode 100644
index 0000000000..2cfbd6bcff
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for whole message encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
+ authentication" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
+ alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml
new file mode 100644
index 0000000000..dc7f5c422c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ attachTo = "//sca:component[@name='CalculatorServiceComponent']/sca:reference[@name='addService']"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for whole message encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
+ authentication" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
+ alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite
new file mode 100644
index 0000000000..0e7aad877e
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent" requires="confidentiality">
+ <implementation.java class="calculator.CalculatorServiceImpl" xmlns:test="http://test" requiers="test:TestIntentOne"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
new file mode 100644
index 0000000000..a262b00345
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ attachTo = "//sca:component[@name='CalculatorServiceComponent']/sca:reference[@name='addService']"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
+ authentication" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
+ alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/LICENSE b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/LICENSE
new file mode 100644
index 0000000000..0bea130c88
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/LICENSE
@@ -0,0 +1,338 @@
+
+ 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.
+
+
+
+===============================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+
+This module includes XSD files under the following OASIS license:
+
+Copyright (C) OASIS(R) 2005, 2009. All Rights Reserved.
+All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual
+Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.
+This document and translations of it may be copied and furnished to others, and derivative works that
+comment on or otherwise explain it or assist in its implementation may be prepared, copied, published,
+and distributed, in whole or in part, without restriction of any kind, provided that the above copyright
+notice and this section are included on all such copies and derivative works. However, this document
+itself may not be modified in any way, including by removing the copyright notice or references to OASIS,
+except as needed for the purpose of developing any document or deliverable produced by an OASIS
+Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR
+Policy, must be followed) or as required to translate it into languages other than English.
+The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors
+or assigns.
+This document and the information contained herein is provided on an "AS IS" basis and OASIS
+DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
+WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP
+RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.
+OASIS requests that any OASIS Party or any other party that believes it has patent claims that would
+necessarily be infringed by implementations of this OASIS Committee Specification or OASIS Standard,
+to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to
+such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that
+produced this specification.
+OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of
+any patent claims that would necessarily be infringed by implementations of this specification by a patent
+holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR
+Mode of the OASIS Technical Committee that produced this specification. OASIS may include such
+claims on its website, but disclaims any obligation to do so.
+OASIS takes no position regarding the validity or scope of any intellectual property or other rights that
+might be claimed to pertain to the implementation or use of the technology described in this document or
+the extent to which any license under such rights might or might not be available; neither does it represent
+that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to
+rights in any document or deliverable produced by an OASIS Technical Committee can be found on the
+OASIS website. Copies of claims of rights made available for publication and any assurances of licenses
+to be made available, or the result of an attempt made to obtain a general license or permission for the use
+of such proprietary rights by implementers or users of this OASIS Committee Specification or OASIS
+Standard, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any
+information or list of intellectual property rights will at any time be complete, or that any claims in such list
+are, in fact, Essential Claims.
+The names "OASIS", are trademarks of OASIS, the owner and developer of this specification, and should
+be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and
+implementation and use of, specifications, while reserving the right to enforce its marks against misleading
+uses. Please see http://www.oasis-open.org/who/trademark.php for above guidance.
+
+===============================================================================
+
+This module includes XSD files under the following W3C(r) Software License:
+
+W3C(r) SOFTWARE NOTICE AND LICENSE
+http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+This work (and included software, documentation such as READMEs, or other related items)
+is being provided by the copyright holders under the following license. By obtaining,
+using and/or copying this work, you (the licensee) agree that you have read, understood,
+and will comply with the following terms and conditions.
+
+Permission to copy, modify, and distribute this software and its documentation, with or
+without modification, for any purpose and without fee or royalty is hereby granted, provided
+that you include the following on ALL copies of the software and documentation or portions
+thereof, including modifications:
+
+ 1. The full text of this NOTICE in a location viewable to users of the redistributed or
+ derivative work.
+ 2. Any pre-existing intellectual property disclaimers, notices, or terms and conditions.
+ If none exist, the W3C Software Short Notice should be included (hypertext is preferred,
+ text is permitted) within the body of any redistributed or derivative code.
+ 3. Notice of any changes or modifications to the files, including the date changes were
+ made. (We recommend you provide URIs to the location from which the code is derived.)
+
+THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
+REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES
+OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR
+DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER
+RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL
+DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+The name and trademarks of copyright holders may NOT be used in advertising or publicity
+pertaining to the software without specific, written prior permission. Title to copyright
+in this software and any associated documentation will at all times remain with copyright
+holders.
+
+===============================================================================
+
+This module includes XSD files under the following license:
+
+http://www.w3.org/Consortium/Legal/copyright-software-19980720
+
+W3C® SOFTWARE NOTICE AND LICENSE
+Copyright (c) 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche
+en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/
+
+This W3C work (including software, documents, or other related items) is being provided by the copyright holders under
+the following license. By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood,
+and will comply with the following terms and conditions:
+
+Permission to use, copy, modify, and distribute this software and its documentation, with or without modification,
+for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies
+of the software and documentation or portions thereof, including modifications, that you make:
+
+ 1. The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
+ 2. Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, a short
+notice of the following form (hypertext is preferred, text is permitted) should be used within the body of any redistributed
+or derivative code: "Copyright (c) [$date-of-software] World Wide Web Consortium, (Massachusetts Institute of Technology,
+Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/"
+ 3. Notice of any changes or modifications to the W3C files, including the date changes were made. (We recommend you provide URIs
+to the location from which the code is derived.)
+
+THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE
+OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE
+OF THE SOFTWARE OR DOCUMENTATION.
+
+The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software
+without specific, written prior permission. Title to copyright in this software and any associated documentation will
+at all times remain with copyright holders.
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/META-INF/MANIFEST.MF b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ff93db6b14
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Assembly Model XML Schemas
+Bundle-ManifestVersion: 2
+Bundle-Description: Apache Tuscany SCA Assembly Model XML Schemas
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-DocURL: http://www.apache.org/
+Bundle-SymbolicName: org.apache.tuscany.sca.assembly.xsd
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Export-Package: org.apache.tuscany.sca.assembly.xsd;version="2.0.0"
+Import-Package: javax.xml.namespace
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/NOTICE b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/NOTICE
new file mode 100644
index 0000000000..c5118ba0fd
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/NOTICE
@@ -0,0 +1,38 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product also includes software under the OASIS license
+(see the LICENSE file contained in this distribution), with the following
+copyright:
+
+Copyright (C) OASIS(R) 2005, 2009. All Rights Reserved.
+OASIS trademark, IPR and other policies apply.
+
+This product also includes software under the W3C(r) Software License
+(see the LICENSE file contained in this distribution), with the following
+copyright:
+
+Copyright (c) 2004 World Wide Web Consortium (Massachusetts Institute of Technology,
+European Research Consortium for Informatics and Mathematics, Keio University).
+All Rights Reserved. This work is distributed under the W3C(r) Software License [1]
+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.
+
+ [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+This product also includes software under the W3C(c) Software License
+with the following copyright:
+
+Copyright 2001 The Internet Society and W3C (Massachusetts Institute
+of Technology, Institut National de Recherche en Informatique et en
+Automatique, Keio University). All Rights Reserved.
+http://www.w3.org/Consortium/Legal/
+
+This document is governed by the W3C Software License [1] as described
+in the FAQ [2].
+
+[1] http://www.w3.org/Consortium/Legal/copyright-software-19980720
+[2] http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/pom.xml b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/pom.xml
new file mode 100644
index 0000000000..8193461b62
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <name>Apache Tuscany SCA Assembly Model XSD Files</name>
+
+</project>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java
new file mode 100644
index 0000000000..d782b20a4f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.xsd;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Constants used in SCA assembly XML files.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Constants {
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ String COMPONENT_TYPE = "componentType";
+ QName COMPONENT_TYPE_QNAME = new QName(SCA11_NS, COMPONENT_TYPE);
+
+ String SERVICE = "service";
+ QName SERVICE_QNAME = new QName(SCA11_NS, SERVICE);
+
+ String REFERENCE = "reference";
+ QName REFERENCE_QNAME = new QName(SCA11_NS, REFERENCE);
+
+ String PROPERTY = "property";
+ QName PROPERTY_QNAME = new QName(SCA11_NS, PROPERTY);
+
+ String COMPOSITE = "composite";
+ QName COMPOSITE_QNAME = new QName(SCA11_NS, COMPOSITE);
+
+ String INCLUDE = "include";
+ QName INCLUDE_QNAME = new QName(SCA11_NS, INCLUDE);
+
+ String COMPONENT = "component";
+ QName COMPONENT_QNAME = new QName(SCA11_NS, COMPONENT);
+
+ String WIRE = "wire";
+ QName WIRE_QNAME = new QName(SCA11_NS, WIRE);
+
+ String OPERATION = "operation";
+ QName OPERATION_QNAME = new QName(SCA11_NS, OPERATION);
+
+ String CALLBACK = "callback";
+ QName CALLBACK_QNAME = new QName(SCA11_NS, CALLBACK);
+
+ String IMPLEMENTATION_COMPOSITE = "implementation.composite";
+ QName IMPLEMENTATION_COMPOSITE_QNAME = new QName(SCA11_NS, IMPLEMENTATION_COMPOSITE);
+
+ String IMPLEMENTATION = "implementation";
+ QName IMPLEMENTATION_QNAME = new QName(SCA11_NS, IMPLEMENTATION);
+
+ String BINDING_SCA = "binding.sca";
+ QName BINDING_SCA_QNAME = new QName(Constants.SCA11_NS, BINDING_SCA);
+
+ String NAME = "name";
+ String VALUE = "value";
+ QName VALUE_QNAME = new QName(SCA11_NS, VALUE);
+ String TARGET_NAMESPACE = "targetNamespace";
+ String LOCAL = "local";
+ String AUTOWIRE = "autowire";
+ String NONOVERRIDABLE = "nonOverridable";
+ String REPLACE = "replace";
+ String REQUIRES = "requires";
+ String POLICY_SETS = "policySets";
+ String APPLICABLE_POLICY_SETS = "applicablePolicySets";
+ String PROMOTE = "promote";
+ String TARGET = "target";
+ String WIRED_BY_IMPL = "wiredByImpl";
+ String MULTIPLICITY = "multiplicity";
+ String TYPE = "type";
+ String ELEMENT = "element";
+ String MANY = "many";
+ String MUST_SUPPLY = "mustSupply";
+ String SOURCE = "source";
+ String FILE = "file";
+ String URI = "uri";
+ String ZERO_ONE = "0..1";
+ String ZERO_N = "0..n";
+ String ONE_ONE = "1..1";
+ String ONE_N = "1..n";
+
+ /**
+ * Cache for public XSDs and DTDs
+ */
+ Map<String, URL> CACHED_XSDS = XSDCache.cache();
+
+ static class XSDCache {
+ static Map<String, URL> cache() {
+ Map<String, URL> cachedXSDs = new HashMap<String, URL>();
+ cachedXSDs.put(Constants.SCA11_NS, Constants.class.getResource("/sca-1.1-cd05.xsd"));
+ cachedXSDs
+ .put("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
+ Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd"));
+ cachedXSDs
+ .put("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd",
+ Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd"));
+ cachedXSDs.put("http://www.w3.org/2005/08/addressing", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd"));
+ cachedXSDs.put("http://www.w3.org/ns/ws-policy", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd"));
+ cachedXSDs.put("http://www.w3.org/ns/wsdl-instance", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd"));
+ cachedXSDs.put("http://www.w3.org/XML/1998/namespace", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/xml.xsd"));
+ cachedXSDs.put("http://www.w3.org/2000/09/xmldsig#", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd"));
+
+ cachedXSDs.put("-//W3C//DTD XMLSchema 200102//EN", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd"));
+ cachedXSDs.put("-//W3C//DTD XMLSCHEMA 200102//EN", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd"));
+ cachedXSDs.put("datatypes", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd"));
+ return cachedXSDs;
+ }
+ };
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..ad8ef70c3c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+tuscany-sca-1.1.xsd
+sca-1.1-cd05.xsd
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd
new file mode 100644
index 0000000000..e8e8f7625a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd
@@ -0,0 +1,402 @@
+<!-- DTD for XML Schemas: Part 1: Structures
+ Public Identifier: "-//W3C//DTD XMLSCHEMA 200102//EN"
+ Official Location: http://www.w3.org/2001/XMLSchema.dtd -->
+<!-- $Id: XMLSchema.dtd,v 1.31 2001/10/24 15:50:16 ht Exp $ -->
+<!-- Note this DTD is NOT normative, or even definitive. --> <!--d-->
+<!-- prose copy in the structures REC is the definitive version --> <!--d-->
+<!-- (which shouldn't differ from this one except for this --> <!--d-->
+<!-- comment and entity expansions, but just in case) --> <!--d-->
+<!-- With the exception of cases with multiple namespace
+ prefixes for the XML Schema namespace, any XML document which is
+ not valid per this DTD given redefinitions in its internal subset of the
+ 'p' and 's' parameter entities below appropriate to its namespace
+ declaration of the XML Schema namespace is almost certainly not
+ a valid schema. -->
+
+<!-- The simpleType element and its constituent parts
+ are defined in XML Schema: Part 2: Datatypes -->
+<!ENTITY % xs-datatypes PUBLIC 'datatypes' 'datatypes.dtd' >
+
+<!ENTITY % p 'xs:'> <!-- can be overriden in the internal subset of a
+ schema document to establish a different
+ namespace prefix -->
+<!ENTITY % s ':xs'> <!-- if %p is defined (e.g. as foo:) then you must
+ also define %s as the suffix for the appropriate
+ namespace declaration (e.g. :foo) -->
+<!ENTITY % nds 'xmlns%s;'>
+
+<!-- Define all the element names, with optional prefix -->
+<!ENTITY % schema "%p;schema">
+<!ENTITY % complexType "%p;complexType">
+<!ENTITY % complexContent "%p;complexContent">
+<!ENTITY % simpleContent "%p;simpleContent">
+<!ENTITY % extension "%p;extension">
+<!ENTITY % element "%p;element">
+<!ENTITY % unique "%p;unique">
+<!ENTITY % key "%p;key">
+<!ENTITY % keyref "%p;keyref">
+<!ENTITY % selector "%p;selector">
+<!ENTITY % field "%p;field">
+<!ENTITY % group "%p;group">
+<!ENTITY % all "%p;all">
+<!ENTITY % choice "%p;choice">
+<!ENTITY % sequence "%p;sequence">
+<!ENTITY % any "%p;any">
+<!ENTITY % anyAttribute "%p;anyAttribute">
+<!ENTITY % attribute "%p;attribute">
+<!ENTITY % attributeGroup "%p;attributeGroup">
+<!ENTITY % include "%p;include">
+<!ENTITY % import "%p;import">
+<!ENTITY % redefine "%p;redefine">
+<!ENTITY % notation "%p;notation">
+
+<!-- annotation elements -->
+<!ENTITY % annotation "%p;annotation">
+<!ENTITY % appinfo "%p;appinfo">
+<!ENTITY % documentation "%p;documentation">
+
+<!-- Customisation entities for the ATTLIST of each element type.
+ Define one of these if your schema takes advantage of the
+ anyAttribute='##other' in the schema for schemas -->
+
+<!ENTITY % schemaAttrs ''>
+<!ENTITY % complexTypeAttrs ''>
+<!ENTITY % complexContentAttrs ''>
+<!ENTITY % simpleContentAttrs ''>
+<!ENTITY % extensionAttrs ''>
+<!ENTITY % elementAttrs ''>
+<!ENTITY % groupAttrs ''>
+<!ENTITY % allAttrs ''>
+<!ENTITY % choiceAttrs ''>
+<!ENTITY % sequenceAttrs ''>
+<!ENTITY % anyAttrs ''>
+<!ENTITY % anyAttributeAttrs ''>
+<!ENTITY % attributeAttrs ''>
+<!ENTITY % attributeGroupAttrs ''>
+<!ENTITY % uniqueAttrs ''>
+<!ENTITY % keyAttrs ''>
+<!ENTITY % keyrefAttrs ''>
+<!ENTITY % selectorAttrs ''>
+<!ENTITY % fieldAttrs ''>
+<!ENTITY % includeAttrs ''>
+<!ENTITY % importAttrs ''>
+<!ENTITY % redefineAttrs ''>
+<!ENTITY % notationAttrs ''>
+<!ENTITY % annotationAttrs ''>
+<!ENTITY % appinfoAttrs ''>
+<!ENTITY % documentationAttrs ''>
+
+<!ENTITY % complexDerivationSet "CDATA">
+ <!-- #all or space-separated list drawn from derivationChoice -->
+<!ENTITY % blockSet "CDATA">
+ <!-- #all or space-separated list drawn from
+ derivationChoice + 'substitution' -->
+
+<!ENTITY % mgs '%all; | %choice; | %sequence;'>
+<!ENTITY % cs '%choice; | %sequence;'>
+<!ENTITY % formValues '(qualified|unqualified)'>
+
+
+<!ENTITY % attrDecls '((%attribute;| %attributeGroup;)*,(%anyAttribute;)?)'>
+
+<!ENTITY % particleAndAttrs '((%mgs; | %group;)?, %attrDecls;)'>
+
+<!-- This is used in part2 -->
+<!ENTITY % restriction1 '((%mgs; | %group;)?)'>
+
+%xs-datatypes;
+
+<!-- the duplication below is to produce an unambiguous content model
+ which allows annotation everywhere -->
+<!ELEMENT %schema; ((%include; | %import; | %redefine; | %annotation;)*,
+ ((%simpleType; | %complexType;
+ | %element; | %attribute;
+ | %attributeGroup; | %group;
+ | %notation; ),
+ (%annotation;)*)* )>
+<!ATTLIST %schema;
+ targetNamespace %URIref; #IMPLIED
+ version CDATA #IMPLIED
+ %nds; %URIref; #FIXED 'http://www.w3.org/2001/XMLSchema'
+ xmlns CDATA #IMPLIED
+ finalDefault %complexDerivationSet; ''
+ blockDefault %blockSet; ''
+ id ID #IMPLIED
+ elementFormDefault %formValues; 'unqualified'
+ attributeFormDefault %formValues; 'unqualified'
+ xml:lang CDATA #IMPLIED
+ %schemaAttrs;>
+<!-- Note the xmlns declaration is NOT in the Schema for Schemas,
+ because at the Infoset level where schemas operate,
+ xmlns(:prefix) is NOT an attribute! -->
+<!-- The declaration of xmlns is a convenience for schema authors -->
+
+<!-- The id attribute here and below is for use in external references
+ from non-schemas using simple fragment identifiers.
+ It is NOT used for schema-to-schema reference, internal or
+ external. -->
+
+<!-- a type is a named content type specification which allows attribute
+ declarations-->
+<!-- -->
+
+<!ELEMENT %complexType; ((%annotation;)?,
+ (%simpleContent;|%complexContent;|
+ %particleAndAttrs;))>
+
+<!ATTLIST %complexType;
+ name %NCName; #IMPLIED
+ id ID #IMPLIED
+ abstract %boolean; #IMPLIED
+ final %complexDerivationSet; #IMPLIED
+ block %complexDerivationSet; #IMPLIED
+ mixed (true|false) 'false'
+ %complexTypeAttrs;>
+
+<!-- particleAndAttrs is shorthand for a root type -->
+<!-- mixed is disallowed if simpleContent, overriden if complexContent
+ has one too. -->
+
+<!-- If anyAttribute appears in one or more referenced attributeGroups
+ and/or explicitly, the intersection of the permissions is used -->
+
+<!ELEMENT %complexContent; ((%annotation;)?, (%restriction;|%extension;))>
+<!ATTLIST %complexContent;
+ mixed (true|false) #IMPLIED
+ id ID #IMPLIED
+ %complexContentAttrs;>
+
+<!-- restriction should use the branch defined above, not the simple
+ one from part2; extension should use the full model -->
+
+<!ELEMENT %simpleContent; ((%annotation;)?, (%restriction;|%extension;))>
+<!ATTLIST %simpleContent;
+ id ID #IMPLIED
+ %simpleContentAttrs;>
+
+<!-- restriction should use the simple branch from part2, not the
+ one defined above; extension should have no particle -->
+
+<!ELEMENT %extension; ((%annotation;)?, (%particleAndAttrs;))>
+<!ATTLIST %extension;
+ base %QName; #REQUIRED
+ id ID #IMPLIED
+ %extensionAttrs;>
+
+<!-- an element is declared by either:
+ a name and a type (either nested or referenced via the type attribute)
+ or a ref to an existing element declaration -->
+
+<!ELEMENT %element; ((%annotation;)?, (%complexType;| %simpleType;)?,
+ (%unique; | %key; | %keyref;)*)>
+<!-- simpleType or complexType only if no type|ref attribute -->
+<!-- ref not allowed at top level -->
+<!ATTLIST %element;
+ name %NCName; #IMPLIED
+ id ID #IMPLIED
+ ref %QName; #IMPLIED
+ type %QName; #IMPLIED
+ minOccurs %nonNegativeInteger; #IMPLIED
+ maxOccurs CDATA #IMPLIED
+ nillable %boolean; #IMPLIED
+ substitutionGroup %QName; #IMPLIED
+ abstract %boolean; #IMPLIED
+ final %complexDerivationSet; #IMPLIED
+ block %blockSet; #IMPLIED
+ default CDATA #IMPLIED
+ fixed CDATA #IMPLIED
+ form %formValues; #IMPLIED
+ %elementAttrs;>
+<!-- type and ref are mutually exclusive.
+ name and ref are mutually exclusive, one is required -->
+<!-- In the absence of type AND ref, type defaults to type of
+ substitutionGroup, if any, else the ur-type, i.e. unconstrained -->
+<!-- default and fixed are mutually exclusive -->
+
+<!ELEMENT %group; ((%annotation;)?,(%mgs;)?)>
+<!ATTLIST %group;
+ name %NCName; #IMPLIED
+ ref %QName; #IMPLIED
+ minOccurs %nonNegativeInteger; #IMPLIED
+ maxOccurs CDATA #IMPLIED
+ id ID #IMPLIED
+ %groupAttrs;>
+
+<!ELEMENT %all; ((%annotation;)?, (%element;)*)>
+<!ATTLIST %all;
+ minOccurs (1) #IMPLIED
+ maxOccurs (1) #IMPLIED
+ id ID #IMPLIED
+ %allAttrs;>
+
+<!ELEMENT %choice; ((%annotation;)?, (%element;| %group;| %cs; | %any;)*)>
+<!ATTLIST %choice;
+ minOccurs %nonNegativeInteger; #IMPLIED
+ maxOccurs CDATA #IMPLIED
+ id ID #IMPLIED
+ %choiceAttrs;>
+
+<!ELEMENT %sequence; ((%annotation;)?, (%element;| %group;| %cs; | %any;)*)>
+<!ATTLIST %sequence;
+ minOccurs %nonNegativeInteger; #IMPLIED
+ maxOccurs CDATA #IMPLIED
+ id ID #IMPLIED
+ %sequenceAttrs;>
+
+<!-- an anonymous grouping in a model, or
+ a top-level named group definition, or a reference to same -->
+
+<!-- Note that if order is 'all', group is not allowed inside.
+ If order is 'all' THIS group must be alone (or referenced alone) at
+ the top level of a content model -->
+<!-- If order is 'all', minOccurs==maxOccurs==1 on element/any inside -->
+<!-- Should allow minOccurs=0 inside order='all' . . . -->
+
+<!ELEMENT %any; (%annotation;)?>
+<!ATTLIST %any;
+ namespace CDATA '##any'
+ processContents (skip|lax|strict) 'strict'
+ minOccurs %nonNegativeInteger; '1'
+ maxOccurs CDATA '1'
+ id ID #IMPLIED
+ %anyAttrs;>
+
+<!-- namespace is interpreted as follows:
+ ##any - - any non-conflicting WFXML at all
+
+ ##other - - any non-conflicting WFXML from namespace other
+ than targetNamespace
+
+ ##local - - any unqualified non-conflicting WFXML/attribute
+ one or - - any non-conflicting WFXML from
+ more URI the listed namespaces
+ references
+
+ ##targetNamespace ##local may appear in the above list,
+ with the obvious meaning -->
+
+<!ELEMENT %anyAttribute; (%annotation;)?>
+<!ATTLIST %anyAttribute;
+ namespace CDATA '##any'
+ processContents (skip|lax|strict) 'strict'
+ id ID #IMPLIED
+ %anyAttributeAttrs;>
+<!-- namespace is interpreted as for 'any' above -->
+
+<!-- simpleType only if no type|ref attribute -->
+<!-- ref not allowed at top level, name iff at top level -->
+<!ELEMENT %attribute; ((%annotation;)?, (%simpleType;)?)>
+<!ATTLIST %attribute;
+ name %NCName; #IMPLIED
+ id ID #IMPLIED
+ ref %QName; #IMPLIED
+ type %QName; #IMPLIED
+ use (prohibited|optional|required) #IMPLIED
+ default CDATA #IMPLIED
+ fixed CDATA #IMPLIED
+ form %formValues; #IMPLIED
+ %attributeAttrs;>
+<!-- type and ref are mutually exclusive.
+ name and ref are mutually exclusive, one is required -->
+<!-- default for use is optional when nested, none otherwise -->
+<!-- default and fixed are mutually exclusive -->
+<!-- type attr and simpleType content are mutually exclusive -->
+
+<!-- an attributeGroup is a named collection of attribute decls, or a
+ reference thereto -->
+<!ELEMENT %attributeGroup; ((%annotation;)?,
+ (%attribute; | %attributeGroup;)*,
+ (%anyAttribute;)?) >
+<!ATTLIST %attributeGroup;
+ name %NCName; #IMPLIED
+ id ID #IMPLIED
+ ref %QName; #IMPLIED
+ %attributeGroupAttrs;>
+
+<!-- ref iff no content, no name. ref iff not top level -->
+
+<!-- better reference mechanisms -->
+<!ELEMENT %unique; ((%annotation;)?, %selector;, (%field;)+)>
+<!ATTLIST %unique;
+ name %NCName; #REQUIRED
+ id ID #IMPLIED
+ %uniqueAttrs;>
+
+<!ELEMENT %key; ((%annotation;)?, %selector;, (%field;)+)>
+<!ATTLIST %key;
+ name %NCName; #REQUIRED
+ id ID #IMPLIED
+ %keyAttrs;>
+
+<!ELEMENT %keyref; ((%annotation;)?, %selector;, (%field;)+)>
+<!ATTLIST %keyref;
+ name %NCName; #REQUIRED
+ refer %QName; #REQUIRED
+ id ID #IMPLIED
+ %keyrefAttrs;>
+
+<!ELEMENT %selector; ((%annotation;)?)>
+<!ATTLIST %selector;
+ xpath %XPathExpr; #REQUIRED
+ id ID #IMPLIED
+ %selectorAttrs;>
+<!ELEMENT %field; ((%annotation;)?)>
+<!ATTLIST %field;
+ xpath %XPathExpr; #REQUIRED
+ id ID #IMPLIED
+ %fieldAttrs;>
+
+<!-- Schema combination mechanisms -->
+<!ELEMENT %include; (%annotation;)?>
+<!ATTLIST %include;
+ schemaLocation %URIref; #REQUIRED
+ id ID #IMPLIED
+ %includeAttrs;>
+
+<!ELEMENT %import; (%annotation;)?>
+<!ATTLIST %import;
+ namespace %URIref; #IMPLIED
+ schemaLocation %URIref; #IMPLIED
+ id ID #IMPLIED
+ %importAttrs;>
+
+<!ELEMENT %redefine; (%annotation; | %simpleType; | %complexType; |
+ %attributeGroup; | %group;)*>
+<!ATTLIST %redefine;
+ schemaLocation %URIref; #REQUIRED
+ id ID #IMPLIED
+ %redefineAttrs;>
+
+<!ELEMENT %notation; (%annotation;)?>
+<!ATTLIST %notation;
+ name %NCName; #REQUIRED
+ id ID #IMPLIED
+ public CDATA #REQUIRED
+ system %URIref; #IMPLIED
+ %notationAttrs;>
+
+<!-- Annotation is either application information or documentation -->
+<!-- By having these here they are available for datatypes as well
+ as all the structures elements -->
+
+<!ELEMENT %annotation; (%appinfo; | %documentation;)*>
+<!ATTLIST %annotation; %annotationAttrs;>
+
+<!-- User must define annotation elements in internal subset for this
+ to work -->
+<!ELEMENT %appinfo; ANY> <!-- too restrictive -->
+<!ATTLIST %appinfo;
+ source %URIref; #IMPLIED
+ id ID #IMPLIED
+ %appinfoAttrs;>
+<!ELEMENT %documentation; ANY> <!-- too restrictive -->
+<!ATTLIST %documentation;
+ source %URIref; #IMPLIED
+ id ID #IMPLIED
+ xml:lang CDATA #IMPLIED
+ %documentationAttrs;>
+
+<!NOTATION XMLSchemaStructures PUBLIC
+ 'structures' 'http://www.w3.org/2001/XMLSchema.xsd' >
+<!NOTATION XML PUBLIC
+ 'REC-xml-1998-0210' 'http://www.w3.org/TR/1998/REC-xml-19980210' >
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd
new file mode 100644
index 0000000000..685e89a57e
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd
@@ -0,0 +1,204 @@
+<!--
+ DTD for XML Schemas: Part 2: Datatypes
+ $Id: datatypes.dtd,v 1.23 2001/03/16 17:36:30 ht Exp $
+ Note this DTD is NOT normative, or even definitive. - - the
+ prose copy in the datatypes REC is the definitive version
+ (which shouldn't differ from this one except for this comment
+ and entity expansions, but just in case)
+ -->
+
+<!--
+ This DTD cannot be used on its own, it is intended
+ only for incorporation in XMLSchema.dtd, q.v.
+ -->
+
+<!-- Define all the element names, with optional prefix -->
+<!ENTITY % simpleType "%p;simpleType">
+<!ENTITY % restriction "%p;restriction">
+<!ENTITY % list "%p;list">
+<!ENTITY % union "%p;union">
+<!ENTITY % maxExclusive "%p;maxExclusive">
+<!ENTITY % minExclusive "%p;minExclusive">
+<!ENTITY % maxInclusive "%p;maxInclusive">
+<!ENTITY % minInclusive "%p;minInclusive">
+<!ENTITY % totalDigits "%p;totalDigits">
+<!ENTITY % fractionDigits "%p;fractionDigits">
+<!ENTITY % length "%p;length">
+<!ENTITY % minLength "%p;minLength">
+<!ENTITY % maxLength "%p;maxLength">
+<!ENTITY % enumeration "%p;enumeration">
+<!ENTITY % whiteSpace "%p;whiteSpace">
+<!ENTITY % pattern "%p;pattern">
+
+<!--
+ Customisation entities for the ATTLIST of each element
+ type. Define one of these if your schema takes advantage
+ of the anyAttribute='##other' in the schema for schemas
+ -->
+
+<!ENTITY % simpleTypeAttrs "">
+<!ENTITY % restrictionAttrs "">
+<!ENTITY % listAttrs "">
+<!ENTITY % unionAttrs "">
+<!ENTITY % maxExclusiveAttrs "">
+<!ENTITY % minExclusiveAttrs "">
+<!ENTITY % maxInclusiveAttrs "">
+<!ENTITY % minInclusiveAttrs "">
+<!ENTITY % totalDigitsAttrs "">
+<!ENTITY % fractionDigitsAttrs "">
+<!ENTITY % lengthAttrs "">
+<!ENTITY % minLengthAttrs "">
+<!ENTITY % maxLengthAttrs "">
+<!ENTITY % enumerationAttrs "">
+<!ENTITY % whiteSpaceAttrs "">
+<!ENTITY % patternAttrs "">
+
+<!-- Define some entities for informative use as attribute
+ types -->
+<!ENTITY % URIref "CDATA">
+<!ENTITY % XPathExpr "CDATA">
+<!ENTITY % QName "NMTOKEN">
+<!ENTITY % QNames "NMTOKENS">
+<!ENTITY % NCName "NMTOKEN">
+<!ENTITY % nonNegativeInteger "NMTOKEN">
+<!ENTITY % boolean "(true|false)">
+<!ENTITY % simpleDerivationSet "CDATA">
+<!--
+ #all or space-separated list drawn from derivationChoice
+ -->
+
+<!--
+ Note that the use of 'facet' below is less restrictive
+ than is really intended: There should in fact be no
+ more than one of each of minInclusive, minExclusive,
+ maxInclusive, maxExclusive, totalDigits, fractionDigits,
+ length, maxLength, minLength within datatype,
+ and the min- and max- variants of Inclusive and Exclusive
+ are mutually exclusive. On the other hand, pattern and
+ enumeration may repeat.
+ -->
+<!ENTITY % minBound "(%minInclusive; | %minExclusive;)">
+<!ENTITY % maxBound "(%maxInclusive; | %maxExclusive;)">
+<!ENTITY % bounds "%minBound; | %maxBound;">
+<!ENTITY % numeric "%totalDigits; | %fractionDigits;">
+<!ENTITY % ordered "%bounds; | %numeric;">
+<!ENTITY % unordered
+ "%pattern; | %enumeration; | %whiteSpace; | %length; |
+ %maxLength; | %minLength;">
+<!ENTITY % facet "%ordered; | %unordered;">
+<!ENTITY % facetAttr
+ "value CDATA #REQUIRED
+ id ID #IMPLIED">
+<!ENTITY % fixedAttr "fixed %boolean; #IMPLIED">
+<!ENTITY % facetModel "(%annotation;)?">
+<!ELEMENT %simpleType;
+ ((%annotation;)?, (%restriction; | %list; | %union;))>
+<!ATTLIST %simpleType;
+ name %NCName; #IMPLIED
+ final %simpleDerivationSet; #IMPLIED
+ id ID #IMPLIED
+ %simpleTypeAttrs;>
+<!-- name is required at top level -->
+<!ELEMENT %restriction; ((%annotation;)?,
+ (%restriction1; |
+ ((%simpleType;)?,(%facet;)*)),
+ (%attrDecls;))>
+<!ATTLIST %restriction;
+ base %QName; #IMPLIED
+ id ID #IMPLIED
+ %restrictionAttrs;>
+<!--
+ base and simpleType child are mutually exclusive,
+ one is required.
+
+ restriction is shared between simpleType and
+ simpleContent and complexContent (in XMLSchema.xsd).
+ restriction1 is for the latter cases, when this
+ is restricting a complex type, as is attrDecls.
+ -->
+<!ELEMENT %list; ((%annotation;)?,(%simpleType;)?)>
+<!ATTLIST %list;
+ itemType %QName; #IMPLIED
+ id ID #IMPLIED
+ %listAttrs;>
+<!--
+ itemType and simpleType child are mutually exclusive,
+ one is required
+ -->
+<!ELEMENT %union; ((%annotation;)?,(%simpleType;)*)>
+<!ATTLIST %union;
+ id ID #IMPLIED
+ memberTypes %QNames; #IMPLIED
+ %unionAttrs;>
+<!--
+ At least one item in memberTypes or one simpleType
+ child is required
+ -->
+
+<!ELEMENT %maxExclusive; %facetModel;>
+<!ATTLIST %maxExclusive;
+ %facetAttr;
+ %fixedAttr;
+ %maxExclusiveAttrs;>
+<!ELEMENT %minExclusive; %facetModel;>
+<!ATTLIST %minExclusive;
+ %facetAttr;
+ %fixedAttr;
+ %minExclusiveAttrs;>
+
+<!ELEMENT %maxInclusive; %facetModel;>
+<!ATTLIST %maxInclusive;
+ %facetAttr;
+ %fixedAttr;
+ %maxInclusiveAttrs;>
+<!ELEMENT %minInclusive; %facetModel;>
+<!ATTLIST %minInclusive;
+ %facetAttr;
+ %fixedAttr;
+ %minInclusiveAttrs;>
+
+<!ELEMENT %totalDigits; %facetModel;>
+<!ATTLIST %totalDigits;
+ %facetAttr;
+ %fixedAttr;
+ %totalDigitsAttrs;>
+<!ELEMENT %fractionDigits; %facetModel;>
+<!ATTLIST %fractionDigits;
+ %facetAttr;
+ %fixedAttr;
+ %fractionDigitsAttrs;>
+
+<!ELEMENT %length; %facetModel;>
+<!ATTLIST %length;
+ %facetAttr;
+ %fixedAttr;
+ %lengthAttrs;>
+<!ELEMENT %minLength; %facetModel;>
+<!ATTLIST %minLength;
+ %facetAttr;
+ %fixedAttr;
+ %minLengthAttrs;>
+<!ELEMENT %maxLength; %facetModel;>
+<!ATTLIST %maxLength;
+ %facetAttr;
+ %fixedAttr;
+ %maxLengthAttrs;>
+
+<!-- This one can be repeated -->
+<!ELEMENT %enumeration; %facetModel;>
+<!ATTLIST %enumeration;
+ %facetAttr;
+ %enumerationAttrs;>
+
+<!ELEMENT %whiteSpace; %facetModel;>
+<!ATTLIST %whiteSpace;
+ %facetAttr;
+ %fixedAttr;
+ %whiteSpaceAttrs;>
+
+<!-- This one can be repeated -->
+<!ELEMENT %pattern; %facetModel;>
+<!ATTLIST %pattern;
+ %facetAttr;
+ %patternAttrs;>
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd
new file mode 100644
index 0000000000..641798b17f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS's procedures with respect to rights in OASIS specifications can be found at the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementors or users of this specification, can be obtained from the OASIS Executive Director.
+OASIS invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights which may cover technology that may be required to implement this specification. Please address the information to the OASIS Executive Director.
+Copyright © OASIS Open 2002-2004. All Rights Reserved.
+This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself does not be modified in any way, such as by removing the copyright notice or references to OASIS, except as needed for the purpose of developing OASIS specifications, in which case the procedures for copyrights defined in the OASIS Intellectual Property Rights document must be followed, or as required to translate it into languages other than English.
+The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns.
+This document and the information contained herein is provided on an “AS IS†basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+-->
+<xsd:schema targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" elementFormDefault="qualified" attributeFormDefault="unqualified" blockDefault="#all" version="0.2">
+ <xsd:import namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" schemaLocation="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"/>
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+ <xsd:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"/>
+ <xsd:complexType name="AttributedString">
+ <xsd:annotation>
+ <xsd:documentation>This type represents an element with arbitrary attributes.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute ref="wsu:Id"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:complexType name="PasswordString">
+ <xsd:annotation>
+ <xsd:documentation>This type is used for password elements per Section 4.1.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="wsse:AttributedString">
+ <xsd:attribute name="Type" type="xsd:anyURI"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:complexType name="EncodedString">
+ <xsd:annotation>
+ <xsd:documentation>This type is used for elements containing stringified binary data.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="wsse:AttributedString">
+ <xsd:attribute name="EncodingType" type="xsd:anyURI"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:complexType name="UsernameTokenType">
+ <xsd:annotation>
+ <xsd:documentation>This type represents a username token per Section 4.1</xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="Username" type="wsse:AttributedString"/>
+ <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute ref="wsu:Id"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:complexType name="BinarySecurityTokenType">
+ <xsd:annotation>
+ <xsd:documentation>A security token that is encoded in binary</xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="wsse:EncodedString">
+ <xsd:attribute name="ValueType" type="xsd:anyURI"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:complexType name="KeyIdentifierType">
+ <xsd:annotation>
+ <xsd:documentation>A security token key identifier</xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="wsse:EncodedString">
+ <xsd:attribute name="ValueType" type="xsd:anyURI"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:simpleType name="tUsage">
+ <xsd:annotation>
+ <xsd:documentation>Typedef to allow a list of usages (as URIs).</xsd:documentation>
+ </xsd:annotation>
+ <xsd:list itemType="xsd:anyURI"/>
+ </xsd:simpleType>
+ <xsd:attribute name="Usage" type="tUsage">
+ <xsd:annotation>
+ <xsd:documentation>This global attribute is used to indicate the usage of a referenced or indicated token within the containing context</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:complexType name="ReferenceType">
+ <xsd:annotation>
+ <xsd:documentation>This type represents a reference to an external security token.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="URI" type="xsd:anyURI"/>
+ <xsd:attribute name="ValueType" type="xsd:anyURI"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:complexType name="EmbeddedType">
+ <xsd:annotation>
+ <xsd:documentation>This type represents a reference to an embedded security token.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:any processContents="lax"/>
+ </xsd:choice>
+ <xsd:attribute name="ValueType" type="xsd:anyURI"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:complexType name="SecurityTokenReferenceType">
+ <xsd:annotation>
+ <xsd:documentation>This type is used reference a security token.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:any processContents="lax"/>
+ </xsd:choice>
+ <xsd:attribute ref="wsu:Id"/>
+ <xsd:attribute ref="wsse:Usage"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:complexType name="SecurityHeaderType">
+ <xsd:annotation>
+ <xsd:documentation>This complexType defines header block to use for security-relevant data directed at a specific SOAP actor.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>The use of "any" is to allow extensibility and different forms of security data.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:any>
+ </xsd:sequence>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:complexType name="TransformationParametersType">
+ <xsd:annotation>
+ <xsd:documentation>This complexType defines a container for elements to be specified from any namespace as properties/parameters of a DSIG transformation.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>The use of "any" is to allow extensibility from any namespace.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:any>
+ </xsd:sequence>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:element name="UsernameToken" type="wsse:UsernameTokenType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines the wsse:UsernameToken element per Section 4.1.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="BinarySecurityToken" type="wsse:BinarySecurityTokenType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines the wsse:BinarySecurityToken element per Section 4.2.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="Reference" type="wsse:ReferenceType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines a security token reference</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="Embedded" type="wsse:EmbeddedType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines a security token embedded reference</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="KeyIdentifier" type="wsse:KeyIdentifierType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines a key identifier reference</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="SecurityTokenReference" type="wsse:SecurityTokenReferenceType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines the wsse:SecurityTokenReference per Section 4.3.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="Security" type="wsse:SecurityHeaderType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines the wsse:Security SOAP header element per Section 4.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="TransformationParameters" type="wsse:TransformationParametersType">
+ <xsd:annotation>
+ <xsd:documentation>This element contains properties for transformations from any namespace, including DSIG.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="Password" type="wsse:PasswordString"/>
+ <xsd:element name="Nonce" type="wsse:EncodedString"/>
+ <xsd:simpleType name="FaultcodeEnum">
+ <xsd:restriction base="xsd:QName">
+ <xsd:enumeration value="wsse:UnsupportedSecurityToken"/>
+ <xsd:enumeration value="wsse:UnsupportedAlgorithm"/>
+ <xsd:enumeration value="wsse:InvalidSecurity"/>
+ <xsd:enumeration value="wsse:InvalidSecurityToken"/>
+ <xsd:enumeration value="wsse:FailedAuthentication"/>
+ <xsd:enumeration value="wsse:FailedCheck"/>
+ <xsd:enumeration value="wsse:SecurityTokenUnavailable"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+</xsd:schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd
new file mode 100644
index 0000000000..f8d74e9c6e
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS's procedures with respect to rights in OASIS specifications can be found at the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementors or users of this specification, can be obtained from the OASIS Executive Director.
+OASIS invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights which may cover technology that may be required to implement this specification. Please address the information to the OASIS Executive Director.
+Copyright © OASIS Open 2002-2004. All Rights Reserved.
+This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself does not be modified in any way, such as by removing the copyright notice or references to OASIS, except as needed for the purpose of developing OASIS specifications, in which case the procedures for copyrights defined in the OASIS Intellectual Property Rights document must be followed, or as required to translate it into languages other than English.
+The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns.
+This document and the information contained herein is provided on an “AS IS†basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+-->
+<xsd:schema targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
+
+
+xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.1">
+ <!-- // Fault Codes /////////////////////////////////////////// -->
+ <xsd:simpleType name="tTimestampFault">
+ <xsd:annotation>
+ <xsd:documentation>
+This type defines the fault code value for Timestamp message expiration.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:QName">
+ <xsd:enumeration value="wsu:MessageExpired"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- // Global attributes //////////////////////////////////// -->
+ <xsd:attribute name="Id" type="xsd:ID">
+ <xsd:annotation>
+ <xsd:documentation>
+This global attribute supports annotating arbitrary elements with an ID.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attributeGroup name="commonAtts">
+ <xsd:annotation>
+ <xsd:documentation>
+Convenience attribute group used to simplify this schema.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute ref="wsu:Id" use="optional"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:attributeGroup>
+ <!-- // Utility types //////////////////////////////////////// -->
+ <xsd:complexType name="AttributedDateTime">
+ <xsd:annotation>
+ <xsd:documentation>
+This type is for elements whose [children] is a psuedo-dateTime and can have arbitrary attributes.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attributeGroup ref="wsu:commonAtts"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:complexType name="AttributedURI">
+ <xsd:annotation>
+ <xsd:documentation>
+This type is for elements whose [children] is an anyURI and can have arbitrary attributes.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:anyURI">
+ <xsd:attributeGroup ref="wsu:commonAtts"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <!-- // Timestamp header components /////////////////////////// -->
+ <xsd:complexType name="TimestampType">
+ <xsd:annotation>
+ <xsd:documentation>
+This complex type ties together the timestamp related elements into a composite type.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="wsu:Created" minOccurs="0"/>
+ <xsd:element ref="wsu:Expires" minOccurs="0"/>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:any namespace="##other" processContents="lax"/>
+ </xsd:choice>
+ </xsd:sequence>
+ <xsd:attributeGroup ref="wsu:commonAtts"/>
+ </xsd:complexType>
+ <xsd:element name="Timestamp" type="wsu:TimestampType">
+ <xsd:annotation>
+ <xsd:documentation>
+This element allows Timestamps to be applied anywhere element wildcards are present,
+including as a SOAP header.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- global element decls to allow individual elements to appear anywhere -->
+ <xsd:element name="Expires" type="wsu:AttributedDateTime">
+ <xsd:annotation>
+ <xsd:documentation>
+This element allows an expiration time to be applied anywhere element wildcards are present.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="Created" type="wsu:AttributedDateTime">
+ <xsd:annotation>
+ <xsd:documentation>
+This element allows a creation time to be applied anywhere element wildcards are present.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+</xsd:schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd
new file mode 100644
index 0000000000..f6fc9c53b0
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ W3C XML Schema defined in the Web Services Addressing 1.0 specification
+ http://www.w3.org/TR/ws-addr-core
+
+ Copyright © 2005 World Wide Web Consortium,
+
+ (Massachusetts Institute of Technology, European Research Consortium for
+ Informatics and Mathematics, Keio University). All Rights Reserved. This
+ work is distributed under the W3C® Software License [1] 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.
+
+ [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+ $Id: ws-addr.xsd,v 1.2 2008/07/23 13:38:16 plehegar Exp $
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.w3.org/2005/08/addressing" targetNamespace="http://www.w3.org/2005/08/addressing" blockDefault="#all" elementFormDefault="qualified" finalDefault="" attributeFormDefault="unqualified">
+
+ <!-- Constructs from the WS-Addressing Core -->
+
+ <xs:element name="EndpointReference" type="tns:EndpointReferenceType"/>
+ <xs:complexType name="EndpointReferenceType" mixed="false">
+ <xs:sequence>
+ <xs:element name="Address" type="tns:AttributedURIType"/>
+ <xs:element ref="tns:ReferenceParameters" minOccurs="0"/>
+ <xs:element ref="tns:Metadata" minOccurs="0"/>
+ <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
+ <xs:element name="ReferenceParameters" type="tns:ReferenceParametersType"/>
+ <xs:complexType name="ReferenceParametersType" mixed="false">
+ <xs:sequence>
+ <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
+ <xs:element name="Metadata" type="tns:MetadataType"/>
+ <xs:complexType name="MetadataType" mixed="false">
+ <xs:sequence>
+ <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
+ <xs:element name="MessageID" type="tns:AttributedURIType"/>
+ <xs:element name="RelatesTo" type="tns:RelatesToType"/>
+ <xs:complexType name="RelatesToType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:anyURI">
+ <xs:attribute name="RelationshipType" type="tns:RelationshipTypeOpenEnum" use="optional" default="http://www.w3.org/2005/08/addressing/reply"/>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:simpleType name="RelationshipTypeOpenEnum">
+ <xs:union memberTypes="tns:RelationshipType xs:anyURI"/>
+ </xs:simpleType>
+
+ <xs:simpleType name="RelationshipType">
+ <xs:restriction base="xs:anyURI">
+ <xs:enumeration value="http://www.w3.org/2005/08/addressing/reply"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:element name="ReplyTo" type="tns:EndpointReferenceType"/>
+ <xs:element name="From" type="tns:EndpointReferenceType"/>
+ <xs:element name="FaultTo" type="tns:EndpointReferenceType"/>
+ <xs:element name="To" type="tns:AttributedURIType"/>
+ <xs:element name="Action" type="tns:AttributedURIType"/>
+
+ <xs:complexType name="AttributedURIType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:anyURI">
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <!-- Constructs from the WS-Addressing SOAP binding -->
+
+ <xs:attribute name="IsReferenceParameter" type="xs:boolean"/>
+
+ <xs:simpleType name="FaultCodesOpenEnumType">
+ <xs:union memberTypes="tns:FaultCodesType xs:QName"/>
+ </xs:simpleType>
+
+ <xs:simpleType name="FaultCodesType">
+ <xs:restriction base="xs:QName">
+ <xs:enumeration value="tns:InvalidAddressingHeader"/>
+ <xs:enumeration value="tns:InvalidAddress"/>
+ <xs:enumeration value="tns:InvalidEPR"/>
+ <xs:enumeration value="tns:InvalidCardinality"/>
+ <xs:enumeration value="tns:MissingAddressInEPR"/>
+ <xs:enumeration value="tns:DuplicateMessageID"/>
+ <xs:enumeration value="tns:ActionMismatch"/>
+ <xs:enumeration value="tns:MessageAddressingHeaderRequired"/>
+ <xs:enumeration value="tns:DestinationUnreachable"/>
+ <xs:enumeration value="tns:ActionNotSupported"/>
+ <xs:enumeration value="tns:EndpointUnavailable"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:element name="RetryAfter" type="tns:AttributedUnsignedLongType"/>
+ <xs:complexType name="AttributedUnsignedLongType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:unsignedLong">
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:element name="ProblemHeaderQName" type="tns:AttributedQNameType"/>
+ <xs:complexType name="AttributedQNameType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:QName">
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:element name="ProblemIRI" type="tns:AttributedURIType"/>
+
+ <xs:element name="ProblemAction" type="tns:ProblemActionType"/>
+ <xs:complexType name="ProblemActionType" mixed="false">
+ <xs:sequence>
+ <xs:element ref="tns:Action" minOccurs="0"/>
+ <xs:element name="SoapAction" minOccurs="0" type="xs:anyURI"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
+</xs:schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd
new file mode 100644
index 0000000000..c43e5814ed
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd
@@ -0,0 +1,141 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<!--
+
+ W3C XML Schema defined in the Web Services Policy 1.5
+ Framework specification
+
+ http://www.w3.org/TR/ws-policy-framework
+
+ Copyright © 2006 World Wide Web Consortium,
+
+ (Massachusetts Institute of Technology, European Research Consortium for
+ Informatics and Mathematics, Keio University). All Rights Reserved. This
+ work is distributed under the W3C® Software License [1] 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.
+
+ [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+ $Id: ws-policy.xsd,v 1.2 2007/02/14 16:38:37 fsasaki Exp $
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://www.w3.org/ns/ws-policy"
+ xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ targetNamespace="http://www.w3.org/ns/ws-policy" blockDefault="#all"
+ elementFormDefault="qualified">
+
+ <xs:import
+ namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
+ schemaLocation="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" />
+
+ <xs:import
+ namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ schemaLocation="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" />
+
+ <xs:import
+ namespace="http://www.w3.org/XML/1998/namespace"
+ schemaLocation="http://www.w3.org/2001/xml.xsd" />
+
+ <!-- Constructs from the Web Services Policy 1.5 Framework -->
+
+ <xs:element name="Policy" >
+ <xs:complexType>
+
+ <xs:complexContent>
+ <xs:extension base="tns:OperatorContentType" >
+ <xs:attribute name="Name" type="xs:anyURI" />
+ <xs:anyAttribute namespace="##any" processContents="lax" />
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="All" type="tns:OperatorContentType" />
+ <xs:element name="ExactlyOne" type="tns:OperatorContentType" />
+
+ <xs:complexType name="OperatorContentType" >
+ <xs:sequence>
+ <xs:choice minOccurs="0" maxOccurs="unbounded" >
+ <xs:element ref="tns:Policy" />
+ <xs:element ref="tns:All" />
+ <xs:element ref="tns:ExactlyOne" />
+
+ <xs:element ref="tns:PolicyReference" />
+ <xs:any namespace="##other" processContents="lax" />
+ </xs:choice>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="PolicyReference" >
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="URI" type="xs:anyURI" use="required" />
+
+ <xs:attribute name="Digest" type="xs:base64Binary" />
+ <xs:attribute name="DigestAlgorithm"
+ type="xs:anyURI"
+ default="http://www.w3.org/ns/ws-policy/Sha1Exc"
+ />
+ <xs:anyAttribute namespace="##any" processContents="lax" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:attribute name="Optional" type="xs:boolean" default="false" />
+ <xs:attribute name="Ignorable" type="xs:boolean" default="false" />
+
+ <!-- Constructs from the Web Services Policy 1.5 Attachment -->
+
+ <xs:attribute name="PolicyURIs" >
+ <xs:simpleType>
+ <xs:list itemType="xs:anyURI" />
+ </xs:simpleType>
+ </xs:attribute>
+
+ <xs:element name="PolicyAttachment" >
+ <xs:complexType>
+ <xs:sequence>
+
+ <xs:element ref="tns:AppliesTo" />
+ <xs:choice maxOccurs="unbounded" >
+ <xs:element ref="tns:Policy" />
+ <xs:element ref="tns:PolicyReference" />
+ </xs:choice>
+ <!-- omitted only because it causes the content model to be non-determistic
+ <xs:element ref="wsse:Security" minOccurs="0" />
+-->
+ <xs:any namespace="##other"
+ processContents="lax"
+ minOccurs="0"
+ maxOccurs="unbounded" />
+ </xs:sequence>
+ <xs:anyAttribute namespace="##any" processContents="lax" />
+
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="AppliesTo" >
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any namespace="##any"
+ processContents="lax"
+ maxOccurs="unbounded" />
+ </xs:sequence>
+ <xs:anyAttribute namespace="##any" processContents="lax" />
+
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="URI">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:anyURI">
+ <xs:anyAttribute namespace="##any" processContents="lax" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+
+</xs:schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd
new file mode 100644
index 0000000000..7fb8c1beed
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd">
+<!--
+ W3C XML Schema defined in the Web Services Description (WSDL)
+ Version 2.0 specification
+ http://www.w3.org/TR/wsdl20
+
+ Copyright © 2007 World Wide Web Consortium,
+
+ (Massachusetts Institute of Technology, European Research Consortium for
+ Informatics and Mathematics, Keio University). All Rights Reserved. This
+ work is distributed under the W3C® Software License [1] 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.
+
+ [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+ $Id: wsdl20-instance.xsd,v 1.1 2007/06/19 15:59:38 plehegar Exp $
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdli="http://www.w3.org/ns/wsdl-instance" targetNamespace="http://www.w3.org/ns/wsdl-instance" elementFormDefault="qualified" finalDefault="" blockDefault="" attributeFormDefault="unqualified">
+
+ <xs:attribute name="wsdlLocation">
+ <xs:annotation>
+ <xs:documentation>
+ This attribute can be used to provide some hints on where
+ additional WSDL information for a given namespace can be
+ found in order to help with QName resolution
+ </xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
+ <xs:list itemType="xs:anyURI"/>
+ </xs:simpleType>
+ </xs:attribute>
+
+</xs:schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd
new file mode 100644
index 0000000000..ac4b0ec8e6
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd
@@ -0,0 +1,117 @@
+<?xml version='1.0'?>
+<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd" >
+<xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en">
+
+ <xs:annotation>
+ <xs:documentation>
+ See http://www.w3.org/XML/1998/namespace.html and
+ http://www.w3.org/TR/REC-xml for information about this namespace.
+
+ This schema document describes the XML namespace, in a form
+ suitable for import by other schema documents.
+
+ Note that local names in this namespace are intended to be defined
+ only by the World Wide Web Consortium or its subgroups. The
+ following names are currently defined in this namespace and should
+ not be used with conflicting semantics by any Working Group,
+ specification, or document instance:
+
+ base (as an attribute name): denotes an attribute whose value
+ provides a URI to be used as the base for interpreting any
+ relative URIs in the scope of the element on which it
+ appears; its value is inherited. This name is reserved
+ by virtue of its definition in the XML Base specification.
+
+ lang (as an attribute name): denotes an attribute whose value
+ is a language code for the natural language of the content of
+ any element; its value is inherited. This name is reserved
+ by virtue of its definition in the XML specification.
+
+ space (as an attribute name): denotes an attribute whose
+ value is a keyword indicating what whitespace processing
+ discipline is intended for the content of the element; its
+ value is inherited. This name is reserved by virtue of its
+ definition in the XML specification.
+
+ Father (in any context at all): denotes Jon Bosak, the chair of
+ the original XML Working Group. This name is reserved by
+ the following decision of the W3C XML Plenary and
+ XML Coordination groups:
+
+ In appreciation for his vision, leadership and dedication
+ the W3C XML Plenary on this 10th day of February, 2000
+ reserves for Jon Bosak in perpetuity the XML name
+ xml:Father
+ </xs:documentation>
+ </xs:annotation>
+
+ <xs:annotation>
+ <xs:documentation>This schema defines attributes and an attribute group
+ suitable for use by
+ schemas wishing to allow xml:base, xml:lang or xml:space attributes
+ on elements they define.
+
+ To enable this, such a schema must import this schema
+ for the XML namespace, e.g. as follows:
+ &lt;schema . . .>
+ . . .
+ &lt;import namespace="http://www.w3.org/XML/1998/namespace"
+ schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
+
+ Subsequently, qualified reference to any of the attributes
+ or the group defined below will have the desired effect, e.g.
+
+ &lt;type . . .>
+ . . .
+ &lt;attributeGroup ref="xml:specialAttrs"/>
+
+ will define a type which will schema-validate an instance
+ element with any of those attributes</xs:documentation>
+ </xs:annotation>
+
+ <xs:annotation>
+ <xs:documentation>In keeping with the XML Schema WG's standard versioning
+ policy, this schema document will persist at
+ http://www.w3.org/2001/03/xml.xsd.
+ At the date of issue it can also be found at
+ http://www.w3.org/2001/xml.xsd.
+ The schema document at that URI may however change in the future,
+ in order to remain compatible with the latest version of XML Schema
+ itself. In other words, if the XML Schema namespace changes, the version
+ of this document at
+ http://www.w3.org/2001/xml.xsd will change
+ accordingly; the version at
+ http://www.w3.org/2001/03/xml.xsd will not change.
+ </xs:documentation>
+ </xs:annotation>
+
+ <xs:attribute name="lang" type="xs:language">
+ <xs:annotation>
+ <xs:documentation>In due course, we should install the relevant ISO 2- and 3-letter
+ codes as the enumerated possible values . . .</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attribute name="space" default="preserve">
+ <xs:simpleType>
+ <xs:restriction base="xs:NCName">
+ <xs:enumeration value="default"/>
+ <xs:enumeration value="preserve"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+
+ <xs:attribute name="base" type="xs:anyURI">
+ <xs:annotation>
+ <xs:documentation>See http://www.w3.org/TR/xmlbase/ for
+ information about this attribute.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attributeGroup name="specialAttrs">
+ <xs:attribute ref="xml:base"/>
+ <xs:attribute ref="xml:lang"/>
+ <xs:attribute ref="xml:space"/>
+ </xs:attributeGroup>
+
+</xs:schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd
new file mode 100644
index 0000000000..c4e9808cfd
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd
@@ -0,0 +1,318 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE schema
+ PUBLIC "-//W3C//DTD XMLSchema 200102//EN" "XMLSchema.dtd"
+ [
+ <!ATTLIST schema
+ xmlns:ds CDATA #FIXED "http://www.w3.org/2000/09/xmldsig#">
+ <!ENTITY dsig 'http://www.w3.org/2000/09/xmldsig#'>
+ <!ENTITY % p ''>
+ <!ENTITY % s ''>
+ ]>
+
+<!-- Schema for XML Signatures
+ http://www.w3.org/2000/09/xmldsig#
+ $Revision$ on $Date$ by $Author: reagle $
+
+ Copyright 2001 The Internet Society and W3C (Massachusetts Institute
+ of Technology, Institut National de Recherche en Informatique et en
+ Automatique, Keio University). All Rights Reserved.
+ http://www.w3.org/Consortium/Legal/
+
+ This document is governed by the W3C Software License [1] as described
+ in the FAQ [2].
+
+ [1] http://www.w3.org/Consortium/Legal/copyright-software-19980720
+ [2] http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
+-->
+
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
+ targetNamespace="http://www.w3.org/2000/09/xmldsig#"
+ version="0.1" elementFormDefault="qualified">
+
+<!-- Basic Types Defined for Signatures -->
+
+<simpleType name="CryptoBinary">
+ <restriction base="base64Binary">
+ </restriction>
+</simpleType>
+
+<!-- Start Signature -->
+
+<element name="Signature" type="ds:SignatureType"/>
+<complexType name="SignatureType">
+ <sequence>
+ <element ref="ds:SignedInfo"/>
+ <element ref="ds:SignatureValue"/>
+ <element ref="ds:KeyInfo" minOccurs="0"/>
+ <element ref="ds:Object" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+</complexType>
+
+ <element name="SignatureValue" type="ds:SignatureValueType"/>
+ <complexType name="SignatureValueType">
+ <simpleContent>
+ <extension base="base64Binary">
+ <attribute name="Id" type="ID" use="optional"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+<!-- Start SignedInfo -->
+
+<element name="SignedInfo" type="ds:SignedInfoType"/>
+<complexType name="SignedInfoType">
+ <sequence>
+ <element ref="ds:CanonicalizationMethod"/>
+ <element ref="ds:SignatureMethod"/>
+ <element ref="ds:Reference" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+</complexType>
+
+ <element name="CanonicalizationMethod" type="ds:CanonicalizationMethodType"/>
+ <complexType name="CanonicalizationMethodType" mixed="true">
+ <sequence>
+ <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
+ <!-- (0,unbounded) elements from (1,1) namespace -->
+ </sequence>
+ <attribute name="Algorithm" type="anyURI" use="required"/>
+ </complexType>
+
+ <element name="SignatureMethod" type="ds:SignatureMethodType"/>
+ <complexType name="SignatureMethodType" mixed="true">
+ <sequence>
+ <element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
+ <any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
+ <!-- (0,unbounded) elements from (1,1) external namespace -->
+ </sequence>
+ <attribute name="Algorithm" type="anyURI" use="required"/>
+ </complexType>
+
+<!-- Start Reference -->
+
+<element name="Reference" type="ds:ReferenceType"/>
+<complexType name="ReferenceType">
+ <sequence>
+ <element ref="ds:Transforms" minOccurs="0"/>
+ <element ref="ds:DigestMethod"/>
+ <element ref="ds:DigestValue"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+ <attribute name="URI" type="anyURI" use="optional"/>
+ <attribute name="Type" type="anyURI" use="optional"/>
+</complexType>
+
+ <element name="Transforms" type="ds:TransformsType"/>
+ <complexType name="TransformsType">
+ <sequence>
+ <element ref="ds:Transform" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="Transform" type="ds:TransformType"/>
+ <complexType name="TransformType" mixed="true">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax"/>
+ <!-- (1,1) elements from (0,unbounded) namespaces -->
+ <element name="XPath" type="string"/>
+ </choice>
+ <attribute name="Algorithm" type="anyURI" use="required"/>
+ </complexType>
+
+<!-- End Reference -->
+
+<element name="DigestMethod" type="ds:DigestMethodType"/>
+<complexType name="DigestMethodType" mixed="true">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="Algorithm" type="anyURI" use="required"/>
+</complexType>
+
+<element name="DigestValue" type="ds:DigestValueType"/>
+<simpleType name="DigestValueType">
+ <restriction base="base64Binary"/>
+</simpleType>
+
+<!-- End SignedInfo -->
+
+<!-- Start KeyInfo -->
+
+<element name="KeyInfo" type="ds:KeyInfoType"/>
+<complexType name="KeyInfoType" mixed="true">
+ <choice maxOccurs="unbounded">
+ <element ref="ds:KeyName"/>
+ <element ref="ds:KeyValue"/>
+ <element ref="ds:RetrievalMethod"/>
+ <element ref="ds:X509Data"/>
+ <element ref="ds:PGPData"/>
+ <element ref="ds:SPKIData"/>
+ <element ref="ds:MgmtData"/>
+ <any processContents="lax" namespace="##other"/>
+ <!-- (1,1) elements from (0,unbounded) namespaces -->
+ </choice>
+ <attribute name="Id" type="ID" use="optional"/>
+</complexType>
+
+ <element name="KeyName" type="string"/>
+ <element name="MgmtData" type="string"/>
+
+ <element name="KeyValue" type="ds:KeyValueType"/>
+ <complexType name="KeyValueType" mixed="true">
+ <choice>
+ <element ref="ds:DSAKeyValue"/>
+ <element ref="ds:RSAKeyValue"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ </complexType>
+
+ <element name="RetrievalMethod" type="ds:RetrievalMethodType"/>
+ <complexType name="RetrievalMethodType">
+ <sequence>
+ <element ref="ds:Transforms" minOccurs="0"/>
+ </sequence>
+ <attribute name="URI" type="anyURI"/>
+ <attribute name="Type" type="anyURI" use="optional"/>
+ </complexType>
+
+<!-- Start X509Data -->
+
+<element name="X509Data" type="ds:X509DataType"/>
+<complexType name="X509DataType">
+ <sequence maxOccurs="unbounded">
+ <choice>
+ <element name="X509IssuerSerial" type="ds:X509IssuerSerialType"/>
+ <element name="X509SKI" type="base64Binary"/>
+ <element name="X509SubjectName" type="string"/>
+ <element name="X509Certificate" type="base64Binary"/>
+ <element name="X509CRL" type="base64Binary"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ </sequence>
+</complexType>
+
+<complexType name="X509IssuerSerialType">
+ <sequence>
+ <element name="X509IssuerName" type="string"/>
+ <element name="X509SerialNumber" type="integer"/>
+ </sequence>
+</complexType>
+
+<!-- End X509Data -->
+
+<!-- Begin PGPData -->
+
+<element name="PGPData" type="ds:PGPDataType"/>
+<complexType name="PGPDataType">
+ <choice>
+ <sequence>
+ <element name="PGPKeyID" type="base64Binary"/>
+ <element name="PGPKeyPacket" type="base64Binary" minOccurs="0"/>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <sequence>
+ <element name="PGPKeyPacket" type="base64Binary"/>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ </choice>
+</complexType>
+
+<!-- End PGPData -->
+
+<!-- Begin SPKIData -->
+
+<element name="SPKIData" type="ds:SPKIDataType"/>
+<complexType name="SPKIDataType">
+ <sequence maxOccurs="unbounded">
+ <element name="SPKISexp" type="base64Binary"/>
+ <any namespace="##other" processContents="lax" minOccurs="0"/>
+ </sequence>
+</complexType>
+
+<!-- End SPKIData -->
+
+<!-- End KeyInfo -->
+
+<!-- Start Object (Manifest, SignatureProperty) -->
+
+<element name="Object" type="ds:ObjectType"/>
+<complexType name="ObjectType" mixed="true">
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##any" processContents="lax"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+ <attribute name="MimeType" type="string" use="optional"/> <!-- add a grep facet -->
+ <attribute name="Encoding" type="anyURI" use="optional"/>
+</complexType>
+
+<element name="Manifest" type="ds:ManifestType"/>
+<complexType name="ManifestType">
+ <sequence>
+ <element ref="ds:Reference" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+</complexType>
+
+<element name="SignatureProperties" type="ds:SignaturePropertiesType"/>
+<complexType name="SignaturePropertiesType">
+ <sequence>
+ <element ref="ds:SignatureProperty" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+</complexType>
+
+ <element name="SignatureProperty" type="ds:SignaturePropertyType"/>
+ <complexType name="SignaturePropertyType" mixed="true">
+ <choice maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax"/>
+ <!-- (1,1) elements from (1,unbounded) namespaces -->
+ </choice>
+ <attribute name="Target" type="anyURI" use="required"/>
+ <attribute name="Id" type="ID" use="optional"/>
+ </complexType>
+
+<!-- End Object (Manifest, SignatureProperty) -->
+
+<!-- Start Algorithm Parameters -->
+
+<simpleType name="HMACOutputLengthType">
+ <restriction base="integer"/>
+</simpleType>
+
+<!-- Start KeyValue Element-types -->
+
+<element name="DSAKeyValue" type="ds:DSAKeyValueType"/>
+<complexType name="DSAKeyValueType">
+ <sequence>
+ <sequence minOccurs="0">
+ <element name="P" type="ds:CryptoBinary"/>
+ <element name="Q" type="ds:CryptoBinary"/>
+ </sequence>
+ <element name="G" type="ds:CryptoBinary" minOccurs="0"/>
+ <element name="Y" type="ds:CryptoBinary"/>
+ <element name="J" type="ds:CryptoBinary" minOccurs="0"/>
+ <sequence minOccurs="0">
+ <element name="Seed" type="ds:CryptoBinary"/>
+ <element name="PgenCounter" type="ds:CryptoBinary"/>
+ </sequence>
+ </sequence>
+</complexType>
+
+<element name="RSAKeyValue" type="ds:RSAKeyValueType"/>
+<complexType name="RSAKeyValueType">
+ <sequence>
+ <element name="Modulus" type="ds:CryptoBinary"/>
+ <element name="Exponent" type="ds:CryptoBinary"/>
+ </sequence>
+</complexType>
+
+<!-- End KeyValue Element-types -->
+
+<!-- End Signature -->
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-1.1-cd05.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-1.1-cd05.xsd
new file mode 100644
index 0000000000..5f3c796810
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-1.1-cd05.xsd
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <include schemaLocation="sca-interface-java-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-interface-wsdl-1.1-cd05.xsd"/>
+ <include schemaLocation="sca-interface-cpp-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-interface-c-1.1-cd04.xsd"/>
+
+ <include schemaLocation="sca-implementation-java-1.1-cd02.xsd"/>
+ <include schemaLocation="sca-implementation-composite-1.1-cd05.xsd"/>
+ <include schemaLocation="sca-implementation-cpp-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-implementation-c-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-implementation-bpel-1.1-cd03.xsd"/>
+ <include schemaLocation="sca-implementation-spring-1.1-cd01.xsd"/>
+
+ <include schemaLocation="sca-binding-ws-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-binding-ws-callback-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-binding-jms-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-binding-jca-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-binding-sca-1.1-cd05.xsd"/>
+ <include schemaLocation="sca-binding-ejb-1.1-cd01.xsd"/>
+
+ <include schemaLocation="sca-definitions-1.1-cd05.xsd"/>
+ <include schemaLocation="sca-policy-1.1-cd03.xsd"/>
+
+ <include schemaLocation="sca-contribution-1.1-cd05.xsd"/>
+ <include schemaLocation="sca-contribution-cpp-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-contribution-c-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-contribution-java-1.1-cd02.xsd"/>
+
+ <include schemaLocation="sca-jee-1.1-wd03.xsd"/>
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd
new file mode 100644
index 0000000000..4bccf9d5f8
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <element name="binding.ejb" type="sca:EJBSessionBeanBinding"
+ substitutionGroup="sca:binding" />
+
+ <simpleType name="VersionValue">
+ <restriction base="string">
+ <enumeration value="EJB2"/>
+ <enumeration value="EJB3"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="EJBSessionBeanBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <!-- sequence>
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence-->
+ <attribute name="homeInterface" type="NCName" use="optional"/>
+ <attribute name="ejb-link-name" type="string" use="optional"/>
+ <attribute name="ejb-version" type="sca:VersionValue" use="optional" default="EJB3"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd
new file mode 100644
index 0000000000..824ba95b47
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd
@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <complexType name="JCABinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element name="outboundConnection"
+ type="sca:JCAOutboundConnection" minOccurs="0" />
+ <element name="inboundConnection"
+ type="sca:JCAInboundConnection" minOccurs="0" />
+ <element name="outboundInteraction"
+ type="sca:JCAOutboundInteraction" minOccurs="0" />
+ <element name="inboundInteraction"
+ type="sca:JCAInboundInteraction" minOccurs="0" />
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded" />
+ <!-- any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" /-->
+ </sequence>
+ <attribute name="connectionInfo" type="anyURI" use="optional" />
+ <attribute name="initialContextFactory" type="anyURI"
+ use="optional"/>
+ <attribute name="jndiURL" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="JCACreateResource">
+ <restriction base="string">
+ <enumeration value="always" />
+ <enumeration value="never" />
+ <enumeration value="ifNotExist" />
+ </restriction>
+ </simpleType>
+ <simpleType name="ResAuth">
+ <restriction base="string">
+ <enumeration value="container" />
+ <enumeration value="application" />
+ </restriction>
+ </simpleType>
+ <complexType name="JCAOutboundConnection">
+ <sequence>
+ <element name="resourceAdapter" type="sca:ResourceAdapter"
+ minOccurs="0" />
+ <element name="connection" type="sca:Connection" />
+ <element name="resAuth" type="sca:ResAuth" minOccurs="0" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="managed" type="boolean" use="optional"
+ default="true" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="JCAInboundConnection">
+ <sequence>
+ <element name="resourceAdapter" type="sca:ResourceAdapter" />
+ <element name="activationSpec" type="sca:ActivationSpec" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="JCAOutboundInteraction">
+ <sequence>
+ <element name="connectionSpec" type="sca:ConnectionSpec"
+ minOccurs="0" />
+ <element name="interactionSpec" type="sca:InteractionSpec"
+ minOccurs="0" />
+ <element name="operation" type="sca:Operation" minOccurs="0" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="JCAInboundInteraction">
+ <sequence>
+ <element name="listener" type="string" minOccurs="0" />
+ <element name="inboundOperation" type="sca:InboundOperation"
+ minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="ResourceAdapter">
+ <sequence>
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NMTOKEN" use="optional" />
+ <attribute name="type" type="NMTOKEN" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="Connection">
+ <sequence>
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NMTOKEN" use="optional" />
+ <attribute name="type" type="NMTOKEN" use="required" />
+ <attribute name="create" type="sca:JCACreateResource" use="optional"
+ default="ifNotExist" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="ActivationSpec">
+ <sequence>
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NMTOKEN" use="optional" />
+ <attribute name="type" type="NMTOKEN" use="required" />
+ <attribute name="create" type="sca:JCACreateResource" use="optional"
+ default="ifNotExist"/>
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="Operation">
+ <sequence>
+ <element name="interactionSpec" type="sca:InteractionSpec"
+ minOccurs="0" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NMTOKEN" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="InboundOperation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NMTOKEN" use="required" />
+ <attribute name="nativeOperation" type="string" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="ConnectionSpec">
+ <sequence>
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="type" type="NMTOKEN" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="InteractionSpec">
+ <sequence>
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="type" type="NMTOKEN" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+ <element name="binding.jca" type="sca:JCABinding"
+ substitutionGroup="sca:binding" />
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd
new file mode 100644
index 0000000000..50e6aa6201
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <complexType name="JMSBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element name="destination" type="sca:JMSDestination"
+ minOccurs="0"/>
+ <choice minOccurs="0" maxOccurs="1">
+ <element name="connectionFactory"
+ type="sca:JMSConnectionFactory"/>
+ <element name="activationSpec" type="sca:JMSActivationSpec"/>
+ </choice>
+ <element name="response" type="sca:JMSResponse" minOccurs="0"/>
+ <element name="headers" type="sca:JMSHeaders" minOccurs="0"/>
+ <element name="messageSelection" type="sca:JMSMessageSelection"
+ minOccurs="0"/>
+ <element name="resourceAdapter" type="sca:JMSResourceAdapter"
+ minOccurs="0"/>
+ <element name="operationProperties"
+ type="sca:JMSOperationProperties"
+ minOccurs="0" maxOccurs="unbounded"/>
+ <!-- any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/ -->
+ </sequence>
+ <attribute name="correlationScheme" type="QName"
+ default="sca:messageId"/>
+ <attribute name="initialContextFactory" type="anyURI"/>
+ <attribute name="jndiURL" type="anyURI"/>
+ <attribute name="requestConnection" type="QName"/>
+ <attribute name="responseConnection" type="QName"/>
+ <attribute name="operationProperties" type="QName"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="JMSCreateResource">
+ <restriction base="string">
+ <enumeration value="always"/>
+ <enumeration value="never"/>
+ <enumeration value="ifNotExist"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="JMSDestination">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="jndiName" type="anyURI" use="required"/>
+ <attribute name="type" use="optional" default="queue">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="queue"/>
+ <enumeration value="topic"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="create" type="sca:JMSCreateResource"
+ use="optional" default="ifNotExist"/>
+ </complexType>
+
+ <complexType name="JMSConnectionFactory">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="jndiName" type="anyURI" use="required"/>
+ <attribute name="create" type="sca:JMSCreateResource"
+ use="optional" default="ifNotExist"/>
+ </complexType>
+
+ <complexType name="JMSActivationSpec">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="jndiName" type="anyURI" use="required"/>
+ <attribute name="create" type="sca:JMSCreateResource"
+ use="optional" default="ifNotExist"/>
+ </complexType>
+
+ <complexType name="JMSResponse">
+ <sequence>
+ <element ref="sca:wireFormat" minOccurs="0" />
+ <element name="destination" type="sca:JMSDestination" minOccurs="0"/>
+ <choice minOccurs="0">
+ <element name="connectionFactory" type="sca:JMSConnectionFactory"/>
+ <element name="activationSpec" type="sca:JMSActivationSpec"/>
+ </choice>
+ </sequence>
+ </complexType>
+
+ <complexType name="JMSHeaders">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="type" type="string"/>
+ <attribute name="deliveryMode">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="persistent"/>
+ <enumeration value="nonpersistent"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="timeToLive" type="long"/>
+ <attribute name="priority">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="0"/>
+ <enumeration value="1"/>
+ <enumeration value="2"/>
+ <enumeration value="3"/>
+ <enumeration value="4"/>
+ <enumeration value="5"/>
+ <enumeration value="6"/>
+ <enumeration value="7"/>
+ <enumeration value="8"/>
+ <enumeration value="9"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </complexType>
+
+ <complexType name="JMSMessageSelection">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="selector" type="string"/>
+ </complexType>
+
+ <complexType name="JMSResourceAdapter">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="string" use="required"/>
+ </complexType>
+
+ <complexType name="JMSOperationProperties">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ <element name="headers" type="sca:JMSHeaders"/>
+ </sequence>
+ <attribute name="name" type="string" use="required"/>
+ <attribute name="nativeOperation" type="string"/>
+ </complexType>
+
+ <complexType name="BindingProperty">
+ <simpleContent>
+ <extension base="string">
+ <attribute name="name" type="NMTOKEN"/>
+ <attribute name="type" type="string" use="optional"
+ default="xs:string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <element name="binding.jms" type="sca:JMSBinding"
+ substitutionGroup="sca:binding"/>
+
+ <element name="wireFormat.jmsDefault" type="sca:WireFormatType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <element name="operationSelector.jmsDefault" type="sca:OperationSelectorType"
+ substitutionGroup="sca:operationSelector"/>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd05.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd05.xsd
new file mode 100644
index 0000000000..a337296d45
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd05.xsd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <!-- SCA Binding -->
+ <element name="binding.sca" type="sca:SCABinding"
+ substitutionGroup="sca:binding"/>
+ <complexType name="SCABinding">
+ <complexContent>
+ <extension base="sca:Binding"/>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd
new file mode 100644
index 0000000000..65e200bf8a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/ns/wsdl-instance"
+ xmlns:wsa="http://www.w3.org/2005/08/addressing"
+ elementFormDefault="qualified">
+
+ <import namespace="http://www.w3.org/ns/wsdl-instance"
+ schemaLocation="http://www.w3.org/2007/05/wsdl/wsdl20-instance.xsd"/>
+ <import namespace="http://www.w3.org/2005/08/addressing"
+ schemaLocation="http://www.w3.org/2006/03/addressing/ws-addr.xsd"/>
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <element name="binding.ws" type="sca:WebServiceBinding"
+ substitutionGroup="sca:binding"/>
+
+ <complexType name="WebServiceBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element ref="wsa:EndpointReference"
+ minOccurs="0" maxOccurs="unbounded"/>
+ <!-- any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/-->
+ </sequence>
+ <attribute name="wsdlElement" type="anyURI" use="optional"/>
+ <attribute ref="wsdli:wsdlLocation" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd
new file mode 100644
index 0000000000..874e36bab8
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright OASIS 2005, 2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply -->
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <element name="WSCallback">
+ <complexType>
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+ </element>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd05.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd05.xsd
new file mode 100644
index 0000000000..da391a983f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd05.xsd
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <!-- Contribution -->
+ <element name="contribution" type="sca:ContributionType"/>
+ <complexType name="ContributionType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element name="deployable" type="sca:DeployableType"
+ minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="sca:importBase" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:exportBase" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Deployable -->
+ <complexType name="DeployableType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="composite" type="QName" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Import -->
+ <element name="importBase" type="sca:Import" abstract="true" />
+ <complexType name="Import" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="import" type="sca:ImportType"
+ substitutionGroup="sca:importBase"/>
+ <complexType name="ImportType">
+ <complexContent>
+ <extension base="sca:Import">
+ <attribute name="namespace" type="string" use="required"/>
+ <attribute name="location" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Export -->
+ <element name="exportBase" type="sca:Export" abstract="true" />
+ <complexType name="Export" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="export" type="sca:ExportType"
+ substitutionGroup="sca:exportBase"/>
+ <complexType name="ExportType">
+ <complexContent>
+ <extension base="sca:Export">
+ <attribute name="namespace" type="string" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd
new file mode 100644
index 0000000000..a93c4c5960
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2007,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-contribution-1.1-cd05.xsd" />
+
+ <element name="export.c" type="sca:CExport"
+ substitutionGroup="sca:exportBase" />
+
+ <complexType name="CExport">
+ <complexContent>
+ <extension base="sca:Export">
+ <attribute name="name" type="QName" use="required" />
+ <attribute name="path" type="string" use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="import.c" type="sca:CImport"
+ substitutionGroup="sca:importBase" />
+
+ <complexType name="CImport">
+ <complexContent>
+ <extension base="sca:Import">
+ <attribute name="name" type="QName" use="required" />
+ <attribute name="location" type="string" use="required" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd
new file mode 100644
index 0000000000..98fffa201f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2006,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-contribution-1.1-cd05.xsd" />
+
+ <element name="export.cpp" type="sca:CPPExport"
+ substitutionGroup="sca:exportBase" />
+
+ <complexType name="CPPExport">
+ <complexContent>
+ <extension base="sca:Export">
+ <attribute name="name" type="QName" use="required" />
+ <attribute name="path" type="string" use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="import.cpp" type="sca:CPPImport"
+ substitutionGroup="sca:importBase" />
+
+ <complexType name="CPPImport">
+ <complexContent>
+ <extension base="sca:Import">
+ <attribute name="name" type="QName" use="required" />
+ <attribute name="location" type="string" use="required" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd
new file mode 100644
index 0000000000..6131804edc
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-contribution-1.1-cd05.xsd"/>
+
+ <!-- Import.java -->
+ <element name="import.java" type="sca:JavaImportType"
+ substitutionGroup="sca:importBase" />
+ <complexType name="JavaImportType">
+ <complexContent>
+ <extension base="sca:Import">
+ <attribute name="package" type="string" use="required"/>
+ <attribute name="location" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Export.java -->
+ <element name="export.java" type="sca:JavaExportType"
+ substitutionGroup="sca:exportBase" />
+ <complexType name="JavaExportType">
+ <complexContent>
+ <extension base="sca:Export">
+ <attribute name="package" type="string" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd05.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd05.xsd
new file mode 100644
index 0000000000..ab0fce9ac8
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd05.xsd
@@ -0,0 +1,478 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-policy-1.1-cd03.xsd"/>
+ <import namespace="http://www.w3.org/XML/1998/namespace"
+ schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+
+ <!-- Common extension base for SCA definitions -->
+ <complexType name="CommonExtensionBase">
+ <sequence>
+ <element ref="sca:documentation" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <element name="documentation" type="sca:Documentation"/>
+ <complexType name="Documentation" mixed="true">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute ref="xml:lang"/>
+ </complexType>
+
+ <!-- Component Type -->
+ <element name="componentType" type="sca:ComponentType"/>
+ <complexType name="ComponentType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element ref="sca:implementation" minOccurs="0"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="service" type="sca:ComponentService"/>
+ <element name="reference"
+ type="sca:ComponentTypeReference"/>
+ <element name="property" type="sca:Property"/>
+ </choice>
+ <!-- any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/ -->
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Composite -->
+ <element name="composite" type="sca:Composite"/>
+ <complexType name="Composite">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element ref="sca:include" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ <element name="service" type="sca:Service"/>
+ <element name="property" type="sca:Property"/>
+ <element name="component" type="sca:Component"/>
+ <element name="reference" type="sca:Reference"/>
+ <element name="wire" type="sca:Wire"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="targetNamespace" type="anyURI" use="required"/>
+ <attribute name="local" type="boolean" use="optional"
+ default="false"/>
+ <attribute name="autowire" type="boolean" use="optional"
+ default="false"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Contract base type for Service, Reference -->
+ <complexType name="Contract" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element ref="sca:interface" minOccurs="0" maxOccurs="1" />
+ <element ref="sca:binding" minOccurs="0"
+ maxOccurs="unbounded" />
+ <element ref="sca:callback" minOccurs="0" maxOccurs="1" />
+ <element ref="sca:requires" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:policySetAttachment" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Service -->
+ <complexType name="Service">
+ <complexContent>
+ <extension base="sca:Contract">
+ <attribute name="promote" type="anyURI" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Interface -->
+ <element name="interface" type="sca:Interface" abstract="true"/>
+ <complexType name="Interface" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <attribute name="remotable" type="boolean" use="optional"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Reference -->
+ <complexType name="Reference">
+ <complexContent>
+ <extension base="sca:Contract">
+ <attribute name="target" type="sca:listOfAnyURIs"
+ use="optional"/>
+ <attribute name="wiredByImpl" type="boolean" use="optional"
+ default="false"/>
+ <attribute name="multiplicity" type="sca:Multiplicity"
+ use="required"/>
+ <attribute name="promote" type="sca:listOfAnyURIs"
+ use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Property -->
+ <complexType name="SCAPropertyBase" mixed="true">
+ <sequence>
+ <any namespace="##any" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <!-- NOT an extension point; This any exists to accept
+ the element-based or complex type property
+ i.e. no element-based extension point under "sca:property" -->
+ </sequence>
+ <!-- mixed="true" to handle simple type -->
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="type" type="QName" use="optional"/>
+ <attribute name="element" type="QName" use="optional"/>
+ <attribute name="many" type="boolean" use="optional" default="false"/>
+ <attribute name="value" type="anySimpleType" use="optional"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Property" mixed="true">
+ <complexContent mixed="true">
+ <extension base="sca:SCAPropertyBase">
+ <attribute name="mustSupply" type="boolean" use="optional"
+ default="false"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="PropertyValue" mixed="true">
+ <complexContent mixed="true">
+ <extension base="sca:SCAPropertyBase">
+ <attribute name="source" type="string" use="optional"/>
+ <attribute name="file" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Binding -->
+ <element name="binding" type="sca:Binding" abstract="true"/>
+ <complexType name="Binding" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element ref="sca:wireFormat" minOccurs="0" maxOccurs="1" />
+ <element ref="sca:operationSelector" minOccurs="0"
+ maxOccurs="1" />
+ <element ref="sca:requires" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:policySetAttachment" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="uri" type="anyURI" use="optional"/>
+ <attribute name="name" type="NCName" use="optional"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Binding Type -->
+ <element name="bindingType" type="sca:BindingType"/>
+ <complexType name="BindingType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <!-- any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/-->
+ </sequence>
+ <attribute name="type" type="QName" use="required"/>
+ <attribute name="alwaysProvides" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="mayProvide" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- WireFormat Type -->
+ <element name="wireFormat" type="sca:WireFormatType" abstract="true"/>
+ <complexType name="WireFormatType" abstract="true">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <!-- OperationSelector Type -->
+ <element name="operationSelector" type="sca:OperationSelectorType"
+ abstract="true"/>
+ <complexType name="OperationSelectorType" abstract="true">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <!-- Callback -->
+ <element name="callback" type="sca:Callback"/>
+ <complexType name="Callback">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:binding"/>
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ <!-- any namespace="##other" processContents="lax"/ -->
+ </choice>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Component -->
+ <complexType name="Component">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element ref="sca:implementation" minOccurs="1"
+ maxOccurs="1"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="service" type="sca:ComponentService"/>
+ <element name="reference" type="sca:ComponentReference"/>
+ <element name="property" type="sca:PropertyValue"/>
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="autowire" type="boolean" use="optional"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Component Service -->
+ <complexType name="ComponentService">
+ <complexContent>
+ <extension base="sca:Contract">
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Component Reference -->
+ <complexType name="ComponentReference">
+ <complexContent>
+ <extension base="sca:Contract">
+ <attribute name="autowire" type="boolean" use="optional"/>
+ <attribute name="target" type="sca:listOfAnyURIs"
+ use="optional"/>
+ <attribute name="wiredByImpl" type="boolean" use="optional"
+ default="false"/>
+ <attribute name="multiplicity" type="sca:Multiplicity"
+ use="optional" default="1..1"/>
+ <attribute name="nonOverridable" type="boolean" use="optional"
+ default="false"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Component Type Reference -->
+ <complexType name="ComponentTypeReference">
+ <complexContent>
+ <restriction base="sca:ComponentReference">
+ <sequence>
+ <element ref="sca:documentation" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:interface" minOccurs="0"/>
+ <element ref="sca:binding" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:callback" minOccurs="0"/>
+ <element ref="sca:requires" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:policySetAttachment" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="autowire" type="boolean" use="optional"/>
+ <attribute name="wiredByImpl" type="boolean" use="optional"
+ default="false"/>
+ <attribute name="multiplicity" type="sca:Multiplicity"
+ use="optional" default="1..1"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+
+ <!-- Implementation -->
+ <element name="implementation" type="sca:Implementation" abstract="true"/>
+ <complexType name="Implementation" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Implementation Type -->
+ <element name="implementationType" type="sca:ImplementationType"/>
+ <complexType name="ImplementationType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="type" type="QName" use="required"/>
+ <attribute name="alwaysProvides" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="mayProvide" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Wire -->
+ <complexType name="Wire">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="source" type="anyURI" use="required"/>
+ <attribute name="target" type="anyURI" use="required"/>
+ <attribute name="replace" type="boolean" use="optional"
+ default="false"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Include -->
+ <element name="include" type="sca:Include"/>
+ <complexType name="Include">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <attribute name="name" type="QName"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Extensions element -->
+ <element name="extensions">
+ <complexType>
+ <sequence>
+ <any namespace="##other" processContents="lax"
+ minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Intents within WSDL documents -->
+ <attribute name="requires" type="sca:listOfQNames"/>
+
+ <!-- Global attribute definition for @callback to mark a WSDL port type
+ as having a callback interface defined in terms of a second port
+ type. -->
+ <attribute name="callback" type="anyURI"/>
+
+ <!-- Value type definition for property values -->
+ <element name="value" type="sca:ValueType"/>
+ <complexType name="ValueType" mixed="true">
+ <sequence>
+ <any namespace="##any" processContents="lax" minOccurs="0"
+ maxOccurs='unbounded'/>
+ </sequence>
+ <!-- mixed="true" to handle simple type -->
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <!-- Miscellaneous simple type definitions -->
+ <simpleType name="Multiplicity">
+ <restriction base="string">
+ <enumeration value="0..1"/>
+ <enumeration value="1..1"/>
+ <enumeration value="0..n"/>
+ <enumeration value="1..n"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="OverrideOptions">
+ <restriction base="string">
+ <enumeration value="no"/>
+ <enumeration value="may"/>
+ <enumeration value="must"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="listOfQNames">
+ <list itemType="QName"/>
+ </simpleType>
+
+ <simpleType name="listOfAnyURIs">
+ <list itemType="anyURI"/>
+ </simpleType>
+
+ <simpleType name="CreateResource">
+ <restriction base="string">
+ <enumeration value="always" />
+ <enumeration value="never" />
+ <enumeration value="ifnotexist" />
+ </restriction>
+ </simpleType>
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd05.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd05.xsd
new file mode 100644
index 0000000000..8f2f20db19
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd05.xsd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+ <include schemaLocation="sca-policy-1.1-cd03.xsd"/>
+
+ <!-- Definitions -->
+ <element name="definitions" type="sca:tDefinitions"/>
+ <complexType name="tDefinitions">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:intent"/>
+ <element ref="sca:policySet"/>
+ <element ref="sca:bindingType"/>
+ <element ref="sca:implementationType"/>
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </choice>
+ <attribute name="targetNamespace" type="anyURI" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd
new file mode 100644
index 0000000000..967dadf395
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified">
+
+ <!-- SCA-Assembly XML Schema -->
+ <include schemaLocation="sca-core-1.1-cd05.xsd" />
+
+ <!-- SCA-BPEL Component Implementation Type -->
+ <element name="implementation.bpel"
+ type="sca:BPELImplementation" substitutionGroup="sca:implementation" />
+
+ <complexType name="BPELImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="process" type="QName" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd
new file mode 100644
index 0000000000..ee4b313e6d
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Copyright(C) OASIS(R) 2007,2010. All Rights Reserved. OASIS trademark,
+ IPR and other policies apply.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd" />
+
+ <element name="implementation.c" type="sca:CImplementation"
+ substitutionGroup="sca:implementation" />
+
+ <complexType name="CImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <element name="operation" type="sca:CImplementationFunction"
+ minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="module" type="NCName" use="required" />
+ <attribute name="path" type="string" use="optional" />
+ <attribute name="library" type="boolean" use="optional" />
+ <attribute name="componentType" type="string" use="required" />
+ <attribute name="eagerInit" type="boolean" use="optional" />
+ <attribute name="init" type="boolean" use="optional" />
+ <attribute name="destoy" type="boolean" use="optional" />
+ <attribute name="allowsPassByReference" type="boolean"
+ use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="CImplementationFunction">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames" use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames" use="optional" />
+ <attribute name="allowsPassByReference" type="boolean" use="optional" />
+ <attribute name="init" type="boolean" use="optional" />
+ <attribute name="destoy" type="boolean" use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd05.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd05.xsd
new file mode 100644
index 0000000000..f2780f9895
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd05.xsd
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <!-- Composite Implementation -->
+ <element name="implementation.composite" type="sca:SCAImplementation"
+ substitutionGroup="sca:implementation"/>
+ <complexType name="SCAImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="QName" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd
new file mode 100644
index 0000000000..b54ced4e4e
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2006,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd" />
+
+ <element name="implementation.cpp" type="sca:CPPImplementation"
+ substitutionGroup="sca:implementation" />
+ <complexType name="CPPImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <element name="function"
+ type="sca:CPPImplementationFunction" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="library" type="NCName" use="required" />
+ <attribute name="header" type="NCName" use="required" />
+ <attribute name="path" type="string" use="optional" />
+ <attribute name="class" type="Name" use="optional" />
+ <attribute name="componentType" type="string"
+ use="optional" />
+ <attribute name="scope"
+ type="sca:CPPImplementationScope" use="optional" />
+ <attribute name="eagerInit" type="boolean"
+ use="optional" />
+ <attribute name="allowsPassByReference" type="boolean"
+ use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="CPPImplementationScope">
+ <restriction base="string">
+ <enumeration value="stateless" />
+ <enumeration value="composite" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="CPPImplementationFunction">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames" use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames" use="optional" />
+ <attribute name="allowsPassByReference" type="boolean"
+ use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd02.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd02.xsd
new file mode 100644
index 0000000000..2856a51450
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd02.xsd
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <!-- Java Implementation -->
+ <element name="implementation.java" type="sca:JavaImplementation"
+ substitutionGroup="sca:implementation"/>
+ <complexType name="JavaImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="class" type="NCName" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd
new file mode 100644
index 0000000000..5ef3e86c92
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+ <element name="implementation.spring" type="sca:SpringImplementation" substitutionGroup="sca:implementation"/>
+ <complexType name="SpringImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="location" type="anyURI" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd
new file mode 100644
index 0000000000..518f0747fb
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Copyright(C) OASIS(R) 2007,2010. All Rights Reserved. OASIS trademark,
+ IPR and other policies apply.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd" />
+
+ <element name="interface.c" type="sca:CInterface"
+ substitutionGroup="sca:interface" />
+
+ <complexType name="CInterface">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <element name="function" type="sca:CFunction" minOccurs="0"
+ maxOccurs="unbounded" />
+ <element name="callbackFunction" type="sca:CFunction"
+ minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="header" type="string" use="required" />
+ <attribute name="callbackHeader" type="string" use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="CFunction">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames" use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames" use="optional" />
+ <attribute name="oneWay" type="boolean" use="optional" />
+ <attribute name="exclude" type="boolean" use="optional" />
+ <attribute name="input" type="NCName" use="optional" />
+ <attribute name="output" type="NCName" use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd
new file mode 100644
index 0000000000..b07bf01f1d
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Copyright(C) OASIS(R) 2006,2010. All Rights Reserved. OASIS trademark,
+ IPR and other policies apply.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd" />
+
+ <element name="interface.cpp" type="sca:CPPInterface"
+ substitutionGroup="sca:interface" />
+
+ <complexType name="CPPInterface">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <element name="function" type="sca:CPPFunction" minOccurs="0"
+ maxOccurs="unbounded" />
+ <element name="callbackFunction" type="sca:CPPFunction"
+ minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="header" type="string" use="required" />
+ <attribute name="class" type="Name" use="required" />
+ <attribute name="callbackHeader" type="string" use="optional" />
+ <attribute name="callbackClass" type="Name" use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="CPPFunction">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames" use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames" use="optional" />
+ <attribute name="oneWay" type="boolean" use="optional" />
+ <attribute name="exclude" type="boolean" use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd
new file mode 100644
index 0000000000..7b78e13749
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <!-- Java Interface -->
+ <element name="interface.java" type="sca:JavaInterface"
+ substitutionGroup="sca:interface"/>
+ <complexType name="JavaInterface">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="interface" type="NCName" use="required"/>
+ <attribute name="callbackInterface" type="NCName"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd05.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd05.xsd
new file mode 100644
index 0000000000..8d3510be7d
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd05.xsd
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <!-- WSDL Interface -->
+ <element name="interface.wsdl" type="sca:WSDLPortType"
+ substitutionGroup="sca:interface"/>
+ <complexType name="WSDLPortType">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="interface" type="anyURI" use="required"/>
+ <attribute name="callbackInterface" type="anyURI"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd
new file mode 100644
index 0000000000..97b44f8da5
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved. OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <element name="implementation.ejb" type="sca:EJBImplementation"
+ substitutionGroup="sca:implementation"/>
+ <complexType name="EJBImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="ejb-link" type="string" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="implementation.web" type="sca:WebImplementation"
+ substitutionGroup="sca:implementation"/>
+ <complexType name="WebImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="web-uri" type="string" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="implementation.jee" type="sca:JEEImplementation"
+ substitutionGroup="sca:implementation"/>
+ <complexType name="JEEImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="archive" type="string" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd03.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd03.xsd
new file mode 100644
index 0000000000..61693046c1
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd03.xsd
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+ <import namespace="http://www.w3.org/ns/ws-policy"
+ schemaLocation="http://www.w3.org/2007/02/ws-policy.xsd"/>
+
+ <element name="intent" type="sca:Intent"/>
+ <complexType name="Intent">
+ <sequence>
+ <element name="description" type="string" minOccurs="0"
+ maxOccurs="1" />
+ <element name="qualifier" type="sca:IntentQualifier"
+ minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="constrains" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="excludes" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="mutuallyExclusive" type="boolean"
+ use="optional" default="false"/>
+ <attribute name="intentType"
+ type="sca:InteractionOrImplementation"
+ use="optional" default="interaction"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="IntentQualifier">
+ <sequence>
+ <element name="description" type="string" minOccurs="0"
+ maxOccurs="1" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="default" type="boolean" use="optional"
+ default="false"/>
+ </complexType>
+
+ <element name="requires">
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax"/>
+ </sequence>
+ <attribute name="intents" type="sca:listOfQNames" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+ </element>
+
+ <element name="policySet" type="sca:PolicySet"/>
+ <complexType name="PolicySet">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="policySetReference"
+ type="sca:PolicySetReference"/>
+ <element name="intentMap" type="sca:IntentMap"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="provides" type="sca:listOfQNames"/>
+ <attribute name="appliesTo" type="string" use="optional"/>
+ <attribute name="attachTo" type="string" use="optional"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <element name="policySetAttachment">
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax"/>
+ </sequence>
+ <attribute name="name" type="QName" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+ </element>
+
+ <complexType name="PolicySetReference">
+ <attribute name="name" type="QName" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="IntentMap">
+ <choice minOccurs="1" maxOccurs="unbounded">
+ <element name="qualifier" type="sca:Qualifier"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ <attribute name="provides" type="QName" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Qualifier">
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax"/>
+ </sequence>
+ <attribute name="name" type="string" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <simpleType name="listOfNCNames">
+ <list itemType="NCName"/>
+ </simpleType>
+
+ <simpleType name="InteractionOrImplementation">
+ <restriction base="string">
+ <enumeration value="interaction"/>
+ <enumeration value="implementation"/>
+ </restriction>
+ </simpleType>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd03.xml b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd03.xml
new file mode 100644
index 0000000000..4505850072
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd03.xml
@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<sca:definitions xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- Security related intents -->
+ <sca:intent name="serverAuthentication" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding requires that the
+ server is authenticated by the client
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="clientAuthentication" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding requires that the
+ client is authenticated by the server
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="authentication" requires="sca:clientAuthentication">
+ <sca:description>
+ A convenience intent to help migration
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="mutualAuthentication"
+ requires="sca:clientAuthentication sca:serverAuthentication">
+ <sca:description>
+ Communication through the binding requires that the
+ client and server to authenticate each other
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="confidentiality" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding prevents unauthorized
+ users from reading the messages
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="integrity" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding prevents tampering
+ with the messages sent between the client and the service.
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="authorization" constrains="sca:implementation"
+ intentType="implementation">
+ <sca:description>
+ Ensures clients are authorized to use services.
+ </sca:description>
+ </sca:intent>
+
+
+ <!-- Reliable messaging related intents -->
+ <sca:intent name="atLeastOnce" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that a message sent
+ by a client is always delivered to the component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="atMostOnce" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that a message that was
+ successfully sent by a client is not delivered more than
+ once to the component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="exactlyOnce" requires="sca:atLeastOnce sca:atMostOnce"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ This profile intent is used to indicate that a message sent
+ by a client is always delivered to the component. It also
+ indicates that duplicate messages are not delivered to the
+ component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="ordered" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that all the messages are
+ delivered to the component in the order they were sent by
+ the client.
+ </sca:description>
+ </sca:intent>
+
+ <!-- Transaction related intents -->
+ <sca:intent name="managedTransaction" excludes="sca:noManagedTransaction"
+ mutuallyExclusive="true" constrains="sca:implementation"
+ intentType="implementation">
+ <sca:description>
+ A managed transaction environment is necessary in order to
+ run the component. The specific type of managed transaction
+ needed is not constrained.
+ </sca:description>
+ <sca:qualifier name="global" default="true">
+ <sca:description>
+ For a component marked with managedTransaction.global
+ a global transaction needs to be present before dispatching
+ any method on the component - using any transaction
+ propagated from the client or else beginning and completing
+ a new transaction.
+ </sca:description>
+ </sca:qualifier>
+ <sca:qualifier name="local">
+ <sca:description>
+ A component marked with managedTransaction.local needs to
+ run within a local transaction containment (LTC) that
+ is started and ended by the SCA runtime.
+ </sca:description>
+ </sca:qualifier>
+ </sca:intent>
+
+ <sca:intent name="noManagedTransaction" excludes="sca:managedTransaction"
+ constrains="sca:implementation" intentType="implementation">
+ <sca:description>
+ A component marked with noManagedTransaction needs to run without
+ a managed transaction, under neither a global transaction nor
+ an LTC. A transaction propagated to the hosting SCA runtime
+ is not joined by the hosting runtime on behalf of a
+ component marked with noManagedtransaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="transactedOneWay" excludes="sca:immediateOneWay"
+ constrains="sca:binding" intentType="implementation">
+ <sca:description>
+ For a reference marked as transactedOneWay any OneWay invocation
+ messages are transacted as part of a client global
+ transaction.
+ For a service marked as transactedOneWay any OneWay invocation
+ message are received from the transport binding in a
+ transacted fashion, under the service’s global transaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="immediateOneWay" excludes="sca:transactedOneWay"
+ constrains="sca:binding" intentType="implementation">
+ <sca:description>
+ For a reference indicates that any OneWay invocation messages
+ are sent immediately regardless of any client transaction.
+ For a service indicates that any OneWay invocation is
+ received immediately regardless of any target service
+ transaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="propagatesTransaction" excludes="sca:suspendsTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ A service marked with propagatesTransaction is dispatched
+ under any propagated (client) transaction and the service binding
+ needs to be capable of receiving a transaction context.
+ A reference marked with propagatesTransaction propagates any
+ transaction context under which the client runs when the
+ reference is used for a request-response interaction and the
+ binding of a reference marked with propagatesTransaction needs to
+ be capable of propagating a transaction context.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="suspendsTransaction" excludes="sca:propagatesTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ A service marked with suspendsTransaction is not dispatched
+ under any propagated (client) transaction.
+ A reference marked with suspendsTransaction does not propagate
+ any transaction context under which the client runs when the
+ reference is used.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="managedSharedTransaction"
+ requires="sca:managedTransaction.global sca:propagatesTransaction">
+ <sca:description>
+ Used to indicate that the component requires both the
+ managedTransaction.global and the propagatesTransactions
+ intents
+ </sca:description>
+ </sca:intent>
+
+ <!-- Miscellaneous intents -->
+ <sca:intent name="asyncInvocation" excludes="sca:propagatesTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ Indicates that request/response operations for the
+ interface of this wire are "long running" and must be
+ treated as two separate message transmissions
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="EJB" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Specifies that the EJB API is needed to communicate with
+ the service or reference.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="SOAP" constrains="sca:binding" intentType="interaction" mutuallyExclusive="true">
+ <sca:description>
+ Specifies that the SOAP messaging model is used for delivering
+ messages.
+ </sca:description>
+ <sca:qualifier name="v1_1" default="true"/>
+ <sca:qualifier name="v1_2"/>
+ </sca:intent>
+
+ <sca:intent name="JMS" constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ Requires that the messages are delivered and received via the
+ JMS API.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="noListener" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent can only be used on a reference. Indicates that the
+ client is not able to handle new inbound connections. The binding
+ and callback binding are configured so that any
+ response or callback comes either through a back channel of the
+ connection from the client to the server or by having the client
+ poll the server for messages.
+ </sca:description>
+ </sca:intent>
+
+</sca:definitions>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-atom.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-atom.xsd
new file mode 100644
index 0000000000..603455a1f2
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-atom.xsd
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.atom" type="t:AtomBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="AtomBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <!-- sequence>
+ <any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence -->
+ <attribute name="title" type="string" use="optional"/>
+ <attribute name="description" type="string" use="optional"/>
+ <!-- anyAttribute namespace="##any" processContents="lax"/ -->
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd
new file mode 100644
index 0000000000..52445c14c5
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.dwr" type="t:DWRBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="DWRBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <!-- any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/ -->
+ </sequence>
+ <!-- anyAttribute namespace="##any" processContents="lax"/ -->
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd
new file mode 100644
index 0000000000..67feb54963
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.http" type="t:HTTPBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="HTTPBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <!-- any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/ -->
+ </sequence>
+ <!-- anyAttribute namespace="##any" processContents="lax"/-->
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jms.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jms.xsd
new file mode 100644
index 0000000000..200f3e50a4
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jms.xsd
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-binding-jms-1.1-cd04.xsd"/>
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <!-- wire formats -->
+ <!-- -->
+ <complexType name="WireFormatJMSDefaultType">
+ <complexContent>
+ <extension base="sca:WireFormatType">
+ <attribute name="sendFormat" default="bytes">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="text"/>
+ <enumeration value="bytes"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsdefault"
+ type="t:WireFormatJMSDefaultType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatJMSTextType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsText"
+ type="t:WireFormatJMSTextType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatJMSTextXMLType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsTextXML"
+ type="t:WireFormatJMSTextXMLType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatJMSBytesType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsBytes"
+ type="t:WireFormatJMSBytesType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatJMSBytesXMLType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsBytesXML"
+ type="t:WireFormatJMSBytesXMLType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatJMSObjectType">
+ <complexContent>
+ <extension base="sca:WireFormatType">
+ <attribute name="wrapSingle" default="false">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="true"/>
+ <enumeration value="false"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsObject"
+ type="t:WireFormatJMSObjectType"
+ substitutionGroup="sca:wireFormat"/>
+ <!-- -->
+
+ <!-- operation selectors -->
+ <!-- -->
+ <complexType name="OperationSelectorJMSDefaultType">
+ <complexContent>
+ <extension base="sca:OperationSelectorType"/>
+ </complexContent>
+ </complexType>
+ <element name="operationSelector.jmsdefault"
+ type="t:OperationSelectorJMSDefaultType"
+ substitutionGroup="sca:operationSelector"/>
+
+ <complexType name="OperationSelectorJMSUserPropType">
+ <complexContent>
+ <extension base="sca:OperationSelectorType">
+ <attribute name="propertyName" type="string"/>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="operationSelector.jmsUserProp"
+ type="t:OperationSelectorJMSUserPropType"
+ substitutionGroup="sca:operationSelector"/>
+
+ <!-- -->
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd
new file mode 100644
index 0000000000..d1bdcbdfae
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.jsonrpc" type="t:JSONRPCBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="JSONRPCBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <!-- any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/ -->
+ </sequence>
+ <!-- anyAttribute namespace="##any" processContents="lax"/ -->
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rest.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rest.xsd
new file mode 100644
index 0000000000..05adf814c3
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rest.xsd
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.rest" type="t:RESTBinding" substitutionGroup="sca:binding"/>
+
+
+ <complexType name="RESTBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element name="response" type="t:RESTResponse" minOccurs="0"/>
+ <element ref="t:http-headers" minOccurs="0" maxOccurs="1"/>
+ <!-- any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/ -->
+ </sequence>
+ <!-- anyAttribute namespace="##any" processContents="lax"/-->
+ </extension>
+ </complexContent>
+ </complexType>
+
+
+ <complexType name="RESTResponse">
+ <sequence>
+ <element ref="sca:wireFormat" minOccurs="0" />
+ </sequence>
+ </complexType>
+
+ <complexType name="HTTPHeadersType">
+ <sequence>
+ <element ref="t:header" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="http-headers" type="t:HTTPHeadersType"/>
+
+ <complexType name="HTTPHeaderType">
+ <attribute name="name" type="string" use="required" />
+ <attribute name="value" type="string" use="required" />
+ </complexType>
+
+ <element name="header" type="t:HTTPHeaderType" />
+
+ <!-- wire formats -->
+ <complexType name="WireFormatJSONType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+
+ <element name="wireFormat.json" type="t:WireFormatJSONType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatXMLType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+
+ <element name="wireFormat.xml" type="t:WireFormatXMLType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <!-- operation selectors -->
+ <complexType name="OperationSelectorJAXRSType">
+ <complexContent>
+ <extension base="sca:OperationSelectorType"/>
+ </complexContent>
+ </complexType>
+ <element name="operationSelector.jaxrs"
+ type="t:OperationSelectorJAXRSType"
+ substitutionGroup="sca:operationSelector"/>
+
+ <complexType name="OperationSelectorRPCType">
+ <complexContent>
+ <extension base="sca:OperationSelectorType"/>
+ </complexContent>
+ </complexType>
+ <element name="operationSelector.rpc"
+ type="t:OperationSelectorRPCType"
+ substitutionGroup="sca:operationSelector"/>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd
new file mode 100644
index 0000000000..ea39a773e0
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.rmi" type="t:RMIBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="RMIBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <!-- any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/ -->
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rss.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rss.xsd
new file mode 100644
index 0000000000..9857ec62b7
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rss.xsd
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.rss" type="t:RSSBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="RSSBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <!--sequence>
+ <any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence -->
+ <attribute name="title" type="string" use="optional"/>
+ <attribute name="description" type="string" use="optional"/>
+ <!--anyAttribute namespace="##any" processContents="lax"/-->
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd
new file mode 100644
index 0000000000..c97b91251b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="implementation.osgi" type="t:OSGiImplementation" substitutionGroup="sca:implementation"/>
+
+ <complexType name="OSGiImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##targetNamespace" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="bundleSymbolicName" type="string" use="required"/>
+ <attribute name="bundleVersion" type="string" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="osgi.property" type="t:OSGiProperty"/>
+ <complexType name="OSGiProperty">
+ <simpleContent>
+ <extension base="string">
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="value" type="string" use="optional"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-script.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-script.xsd
new file mode 100644
index 0000000000..fab809c7e1
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-script.xsd
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="implementation.script" type="t:ScriptImplementation" substitutionGroup="sca:implementation"/>
+
+ <complexType name="ScriptImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <attribute name="script" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-widget.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-widget.xsd
new file mode 100644
index 0000000000..491cb2abce
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-widget.xsd
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="implementation.widget" type="t:WidgetImplementation" substitutionGroup="sca:implementation"/>
+
+ <complexType name="WidgetImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##targetNamespace" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="location" type="anyURI" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd
new file mode 100644
index 0000000000..4cf8649bc6
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1">
+
+<!--
+ <import namespace="http://www.w3.org/ns/wsdl-instance" schemaLocation="wsdli.xsd"/>
+-->
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+
+ <include schemaLocation="tuscany-sca-1.1-binding-atom.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-jms.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-http.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-jsonrpc.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-rest.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-rmi.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-rss.xsd"/>
+
+ <include schemaLocation="tuscany-sca-1.1-implementation-osgi.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-implementation-widget.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-implementation-script.xsd"/>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/LICENSE b/sandbox/sebastien/java/dynamic/modules/assembly/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/LICENSE
@@ -0,0 +1,205 @@
+
+ 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.
+
+
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/META-INF/MANIFEST.MF b/sandbox/sebastien/java/dynamic/modules/assembly/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..61b8b3ffea
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/META-INF/MANIFEST.MF
@@ -0,0 +1,60 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.assembly;version="2.0.0";
+ uses:="javax.xml.xpath,
+ org.apache.tuscany.sca.assembly.impl,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.interfacedef,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0";
+ uses:="org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.definitions,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0";
+ uses:="javax.xml.xpath,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.interfacedef,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0";uses:="org.apache.tuscany.sca.definitions,org.apache.tuscany.sca.monitor",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0";uses:="org.apache.tuscany.sca.interfacedef.util,org.apache.tuscany.sca.policy",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";uses:="org.apache.tuscany.sca.interfacedef.util,org.apache.tuscany.sca.policy,org.apache.tuscany.sca.interfacedef",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0";uses:="org.apache.tuscany.sca.interfacedef,javax.xml.namespace",
+ org.apache.tuscany.sca.policy;version="2.0.0";uses:="javax.xml.xpath,org.apache.tuscany.sca.policy.impl,javax.xml.namespace",
+ org.apache.tuscany.sca.policy.impl;version="2.0.0";uses:="javax.xml.xpath,org.apache.tuscany.sca.policy,javax.xml.namespace",
+ org.apache.tuscany.sca.policy.util;version="2.0.0";uses:="javax.xml.parsers,org.apache.tuscany.sca.policy"
+Private-Package: org.apache.tuscany.sca.assembly.builder.impl;version=
+ "2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Assembly Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Assembly Model
+Import-Package: javax.xml.datatype,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.stream,
+ javax.xml.xpath,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.impl;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.w3c.dom
+Bundle-SymbolicName: org.apache.tuscany.sca.assembly
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/NOTICE b/sandbox/sebastien/java/dynamic/modules/assembly/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/pom.xml b/sandbox/sebastien/java/dynamic/modules/assembly/pom.xml
new file mode 100644
index 0000000000..11fa07c1e6
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-assembly</artifactId>
+ <name>Apache Tuscany SCA Assembly Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java
new file mode 100644
index 0000000000..dca1decb76
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Interface contracts define one or more business functions. These business
+ * functions are provided by services and are used by references.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface AbstractContract extends Base, Extensible, PolicySubject {
+
+ /**
+ * Returns the name of the contract.
+ *
+ * @return the name of the contract
+ */
+ String getName();
+
+ /**
+ * Sets the name of the contract.
+ *
+ * @param name the name of the contract
+ */
+ void setName(String name);
+
+ /**
+ * Returns the interface contract defining the interface and callback
+ * interface for the contract.
+ *
+ * @return the interface contract
+ */
+ InterfaceContract getInterfaceContract();
+
+ /**
+ * Sets the interface contract defining the interface and callback
+ * interface for the contract.
+ *
+ * @param interfaceContract the interface contract
+ */
+ void setInterfaceContract(InterfaceContract interfaceContract);
+
+ /**
+ * Returns true if this contract is a reference or service created internally
+ * to handle a callback interface of another contract, false otherwise.
+ *
+ * @return true for a callback contract, false otherwise
+ */
+ boolean isForCallback();
+
+ /**
+ * Sets a flag indicating whether this is a callback contract.
+ *
+ * @param isCallback true for a callback contract, false otherwise
+ */
+ void setForCallback(boolean isCallback);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java
new file mode 100644
index 0000000000..45fa05d66c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * A property allows for the configuration of an implementation with externally
+ * set data values. An implementation can have zero or more properties. Each
+ * property has a data type, which may be either simple or complex. An
+ * implementation may also define a default value for a property.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AbstractProperty extends Base, Extensible {
+
+ /**
+ * Returns the property name.
+ *
+ * @return the property name
+ */
+ String getName();
+
+ /**
+ * Sets the property name.
+ *
+ * @param name the property name
+ */
+ void setName(String name);
+
+ /**
+ * Returns the default value of the property.
+ *
+ * @return the default value of this property
+ */
+ Object getValue();
+
+ /**
+ * Sets the default value of the property.
+ *
+ * @param defaultValue the default value of this property
+ */
+ void setValue(Object defaultValue);
+
+ /**
+ * Returns true if the property allows multiple values.
+ *
+ * @return true if the property allows multiple values
+ */
+ boolean isMany();
+
+ /**
+ * Sets whether or not the property allows multiple values.
+ *
+ * @param many true if the property should allow multiple values
+ */
+ void setMany(boolean many);
+
+ /**
+ * Returns true if a value must be supplied for the property.
+ *
+ * @return true is a value must be supplied for the property
+ */
+ boolean isMustSupply();
+
+ /**
+ * Sets whether a value must be supplied for the property.
+ *
+ * @param mustSupply set to true to require that a value be supplied for
+ * uses of this property
+ */
+ void setMustSupply(boolean mustSupply);
+
+ /**
+ * Returns the data type of this property. This is the qualified name of an
+ * XML schema type.
+ *
+ * @return the type of this property
+ */
+ QName getXSDType();
+
+ /**
+ * Sets the data type of this property. This is the qualified name of an XML
+ * schema type.
+ *
+ * @param type the type of this property
+ */
+ void setXSDType(QName type);
+
+ /**
+ * Returns the element defining the data type of this property. This is the
+ * qualified name of an XML schema element.
+ *
+ * @return the element defining the type of this property
+ */
+ QName getXSDElement();
+
+ /**
+ * Sets the element defining the data type of this property. This is the
+ * qualified name of an XML schema element.
+ *
+ * @param element the element defining the type of this property
+ */
+ void setXSDElement(QName element);
+
+ /**
+ * Get the data type for this property
+ * @return The data type
+ */
+ DataType getDataType();
+
+ /**
+ * Set the data type
+ * @param dataType The data type
+ */
+ void setDataType(DataType dataType);
+
+ /**
+ * Get the XML schema that represents the type if this property.
+ * Used during property value validation
+ *
+ * @return
+ */
+ Object getXSDDefinition();
+
+ /**
+ * Set the XML schema that represents the type if this property.
+ * Used during property value validation
+ *
+ * @param xsdDefintion
+ */
+ void setXSDDefinition(Object xsdDefintion);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java
new file mode 100644
index 0000000000..a9ef26bbb9
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * Represents a reference contract.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AbstractReference extends AbstractContract {
+
+ /**
+ * Returns the multiplicity allowed for wires connected to this reference.
+ *
+ * @return the multiplicity allowed for wires connected to this reference
+ */
+ Multiplicity getMultiplicity();
+
+ /**
+ * Sets the multiplicity allowed for wires connected to this reference.
+ *
+ * @param multiplicity the multiplicity allowed for wires connected to this
+ * reference
+ */
+ void setMultiplicity(Multiplicity multiplicity);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java
new file mode 100644
index 0000000000..9ae511c07b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * Represents a service contract.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AbstractService extends AbstractContract {
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
new file mode 100644
index 0000000000..5d82b9b727
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * A factory for the assembly model
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface AssemblyFactory {
+
+ /**
+ * Create a new abstract property.
+ *
+ * @return a new abstract property
+ */
+ AbstractProperty createAbstractProperty();
+
+ /**
+ * Create a new abstract reference.
+ *
+ * @return a new abstract reference
+ */
+ AbstractReference createAbstractReference();
+
+ /**
+ * Create a new abstract service.
+ *
+ * @return a new abstract service
+ */
+ AbstractService createAbstractService();
+
+ /**
+ * Create a new callback.
+ *
+ * @return
+ */
+ Callback createCallback();
+
+ /**
+ * Create a new component.
+ *
+ * @return a new component
+ */
+ Component createComponent();
+
+ /**
+ * Create a new component property.
+ *
+ * @return a new component property
+ */
+ ComponentProperty createComponentProperty();
+
+ /**
+ * Create a new component reference.
+ *
+ * @return a new component reference
+ */
+ ComponentReference createComponentReference();
+
+ /**
+ * Create a new component service.
+ *
+ * @return a new component service
+ */
+ ComponentService createComponentService();
+
+ /**
+ * Create a new component type
+ *
+ * @return a new component type
+ */
+ ComponentType createComponentType();
+
+ /**
+ * Create a new composite.
+ *
+ * @return a new composite
+ */
+ Composite createComposite();
+
+ /**
+ * Create a new composite reference.
+ *
+ * @return a new composite reference
+ */
+ CompositeReference createCompositeReference();
+
+ /**
+ * Create a new composite service.
+ *
+ * @return a new composite service
+ */
+ CompositeService createCompositeService();
+
+ /**
+ * Create a new property.
+ *
+ * @return a new property
+ */
+ Property createProperty();
+
+ /**
+ * Create a new reference.
+ *
+ * @return a new reference
+ */
+ Reference createReference();
+
+ /**
+ * Create a new service.
+ *
+ * @return a new service
+ */
+ Service createService();
+
+ /**
+ * Create a new wire.
+ *
+ * @return a new wire
+ */
+ Wire createWire();
+
+ /**
+ * Create an Extension
+ * @return
+ */
+ Extension createExtension();
+
+ /**
+ * Create a new endpoint
+ *
+ * @return a new endpoint
+ */
+ Endpoint createEndpoint();
+
+ /**
+ * Create a new endpoint reference
+ *
+ * @return a new endpoint reference
+ */
+ EndpointReference createEndpointReference();
+
+ /**
+ * Create a new configured operation.
+ *
+ * @return a new ConfiguredOperation
+ */
+ ConfiguredOperation createConfiguredOperation();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java
new file mode 100644
index 0000000000..b9abb90b03
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * Base interface for all assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Base {
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java
new file mode 100644
index 0000000000..9b96556173
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a binding.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Binding extends Base, Cloneable {
+
+ /**
+ * Returns the binding URI.
+ *
+ * @return the binding URI
+ */
+ String getURI();
+
+ /**
+ * Sets the binding URI.
+ *
+ * @param uri the binding URI
+ */
+ void setURI(String uri);
+
+ /**
+ * Returns the binding name.
+ *
+ * @return the binding name
+ */
+ String getName();
+
+ /**
+ * Sets the binding name.
+ *
+ * @param name the binding name
+ */
+ void setName(String name);
+
+ /**
+ * Clone the binding
+ *
+ * @return the clone
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * Returns the QName type for the binding
+ *
+ * @return the binding type QName
+ */
+ QName getType();
+
+ /**
+ * Returns the request wire format
+ *
+ * @return the request wire format or null is none is specified
+ */
+ WireFormat getRequestWireFormat();
+
+ /**
+ * Sets the request wire format
+ *
+ * @param wireFormat the request wire format
+ */
+ void setRequestWireFormat(WireFormat wireFormat);
+
+ /**
+ * Returns the response wire format
+ *
+ * @return the response wire format or null is none is specified
+ */
+ WireFormat getResponseWireFormat();
+
+ /**
+ * Sets the response wire format
+ *
+ * @param wireFormat the response wire format
+ */
+ void setResponseWireFormat(WireFormat wireFormat);
+
+ /**
+ * Returns the operation selector
+ *
+ * @return the operation selector or null is none is specified
+ */
+ OperationSelector getOperationSelector();
+
+ /**
+ * Sets the operation selector
+ *
+ * @param operationSelector the operation selector
+ */
+ void setOperationSelector(OperationSelector operationSelector);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java
new file mode 100644
index 0000000000..a220f14159
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a callback object describing the bindings to use for callbacks.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Callback extends Base, Extensible, PolicySubject {
+
+ /**
+ * Returns the bindings supported for callbacks.
+ *
+ * @return the bindings supported for callbacks
+ */
+ List<Binding> getBindings();
+
+ /**
+ * Returns the contract that holds this callback
+ *
+ * @return the contract that holds this callback
+ */
+ Contract getParentContract();
+
+ /**
+ * Sets the contract that holds this callback
+ *
+ * @param contract the contract that holds this callback
+ */
+ void setParentContract(Contract contract);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
new file mode 100644
index 0000000000..efd8557e07
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a component. A component is a configured instance of an
+ * implementation.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Component extends Base, Extensible, PolicySubject, Cloneable {
+
+ /**
+ * Returns the URI of the component.
+ *
+ * @return the URI of the component
+ */
+ String getURI();
+
+ /**
+ * Sets the URI of the component.
+ *
+ * @param uri the URI of the component
+ */
+ void setURI(String uri);
+
+ /**
+ * Returns the name of the component.
+ *
+ * @return the name of the component
+ */
+ String getName();
+
+ /**
+ * Sets the name of the component.
+ *
+ * @param name the name of the component
+ */
+ void setName(String name);
+
+ /**
+ * Returns the component implementation.
+ *
+ * @return the component implementation
+ */
+ Implementation getImplementation();
+
+ /**
+ * Sets the component implementation
+ *
+ * @param implementation the component implementation
+ */
+ void setImplementation(Implementation implementation);
+
+ /**
+ * Returns a list of references used by the component.
+ *
+ * @return a list of references used by the component
+ */
+ List<ComponentReference> getReferences();
+
+ /**
+ * Return a reference by name
+ *
+ * @param name the reference name
+ * @return reference the reference
+ */
+ ComponentReference getReference(String name);
+
+ /**
+ * Returns a list of services exposed by the component.
+ *
+ * @return a list of services exposed by the component
+ */
+ List<ComponentService> getServices();
+
+ /**
+ * Return a service by name
+ *
+ * @param name the service name
+ * @return service the service
+ */
+ ComponentService getService(String name);
+
+ /**
+ * Returns a list of properties for the component.
+ *
+ * @return a list of properties
+ */
+ List<ComponentProperty> getProperties();
+
+ /**
+ * Return a property by name
+ *
+ * @param name the property name
+ * @return property the property
+ */
+ ComponentProperty getProperty(String name);
+
+ /**
+ * Return the Boolean value of autowire
+ * @return null/TRUE/FALSE
+ */
+ Boolean getAutowire();
+
+ /**
+ * Sets whether component references should be autowired.
+ *
+ * @param autowire whether component references should be autowired
+ */
+ void setAutowire(Boolean autowire);
+
+ /**
+ * Returns a clone of the component.
+ *
+ * @return a clone of the component
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java
new file mode 100644
index 0000000000..1202b4d83a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import javax.xml.xpath.XPathExpression;
+
+/**
+ * Represents a configured property of a component.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ComponentProperty extends Property {
+
+ /**
+ * Returns the property defined by the component implementation.
+ *
+ * @return the property defined by the component implementation
+ */
+ Property getProperty();
+
+ /**
+ * Sets the property defined by this component implementation.
+ *
+ * @param property the property defined by this component implementation
+ */
+ void setProperty(Property property);
+
+ /**
+ * Returns an XPath expression referencing a property of the enclosing
+ * composite.
+ *
+ * @return an XPath expression referencing a property of the enclosing
+ * composite
+ */
+ String getSource();
+
+ /**
+ * Sets an XPath expression referencing a property of the enclosing
+ * composite.
+ *
+ * @param source an XPath expression referencing a property of the enclosing
+ * composite
+ */
+ void setSource(String source);
+
+ /**
+ * Get the XPath expression for the source attribute
+ * @return the XPath expression for the source attribute
+ */
+ XPathExpression getSourceXPathExpression();
+
+ /**
+ * Set the XPath expression for the source attribute
+ * @param sourceXPathExpression the XPath expression for the source attribute
+ */
+ void setSourceXPathExpression(XPathExpression sourceXPathExpression);
+
+ /**
+ * Returns a URI to a file containing the property value.
+ *
+ * @return a URI to a file containing the property value
+ */
+ String getFile();
+
+ /**
+ * Sets a URI to a file containing the property value.
+ *
+ * @param file a URI to a file containing the property value
+ */
+ void setFile(String file);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java
new file mode 100644
index 0000000000..ad72780de8
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * An instance of a reference associated with a particular component.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ComponentReference extends Reference {
+
+ /**
+ * Returns the reference defined by the implementation for this reference.
+ *
+ * @return the implementation reference
+ */
+ Reference getReference();
+
+ /**
+ * Sets the reference defined by the implementation for this reference.
+ *
+ * @param reference the implementation reference
+ */
+ void setReference(Reference reference);
+
+ /**
+ * Return the Boolean value of autowire
+ * @return null/TRUE/FALSE
+ */
+ Boolean getAutowire();
+
+ /**
+ * Sets whether component references should be autowired.
+ *
+ * @param autowire whether component references should be autowired
+ */
+ void setAutowire(Boolean autowire);
+
+ /**
+ * Returns the callback service created internally as a target endpoint
+ * for callbacks to this reference.
+ *
+ * @return the callback service
+ */
+ ComponentService getCallbackService();
+
+ /**
+ * Sets the callback service created internally as a target endpoint
+ * for callbacks to this reference.
+ *
+ * @param callbackService the callback service
+ */
+ void setCallbackService(ComponentService callbackService);
+
+ /**
+ * A boolean value, "false" by default, which indicates whether this component reference
+ * can have its targets overridden by a composite reference which promotes the
+ * component reference.
+ *
+ * If @nonOverridable==false, the target(s) of the promoting composite reference
+ * replace all the targets explicitly declared on the component reference for any
+ * value of @multiplicity on the component reference.
+ *
+ * If the component reference has @nonOverridable==false and @multiplicity 1..1
+ * and the reference has a target, then any composite reference which promotes
+ * the component reference has @multiplicity 0..1.by default and MAY have an explicit @multiplicity of either
+ * 0..1 or 1..1.
+ *
+ * If @nonOverridable==true, and the component reference has @multiplicity 0..1 or
+ * 1..1 and the component reference also declares a target, promotion implies
+ * that the promoting composite reference has @wiredbyImpl==true and the composite
+ * reference cannot supply a target, but can influence the policy attached to the
+ * component reference.
+ *
+ * If @nonOverridable==true, and the component reference @multiplicity is 0..n
+ * or 1..n, promotion targeting is additive
+ *
+ * @return
+ */
+ boolean isNonOverridable();
+
+ /**
+ * Set the nonOverridable flag
+ * @param nonOverridable
+ */
+ void setNonOverridable(boolean nonOverridable);
+
+ /**
+ * Sets whether this Component Reference is promoted
+ * @param isPromoted - true if the component reference is promoted
+ */
+ void setPromoted(boolean isPromoted);
+
+ boolean isPromoted();
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java
new file mode 100644
index 0000000000..e1e3eab90c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * An addressable instance of a service associated with a particular component.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ComponentService extends Service {
+
+ /**
+ * Returns the service defined by the implementation for this service.
+ *
+ * @return
+ */
+ Service getService();
+
+ /**
+ * Sets the service defined by the implementation for this service.
+ *
+ * @param service
+ */
+ void setService(Service service);
+
+ /**
+ * Returns the callback reference created internally as a source endpoint
+ * for callbacks from this service.
+ *
+ * @return the callback reference
+ */
+ ComponentReference getCallbackReference();
+
+ /**
+ * Sets the callback reference created internally as a source endpoint
+ * for callbacks from this service.
+ *
+ * @param callbackReference the callback reference
+ */
+ void setCallbackReference(ComponentReference callbackReference);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java
new file mode 100644
index 0000000000..f748828999
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Describes an implementation and represents its configurable aspects.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ComponentType extends Base, PolicySubject {
+
+ /**
+ * Returns the URI of this component type.
+ * @return the URI of the component type
+ */
+ String getURI();
+
+ /**
+ * Sets the URI of this component type.
+ * @param uri the URI of the component type
+ */
+ void setURI(String uri);
+
+ /**
+ * Returns a list of services that are offered.
+ *
+ * @return a list of services that are offered
+ */
+ List<Service> getServices();
+
+ /**
+ * Return a service by name
+ *
+ * @param name the service name
+ * @return service the service
+ */
+ Service getService(String name);
+
+ /**
+ * Returns the list of reference types that are used.
+ *
+ * @return the list of reference types that are used
+ */
+ List<Reference> getReferences();
+
+ /**
+ * Return a reference by name
+ *
+ * @param name the reference name
+ * @return reference the reference
+ */
+ Reference getReference(String name);
+
+ /**
+ * Returns the list of properties that can be set.
+ *
+ * @return the list of properties that can be set
+ */
+ List<Property> getProperties();
+
+ /**
+ * Return a property by name
+ *
+ * @param name the property name
+ * @return property the property
+ */
+ Property getProperty(String name);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java
new file mode 100644
index 0000000000..64a55f1b44
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a composite.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Composite extends Implementation, Extensible, Cloneable, PolicySubject {
+ /**
+ * Special name for the domain composite
+ */
+ QName DOMAIN_COMPOSITE = new QName(SCA11_NS, "");
+ QName TYPE = new QName(SCA11_NS, "implementation.composite");
+
+ /**
+ * Returns the spec version of the composite used to build this model
+ *
+ * @return the spec version used to build this model
+ */
+ String getSpecVersion();
+
+ /**
+ * Sets the spec version of the composite used to build this model
+ *
+ * @param specVersion the spec version used to build this model
+ */
+ void setSpecVersion(String specVersion);
+
+ /**
+ * Returns the name of the composite.
+ *
+ * @return the name of the composite
+ */
+ QName getName();
+
+ /**
+ * Sets the name of the composite.
+ *
+ * @param name the name of the composite
+ */
+ void setName(QName name);
+
+ /**
+ * Returns a list of composites included in this composite.
+ *
+ * @return a list of composites included in this composite.
+ */
+ List<Composite> getIncludes();
+
+ /**
+ * Returns a list of components contained in this composite.
+ *
+ * @return a list of components contained in this composite
+ */
+ List<Component> getComponents();
+
+ /**
+ * Returns a component by name
+ */
+ Component getComponent(String name);
+
+ /**
+ * Returns a list of wires contained in this composite.
+ *
+ * @return a list of wires contained in this composite
+ */
+ List<Wire> getWires();
+
+ /**
+ * Returns true if all the components within the composite must run in the
+ * same process.
+ *
+ * @return true if all the components within the composite must run in the
+ * same process
+ */
+ boolean isLocal();
+
+ /**
+ * Sets whether all the components within the composite must run in the same
+ * process.
+ *
+ * @param local whether all the components within the composite must run in
+ * the same process
+ */
+ void setLocal(boolean local);
+
+ /**
+ * Return the Boolean value of autowire
+ * @return null/TRUE/FALSE
+ */
+ Boolean getAutowire();
+
+ /**
+ * Sets whether component references should be autowired.
+ *
+ * @param autowire whether component references should be autowired
+ */
+ void setAutowire(Boolean autowire);
+
+ /**
+ * Returns a clone of the component type.
+ *
+ * @return a clone of the component type
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java
new file mode 100644
index 0000000000..88cb2f9a2c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+/**
+ * Represents composite reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CompositeReference extends Reference {
+ /**
+ * Returns the promoted components. For each promoted component/reference,
+ * they have the same index in the component and reference list.
+ *
+ * @return the promoted components
+ */
+ List<Component> getPromotedComponents();
+
+ /**
+ * Returns the promoted component references.
+ *
+ * @return the promoted component references
+ */
+ List<ComponentReference> getPromotedReferences();
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java
new file mode 100644
index 0000000000..575d0784ce
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * Represents a composite service.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface CompositeService extends Service {
+
+ /**
+ * Returns the promoted component.
+ *
+ * @return the promoted component.
+ */
+ Component getPromotedComponent();
+
+ /**
+ * Sets the promoted component
+ *
+ * @param promotedComponent the promoted component.
+ */
+ void setPromotedComponent(Component promotedComponent);
+
+ /**
+ * Returns the promoted component service .
+ *
+ * @return the promoted component service.
+ */
+ ComponentService getPromotedService();
+
+ /**
+ * Sets the promoted component service
+ *
+ * @param promotedService the promoted component service.
+ */
+ void setPromotedService(ComponentService promotedService);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java
new file mode 100644
index 0000000000..25ae82aa8f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents an Operation. Typically Operation elements are used when there is a
+ * need to apply certain facets such as intents and policysets only to a specific
+ * operation provided by a service or reference.
+ *
+ * @tuscany.spi.extension.asclient
+ * @version $Rev$ $Date$
+ */
+public interface ConfiguredOperation extends Base, PolicySubject {
+ /**
+ * Returns the name of the operation.
+ *
+ * @return the name of the operation
+ */
+ String getName();
+
+ /**
+ * Sets the name of the operation.
+ *
+ * @param name the name of the operation
+ */
+ void setName(String name);
+
+ /**
+ * Returns the name of the service or reference to which this operation belongs.
+ * This method is particularly useful when operation elements are specified under implementation
+ * elements and it is necessary to identify which of the various services provided by the
+ * implementation is referred to by the operation element in question
+ *
+ * @return the name of the contract to which this operation belongs
+ */
+ String getContractName();
+
+ /**
+ * Sets the name of the service or reference to which this operation belongs.
+ *
+ * @param contractName the name of the contract to which this operation belongs
+ */
+ void setContractName(String contractName);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
new file mode 100644
index 0000000000..0c57c74ec0
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a contract. A contract can be either a service or a reference.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Contract extends AbstractContract, PolicySubject, Cloneable {
+
+ /**
+ * Returns the bindings supported by this contract.
+ *
+ * @return the bindings supported by this contract
+ */
+ List<Binding> getBindings();
+
+ /**
+ * Returns a binding of the specified type or null if there is no such
+ * binding configured on this contract.
+ *
+ * @param <B> the binding type
+ * @param bindingClass the binding type class
+ * @return the binding or null if there is no binding of the specified type
+ */
+ <B> B getBinding(Class<B> bindingClass);
+
+ /**
+ * Returns a callback binding of the specified type or null if there is no such
+ * callback binding configured on this contract.
+ *
+ * @param <B> the callback binding type
+ * @param bindingClass the callback binding type class
+ * @return the callback binding or null if there is no callback binding of the specified type
+ */
+ <B> B getCallbackBinding(Class<B> bindingClass);
+
+ /**
+ * Returns a callback definition of the bindings to use for callbacks.
+ *
+ * @return a definition of the bindings to use for callbacks
+ */
+ Callback getCallback();
+
+ /**
+ * Sets a callback definition of the bindings to use for callbacks
+ *
+ * @param callback a definition of the bindings to use for callbacks
+ */
+ void setCallback(Callback callback);
+
+ /**
+ * Returns a clone of the contract.
+ *
+ * @return a clone of the reference
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * Returns the interface contract given a binding. Important in the case where
+ * a reference with multiplicity > 1 has been promoted and has it's list of
+ * resolved bindings extended by a promoting reference. Here the binding
+ * from the promoting reference may need the interface contract from the
+ * promoting reference and not the promoted reference.
+ * TODO - remove this wrinkle with better endpoint support.
+ *
+ * @param binding the binding for which the interface contract is required
+ * @return the interface contract
+ */
+ InterfaceContract getInterfaceContract(Binding binding);
+
+ /**
+ * A flag to tell if there are any binding elements specified for this service or reference.
+ * If true, they override the the bindings in the corresponding reference/service in the
+ * component type or promoted reference/service.
+ * @return
+ */
+ boolean isOverridingBindings();
+
+ /**
+ * Set the flag depending on if there are any binding elements specified for this service or
+ * reference.
+ * @param overridingBindings true if there are binding elements specified
+ */
+ void setOverridingBindings(boolean overridingBindings);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java
new file mode 100644
index 0000000000..6d8350fc66
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly;
+
+import org.apache.tuscany.sca.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * A factory for the assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultAssemblyFactory extends AssemblyFactoryImpl implements AssemblyFactory {
+
+ public DefaultAssemblyFactory(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ public DefaultAssemblyFactory() {
+ super(new DefaultExtensionPointRegistry());
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
new file mode 100644
index 0000000000..43bf17d66a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a service endpoint which is what results from having a configured
+ * binding applied to a component service. In a deployed application an endpoint
+ * will relate directly to a physical endpoint, for example, a HTTP URL or a
+ * JMS destination.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Endpoint extends Base, PolicySubject, Cloneable, Serializable {
+ /**
+ * Get the structural URI of the service binding
+ * @return structural URI of the service/binding
+ */
+ String getURI();
+
+ /**
+ * Set the structural URI of the service binding
+ * @param uri &lt;componentURI&gt;#service-binding(serviceName/bindingName)
+ * or &lt;componentURI&gt;#service(serviceName)
+ */
+ void setURI(String uri);
+
+ /**
+ * Get the component model object
+ *
+ * @return component
+ */
+ Component getComponent();
+
+ /**
+ * Set the component model object
+ *
+ * @param component
+ */
+ void setComponent(Component component);
+
+ /**
+ * Get the service model object
+ *
+ * @return service
+ */
+ ComponentService getService();
+
+ /**
+ * Set the service model object
+ *
+ * @param service
+ */
+ void setService(ComponentService service);
+
+ /**
+ * Get the resolved target binding
+ *
+ * @return target binding
+ */
+ Binding getBinding();
+
+ /**
+ * Set the binding
+ *
+ * @param binding
+ */
+ void setBinding(Binding binding);
+
+ /**
+ * Returns the interface contract defining the interface
+ *
+ * @return the interface contract
+ */
+ InterfaceContract getComponentServiceInterfaceContract();
+
+ /**
+ * Get the service's callback endpoint references that
+ * represent endpoint references from which callbacks
+ * originate
+ *
+ * @return callbackEndpoint the reference callback endpoint
+ */
+ List<EndpointReference> getCallbackEndpointReferences();
+
+ /**
+ * Returns true if this endpoint represents a serivce that is not
+ * running in this JVM
+ *
+ * @return true if the endpoint is remote
+ */
+ boolean isRemote();
+
+ /**
+ * Set true if this endpoint represents a serivce that is not
+ * running in this JVM
+ *
+ * @param remote set to true if the endpoint is remote
+ */
+ void setRemote(boolean remote);
+
+ /**
+ * Supports endpoint cloning
+ *
+ * @return endpoint
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * Tests if the URI of this endpoint matches the service URI
+ * @param serviceName the service URI to test
+ * @return true if the endpoint URI matches the service URI
+ */
+ boolean matches(String serviceURI);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java
new file mode 100644
index 0000000000..f9edbe6e87
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.io.Serializable;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents an endpoint reference. An SCA reference can reference service endpoints in a
+ * number of ways. Target names, autowire, configured bindings. The endpoint reference
+ * captures the result of specifying one of these things.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface EndpointReference extends Base, PolicySubject, Cloneable, Serializable {
+
+ /**
+ * Status of the endpoint reference resolution
+ */
+ enum Status {
+ NOT_CONFIGURED, // Not configured
+ RESOLVED_BINDING, // The endpoint reference is configured with a binding
+ AUTOWIRE_PLACEHOLDER, // Autowire to be performed
+ WIRED_TARGET_NOT_FOUND, // Wire target not found
+ WIRED_TARGET_FOUND_READY_FOR_MATCHING, // Wire target found and ready to be resolved to an endpoint
+ WIRED_TARGET_FOUND_AND_MATCHED, // Wire target found and resolved to an endpoint
+ WIRED_TARGET_IN_BINDING_URI // SCA target specified by the binding uri
+ };
+
+ /**
+ * Get the structural URI of the reference binding
+ * @return The structural URI of the reference/binding
+ */
+ String getURI();
+
+ /**
+ * Set the structural URI of the reference binding
+ * @param uri &lt;componentURI&gt;#reference-binding(referenceName/bindingName)
+ * or &lt;componentURI&gt;#reference(referenceName) if binding is not present
+ *
+ */
+ void setURI(String uri);
+
+ /**
+ * Supports endpoint reference cloning
+ *
+ * @return endpointReference
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * Get the component model object
+ *
+ * @return component
+ */
+ Component getComponent();
+
+ /**
+ * Set the component model object
+ *
+ * @param component the component for the endpoint
+ */
+ void setComponent(Component component);
+
+ /**
+ * Get the source component reference model object
+ *
+ * @return reference the source component reference for the endpoint
+ */
+ ComponentReference getReference();
+
+ /**
+ * Set the source component reference model object
+ *
+ * @param reference
+ */
+ void setReference(ComponentReference reference);
+
+ /**
+ * Get the resolved reference binding
+ *
+ * @return binding the resolved reference binding
+ */
+ Binding getBinding();
+
+ /**
+ * Set the resolved reference binding
+ *
+ * @param binding the resolved reference binding
+ */
+ void setBinding(Binding binding);
+
+ /**
+ * Get the target endpoint
+ *
+ * @return endpoint the target endpoint
+ */
+ Endpoint getTargetEndpoint();
+
+ /**
+ * Set the target endpoint model object
+ *
+ * @param endpoint the target endpoint
+ */
+ void setTargetEndpoint(Endpoint targetEndpoint);
+
+ /**
+ * Returns the interface contract defining the interface
+ *
+ * @return the interface contract
+ */
+ InterfaceContract getComponentReferenceInterfaceContract();
+
+ /**
+ * Get the reference callback endpoint that
+ * represents that target endpoint to which callback
+ * messages will be directed
+ *
+ * @return callbackEndpoint the reference callback endpoint
+ */
+ Endpoint getCallbackEndpoint();
+
+ /**
+ * Set the reference callback endpoint
+ *
+ * @param callbackEndpoint the reference callback endpoint
+ */
+ void setCallbackEndpoint(Endpoint callbackEndpoint);
+
+ /**
+ * Rather than relying on combinations of unresolved flags and
+ * other data we maintain a status enumeration
+ *
+ * @return status
+ */
+ Status getStatus();
+
+ /**
+ * Rather than relying on combinations of unresolved flags and
+ * other data we maintain a status enumeration
+ *
+ * @param status the new status
+ */
+ void setStatus(Status status);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java
new file mode 100644
index 0000000000..da8d054140
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+/**
+ * Base interface for extensible assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Extensible extends Base {
+
+ /**
+ * Returns a list of extension objects contained in this model object.
+ *
+ * @return a list of extension objects container in this model object
+ */
+ List<Object> getExtensions();
+
+ /**
+ * Returns a list of attribute extensions contained in this model object
+ *
+ * @return a list of attribute extensions contained in this model object
+ */
+ List<Extension> getAttributeExtensions();
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java
new file mode 100644
index 0000000000..d179ce7b3b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Base interface for storing contents of extensible assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Extension {
+
+ /**
+ * Return QName for the extension
+ * @return the extension QName
+ */
+ QName getQName();
+
+ /**
+ * Set QName for the extension
+ * @param qName the extension QName
+ */
+ void setQName(QName qName);
+
+ /**
+ * Return the original extension value
+ * @return the extension value
+ */
+ <T> T getValue();
+
+ /**
+ * Set the original extension value
+ * @param value the extension value
+ */
+ <T> void setValue(T value);
+
+ /**
+ * Return whether or not the extension is an attribute
+ * @return
+ */
+ boolean isAttribute();
+
+ /**
+ * Set whether or not the extension is an attribute
+ * @param value
+ */
+ void setAttribute(boolean isAttribute);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
new file mode 100644
index 0000000000..3912896f0c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * Represents a component implementation.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Implementation extends ComponentType {
+ QName getType();
+ List<Operation> getOperations();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java
new file mode 100644
index 0000000000..5b719e50bc
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * Enumeration for multiplicity. Defines the number of wires that can connect a
+ * reference to target services.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension
+ */
+public enum Multiplicity {
+
+ /**
+ * Zero or one wire can have the reference as a source.
+ */
+ ZERO_ONE,
+
+ /**
+ * The default setting, one wire can have the reference as a source.
+ */
+ ONE_ONE,
+
+ /**
+ * Zero or more wires can have the reference as a source.
+ */
+ ZERO_N,
+
+ /**
+ * One or more wires can have the reference as a source.
+ */
+ ONE_N
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java
new file mode 100644
index 0000000000..9df72e358d
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * Represents an operationSelector
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface OperationSelector extends Base, Cloneable {
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java
new file mode 100644
index 0000000000..9563d2e1cb
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+/**
+ * Interface to be implemented by SCA artifacts that support configuration of 'operation' child
+ * elements for policies etc.
+ * @tuscany.spi.extension.inheritfrom
+ * @version $Rev$ $Date$
+ */
+
+public interface OperationsConfigurator {
+ List<ConfiguredOperation> getConfiguredOperations();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java
new file mode 100644
index 0000000000..c65b6213b0
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * A property allows for the configuration of an implementation with externally
+ * set data values. An implementation can have zero or more properties. Each
+ * property has a data type, which may be either simple or complex. An
+ * implementation may also define a default value for a property.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Property extends AbstractProperty, Cloneable {
+
+ /**
+ * Returns a clone of the property.
+ *
+ * @return a clone of the property
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
new file mode 100644
index 0000000000..2ee3e774e4
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+/**
+ * Represents a reference. References within an implementation represent links
+ * to services that the implementation uses that must be provided by other
+ * components.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Reference extends AbstractReference, Contract {
+
+ /**
+ * Returns a boolean value, "false" by default, which indicates that the
+ * implementation wires this reference dynamically.
+ *
+ * @return true if the implementation wires this reference dynamically
+ */
+ boolean isWiredByImpl();
+
+ /**
+ * Sets a boolean value, "false" by default, which indicates that the
+ * implementation wires this reference dynamically.
+ *
+ * @param wiredByImpl whether the implementation wires this reference
+ * dynamically
+ */
+ void setWiredByImpl(boolean wiredByImpl);
+
+
+ /**
+ * Returns the targets of this reference.
+ *
+ * @return the targets of this reference.
+ */
+ List<ComponentService> getTargets();
+
+ /**
+ * Returns the endpoint references implied by this reference.
+ *
+ * Endpoint references are used to represent:
+ *
+ * - manually specified reference targets
+ * - reference targets determined by autowire
+ * - manually configured remote bindings
+ *
+ * @return the endpoint references implied by this reference
+ */
+ List<EndpointReference> getEndpointReferences();
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java
new file mode 100644
index 0000000000..aa356e3857
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents an SCA binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SCABinding extends Binding {
+ QName TYPE = new QName(SCA11_NS, "binding.sca");
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java
new file mode 100644
index 0000000000..feae980326
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * A factory for the SCA binding model
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SCABindingFactory {
+
+ /**
+ * Create a new SCA binding.
+ *
+ * @return a new SCA binding
+ */
+ SCABinding createSCABinding();
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java
new file mode 100644
index 0000000000..1f3d412364
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+/**
+ * Represents a service. Services are used to publish services provided by
+ * implementations, so that they are addressable by other components.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Service extends AbstractService, Contract {
+ /**
+ * Returns the endpoints implied by this service.
+ *
+ * Endpoints represent configured bindings for a service. Hence a service
+ * with two bindings will expose two Endpoints. Where a promoted service has
+ * new binding configuration applied by a promoting component Endpoints are
+ * introduced to represent these new bindings.
+ *
+ * @return the endpoints implied by this service
+ */
+ List<Endpoint> getEndpoints();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java
new file mode 100644
index 0000000000..075b50eec1
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a wire.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Wire extends Base, Extensible, PolicySubject, Cloneable {
+
+ /**
+ * Returns the source of the wire.
+ *
+ * @return the source of the wire
+ */
+ ComponentReference getSource();
+
+ /**
+ * Sets the source of the wire.
+ *
+ * @param source the source of the wire
+ */
+ void setSource(ComponentReference source);
+
+ /**
+ * Returns the target of the wire.
+ *
+ * @return the target of the wire
+ */
+ ComponentService getTarget();
+
+ /**
+ * Sets the target of the wire.
+ *
+ * @param target the target of the wire
+ */
+ void setTarget(ComponentService target);
+
+ /**
+ * A boolean value, with the default of "false". When a wire element has
+ * @replace="false", the wire is added to the set of wires which apply to
+ * the reference identified by the @source attribute. When a wire element
+ * has @replace="true", the wire is added to the set of wires which apply to
+ * the reference identified by the @source attribute - but any wires for that
+ * reference specified by means of the @target attribute of the reference
+ * are removed from the set of wires which apply to the reference.
+ *
+ * @return
+ */
+ boolean isReplace();
+
+ /**
+ * Set the replace flag for the wire
+ * @param replace
+ */
+ void setReplace(boolean replace);
+
+ /**
+ * Returns a clone of the wire.
+ *
+ * @return a clone of the wire
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java
new file mode 100644
index 0000000000..c622737454
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a wireFormat.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface WireFormat extends Base, Cloneable {
+ QName getSchemaName();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java
new file mode 100644
index 0000000000..8c56385c9e
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Contract;
+
+/**
+ * A builder that handles any build-time configuration needed by bindings.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface BindingBuilder<B extends Binding> {
+
+ /**
+ * Configure a binding.
+ *
+ * @param component The component for the binding's service or reference
+ * @param contract The binding's service or reference
+ * @param context The context for the builder
+ * @param rebuild Set true to have derived data in the binding rebuilt
+ * caching can cause problems in the late binding case so we
+ * need to be able to remove cached data
+ */
+ void build(Component component, Contract contract, B binding, BuilderContext context, boolean rebuild);
+
+ /**
+ * Get QName of the binding type
+ * @return The binding type
+ */
+ QName getBindingType();
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java
new file mode 100644
index 0000000000..374c36c1f5
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+
+/**
+ * Context for builders
+ * @tuscany.spi.extension.asclient
+ */
+public class BuilderContext {
+ protected Definitions definitions;
+ protected Map<QName, List<String>> bindingBaseURIs = Collections.emptyMap();
+ protected Monitor monitor;
+
+ /**
+ * @param definitions
+ * @param bindingBaseURIs
+ * @param monitor
+ */
+ public BuilderContext(Definitions definitions, Map<QName, List<String>> bindingBaseURIs, Monitor monitor) {
+ super();
+ this.definitions = definitions;
+ if (bindingBaseURIs != null) {
+ this.bindingBaseURIs = bindingBaseURIs;
+ }
+ this.monitor = monitor;
+ }
+
+ /**
+ * Create a builder context with the monitor
+ * @param monitor
+ */
+ public BuilderContext(Monitor monitor) {
+ super();
+ this.monitor = monitor;
+ }
+
+ /**
+ * Create a builder context with the extension point registry
+ * @param registry
+ */
+ public BuilderContext(ExtensionPointRegistry registry) {
+ super();
+ MonitorFactory monitorFactory =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(MonitorFactory.class);
+ this.monitor = monitorFactory.createMonitor();
+ }
+
+ /**
+ * Create a builder context with a default monitor
+ */
+ public BuilderContext() {
+ super();
+ this.monitor = new DefaultMonitorFactory().createMonitor();
+ }
+
+ public Monitor getMonitor() {
+ return monitor;
+ }
+
+ public Monitor setMonitor(Monitor monitor) {
+ Monitor old = this.monitor;
+ this.monitor = monitor;
+ return old;
+ }
+
+ public Definitions getDefinitions() {
+ return definitions;
+ }
+
+ public Map<QName, List<String>> getBindingBaseURIs() {
+ return bindingBaseURIs;
+ }
+
+ public void setDefinitions(Definitions definitions) {
+ this.definitions = definitions;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java
new file mode 100644
index 0000000000..14ae2042d3
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Implementation;
+
+/**
+ * An extension point for Composite builders.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface BuilderExtensionPoint {
+
+ /**
+ * Adds a contract builder.
+ *
+ * @param compositeBuilder
+ */
+ void addContractBuilder(ContractBuilder contractBuilder);
+
+ /**
+ * Removes a contract builder.
+ *
+ * @param compositeBuilder
+ */
+ void removeContractBuilder(ContractBuilder contractBuilder);
+
+ /**
+ * Returns the contract builder
+ *
+ * @param id
+ * @return
+ */
+ ContractBuilder getContractBuilder();
+
+ /**
+ * Adds a composite builder.
+ *
+ * @param compositeBuilder
+ */
+ void addCompositeBuilder(CompositeBuilder compositeBuilder);
+
+ /**
+ * Removes a composite builder.
+ *
+ * @param compositeBuilder
+ */
+ void removeCompositeBuilder(CompositeBuilder compositeBuilder);
+
+ /**
+ * Returns the composite builder with the given id.
+ *
+ * @param id
+ * @return
+ */
+ CompositeBuilder getCompositeBuilder(String id);
+
+ /**
+ * Add a binding builder
+ * @param bindingBuilder
+ */
+ void addBindingBuilder(BindingBuilder<?> bindingBuilder);
+
+ /**
+ * Look up a binding builder by the binding type
+ * @param <B>
+ * @param bindingType
+ * @return
+ */
+ <B extends Binding> BindingBuilder<B> getBindingBuilder(QName bindingType);
+
+ /**
+ * Remove a binding builder
+ * @param <B>
+ * @param builder
+ */
+ <B extends Binding> void removeBindingBuilder(BindingBuilder<B> builder);
+
+ /**
+ * Add an implementation builder
+ * @param implementationBuilder
+ */
+ void addImplementationBuilder(ImplementationBuilder<?> implementationBuilder);
+
+ /**
+ * Look up an implementation builder by implementation type
+ * @param <I>
+ * @param implementationType
+ * @return
+ */
+ <I extends Implementation> ImplementationBuilder<I> getImplementationBuilder(QName implementationType);
+
+ /**
+ * Remove an implementation builder
+ * @param <I>
+ * @param builder
+ */
+ <I extends Implementation> void removeImplementationBuilder(ImplementationBuilder<I> builder);
+
+ /**
+ * Add a policy builder
+ * @param policyBuilder
+ */
+ void addPolicyBuilder(PolicyBuilder<?> policyBuilder);
+
+ /**
+ * Look up a Policy builder by the Policy type
+ * @param <P>
+ * @param policyType
+ * @return
+ */
+ <P> PolicyBuilder<P> getPolicyBuilder(QName policyType);
+
+ /**
+ * Remove a Policy builder
+ * @param <P>
+ * @param builder
+ */
+ <P> void removePolicyBuilder(PolicyBuilder<P> builder);
+
+ /**
+ * Get a collection of policy builders
+ * @return
+ */
+ public Collection<PolicyBuilder> getPolicyBuilders();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java
new file mode 100644
index 0000000000..50bf10f54a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+import org.apache.tuscany.sca.assembly.Composite;
+
+/**
+ * A builder that handles the configuration of the components inside a
+ * composite and the wiring of component references to component services.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CompositeBuilder {
+
+ /**
+ * Returns the ID of the builder.
+ *
+ * @return An ID that identifies the builder
+ */
+ String getID();
+
+ /**
+ * Build a composite.
+ *
+ * @param composite The composite
+ * @param context The builder context
+ * @return The composite built from the original one. In most cases, it is the same as the orginal one as
+ * most builders only change the content of the composite.
+ *
+ * @throws CompositeBuilderException
+ */
+ Composite build(Composite composite, BuilderContext context) throws CompositeBuilderException;
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java
new file mode 100644
index 0000000000..5a2015f55e
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+/**
+ * Reports a composite builder exception.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeBuilderException extends Exception {
+ private static final long serialVersionUID = -8916323176803443856L;
+
+ public CompositeBuilderException() {
+ }
+
+ public CompositeBuilderException(String message) {
+ super(message);
+ }
+
+ public CompositeBuilderException(Throwable cause) {
+ super(cause);
+ }
+
+ public CompositeBuilderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ContractBuilder.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ContractBuilder.java
new file mode 100644
index 0000000000..99a58dc1c8
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ContractBuilder.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * A builder that builds WSDL versions of component contracts so that the
+ * component contracts can be compared with binding contracts in a generic way.
+ * The generic interface format defined by the Assembly spec is WSDL 1.1
+ */
+public interface ContractBuilder {
+
+ /**
+ * Build the WSDL version of the Interface Contract
+ */
+ boolean build(InterfaceContract interfaceContract, BuilderContext context);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java
new file mode 100644
index 0000000000..8b037a7534
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java
@@ -0,0 +1,479 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDeclarationParser;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+
+/**
+ * Default implementation of a provider factory extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultBuilderExtensionPoint implements BuilderExtensionPoint, LifeCycleListener {
+
+ private ExtensionPointRegistry registry;
+ private final Map<String, CompositeBuilder> builders = new HashMap<String, CompositeBuilder>();
+ private final Map<QName, BindingBuilder> bindingBuilders = new HashMap<QName, BindingBuilder>();
+ private final Map<QName, ImplementationBuilder> implementationBuilders =
+ new HashMap<QName, ImplementationBuilder>();
+ private final Map<QName, PolicyBuilder> policyBuilders = new HashMap<QName, PolicyBuilder>();
+ private ContractBuilder contractBuilder = null;
+
+ private boolean loaded;
+
+ public DefaultBuilderExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ builders.clear();
+ bindingBuilders.clear();
+ implementationBuilders.clear();
+ loaded = false;
+ }
+
+ public void addCompositeBuilder(CompositeBuilder builder) {
+ builders.put(builder.getID(), builder);
+ }
+
+ public void removeCompositeBuilder(CompositeBuilder builder) {
+ builders.remove(builder.getID());
+ }
+
+ public CompositeBuilder getCompositeBuilder(String id) {
+ loadBuilders();
+ return builders.get(id);
+ }
+
+ public void addContractBuilder(ContractBuilder contractBuilder){
+ this.contractBuilder = contractBuilder;
+ }
+
+ public void removeContractBuilder(ContractBuilder contractBuilder){
+ this.contractBuilder = null;
+ }
+
+ public ContractBuilder getContractBuilder(){
+ loadBuilders();
+ return contractBuilder;
+ }
+
+ /**
+ * Load builders declared under META-INF/services.
+ */
+ private synchronized void loadBuilders() {
+ if (loaded)
+ return;
+
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+
+ UtilityExtensionPoint utils = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper mapper = utils.getUtility(InterfaceContractMapper.class);
+
+ // Get the provider factory service declarations
+ Collection<ServiceDeclaration> builderDeclarations;
+ ServiceDiscovery serviceDiscovery = registry.getServiceDiscovery();
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(CompositeBuilder.class.getName());
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ Map<String, String> attributes = builderDeclaration.getAttributes();
+ String id = attributes.get("id");
+
+ CompositeBuilder builder = new LazyCompositeBuilder(id, builderDeclaration, this, factories, mapper);
+ builders.put(id, builder);
+ }
+
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(BindingBuilder.class);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ BindingBuilder<?> builder = new LazyBindingBuilder(builderDeclaration);
+ bindingBuilders.put(builder.getBindingType(), builder);
+ }
+
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(ImplementationBuilder.class);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ ImplementationBuilder<?> builder = new LazyImplementationBuilder(builderDeclaration);
+ implementationBuilders.put(builder.getImplementationType(), builder);
+ }
+
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(PolicyBuilder.class);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ PolicyBuilder<?> builder = new LazyPolicyBuilder(builderDeclaration);
+ policyBuilders.put(builder.getPolicyType(), builder);
+ }
+
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(ContractBuilder.class);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ contractBuilder = new LazyContractBuilder(builderDeclaration);
+ }
+
+
+ loaded = true;
+
+ }
+
+ public void addBindingBuilder(BindingBuilder<?> bindingBuilder) {
+ bindingBuilders.put(bindingBuilder.getBindingType(), bindingBuilder);
+ }
+
+ public <B extends Binding> BindingBuilder<B> getBindingBuilder(QName bindingType) {
+ loadBuilders();
+ return (BindingBuilder<B>)bindingBuilders.get(bindingType);
+ }
+
+ public <B extends Binding> void removeBindingBuilder(BindingBuilder<B> builder) {
+ bindingBuilders.remove(builder.getBindingType());
+ }
+
+ public void addImplementationBuilder(ImplementationBuilder<?> implementationBuilder) {
+ implementationBuilders.put(implementationBuilder.getImplementationType(), implementationBuilder);
+ }
+
+ public <I extends Implementation> ImplementationBuilder<I> getImplementationBuilder(QName implementationType) {
+ loadBuilders();
+ return (ImplementationBuilder<I>)implementationBuilders.get(implementationType);
+ }
+
+ public <I extends Implementation> void removeImplementationBuilder(ImplementationBuilder<I> builder) {
+ implementationBuilders.remove(builder.getImplementationType());
+ }
+
+ public void addPolicyBuilder(PolicyBuilder<?> policyBuilder) {
+ policyBuilders.put(policyBuilder.getPolicyType(), policyBuilder);
+ }
+
+ public <B> PolicyBuilder<B> getPolicyBuilder(QName policyType) {
+ loadBuilders();
+ return (PolicyBuilder<B>)policyBuilders.get(policyType);
+ }
+
+ public Collection<PolicyBuilder> getPolicyBuilders() {
+ loadBuilders();
+ return policyBuilders.values();
+ }
+
+ public <B> void removePolicyBuilder(PolicyBuilder<B> builder) {
+ policyBuilders.remove(builder.getPolicyType());
+ }
+
+ /**
+ * A wrapper around a composite builder allowing lazy
+ * loading and initialization of implementation providers.
+ */
+ private class LazyCompositeBuilder implements CompositeBuilder {
+
+ private FactoryExtensionPoint factories;
+ private InterfaceContractMapper mapper;
+ private String id;
+ private ServiceDeclaration builderDeclaration;
+ private CompositeBuilder builder;
+ private BuilderExtensionPoint builders;
+
+ private LazyCompositeBuilder(String id,
+ ServiceDeclaration factoryDeclaration,
+ BuilderExtensionPoint builders,
+ FactoryExtensionPoint factories,
+ InterfaceContractMapper mapper) {
+ this.id = id;
+ this.builderDeclaration = factoryDeclaration;
+ this.builders = builders;
+ this.factories = factories;
+ this.mapper = mapper;
+ }
+
+ public String getID() {
+ return id;
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ return getBuilder().build(composite, context);
+ }
+
+ private CompositeBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<CompositeBuilder> builderClass = (Class<CompositeBuilder>)builderDeclaration.loadClass();
+ try {
+ Constructor<CompositeBuilder> constructor =
+ builderClass.getConstructor(FactoryExtensionPoint.class, InterfaceContractMapper.class);
+ builder = constructor.newInstance(factories, mapper);
+ } catch (NoSuchMethodException e) {
+ try {
+ Constructor<CompositeBuilder> constructor =
+ builderClass.getConstructor(BuilderExtensionPoint.class,
+ FactoryExtensionPoint.class,
+ InterfaceContractMapper.class);
+ builder = constructor.newInstance(builders, factories, mapper);
+ } catch (NoSuchMethodException ex) {
+ Constructor<CompositeBuilder> constructor =
+ builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = constructor.newInstance(registry);
+ }
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+
+ }
+
+ private class LazyBindingBuilder implements BindingBuilder {
+ private ServiceDeclaration sd;
+ private BindingBuilder<?> builder;
+ private QName qname;;
+
+ /**
+ * @param sd
+ */
+ public LazyBindingBuilder(ServiceDeclaration sd) {
+ super();
+ this.sd = sd;
+ this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname"));
+ }
+
+ public void build(Component component, Contract contract, Binding binding, BuilderContext context, boolean rebuild) {
+ getBuilder().build(component, contract, binding, context, rebuild);
+ }
+
+ public QName getBindingType() {
+ return qname;
+ }
+
+
+ private synchronized BindingBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<?> builderClass = sd.loadClass();
+ try {
+ Constructor<?> constructor = builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = (BindingBuilder)constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ Constructor<?> constructor = builderClass.getConstructor();
+ builder = (BindingBuilder)constructor.newInstance();
+
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+
+ }
+
+ private class LazyImplementationBuilder implements ImplementationBuilder {
+ private ServiceDeclaration sd;
+ private ImplementationBuilder<?> builder;
+ private QName qname;;
+
+ /**
+ * @param sd
+ */
+ public LazyImplementationBuilder(ServiceDeclaration sd) {
+ super();
+ this.sd = sd;
+ this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname"));
+ }
+
+ public void build(Component component, Implementation implementation, BuilderContext context) {
+ getBuilder().build(component, implementation, context);
+ }
+
+ public QName getImplementationType() {
+ return qname;
+ }
+
+ private synchronized ImplementationBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<?> builderClass = sd.loadClass();
+ try {
+ Constructor<?> constructor = builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = (ImplementationBuilder)constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ Constructor<?> constructor = builderClass.getConstructor();
+ builder = (ImplementationBuilder)constructor.newInstance();
+
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+
+ }
+
+ private class LazyPolicyBuilder implements PolicyBuilder {
+ private ServiceDeclaration sd;
+ private PolicyBuilder<?> builder;
+ private QName qname;;
+
+ /**
+ * @param sd
+ */
+ public LazyPolicyBuilder(ServiceDeclaration sd) {
+ super();
+ this.sd = sd;
+ this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname"));
+ }
+
+ public boolean build(Component component, Implementation implementation, BuilderContext context) {
+ return getBuilder().build(component, implementation, context);
+ }
+
+ public QName getPolicyType() {
+ return qname;
+ }
+
+ public List<QName> getSupportedBindings() {
+ return getBuilder().getSupportedBindings();
+ }
+
+ private synchronized PolicyBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<?> builderClass = sd.loadClass();
+ try {
+ Constructor<?> constructor = builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = (PolicyBuilder)constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ Constructor<?> constructor = builderClass.getConstructor();
+ builder = (PolicyBuilder)constructor.newInstance();
+
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+
+ public boolean build(Endpoint endpoint, BuilderContext context) {
+ return getBuilder().build(endpoint, context);
+ }
+
+ public boolean build(org.apache.tuscany.sca.assembly.EndpointReference endpointReference, BuilderContext context) {
+ return getBuilder().build(endpointReference, context);
+ }
+
+ public boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context) {
+ return getBuilder().build(endpointReference, endpoint, context);
+ }
+ }
+
+ private class LazyContractBuilder implements ContractBuilder {
+ private ServiceDeclaration sd;
+ private ContractBuilder builder;
+
+ /**
+ * @param sd
+ */
+ public LazyContractBuilder(ServiceDeclaration sd) {
+ super();
+ this.sd = sd;
+ }
+
+/*
+ public boolean build(EndpointReference endpointReference, BuilderContext context){
+ return getBuilder().build(endpointReference, context);
+ }
+
+ public boolean build(Endpoint endpoint, BuilderContext context){
+ return getBuilder().build(endpoint, context);
+ }
+*/
+
+ public boolean build(InterfaceContract interfaceContract, BuilderContext context){
+ return getBuilder().build(interfaceContract, context);
+ }
+
+ private synchronized ContractBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<?> builderClass = sd.loadClass();
+ try {
+ Constructor<?> constructor = builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = (ContractBuilder)constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ Constructor<?> constructor = builderClass.getConstructor();
+ builder = (ContractBuilder)constructor.newInstance();
+
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java
new file mode 100644
index 0000000000..d47c3d9032
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Implementation;
+
+/**
+ * A builder that handles any build-time configuration needed by implementations.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ImplementationBuilder<I extends Implementation> {
+
+ /**
+ * Configure a component implementation.
+ *
+ * @param component The component
+ * @param context TODO
+ * @param contract The implementation
+ */
+ void build(Component component, I implmentation, BuilderContext context);
+
+ /**
+ * Get the QName of the implementation type
+ * @return
+ */
+ QName getImplementationType();
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java
new file mode 100644
index 0000000000..4f2842c61a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+/**
+ * Constants for resource bundle names
+ */
+public interface Messages {
+ String RESOURCE_PACKAGE = "org.apache.tuscany.sca.assembly.builder.";
+ String ASSEMBLY_VALIDATION = RESOURCE_PACKAGE + "assembly-validation-messages";
+ String ASSEMBLY_CONFORMANCE = RESOURCE_PACKAGE + "assembly-conformance-messages";
+ String DEFINITIONS_VALIDATION = RESOURCE_PACKAGE + "definitions-validation-messages";
+ String BUILDER_VALIDATION_BUNDLE = "org.apache.tuscany.sca.builder.builder-validation-messages";
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java
new file mode 100644
index 0000000000..423c856973
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+
+/**
+ * A builder that is contributed by a specific policy language to validate the configurations
+ * for SCA endpoints, endpoint references and component implementations
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface PolicyBuilder<T> {
+ /**
+ * Get the policy type
+ * @return
+ */
+ QName getPolicyType();
+
+ /**
+ * Return the list of binding type QNames at which this policy implementation
+ * is targeted. Or null if the policy is not binding specific
+ * @return list of binding type QNames at which this policy implementation or null if it's not binding specific
+ */
+ List<QName> getSupportedBindings();
+
+ /**
+ * Build (and validate) the policy settings on the endpoint
+ * @param endpoint
+ * @param monitor
+ * @return true if the policy setting is compatible
+ */
+ boolean build(Endpoint endpoint, BuilderContext context);
+
+ /**
+ * Build (and validate) the policy settings on the endpoint reference
+ * @param endpointReference
+ * @param monitor
+ * @return true if the policy setting is compatible
+ */
+ boolean build(EndpointReference endpointReference, BuilderContext context);
+
+ /**
+ * Build (and validate) the policy settings on the component implementation
+ * @param component
+ * @param implementation
+ * @param monitor
+ * @return true if the policy setting is compatible
+ */
+ boolean build(Component component, Implementation implementation, BuilderContext context);
+
+ /**
+ * Build (and validate) the policy settings on the endpoint reference is compatible with the endpoint
+ * @param endpointReference
+ * @param endpoint
+ * @param context
+ * @return if the policy setting is compatible
+ */
+ boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/WireBuilder.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/WireBuilder.java
new file mode 100644
index 0000000000..2bfbe85664
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/WireBuilder.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+
+/**
+ * A builder that connects an endpoint reference to an endpoint
+ */
+public interface WireBuilder {
+ /**
+ * Build the endpoint reference against the endpoint. If the endpoint is a valid target for the
+ * endpoint reference, the wire buidler can populate some information from the endpoint into the
+ * endpoint reference (such as targetEndpoint, policySets or requiredIntents)
+ * @param endpointReference
+ * @param endpoint
+ * @param context
+ * @return true if the endpoint is a valid target for the endpoint reference
+ */
+ boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
new file mode 100644
index 0000000000..24dc20f815
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AbstractProperty;
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * Represents an abstract property.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractPropertyImpl extends ExtensibleImpl implements AbstractProperty {
+ protected Object value;
+ protected String name;
+ protected QName xsdType;
+ protected QName xsdElement;
+ protected boolean many;
+ protected boolean mustSupply;
+ protected DataType dataType;
+ protected Object xsdDefinition;
+
+ /**
+ * Constructs a new abstract property.
+ */
+ protected AbstractPropertyImpl() {
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public QName getXSDElement() {
+ return xsdElement;
+ }
+
+ public QName getXSDType() {
+ return xsdType;
+ }
+
+ public boolean isMany() {
+ return many;
+ }
+
+ public boolean isMustSupply() {
+ return mustSupply;
+ }
+
+ public void setValue(Object defaultValue) {
+ this.value = defaultValue;
+ }
+
+ public void setMany(boolean many) {
+ this.many = many;
+ }
+
+ public void setMustSupply(boolean mustSupply) {
+ this.mustSupply = mustSupply;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setXSDElement(QName element) {
+ this.xsdElement = element;
+ }
+
+ public void setXSDType(QName type) {
+ this.xsdType = type;
+ }
+
+ public DataType getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(DataType dataType) {
+ this.dataType = dataType;
+ }
+
+ public Object getXSDDefinition() {
+ return xsdDefinition;
+ }
+
+ public void setXSDDefinition(Object xsdDefinition) {
+ this.xsdDefinition = xsdDefinition;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java
new file mode 100644
index 0000000000..3e44f5f7ae
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.AbstractReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+
+/**
+ * Represents an abstract reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractReferenceImpl extends ContractImpl implements AbstractReference {
+ private Multiplicity multiplicity = Multiplicity.ONE_ONE;
+
+ /**
+ * Constructs a new abstract reference.
+ */
+ protected AbstractReferenceImpl() {
+ }
+
+ public Multiplicity getMultiplicity() {
+ return multiplicity;
+ }
+
+ public void setMultiplicity(Multiplicity multiplicity) {
+ this.multiplicity = multiplicity;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java
new file mode 100644
index 0000000000..24b1a0e03e
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.AbstractService;
+
+/**
+ * Represents an abstract service
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractServiceImpl extends ContractImpl implements AbstractService {
+
+ /**
+ * Constructs a new abstract service.
+ */
+ protected AbstractServiceImpl() {
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
new file mode 100644
index 0000000000..0759ff1361
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.AbstractProperty;
+import org.apache.tuscany.sca.assembly.AbstractReference;
+import org.apache.tuscany.sca.assembly.AbstractService;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Wire;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * A factory for the assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AssemblyFactoryImpl implements AssemblyFactory {
+
+ protected ExtensionPointRegistry registry;
+
+ protected AssemblyFactoryImpl(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public AbstractProperty createAbstractProperty() {
+ return new AbstractPropertyImpl();
+ }
+
+ public AbstractReference createAbstractReference() {
+ return new AbstractReferenceImpl();
+ }
+
+ public AbstractService createAbstractService() {
+ return new AbstractServiceImpl();
+ }
+
+ public Callback createCallback() {
+ return new CallbackImpl();
+ }
+
+ public Component createComponent() {
+ return new ComponentImpl();
+ }
+
+ public ComponentProperty createComponentProperty() {
+ return new ComponentPropertyImpl();
+ }
+
+ public ComponentReference createComponentReference() {
+ return new ComponentReferenceImpl();
+ }
+
+ public ComponentService createComponentService() {
+ return new ComponentServiceImpl();
+ }
+
+ public ComponentType createComponentType() {
+ return new ComponentTypeImpl();
+ }
+
+ public Composite createComposite() {
+ return new CompositeImpl();
+ }
+
+ public CompositeReference createCompositeReference() {
+ return new CompositeReferenceImpl();
+ }
+
+ public CompositeService createCompositeService() {
+ return new CompositeServiceImpl();
+ }
+
+ public Property createProperty() {
+ return new PropertyImpl();
+ }
+
+ public Reference createReference() {
+ return new ReferenceImpl();
+ }
+
+ public Service createService() {
+ return new ServiceImpl();
+ }
+
+ public Wire createWire() {
+ return new WireImpl();
+ }
+
+ public Extension createExtension() {
+ return new ExtensionImpl();
+ }
+
+ public Endpoint createEndpoint() {
+ return new EndpointImpl(registry);
+ }
+
+ public EndpointReference createEndpointReference() {
+ return new EndpointReferenceImpl(registry);
+ }
+
+ public ConfiguredOperation createConfiguredOperation() {
+ return new ConfiguredOperationImpl();
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java
new file mode 100644
index 0000000000..516b11724f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.Base;
+
+/**
+ * Convenience base class for assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseImpl implements Base {
+ private boolean unresolved;
+
+ /**
+ * Constructs a new base model object.
+ */
+ protected BaseImpl() {
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java
new file mode 100644
index 0000000000..d912606f1d
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Base Binding implementation class
+ */
+public abstract class BindingImpl extends ExtensibleImpl implements Binding {
+ private String name;
+ private ExtensionType extensionType;
+ private String uri;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ protected QName type;
+
+ protected BindingImpl(QName type) {
+ super();
+ this.type = type;
+ }
+
+ public QName getType() {
+ return type;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ExtensionType getExtensionType() {
+ return extensionType;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.extensionType = type;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append(getType()).append(" (");
+ buf.append("uri=").append(getURI());
+ buf.append(",name=").append(getName());
+ buf.append(")");
+ return buf.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
new file mode 100644
index 0000000000..dec68d1413
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CallbackImpl extends ExtensibleImpl implements Callback {
+ private List<Binding> bindings = new ArrayList<Binding>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private Contract parentContract;
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ protected CallbackImpl() {
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ public ExtensionType getExtensionType() {
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ public Contract getParentContract() {
+ return parentContract;
+ }
+
+ public void setParentContract(Contract contract) {
+ this.parentContract = contract;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
new file mode 100644
index 0000000000..8a03df339c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentImpl extends ExtensibleImpl implements Component, Cloneable {
+ private Implementation implementation;
+ private String name;
+ private String uri;
+ private List<ComponentProperty> properties = new ArrayList<ComponentProperty>();
+ private List<ComponentReference> references = new ArrayList<ComponentReference>();
+ private List<ComponentService> services = new ArrayList<ComponentService>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private Boolean autowire;
+ private ExtensionType type;
+
+ /**
+ * Constructs a new component.
+ */
+ protected ComponentImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ComponentImpl clone = (ComponentImpl)super.clone();
+
+ clone.properties = new ArrayList<ComponentProperty>();
+ for (ComponentProperty property : getProperties()) {
+ clone.properties.add((ComponentProperty)property.clone());
+ }
+ clone.references = new ArrayList<ComponentReference>();
+ for (ComponentReference reference : getReferences()) {
+ clone.references.add((ComponentReference)reference.clone());
+ }
+ clone.services = new ArrayList<ComponentService>();
+ for (ComponentService service : getServices()) {
+ clone.services.add((ComponentService)service.clone());
+ }
+
+ // Clone the implementation.composite
+ if(implementation instanceof Composite) {
+ clone.implementation = (Composite) ((Composite) implementation).clone();
+ }
+
+ // Clone the Lists for intents and policySets
+ clone.requiredIntents = new ArrayList<Intent>(getRequiredIntents());
+ clone.policySets = new ArrayList<PolicySet>(getPolicySets());
+
+ return clone;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public Implementation getImplementation() {
+ return implementation;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List<ComponentProperty> getProperties() {
+ return properties;
+ }
+
+ public ComponentProperty getProperty(String name) {
+ for (ComponentProperty property : getProperties()) {
+ if (property.getName().equals(name)) {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ public List<ComponentReference> getReferences() {
+ return references;
+ }
+
+ public ComponentReference getReference(String name){
+ for (ComponentReference ref : getReferences()){
+ if (ref.getName().equals(name)){
+ return ref;
+ }
+ }
+ return null;
+ }
+
+ public List<ComponentService> getServices() {
+ return services;
+ }
+
+ public ComponentService getService(String name) {
+ for (ComponentService service : getServices()) {
+ if (service.getName().equals(name)) {
+ return service;
+ }
+ }
+ return null;
+ }
+
+ public void setImplementation(Implementation implementation) {
+ this.implementation = implementation;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public boolean isAutowire() {
+ return (autowire == null) ? false : autowire.booleanValue();
+ }
+
+ public void setAutowire(Boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public Boolean getAutowire() {
+ return autowire;
+ }
+
+ public ExtensionType getExtensionType() {
+ return type;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.type = type;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer("Component (");
+ buf.append("uri=").append(uri);
+ buf.append(",name=").append(name);
+ buf.append(",implementation=").append(implementation);
+ buf.append(")");
+ return buf.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java
new file mode 100644
index 0000000000..9db522930f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import javax.xml.xpath.XPathExpression;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+
+/**
+ * Represents a component property.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentPropertyImpl extends PropertyImpl implements ComponentProperty, Cloneable {
+ private String file;
+ private Property property;
+ private String source;
+ private XPathExpression sourceXPathExpression;
+
+ /**
+ * Constructs a new component property.
+ */
+ protected ComponentPropertyImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ // FIXME getValue should not delegate to property.getValue()
+ // Doing this violates the setValue/getValue semantics, as you
+ // can call setValue() then get a different value from getValue()
+ @Override
+ public Object getValue() {
+ if (super.getValue() == null && property != null) {
+ return property.getValue();
+ } else {
+ return super.getValue();
+ }
+ }
+
+ public String getFile() {
+ return file;
+ }
+
+ public Property getProperty() {
+ return property;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public void setFile(String file) {
+ this.file = file;
+ }
+
+ public void setProperty(Property property) {
+ this.property = property;
+ }
+
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public XPathExpression getSourceXPathExpression() {
+ return sourceXPathExpression;
+ }
+
+ public void setSourceXPathExpression(XPathExpression sourceXPathExpression) {
+ this.sourceXPathExpression = sourceXPathExpression;
+ }
+
+ public String toString() {
+ return "Property: " + getName() + " Value: " + getValue();
+ } // end method toString
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
new file mode 100644
index 0000000000..78b54668b3
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents a component reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentReferenceImpl extends ReferenceImpl implements ComponentReference, Cloneable {
+ private Reference reference;
+ private Boolean autowire;
+ private boolean nonOverridable;
+ private List<CompositeReference> promotedAs = new ArrayList<CompositeReference>();
+ private ComponentService callbackService;
+ private boolean isPromoted = false;
+
+ /**
+ * Constructs a new component reference.
+ */
+ protected ComponentReferenceImpl() {
+ // Set multiplicity to null so that by default it'll inherit from the Reference
+ setMultiplicity(null);
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public Reference getReference() {
+ return reference;
+ }
+
+ public void setReference(Reference reference) {
+ this.reference = reference;
+ }
+
+ public boolean isAutowire() {
+ return (autowire == null) ? false : autowire.booleanValue();
+ }
+
+ public void setAutowire(Boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public Boolean getAutowire() {
+ return autowire;
+ }
+
+ public List<CompositeReference> promotedAs() {
+ return promotedAs;
+ }
+
+ public ComponentService getCallbackService() {
+ return callbackService;
+ }
+
+ public void setCallbackService(ComponentService callbackService) {
+ this.callbackService = callbackService;
+ }
+
+ /**
+ * Use endpoint information to work out what the interface contract for the
+ * binding is.
+ */
+ @Override
+ public InterfaceContract getInterfaceContract(Binding binding) {
+ InterfaceContract interfaceContract = null;
+
+ if (interfaceContract == null) {
+ interfaceContract = getInterfaceContract();
+ }
+ return interfaceContract;
+ }
+
+ public boolean isNonOverridable() {
+ return nonOverridable;
+ }
+
+ public void setNonOverridable(boolean nonOverridable) {
+ this.nonOverridable = nonOverridable;
+ }
+
+ public void setPromoted(boolean isPromoted) {
+ this.isPromoted = isPromoted;
+ } // end method setPromoted
+
+ public boolean isPromoted() {
+ return isPromoted;
+ }
+} // end class ComponentReferenceImpl
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java
new file mode 100644
index 0000000000..f8c9f53413
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Service;
+
+/**
+ * Represents a component service
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentServiceImpl extends ServiceImpl implements ComponentService, Cloneable {
+ private Service service;
+ private List<CompositeService> promotedAs = new ArrayList<CompositeService>();
+ private ComponentReference callbackReference;
+
+ /**
+ * Constructs a new component service.
+ */
+ protected ComponentServiceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public Service getService() {
+ return service;
+ }
+
+ public void setService(Service service) {
+ this.service = service;
+ }
+
+ public List<CompositeService> promotedAs() {
+ return promotedAs;
+ }
+
+ public ComponentReference getCallbackReference() {
+ return callbackReference;
+ }
+
+ public void setCallbackReference(ComponentReference callbackReference) {
+ this.callbackReference = callbackReference;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
new file mode 100644
index 0000000000..b52c65ef8b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a component type.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType, Cloneable {
+ private String uri;
+ private List<Property> properties = new ArrayList<Property>();
+ private List<Reference> references = new ArrayList<Reference>();
+ private List<Service> services = new ArrayList<Service>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ /**
+ * Constructs a new component type.
+ */
+ protected ComponentTypeImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ComponentTypeImpl clone = (ComponentTypeImpl)super.clone();
+
+ clone.services = new ArrayList<Service>();
+ for (Service service : getServices()) {
+ clone.services.add((Service)service.clone());
+ }
+ clone.references = new ArrayList<Reference>();
+ for (Reference reference : getReferences()) {
+ clone.references.add((Reference)reference.clone());
+ }
+ clone.properties = new ArrayList<Property>();
+ for (Property property : getProperties()) {
+ clone.properties.add((Property)property.clone());
+ }
+ clone.requiredIntents = new ArrayList<Intent>(requiredIntents);
+ clone.policySets = new ArrayList<PolicySet>(policySets);
+ return clone;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ public Property getProperty(String name){
+ Property property = null;
+
+ for (Property tmp : getProperties()){
+ if (tmp.getName().equals(name)){
+ property = tmp;
+ break;
+ }
+ }
+
+ return property;
+ }
+
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ public Reference getReference(String name){
+ Reference reference = null;
+
+ for (Reference tmp : getReferences()){
+ if (tmp.getName().equals(name)){
+ reference = tmp;
+ break;
+ }
+ }
+
+ return reference;
+ }
+
+ public List<Service> getServices() {
+ return services;
+ }
+
+ public Service getService(String name){
+ Service service = null;
+
+ for (Service tmp : getServices()){
+ if (tmp.getName().equals(name)){
+ service = tmp;
+ break;
+ }
+ }
+
+ return service;
+ }
+
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public ExtensionType getExtensionType() {
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((uri == null) ? 0 : uri.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ComponentTypeImpl other = (ComponentTypeImpl)obj;
+ if (uri == null) {
+ if (other.uri != null) {
+ return false;
+ }
+ } else if (!uri.equals(other.uri)) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java
new file mode 100644
index 0000000000..fba6af7e7f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Wire;
+
+/**
+ * Implementation of a Composite.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeImpl extends ImplementationImpl implements Composite, Cloneable {
+ private String specVersion = "undefined";
+ private List<Component> components = new ArrayList<Component>();
+ private List<Composite> includes = new ArrayList<Composite>();
+ private QName name;
+ private List<Wire> wires = new ArrayList<Wire>();
+ private Boolean autowire;
+ private boolean local = true;
+
+ /**
+ * Constructs a new composite.
+ */
+ protected CompositeImpl() {
+ super(TYPE);
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ CompositeImpl clone = (CompositeImpl)super.clone();
+
+ // clone the child components
+ clone.components = new ArrayList<Component>();
+ for (Component component : getComponents()) {
+ Component clonedComponent = (Component)component.clone();
+ clone.components.add(clonedComponent);
+ }
+
+ // reset the references and services so the get re-resolved
+ for (Service service : clone.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ // Force the promoted component/service to be rebuilt against the clone
+ if (compositeService.getPromotedComponent() != null) {
+ compositeService.getPromotedComponent().setUnresolved(true);
+ }
+ if (compositeService.getPromotedService() != null) {
+ compositeService.getPromotedService().setUnresolved(true);
+ }
+ }
+ for (Reference reference : clone.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ for (ComponentReference ref : compositeReference.getPromotedReferences()) {
+ // Force the promoted reference to be rebuilt against the clone
+ ref.setUnresolved(true);
+ }
+ }
+
+ // clone the wires
+ clone.wires = new ArrayList<Wire>();
+ for (Wire wire : getWires()) {
+ clone.wires.add((Wire)wire.clone());
+ }
+
+ // Clone the includes
+ clone.includes = new ArrayList<Composite>();
+ for (Composite included : getIncludes()) {
+ clone.includes.add((Composite)included.clone());
+ }
+ return clone;
+ }
+
+ public String getSpecVersion() {
+ return specVersion;
+ }
+
+ public void setSpecVersion(String specVersion) {
+ this.specVersion = specVersion;
+ }
+
+ public List<Component> getComponents() {
+ return components;
+ }
+
+ public Component getComponent(String name) {
+ Component component = null;
+
+ for (Component tmp : getComponents()){
+ if (tmp.getName().equals(name)){
+ component = tmp;
+ break;
+ }
+ }
+ return component;
+ }
+
+ public List<Composite> getIncludes() {
+ return includes;
+ }
+
+ public QName getName() {
+ return name;
+ }
+
+ public List<Wire> getWires() {
+ return wires;
+ }
+
+ public boolean isLocal() {
+ return local;
+ }
+
+ public void setLocal(boolean local) {
+ this.local = local;
+ }
+
+ public boolean isAutowire() {
+ return (autowire == null) ? false : autowire.booleanValue();
+ }
+
+ public void setAutowire(Boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public Boolean getAutowire() {
+ return autowire;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(getName()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof Composite) {
+ if (getName() != null) {
+ return getName().equals(((Composite)obj).getName());
+ } else {
+ return ((Composite)obj).getName() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Composite (name=" + getName() + ")";
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java
new file mode 100644
index 0000000000..ae5fad461b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+
+/**
+ * Represents a composite reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeReferenceImpl extends ReferenceImpl implements CompositeReference, Cloneable {
+ private List<Component> promotedComponents = new ArrayList<Component>();
+ private List<ComponentReference> promotedReferences = new ArrayList<ComponentReference>();
+
+ /**
+ * Constructs a new composite reference.
+ */
+ protected CompositeReferenceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ CompositeReferenceImpl copy = (CompositeReferenceImpl)super.clone();
+ copy.promotedComponents = new ArrayList<Component>(promotedComponents);
+ copy.promotedReferences = new ArrayList<ComponentReference>(promotedReferences);
+ return copy;
+ }
+
+ public List<ComponentReference> getPromotedReferences() {
+ return promotedReferences;
+ }
+
+ public List<Component> getPromotedComponents() {
+ return promotedComponents;
+ }
+
+ public String toString() {
+ return getName();
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java
new file mode 100644
index 0000000000..55b48ec578
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeService;
+
+/**
+ * Represents a composite service
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeServiceImpl extends ServiceImpl implements CompositeService, Cloneable {
+ private ComponentService promotedService;
+ private Component promotedComponent;
+
+ /**
+ * Constructs a new composite service.
+ */
+ protected CompositeServiceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public ComponentService getPromotedService() {
+ return promotedService;
+ }
+
+ public void setPromotedService(ComponentService promotedService) {
+ this.promotedService = promotedService;
+ }
+
+ public Component getPromotedComponent() {
+ return promotedComponent;
+ }
+
+ public void setPromotedComponent(Component promotedComponent) {
+ this.promotedComponent = promotedComponent;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java
new file mode 100644
index 0000000000..80c1c7cd21
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents an Operation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConfiguredOperationImpl extends BaseImpl implements ConfiguredOperation {
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ private String name;
+ private String contractName;
+ private ExtensionType type;
+
+ /**
+ * Constructs a new Operation.
+ */
+ protected ConfiguredOperationImpl() {
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ public String getContractName() {
+ return contractName;
+ }
+
+ public void setContractName(String contractName) {
+ this.contractName = contractName;
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ public ExtensionType getExtensionType() {
+ return type;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.type = type;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java
new file mode 100644
index 0000000000..2b72f1f047
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AbstractContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Implementation of a Contract.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContractImpl extends ExtensibleImpl implements AbstractContract {
+ private InterfaceContract interfaceContract;
+ private String name;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ private boolean isCallback = false;
+
+ /**
+ * Constructs a new contract.
+ */
+ protected ContractImpl() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public InterfaceContract getInterfaceContract() {
+ return interfaceContract;
+ }
+
+ public void setInterfaceContract(InterfaceContract interfaceContract) {
+ this.interfaceContract = interfaceContract;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public boolean isForCallback() {
+ return isCallback;
+ }
+
+ public void setForCallback(boolean isCallback) {
+ this.isCallback = isCallback;
+ }
+
+ public ExtensionType getExtensionType() {
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
new file mode 100644
index 0000000000..e25bd4206b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
@@ -0,0 +1,283 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.ContractBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * The assembly model object for an endpoint.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EndpointImpl implements Endpoint {
+ private static final long serialVersionUID = 7344399683703812593L;
+
+ protected transient ExtensionPointRegistry registry;
+ protected transient BuilderExtensionPoint builders;
+ protected transient ContractBuilder contractBuilder;
+ protected boolean unresolved;
+ protected String uri;
+ protected Component component;
+ protected ComponentService service;
+ protected Binding binding;
+ protected InterfaceContract interfaceContract;
+ protected List<EndpointReference> callbackEndpointReferences = new ArrayList<EndpointReference>();
+ protected List<PolicySet> policySets = new ArrayList<PolicySet>();
+ protected List<Intent> requiredIntents = new ArrayList<Intent>();
+ protected boolean remote = false;
+
+ protected EndpointImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public Component getComponent() {
+ resolve();
+ return component;
+ }
+
+ public void setComponent(Component component) {
+ this.component = component;
+ reset();
+ }
+
+ public ComponentService getService() {
+ resolve();
+ return service;
+ }
+
+ public void setService(ComponentService service) {
+ this.service = service;
+ reset();
+ }
+
+ public Binding getBinding() {
+ resolve();
+ return binding;
+ }
+
+ public void setBinding(Binding binding) {
+ this.binding = binding;
+ reset();
+ }
+
+ public InterfaceContract getComponentServiceInterfaceContract() {
+ resolve();
+ if (interfaceContract == null && service != null) {
+ interfaceContract = service.getInterfaceContract();
+ }
+ return interfaceContract;
+ }
+
+ public void setInterfaceContract(InterfaceContract interfaceContract) {
+ this.interfaceContract = interfaceContract;
+ }
+
+ /**
+ * Get the services callbacl enpoint references that
+ * represent endpoint references from which callbacks
+ * originate
+ *
+ * @return callbackEndpoint the reference callback endpoint
+ */
+ public List<EndpointReference> getCallbackEndpointReferences() {
+ resolve();
+ return callbackEndpointReferences;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ resolve();
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ resolve();
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ getBinding();
+ if (binding instanceof PolicySubject) {
+ return ((PolicySubject)binding).getExtensionType();
+ }
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String toStringWithoutHash() {
+ String output = "Endpoint: ";
+
+ if (getURI() != null) {
+ output += " URI = " + getURI();
+ }
+
+ if (unresolved) {
+ output += " [Unresolved]";
+ }
+
+ return output;
+ }
+
+ public String toString() {
+ return "(@" + this.hashCode() + ")" + toStringWithoutHash();
+ }
+
+ public String getURI() {
+ if (uri == null) {
+ if (component != null && service != null && binding != null) {
+ String bindingName = binding.getName();
+ if (bindingName == null) {
+ bindingName = service.getName();
+ }
+ uri = component.getURI() + "#service-binding(" + service.getName() + "/" + bindingName + ")";
+ } else if (component != null && service != null) {
+ uri = component.getURI() + "#service(" + service.getName() + ")";
+ } else if (component != null) {
+ uri = component.getURI();
+ }
+ }
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ protected void resolve() {
+ }
+
+ protected void reset() {
+ this.uri = null;
+ }
+
+ protected void setExtensionPointRegistry(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public boolean isRemote() {
+ return remote;
+ }
+
+ public void setRemote(boolean remote) {
+ this.remote = remote;
+ }
+
+ public boolean matches(String serviceURI) {
+ String[] parts1 = parseServiceURI(serviceURI);
+ String[] parts2 = parseStructuralURI(getURI());
+ for (int i = 0; i < parts1.length; i++) {
+ if (parts1[i] == null || parts1[i].equals(parts2[i])) {
+ continue;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Parse the service URI into an array of names. The service URI is in one of the following formats:
+ * <ul>
+ * <li>componentName
+ * <li>componentName/serviceName
+ * <li>componentName/serviceName/bindingName
+ * </ul>
+ * @param serviceURI
+ * @return
+ */
+ private static String[] parseServiceURI(String serviceURI) {
+ if (serviceURI.startsWith("/")) {
+ serviceURI = serviceURI.substring(1);
+ }
+ if (serviceURI.contains("#")) {
+ return parseStructuralURI(serviceURI);
+ }
+ String[] names = new String[3];
+ String[] segments = serviceURI.split("/");
+ for (int i = 0; i < names.length && i < segments.length; i++) {
+ names[i] = segments[i];
+ }
+ return names;
+ }
+
+ /**
+ * Parse the structural URI into an array of parts (componentURI, serviceName, bindingName)
+ * @param structuralURI
+ * @return [0]: componentURI [1]: serviceName [2]: bindingName
+ */
+ private static String[] parseStructuralURI(String structuralURI) {
+ String[] names = new String[3];
+ int index = structuralURI.lastIndexOf('#');
+ if (index == -1) {
+ names[0] = structuralURI;
+ } else {
+ names[0] = structuralURI.substring(0, index);
+ String str = structuralURI.substring(index + 1);
+ if (str.startsWith("service-binding(") && str.endsWith(")")) {
+ str = str.substring("service-binding(".length(), str.length() - 1);
+ String[] parts = str.split("/");
+ if (parts.length != 2) {
+ throw new IllegalArgumentException("Invalid service-binding URI: " + structuralURI);
+ }
+ names[1] = parts[0];
+ names[2] = parts[1];
+ } else if (str.startsWith("service(") && str.endsWith(")")) {
+ str = str.substring("service(".length(), str.length() - 1);
+ // [rfeng] Deal with empty service name
+ if (!"".equals(str)) {
+ names[1] = str;
+ }
+ } else {
+ throw new IllegalArgumentException("Invalid structural URI: " + structuralURI);
+ }
+ }
+ return names;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java
new file mode 100644
index 0000000000..ac35b45678
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.ContractBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * The assembly model object for an endpoint.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EndpointReferenceImpl implements EndpointReference {
+ private static final long serialVersionUID = 8838066441709300972L;
+
+ protected transient ExtensionPointRegistry registry;
+ protected transient BuilderExtensionPoint builders;
+ protected transient ContractBuilder contractBuilder;
+ protected boolean unresolved = true;
+ protected String uri;
+ protected Component component;
+ protected ComponentReference reference;
+ protected Binding binding;
+ protected List<PolicySet> policySets = new ArrayList<PolicySet>();
+ protected List<Intent> requiredIntents = new ArrayList<Intent>();
+ protected InterfaceContract interfaceContract;
+ protected Status status = Status.NOT_CONFIGURED;
+
+ // the target of the endpoint reference
+ protected Endpoint targetEndpoint;
+
+ // callback endpoint that messages across this reference
+ // will be directed toward
+ protected Endpoint callbackEndpoint;
+
+ protected EndpointReferenceImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ EndpointReference cloned = (EndpointReference)super.clone();
+
+ if (targetEndpoint != null) {
+ cloned.setTargetEndpoint((Endpoint)targetEndpoint.clone());
+ }
+
+ return cloned;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public Component getComponent() {
+ resolve();
+ return component;
+ }
+
+ public void setComponent(Component component) {
+ this.component = component;
+ reset();
+ }
+
+ public ComponentReference getReference() {
+ resolve();
+ return reference;
+ }
+
+ public void setReference(ComponentReference reference) {
+ this.reference = reference;
+ reset();
+ }
+
+ public Binding getBinding() {
+ resolve();
+ return binding;
+ }
+
+ public void setBinding(Binding binding) {
+ this.binding = binding;
+ reset();
+ }
+
+ public Endpoint getTargetEndpoint() {
+ resolve();
+ return targetEndpoint;
+ }
+
+ public void setTargetEndpoint(Endpoint targetEndpoint) {
+ this.targetEndpoint = targetEndpoint;
+ reset();
+ }
+
+ public InterfaceContract getComponentReferenceInterfaceContract() {
+ resolve();
+ if (interfaceContract == null && reference != null) {
+ interfaceContract = reference.getInterfaceContract();
+ }
+ return interfaceContract;
+ }
+
+ public void setInterfaceContract(InterfaceContract interfaceContract) {
+ this.interfaceContract = interfaceContract;
+ reset();
+ }
+
+ public List<PolicySet> getPolicySets() {
+ resolve();
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ resolve();
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ getBinding();
+ if (binding instanceof PolicySubject) {
+ return ((PolicySubject)binding).getExtensionType();
+ }
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Endpoint getCallbackEndpoint() {
+ resolve();
+ return callbackEndpoint;
+ }
+
+ public void setCallbackEndpoint(Endpoint callbackEndpoint) {
+ this.callbackEndpoint = callbackEndpoint;
+ reset();
+ }
+
+ public String toStringWithoutHash() {
+ StringBuffer output = new StringBuffer("EndpointReference: ");
+
+ if (getURI() != null) {
+ output.append(" URI = ").append(getURI());
+ }
+
+ output.append(" ").append(status);
+
+ if (targetEndpoint != null) {
+ output.append(" Target = ").append(targetEndpoint);
+ }
+
+ return output.toString();
+ }
+
+ public String toString() {
+ return "(@" + this.hashCode() + ")" + toStringWithoutHash();
+ }
+
+ public String getURI() {
+ if (uri == null) {
+ if (component != null && reference != null && binding != null) {
+ String bindingName = binding.getName();
+ if (bindingName == null) {
+ bindingName = reference.getName();
+ }
+ uri = component.getURI() + "#reference-binding(" + reference.getName() + "/" + bindingName + ")";
+ } else if (component != null && reference != null) {
+ uri = component.getURI() + "#reference(" + reference.getName() + ")";
+ } else if (component != null) {
+ uri = component.getURI();
+ }
+ }
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ protected void resolve() {
+ }
+
+ protected void reset() {
+ this.uri = null;
+ }
+
+ public void setExtensionPointRegistry(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java
new file mode 100644
index 0000000000..340fa2854c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
+
+/**
+ * Convenience base class for extensible assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ExtensibleImpl extends BaseImpl implements Extensible {
+ private List<Object> extensions = new ArrayList<Object>();
+ private List<Extension> attributeExtensions = new ArrayList<Extension>();
+
+ /**
+ * Constructs a new base model object.
+ */
+ protected ExtensibleImpl() {
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public List<Extension> getAttributeExtensions() {
+ return attributeExtensions;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java
new file mode 100644
index 0000000000..e69eb4a771
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Extension;
+
+public class ExtensionImpl implements Extension {
+ private QName qName;
+ private Object value;
+ private boolean isAttribute = false;
+
+ public ExtensionImpl() {
+ }
+
+ public ExtensionImpl(QName qName, Object value, boolean isAttribute) {
+ this.qName = qName;
+ this.value = value;
+ this.isAttribute = isAttribute;
+ }
+
+ public QName getQName() {
+ return qName;
+ }
+
+ public void setQName(QName qName) {
+ this.qName = qName;
+ }
+
+ public <T> T getValue() {
+ return (T)value;
+ }
+
+ public <T> void setValue(T value) {
+ this.value = value;
+ }
+
+ public boolean isAttribute() {
+ return isAttribute;
+ }
+
+ public void setAttribute(boolean isAttribute) {
+ this.isAttribute = isAttribute;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
new file mode 100644
index 0000000000..677e86c759
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Base implementation class of Implementation model interface
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class ImplementationImpl extends ComponentTypeImpl implements Implementation, PolicySubject {
+ private QName type;
+ private ExtensionType extensionType;
+ private List<Operation> operations = new ArrayList<Operation>();
+
+ protected ImplementationImpl(QName type) {
+ super();
+ this.type = type;
+ }
+
+ public ExtensionType getExtensionType() {
+ return extensionType;
+ }
+
+ public void setExtensionType(ExtensionType extensionType) {
+ this.extensionType = extensionType;
+ }
+
+ public QName getType() {
+ return type;
+ }
+
+ public String toString() {
+ return String.valueOf(getType());
+ }
+
+ public List<Operation> getOperations() {
+ return operations;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ImplementationImpl impl = (ImplementationImpl)super.clone();
+ impl.operations = new ArrayList<Operation>();
+ for (Operation operation : operations) {
+ impl.operations.add((Operation)operation.clone());
+ }
+ return impl;
+ }
+
+ // Override the ComponentTypeImpl.hashCode()
+ @Override
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+
+ // Override the ComponentTypeImpl.equals()
+ @Override
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java
new file mode 100644
index 0000000000..263af296b1
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a property.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PropertyImpl extends AbstractPropertyImpl implements Property, Cloneable {
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ /**
+ * Constructs a new property.
+ */
+ protected PropertyImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
new file mode 100644
index 0000000000..69d76f238d
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents a reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceImpl extends AbstractReferenceImpl implements Reference, Cloneable {
+ private List<Binding> bindings = new ArrayList<Binding>();
+ private boolean wiredByImpl;
+ private List<ComponentService> targets = new ArrayList<ComponentService>();
+ private Callback callback;
+ private boolean overridingBindings;
+ private List<EndpointReference> endpointReferences = new ArrayList<EndpointReference>();
+
+ /**
+ * Constructs a new reference.
+ */
+ protected ReferenceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ReferenceImpl clone = (ReferenceImpl)super.clone();
+ clone.bindings = new ArrayList<Binding>(bindings);
+ clone.targets = new ArrayList<ComponentService>(targets);
+ // clone the endpoint references themselves and set the reference pointer back to
+ // this new refrence
+ clone.endpointReferences = new ArrayList<EndpointReference>();
+
+ for (EndpointReference epr : endpointReferences) {
+ EndpointReference eprClone = (EndpointReference)epr.clone();
+ eprClone.setReference((ComponentReference)clone);
+ clone.endpointReferences.add(eprClone);
+ }
+ return clone;
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ public <B> B getBinding(Class<B> bindingClass) {
+ for (Binding binding : bindings) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ return null;
+ }
+
+ public <B> B getCallbackBinding(Class<B> bindingClass) {
+ if (callback != null) {
+ for (Binding binding : callback.getBindings()) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean isWiredByImpl() {
+ return wiredByImpl;
+ }
+
+ public void setWiredByImpl(boolean wiredByImpl) {
+ this.wiredByImpl = wiredByImpl;
+ }
+
+ public List<ComponentService> getTargets() {
+ return targets;
+ }
+
+ public Callback getCallback() {
+ return callback;
+ }
+
+ public void setCallback(Callback callback) {
+ this.callback = callback;
+ }
+
+ /**
+ * By default return the interface contract for the reference
+ */
+ public InterfaceContract getInterfaceContract(Binding binding) {
+ return getInterfaceContract();
+ }
+
+ public List<EndpointReference> getEndpointReferences() {
+ return endpointReferences;
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ public boolean isOverridingBindings() {
+ return overridingBindings;
+ }
+
+ public void setOverridingBindings(boolean overridingBindings) {
+ this.overridingBindings = overridingBindings;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java
new file mode 100644
index 0000000000..84e5825b50
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+
+/**
+ * A factory for the SCA binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCABindingFactoryImpl implements SCABindingFactory {
+
+ public SCABindingFactoryImpl() {
+
+ }
+
+ public SCABinding createSCABinding() {
+ return new SCABindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java
new file mode 100644
index 0000000000..b42f3f929f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * The assembly mode object for an SCA binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCABindingImpl implements SCABinding, Extensible, PolicySubject {
+ private String name;
+ private String uri;
+ private List<Object> extensions = new ArrayList<Object>();
+ private List<Extension> attributeExtensions = new ArrayList<Extension>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private ExtensionType extensionType;
+
+ /**
+ * Constructs a new SCA binding.
+ */
+ protected SCABindingImpl() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Getters for the binding URI. The computed URI for the
+ * service that the reference is targeting or which the service represents
+ * depending on whether the biding is associated with a reference or
+ * service
+ *
+ * @return the binding URI
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public List<Extension> getAttributeExtensions() {
+ return attributeExtensions;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ return extensionType;
+ }
+
+ public void setExtensionType(ExtensionType intentAttachPointType) {
+ this.extensionType = intentAttachPointType;
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
new file mode 100644
index 0000000000..62523e5c17
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents a reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneable {
+ private List<Binding> bindings = new ArrayList<Binding>();
+ private boolean overridingBindings;
+ private Callback callback;
+ private List<Endpoint> endpoints = new ArrayList<Endpoint>();
+
+ /**
+ * Constructs a new service.
+ */
+ protected ServiceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ServiceImpl clone = (ServiceImpl)super.clone();
+ clone.bindings = new ArrayList<Binding>();
+ clone.bindings.addAll(getBindings());
+ return clone;
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ public <B> B getBinding(Class<B> bindingClass) {
+ for (Binding binding : bindings) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ return null;
+ }
+
+ public <B> B getCallbackBinding(Class<B> bindingClass) {
+ if (callback != null) {
+ for (Binding binding : callback.getBindings()) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ }
+ return null;
+ }
+
+ public Callback getCallback() {
+ return callback;
+ }
+
+ public void setCallback(Callback callback) {
+ this.callback = callback;
+ }
+
+ /**
+ * By default return the interface contract for the service
+ */
+ public InterfaceContract getInterfaceContract(Binding binding) {
+ return getInterfaceContract();
+ }
+
+ public List<Endpoint> getEndpoints() {
+ return endpoints;
+ }
+
+ public boolean isOverridingBindings() {
+ return overridingBindings;
+ }
+
+ public void setOverridingBindings(boolean overridingBindings) {
+ this.overridingBindings = overridingBindings;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java
new file mode 100644
index 0000000000..a4990f6a98
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Wire;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireImpl extends ExtensibleImpl implements Wire, Cloneable {
+ private ComponentReference source;
+ private ComponentService target;
+ private boolean replace;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ /**
+ * Constructs a new wire.
+ */
+ protected WireImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public ComponentReference getSource() {
+ return source;
+ }
+
+ public ComponentService getTarget() {
+ return target;
+ }
+
+ public void setSource(ComponentReference source) {
+ this.source = source;
+ }
+
+ public void setTarget(ComponentService target) {
+ this.target = target;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public ExtensionType getExtensionType() {
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ public boolean isReplace() {
+ return replace;
+ }
+
+ public void setReplace(boolean replace) {
+ this.replace = replace;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java
new file mode 100644
index 0000000000..156fd0af75
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.definitions;
+
+import org.apache.tuscany.sca.definitions.impl.DefinitionsImpl;
+
+/**
+ * Default Implementation of DefinitionsFactory
+ */
+public class DefaultDefinitionsFactory implements DefinitionsFactory {
+
+ public Definitions createDefinitions() {
+ return new DefinitionsImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java
new file mode 100644
index 0000000000..7a63bbedc5
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java
@@ -0,0 +1,84 @@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.definitions;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+
+/**
+ * Represents SCA Definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Definitions {
+ /**
+ * Returns the target namespace for this SCA Definition
+ * @return the target namespace
+ */
+ String getTargetNamespace();
+
+ /**
+ * Sets the target names for this SCA Definition.
+ *
+ * @param ns the target namespace for this SCA Definition
+ */
+ void setTargetNamespace(String ns);
+
+ /**
+ * Returns a list of domain wide Policy Intents
+ *
+ * @return a list of domain wide Policy Intents
+ */
+ List<Intent> getIntents();
+
+ /**
+ * Returns a list of domain wide PolicySets
+ *
+ * @return a list of domain wide PolicySets
+ */
+ List<PolicySet> getPolicySets();
+
+ /**
+ * Returns a list of domain wide Binding Types
+ *
+ * @return a list of domain wide Binding Types
+ */
+ List<BindingType> getBindingTypes();
+
+
+ /**
+ * Returns a list of domain wide Implementation Types
+ *
+ * @return a list of domain wide Implementation Types
+ */
+ List<ImplementationType> getImplementationTypes();
+
+ /**
+ * Returns a list of domain wide binding definition objects
+ *
+ * @return a list of domain wide binding definition objects
+ */
+ List<Binding> getBindings();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java
new file mode 100644
index 0000000000..5c68c6cbff
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.definitions;
+
+
+/**
+ * Interface to abstract building of SCA Definitions for a Domain
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DefinitionsBuilder {
+ /**
+ * Builds the SCA definitions
+ *
+ * @param scaDefns
+ */
+ void build(Definitions scaDefns) throws DefinitionsBuilderException;
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java
new file mode 100644
index 0000000000..f45be80888
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.definitions;
+
+/**
+ * Builder Exception
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsBuilderException extends Exception {
+ private static final long serialVersionUID = 2513219325230252783L;
+
+ public DefinitionsBuilderException() {
+ }
+
+ public DefinitionsBuilderException(String message) {
+ super(message);
+ }
+
+ public DefinitionsBuilderException(Throwable cause) {
+ super(cause);
+ }
+
+ public DefinitionsBuilderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java
new file mode 100644
index 0000000000..616616ae7a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.definitions;
+
+/**
+ * Factory interface to create SCA definitions model
+ *
+ */
+public interface DefinitionsFactory {
+ /**
+ * Create an instance of SCA definitions
+ * @return a new instance of SCA definitions
+ */
+ Definitions createDefinitions();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java
new file mode 100644
index 0000000000..d87d45b27a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java
@@ -0,0 +1,307 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.definitions.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.definitions.DefinitionsBuilder;
+import org.apache.tuscany.sca.definitions.DefinitionsBuilderException;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+/**
+ * Provides a concrete implementation for a SCADefinitionsBuilder
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsBuilderImpl implements DefinitionsBuilder {
+
+ public void build(Definitions scaDefns) throws DefinitionsBuilderException {
+ Map<QName, Intent> definedIntents = new HashMap<QName, Intent>();
+ for (Intent intent : scaDefns.getIntents()) {
+ definedIntents.put(intent.getName(), intent);
+ }
+
+ Map<QName, PolicySet> definedPolicySets = new HashMap<QName, PolicySet>();
+ for (PolicySet policySet : scaDefns.getPolicySets()) {
+ definedPolicySets.put(policySet.getName(), policySet);
+ }
+
+ Map<QName, BindingType> definedBindingTypes = new HashMap<QName, BindingType>();
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
+ definedBindingTypes.put(bindingType.getType(), bindingType);
+ }
+
+ Map<QName, ImplementationType> definedImplTypes = new HashMap<QName, ImplementationType>();
+ for (ImplementationType implType : scaDefns.getImplementationTypes()) {
+ definedImplTypes.put(implType.getType(), implType);
+ }
+
+ //filling up the maps removes all duplicate entries... so fill this unique lists
+ //into the scaDefns.
+ scaDefns.getIntents().clear();
+ scaDefns.getPolicySets().clear();
+ scaDefns.getBindingTypes().clear();
+ scaDefns.getImplementationTypes().clear();
+
+ scaDefns.getIntents().addAll(definedIntents.values());
+ scaDefns.getPolicySets().addAll(definedPolicySets.values());
+ scaDefns.getBindingTypes().addAll(definedBindingTypes.values());
+ scaDefns.getImplementationTypes().addAll(definedImplTypes.values());
+
+ buildPolicyIntents(scaDefns, definedIntents);
+ buildPolicySets(scaDefns, definedPolicySets, definedIntents);
+ buildBindingTypes(scaDefns, definedBindingTypes, definedIntents);
+ buildImplementationTypes(scaDefns, definedImplTypes, definedIntents);
+ }
+
+ private void buildBindingTypes(Definitions scaDefns,
+ Map<QName, BindingType> definedBindingTypes,
+ Map<QName, Intent> definedIntents) throws DefinitionsBuilderException {
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
+ buildAlwaysProvidedIntents(bindingType, definedIntents);
+ buildMayProvideIntents(bindingType, definedIntents);
+ }
+
+ }
+
+ private void buildImplementationTypes(Definitions scaDefns,
+ Map<QName, ImplementationType> definedImplTypes,
+ Map<QName, Intent> definedIntents) throws DefinitionsBuilderException {
+ for (ImplementationType implType : scaDefns.getImplementationTypes()) {
+ buildAlwaysProvidedIntents(implType, definedIntents);
+ buildMayProvideIntents(implType, definedIntents);
+ }
+ }
+
+ private void buildPolicyIntents(Definitions scaDefns, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ for (Intent policyIntent : scaDefns.getIntents()) {
+ if (!policyIntent.getRequiredIntents().isEmpty()) {
+ buildProfileIntent(policyIntent, definedIntents);
+ }
+
+ if (!policyIntent.getQualifiedIntents().isEmpty()) {
+ buildQualifiedIntent(policyIntent, definedIntents);
+ }
+ }
+ }
+
+ private void buildPolicySets(Definitions scaDefns,
+ Map<QName, PolicySet> definedPolicySets,
+ Map<QName, Intent> definedIntents) throws DefinitionsBuilderException {
+
+ for (PolicySet policySet : scaDefns.getPolicySets()) {
+ buildProvidedIntents(policySet, definedIntents);
+ buildIntentsInMappedPolicies(policySet, definedIntents);
+ buildReferredPolicySets(policySet, definedPolicySets);
+ }
+
+ for (PolicySet policySet : scaDefns.getPolicySets()) {
+ for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+ includeReferredPolicySets(policySet, referredPolicySet);
+ }
+ }
+ }
+
+ private void buildProfileIntent(Intent policyIntent, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ //FIXME: Need to check for cyclic references first i.e an A requiring B and then B requiring A...
+ if (policyIntent != null) {
+ //resolve all required intents
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
+ if (requiredIntent.isUnresolved()) {
+ Intent resolvedRequiredIntent = definedIntents.get(requiredIntent.getName());
+ if (resolvedRequiredIntent != null) {
+ requiredIntents.add(resolvedRequiredIntent);
+ } else {
+ throw new DefinitionsBuilderException("Required Intent - " + requiredIntent
+ + " not found for ProfileIntent "
+ + policyIntent);
+
+ }
+ } else {
+ requiredIntents.add(requiredIntent);
+ }
+ }
+ policyIntent.getRequiredIntents().clear();
+ policyIntent.getRequiredIntents().addAll(requiredIntents);
+ }
+ }
+
+ private void buildQualifiedIntent(Intent policyIntent, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ /*
+ if (policyIntent != null) {
+ //resolve the qualifiable intent
+ Intent qualifiableIntent = policyIntent.getQualifiableIntent();
+ if (qualifiableIntent.isUnresolved()) {
+ Intent resolvedQualifiableIntent = definedIntents.get(qualifiableIntent.getName());
+
+ if (resolvedQualifiableIntent != null) {
+ policyIntent.setQualifiableIntent(resolvedQualifiableIntent);
+ } else {
+ throw new DefinitionsBuilderException("Qualifiable Intent - " + qualifiableIntent
+ + " not found for QualifiedIntent "
+ + policyIntent);
+ }
+
+ }
+ }
+ */
+ }
+
+ private void buildAlwaysProvidedIntents(ExtensionType extensionType, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> alwaysProvided = new ArrayList<Intent>();
+ for (Intent providedIntent : extensionType.getAlwaysProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ Intent resolvedProvidedIntent = definedIntents.get(providedIntent.getName());
+ if (resolvedProvidedIntent != null) {
+ alwaysProvided.add(resolvedProvidedIntent);
+ } else {
+ throw new DefinitionsBuilderException("Always Provided Intent - " + providedIntent
+ + " not found for ExtensionType "
+ + extensionType);
+
+ }
+ } else {
+ alwaysProvided.add(providedIntent);
+ }
+ }
+ extensionType.getAlwaysProvidedIntents().clear();
+ extensionType.getAlwaysProvidedIntents().addAll(alwaysProvided);
+ }
+ }
+
+ private void buildMayProvideIntents(ExtensionType extensionType, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> mayProvide = new ArrayList<Intent>();
+ for (Intent providedIntent : extensionType.getMayProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ Intent resolvedProvidedIntent = definedIntents.get(providedIntent.getName());
+ if (resolvedProvidedIntent != null) {
+ mayProvide.add(resolvedProvidedIntent);
+ } else {
+ throw new DefinitionsBuilderException("May Provide Intent - " + providedIntent
+ + " not found for ExtensionType "
+ + extensionType);
+
+ }
+ } else {
+ mayProvide.add(providedIntent);
+ }
+ }
+ extensionType.getMayProvidedIntents().clear();
+ extensionType.getMayProvidedIntents().addAll(mayProvide);
+ }
+ }
+
+ private void buildProvidedIntents(PolicySet policySet, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ if (policySet != null) {
+ //resolve all provided intents
+ List<Intent> providedIntents = new ArrayList<Intent>();
+ for (Intent providedIntent : policySet.getProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ Intent resolvedProvidedIntent = definedIntents.get(providedIntent.getName());
+ if (resolvedProvidedIntent != null) {
+ providedIntents.add(resolvedProvidedIntent);
+ } else {
+ throw new DefinitionsBuilderException("Provided Intent - " + providedIntent
+ + " not found for PolicySet "
+ + policySet);
+
+ }
+ } else {
+ providedIntents.add(providedIntent);
+ }
+ }
+ policySet.getProvidedIntents().clear();
+ policySet.getProvidedIntents().addAll(providedIntents);
+ }
+ }
+
+ private void buildIntentsInMappedPolicies(PolicySet policySet, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ for (IntentMap intentMap : policySet.getIntentMaps()) {
+ for (Qualifier qualifier : intentMap.getQualifiers()) {
+ Intent mappedIntent = qualifier.getIntent();
+ if (mappedIntent.isUnresolved()) {
+ Intent resolvedMappedIntent = definedIntents.get(mappedIntent.getName());
+
+ if (resolvedMappedIntent != null) {
+ qualifier.setIntent(resolvedMappedIntent);
+ } else {
+ throw new DefinitionsBuilderException("Mapped Intent - " + mappedIntent
+ + " not found for PolicySet "
+ + policySet);
+
+ }
+ }
+ }
+ }
+ }
+
+ private void buildReferredPolicySets(PolicySet policySet, Map<QName, PolicySet> definedPolicySets)
+ throws DefinitionsBuilderException {
+
+ List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
+ for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+ if (referredPolicySet.isUnresolved()) {
+ PolicySet resolvedReferredPolicySet = definedPolicySets.get(referredPolicySet.getName());
+ if (resolvedReferredPolicySet != null) {
+ referredPolicySets.add(resolvedReferredPolicySet);
+ } else {
+ throw new DefinitionsBuilderException("Referred PolicySet - " + referredPolicySet
+ + "not found for PolicySet - "
+ + policySet);
+ }
+ } else {
+ referredPolicySets.add(referredPolicySet);
+ }
+ }
+ policySet.getReferencedPolicySets().clear();
+ policySet.getReferencedPolicySets().addAll(referredPolicySets);
+ }
+
+ private void includeReferredPolicySets(PolicySet policySet, PolicySet referredPolicySet) {
+ for (PolicySet furtherReferredPolicySet : referredPolicySet.getReferencedPolicySets()) {
+ includeReferredPolicySets(referredPolicySet, furtherReferredPolicySet);
+ }
+ policySet.getPolicies().addAll(referredPolicySet.getPolicies());
+ policySet.getIntentMaps().addAll(referredPolicySet.getIntentMaps());
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java
new file mode 100644
index 0000000000..224bc0a69a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.definitions.impl;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Provides a concrete implementation for SCADefinitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsImpl implements Definitions {
+ private String targetNamespace = null;
+ private List<Intent> intents = new CopyOnWriteArrayList<Intent>();
+ private List<PolicySet> policySets = new CopyOnWriteArrayList<PolicySet>();
+ private List<BindingType> bindingTypes = new CopyOnWriteArrayList<BindingType>();
+ private List<ImplementationType> implementationTypes = new CopyOnWriteArrayList<ImplementationType>();
+ private List<Binding> bindings = new CopyOnWriteArrayList<Binding>();
+
+
+ public List<BindingType> getBindingTypes() {
+ return bindingTypes;
+ }
+
+ public List<ImplementationType> getImplementationTypes() {
+ return implementationTypes;
+ }
+
+ public List<Intent> getIntents() {
+ return intents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public String getTargetNamespace() {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(String ns) {
+ this.targetNamespace = ns;
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java
new file mode 100644
index 0000000000..eb74677236
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.definitions.util;
+
+import static org.apache.tuscany.sca.assembly.builder.Messages.DEFINITIONS_VALIDATION;
+
+import java.util.HashSet;
+
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Some utility functions to deal with SCADefinitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsUtil {
+
+ /**
+ * Add the source set of definitions into the target set of definitions checking that
+ * definitions artifacts are unique in the process
+ *
+ * @param source the input definitions collection
+ * @param target the definition collection into which source will aggregated
+ */
+ public static void aggregate(Definitions source, Definitions target, Monitor monitor) {
+
+ HashSet<Intent> intents = new HashSet<Intent>(target.getIntents());
+ for(Intent intent : source.getIntents()){
+ if (intents.contains(intent)){
+ Monitor.error(monitor,
+ target,
+ DEFINITIONS_VALIDATION,
+ "DuplicateIntent",
+ intent.getName().toString());
+ } else {
+ target.getIntents().add(intent);
+ intents.add(intent);
+ }
+ }
+
+ HashSet<PolicySet> policySets = new HashSet<PolicySet>(target.getPolicySets());
+ for(PolicySet policySet : source.getPolicySets()){
+ if (policySets.contains(policySet)){
+ Monitor.error(monitor,
+ target,
+ DEFINITIONS_VALIDATION,
+ "DuplicatePolicySet",
+ policySet.getName().toString());
+ } else {
+ target.getPolicySets().add(policySet);
+ policySets.add(policySet);
+ }
+ }
+
+ HashSet<BindingType> bindingTypes = new HashSet<BindingType>(target.getBindingTypes());
+ for(BindingType bindingType : source.getBindingTypes()){
+ if (bindingTypes.contains(bindingType)){
+ Monitor.error(monitor,
+ target,
+ DEFINITIONS_VALIDATION,
+ "DuplicateBindingType",
+ bindingType.getType().toString());
+ } else {
+ target.getBindingTypes().add(bindingType);
+ bindingTypes.add(bindingType);
+ }
+ }
+
+ HashSet<ImplementationType> implementationTypes = new HashSet<ImplementationType>(target.getImplementationTypes());
+ for(ImplementationType implementationType : source.getImplementationTypes()){
+ if (implementationTypes.contains(implementationType)){
+ Monitor.error(monitor,
+ target,
+ DEFINITIONS_VALIDATION,
+ "DuplicateImplementationType",
+ implementationType.getType().toString());
+ } else {
+ target.getImplementationTypes().add(implementationType);
+ implementationTypes.add(implementationType);
+ }
+ }
+
+ target.getBindings().addAll(source.getBindings());
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Compatibility.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Compatibility.java
new file mode 100644
index 0000000000..e05a05476a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Compatibility.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+/**
+ * Types of compatibility
+ */
+public enum Compatibility {
+ SUPERSET, // The source is a superset of the target
+ SUBSET, // The source is a subset of the target
+ MUTUAL, // The source is the same set as the target
+ INCOMPATIBLE // The source is not compatible with the target
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java
new file mode 100644
index 0000000000..386275b41b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+import java.lang.reflect.Type;
+
+/**
+ * Representation of the type of data associated with an operation. Data is
+ * represented in two forms: the physical form used by the runtime and a logical
+ * form used by the assembly. The physical form is a Java Type because the
+ * runtime is written in Java. This may be the same form used by the application
+ * but it may not; for example, an application that is performing stream
+ * processing may want a physical form such as an
+ * {@link java.io.InputStream InputStream} to semantically operate on application
+ * data such as a purchase order. The logical description is that used by the
+ * assembly model and is an identifier into some well-known type space; examples
+ * may be a Java type represented by its Class or an XML type represented by its
+ * QName. Every data type may also contain metadata describing the expected
+ * data; for example, it could specify a preferred data binding technology or
+ * the size of a typical instance.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface DataType<L> extends Cloneable {
+ /**
+ * Set the java type for the data
+ * @param cls
+ */
+ void setPhysical(Class<?> cls);
+
+ /**
+ * Returns the physical type used by the runtime.
+ *
+ * @return the physical type used by the runtime
+ */
+ Class<?> getPhysical();
+
+ /**
+ * Get the java generic type
+ * @return The java generic type
+ */
+ Type getGenericType();
+
+ /**
+ * Set the java generic type
+ * @param genericType
+ */
+ void setGenericType(Type genericType);
+
+ /**
+ * Returns the logical identifier used by the assembly. The type of this
+ * value identifies the logical type system in use. Known values are:
+ * <ul>
+ * <li>a Class identifies a Java type by name and
+ * ClassLoader; this includes Java Classes as they are specializations of
+ * Type</li>
+ * <li>a XMLType identifies an XML type by local name and
+ * namespace</li>
+ * </ul>
+ *
+ * @return the logical type name
+ */
+ L getLogical();
+
+ /**
+ * Get the databinding for the given data type
+ * @return the databinding
+ */
+ String getDataBinding();
+
+ /**
+ * Set the databinding for the given data type
+ * @param dataBinding the dataBinding to set
+ */
+ void setDataBinding(String dataBinding);
+
+ /**
+ * Clone a data type
+ * @return The cloned data type
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * Set the logical type of the data type
+ * @param logical the logical to set
+ */
+ void setLogical(L logical);
+
+ /**
+ * Get the databinding-specific metadata
+ * @param type The java type of the metadata
+ * @return the databinding-specific metadata
+ */
+ <T> T getMetaData(Class<T> type);
+ /**
+ * Set the databinding-specific metadata
+ * @param type The java type of the metadata
+ * @param metaData the databinding-specific metadata, such as SDO's commonj.sdo.Type or
+ * JAXB's javax.xml.bind.JAXBContext
+ */
+ <T> void setMetaData(Class<T> type, T metaData);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java
new file mode 100644
index 0000000000..4aa5f2780a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef;
+
+/**
+ * This interface represents the mapping between WSDL faults and Java exceptions
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+@SuppressWarnings("unchecked")
+public interface FaultExceptionMapper {
+ /**
+ * Introspect an exception class to find out the fault data type following the WSDL2Java
+ * mapping rules. The result will be populated into the logical type of the exception data
+ * type
+ *
+ * @param exceptionDataType The data type representing a java exception class
+ * @param operation TODO
+ * @param generatingFaultBean If JAXWS Section 3.7 Fault Bean will be generated
+ * @return true if the introspection can recognize the exception data type
+ */
+ boolean introspectFaultDataType(DataType<DataType> exceptionDataType, Operation operation, boolean generatingFaultBean);
+
+ /**
+ * Create a java exception to wrap the fault data
+ *
+ * @param exceptionType The DataType for the exception
+ * @param message message for the exception
+ * @param faultInfo The fault data
+ * @param cause of the exception
+ * @param operation TODO
+ * @return An instance of java exception to represent the fault
+ */
+ Throwable wrapFaultInfo(DataType<DataType> exceptionType, String message, Object faultInfo, Throwable cause, Operation operation);
+
+ /**
+ * Retrieve the fault info from a java exception
+ *
+ * @param exception The java exception that represents the fault data
+ * @param faultBeanClass
+ * @param operation TODO
+ * @return The fault data
+ */
+ Object getFaultInfo(Throwable exception, Class<?> faultBeanClass, Operation operation);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java
new file mode 100644
index 0000000000..179dc1755e
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef;
+
+/**
+ * Denotes incompatible service contracts for a wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class IncompatibleInterfaceContractException extends Exception {
+ private static final long serialVersionUID = 5127478601823295587L;
+ private final InterfaceContract source;
+ private final InterfaceContract target;
+ private final Operation sourceOperation;
+ private final Operation targetOperation;
+
+ public IncompatibleInterfaceContractException(String message, InterfaceContract source, InterfaceContract target) {
+ super(message);
+ this.source = source;
+ this.target = target;
+ this.sourceOperation = null;
+ this.targetOperation = null;
+ }
+
+ public IncompatibleInterfaceContractException(String message,
+ InterfaceContract source,
+ InterfaceContract target,
+ Operation sourceOperation,
+ Operation targetOperation) {
+ super(message);
+ this.source = source;
+ this.target = target;
+ this.sourceOperation = sourceOperation;
+ this.targetOperation = targetOperation;
+ }
+
+ public InterfaceContract getTarget() {
+ return target;
+ }
+
+ public InterfaceContract getSource() {
+ return source;
+ }
+
+ public Operation getSourceOperation() {
+ return sourceOperation;
+ }
+
+ public Operation getTargetOperation() {
+ return targetOperation;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java
new file mode 100644
index 0000000000..e3103b768a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a service interface. This interface will typically be extended to
+ * support concrete interface type systems, such as Java interfaces, WSDL 1.1
+ * portTypes and WSDL 2.0 interfaces.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Interface extends Cloneable, PolicySubject {
+
+ /**
+ * Returns true if the interface is a remotable interface..
+ *
+ * @return true if the interface is a remotable interface
+ */
+ boolean isRemotable();
+
+ /**
+ * Sets whether the interface is a remotable or local interface.
+ *
+ * @param remotable indicates whether the interface is remotable or local
+ */
+ void setRemotable(boolean remotable);
+
+ /**
+ * Returns true if the interface remotable property is set..
+ *
+ * This is used to verify if a @remotable attribute is used in the
+ * <interface.java> SCDL element. If true, use isRemotable to verify the
+ * current value
+ *
+ * @return
+ */
+ boolean isRemotableSet();
+
+ /**
+ * Returns the operations defined on this interface.
+ *
+ * @return the operations defined on this interface
+ */
+ List<Operation> getOperations();
+
+ /**
+ * Set the databinding for the interface
+ * @param dataBinding
+ * @deprecated Please use resetDataBinding
+ */
+ @Deprecated
+ void setDefaultDataBinding(String dataBinding);
+
+ /**
+ * Reset the databinding for the interface
+ * @param dataBinding
+ */
+ void resetDataBinding(String dataBinding);
+
+ /**
+ * Set the interface input types by copying those from the
+ * interface provided
+ *
+ * @param newInterface
+ */
+ public void resetInterfaceInputTypes(Interface newInterface);
+
+ /**
+ * Set the interface output types by copying those from the
+ * interface provided
+ *
+ * @param newInterface
+ */
+ public void resetInterfaceOutputTypes(Interface newInterface);
+
+ /**
+ * Returns true if the Interface is dynamic.
+ *
+ * @return true if the Interface is dynamic.
+ */
+ boolean isDynamic();
+
+ /**
+ * Get a map of attributes associated with the interface
+ * @return A map of attributes
+ */
+ Map<Object, Object> getAttributes();
+
+ /**
+ * Implementations must support cloning.
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java
new file mode 100644
index 0000000000..3eda9f37e5
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+
+/**
+ * Interface contracts define one or more business functions. These business
+ * functions are provided by services and are used by references.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface InterfaceContract extends Cloneable {
+
+ /**
+ * Returns the interface definition representing the interface for
+ * invocations from the requestor to the provider.
+ *
+ * @return the interface definition representing the interface for
+ * invocations from the requestor to the provider
+ */
+ Interface getInterface();
+
+ /**
+ * Sets the interface definition representing the interface for invocations
+ * from the requestor to the provider.
+ *
+ * @param callInterface the interface definition representing the interface
+ * for invocations from the requestor to the provider
+ */
+ void setInterface(Interface callInterface);
+
+ /**
+ * Returns the interface definition representing the interface for
+ * invocations from the provider to the requestor.
+ *
+ * @return the interface definition representing the interface for
+ * invocations from the provider to the requestor.
+ */
+ Interface getCallbackInterface();
+
+ /**
+ * Sets the interface definition representing the interface for invocations
+ * from the provider to the requestor.
+ *
+ * @param callbackInterface the interface definition representing the
+ * interface for invocations from the provider to the requestor.
+ */
+ void setCallbackInterface(Interface callbackInterface);
+
+ // FIXME: We need a better way to do this
+ /**
+ * Convert an interface contract to a unidirectional interface contract
+ *
+ * @param isCallback true for a callback interface contract, false for
+ * a forward interface contract
+ * @return A unidirectional interface contract, cloned if necessary
+ */
+ InterfaceContract makeUnidirectional(boolean isCallback);
+
+ /**
+ * Implementations must support cloning.
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * For matching purposes the Java interface contract is
+ * turned into a WSDL contract in the cases where it needs to be matched
+ * against another WSDL contract
+ *
+ * @return WSDL interface contract
+ */
+ InterfaceContract getNormalizedWSDLContract();
+
+ /**
+ * For matching purposes the Java interface contract is
+ * turned into a WSDL contract in the cases where it needs to be matched
+ * against another WSDL contract
+ *
+ * @param wsdlInterfaceContract
+ */
+ void setNormailizedWSDLContract(InterfaceContract wsdlInterfaceContract);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java
new file mode 100644
index 0000000000..930d4e22e5
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef;
+
+/**
+ * The InterfaceContractMapper is responsible to match interfaces
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface InterfaceContractMapper {
+ /**
+ * @param source The source interface contract
+ * @param target The target interface contract
+ * @param compatibility The compatibility style
+ * @param ignoreCallback
+ * @param silent
+ * @return
+ * @throws IncompatibleInterfaceContractException
+ */
+ boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target,
+ Compatibility compatibility,
+ boolean ignoreCallback,
+ boolean silent) throws IncompatibleInterfaceContractException;
+
+ /**
+ * @param source The source interface contract
+ * @param target The target interface contract
+ * @param compatibility The compatibility style
+ * @param ignoreCallback
+ * @param silent
+ * @return
+ * @throws IncompatibleInterfaceContractException
+ * this interface is intended to incrementally replace the variant without the audit trail
+ * the presence of both interfaces implies a state of partial development
+ */
+ boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target,
+ Compatibility compatibility,
+ boolean ignoreCallback,
+ boolean silent,
+ StringBuffer audit) throws IncompatibleInterfaceContractException;
+
+ /**
+ * Test if the source data type is compatible with the target data type. The
+ * compatibility is defined as follows.
+ * <ul>
+ * <li>source's logical type is either the same or subtype of the target's
+ * logical type
+ * </ul>
+ * For example, if the source type is a SDO Customer and the target type is
+ * a JAXB Customer and both Customer are generated from the same XSD type.
+ *
+ * @param source The source data type
+ * @param target The target data type
+ * @param passByValue A flag to indicate how the compatibility is checked
+ * <ul>
+ * <li>true: Check the two types as compatible "by-value" (can be copied)
+ * <li>false: Check the two types as compatible "by-reference" (can be assigned)
+ * </ul>
+ * @return true if the source data type is the same or subtype of the target data type
+ */
+ boolean isCompatible(DataType<?> source, DataType<?> target, boolean passByValue);
+
+ /**
+ * Check if source operation is compatible with the target operation. A source operation is
+ * compatible with the target operation means the following:
+ *
+ * <ol>
+ * <li>compatibility for the two operations is defined as compatibility
+ * of the signature, i.e., the operation name, the input types, and the output types are the same
+ *
+ * <li>the order of the input and output types of the source operation is the same as the order of
+ * the input and output types for the corresponding target operation
+ * <li>the set of Faults and Exceptions expected by the source operation is the same as or is
+ * a SUPERSET of the set of Faults and Exceptions specified by the corresponding target operation
+ * </ol>
+ *
+ * Simply speaking, any request from the source operation can be processed by the target operation and
+ * the normal response or fault/exception from the target operation can be handled by the source operation.
+ *
+ * Please note this compatibility check is NOT symmetric. But the following should be guaranteed:
+ * <ul>
+ * <li>(source, target, SUB) == (target, source, SUPER)
+ * <li>(source, target, MUTUAL) == (source, target, SUB) && (target, source, SUB) == (source, target, SUPER) && (source, target, SUPER)
+ *
+ * @param source The source operation
+ * @param target The target operation
+ * @param compatibilityType The type of compatibility
+ * @return true if the source operation is compatible with the target
+ * operation
+ */
+ boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType);
+
+ boolean isCompatibleByReference(Operation source, Operation target, Compatibility compatibilityType);
+ boolean isCompatibleByValue(Operation source, Operation target, Compatibility compatibilityType);
+
+ /**
+ * An interface A is a Compatible Subset of a second interface B if and only if all of points 1 through 6
+ * in the following list apply:
+ * <ol>
+ * <li>interfaces A and B are either both remotable or else both local
+ * <li>the set of operations in interface A is the same as or is a subset of the set of operations in
+ * interface B
+ * <li>compatibility for individual operations of the interfaces A and B is defined as compatibility
+ * of the signature, i.e., the operation name, the input types, and the output types are the same
+ * <li>the order of the input and output types for each operation in interface A is the same as the
+ * order of the input and output types for the corresponding operation in interface B
+ * <li>the set of Faults and Exceptions expected by each operation in interface A is the same as or is
+ * a superset of the set of Faults and Exceptions specified by the corresponding operation in interface B
+ * <li>for checking the compatibility of 2 remotable interfaces which are in different interface
+ * languages, both are mapped to WSDL 1.1 (if not already WSDL 1.1) and compatibility checking is done
+ * between the WSDL 1.1 mapped interfaces.<br>
+ * For checking the compatibility of 2 local interfaces which are in different interface languages, the
+ * method of checking compatibility is defined by the specifications which define those interface types,
+ * which must define mapping rules for the 2 interface types concerned.
+ *
+ * </ol>
+ *
+ * <b>The callback interfaces are not considered her.</b>
+ *
+ * @param source The source interface
+ * @param target The target interface
+ * @return true if the source interface is a compatible subset of the target interface
+ */
+ boolean isCompatibleSubset(Interface source, Interface target);
+
+ /**
+ * An interface A is a Compatible Subset of a second interface B if and only if all of points 1 through 7
+ * in the following list apply:
+ * <ol>
+ * <li>interfaces A and B are either both remotable or else both local
+ * <li>the set of operations in interface A is the same as or is a subset of the set of operations in
+ * interface B
+ * <li>compatibility for individual operations of the interfaces A and B is defined as compatibility
+ * of the signature, i.e., the operation name, the input types, and the output types are the same
+ * <li>the order of the input and output types for each operation in interface A is the same as the
+ * order of the input and output types for the corresponding operation in interface B
+ * <li>the set of Faults and Exceptions expected by each operation in interface A is the same as or is
+ * a superset of the set of Faults and Exceptions specified by the corresponding operation in interface B
+ * <li>for checking the compatibility of 2 remotable interfaces which are in different interface
+ * languages, both are mapped to WSDL 1.1 (if not already WSDL 1.1) and compatibility checking is done
+ * between the WSDL 1.1 mapped interfaces.<br>
+ * For checking the compatibility of 2 local interfaces which are in different interface languages, the
+ * method of checking compatibility is defined by the specifications which define those interface types,
+ * which must define mapping rules for the 2 interface types concerned.
+ * <li>if either interface A or interface B declares a callback interface then both interface
+ * A and interface B declare callback interfaces and the callback interface declared on interface B is a
+ * compatible subset of the callback interface declared on interface A, according to points 1 through 6
+ * above
+ * </ol>
+ *
+ * @param source The source interface contract
+ * @param target The target interface contract
+ * @return true if the source interface contract is a compatible subset of the target interface contract
+ */
+ boolean isCompatibleSubset(InterfaceContract source, InterfaceContract target);
+ /*
+ * the variant of isCompatibleSubset with the audit parameter is intended to supersed the other
+ * -- the presence of both indicates a partial development state
+ */
+ boolean isCompatibleSubset(InterfaceContract source, InterfaceContract target, StringBuffer audit);
+
+ /**
+ * Check that two interfaces are mutually compatible. The interfaces are mutually compatible if the two
+ * interfaces have the same set of operations, with each operation having the same signature (name, input
+ * types, output types and fault/exception types).
+ *
+ * @param source an interface
+ * @param target a second interface
+ * @return true if the two interfaces are mutually compatible, otherwise return false
+ */
+ public boolean isMutuallyCompatible(Interface source, Interface target);
+
+ /**
+ * An interface A is Compatible with a second interface B if and only if all of points 1 through 7 in the
+ * following list apply:<p>
+ * <ol>
+ * <li>interfaces A and B are either both remotable or else both local
+ * <li>the set of operations in interface A is the same as the set of operations in interface B
+ * <li>compatibility for individual operations of the interfaces A and B is defined as compatibility
+ * of the signature, i.e., the operation name, the input types, and the output types are the same
+ * <li>the order of the input and output types for each operation in interface A is the same as the
+ * order of the input and output types for the corresponding operation in interface B
+ * <li>the set of Faults and Exceptions expected by each operation in interface A is the
+ * same as the set of Faults and Exceptions specified by the corresponding operation in interface B
+ * <li>for checking the compatibility of 2 remotable interfaces which are in different interface
+ * languages, both are mapped to WSDL 1.1 (if not already WSDL 1.1) and compatibility checking is done
+ * between the WSDL 1.1 mapped interfaces.
+ * <br>For checking the compatibility of 2 local interfaces which are in different interface languages,
+ * the method of checking compatibility is defined by the specifications which define those interface types,
+ * which must define mapping rules for the 2 interface types concerned.
+ * <li>if either interface A or interface B declares a callback interface then both interface
+ * A and interface B declare callback interfaces and the callback interface declared on interface A is
+ * compatible with the callback interface declared on interface B, according to points 1 through 6 above
+ *
+ * @param source - the source interface contract
+ * @param target - the target interface contract
+ * @return true if the source and target interface contracts are mutually compatible
+ */
+ boolean isMutuallyCompatible(InterfaceContract source, InterfaceContract target);
+
+ /**
+ * Map the source operation to a compatible operation in the target interface
+ *
+ * @param target The target interface
+ * @param source The source operation
+ * @return A compatible operation if the target interface is compatible superset of the source interface
+ */
+ Operation map(Interface target, Operation source);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java
new file mode 100644
index 0000000000..db1d5f7fd7
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef;
+
+/**
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+public class InvalidAnnotationException extends InvalidInterfaceException {
+
+ private static final long serialVersionUID = 4923028138353415223L;
+ private final Class<?> clazz;
+
+ public InvalidAnnotationException(String message, Class<?> clazz) {
+ super(message);
+ this.clazz = clazz;
+ }
+
+ public Class<?> getAnnotation() {
+ return clazz;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java
new file mode 100644
index 0000000000..392e81a8fa
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+
+/**
+ * Denotes an illegal callback interface
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+
+public class InvalidCallbackException extends InvalidInterfaceException {
+ private static final long serialVersionUID = 2727755895702116397L;
+
+ public InvalidCallbackException(String message) {
+ super(message);
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java
new file mode 100644
index 0000000000..0cac606e1a
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class InvalidInterfaceException extends Exception {
+ private static final long serialVersionUID = -3850574026273544538L;
+
+ public InvalidInterfaceException() {
+ super();
+ }
+
+ public InvalidInterfaceException(String message) {
+ super(message);
+ }
+
+ public InvalidInterfaceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidInterfaceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java
new file mode 100644
index 0000000000..2e82c201d9
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+import java.lang.reflect.Method;
+
+/**
+ * Denotes an invalid conversational interface definition
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class InvalidOperationException extends InvalidInterfaceException {
+
+ private static final long serialVersionUID = -1797615361821517091L;
+ private final Method operation;
+
+ public InvalidOperationException(String message, Method operation) {
+ super(message);
+ this.operation = operation;
+ }
+
+ public Method getOperation() {
+ return operation;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
new file mode 100644
index 0000000000..c71225c9e2
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents an operation on a service interface.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Operation extends Cloneable, PolicySubject {
+ /**
+ * Returns the name of the operation.
+ *
+ * @return the name of the operation
+ */
+ String getName();
+
+ /**
+ * Sets the name of the operation.
+ *
+ * @param name the name of the operation
+ */
+ void setName(String name);
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+ /**
+ * Get the data type that represents the input of this operation. The logic
+ * type is a list of data types and each element represents a parameter
+ *
+ * @return the inputType
+ */
+ DataType<List<DataType>> getInputType();
+
+ /**
+ * @param inputType
+ */
+ void setInputType(DataType<List<DataType>> inputType);
+
+ /**
+ * Get the data type for the output
+ *
+ * @return the outputType
+ */
+ DataType getOutputType();
+
+ /**
+ * @param outputType
+ */
+ void setOutputType(DataType outputType);
+
+ /**
+ * Get a list of data types to represent the faults/exceptions
+ *
+ * @return the faultTypes
+ */
+ List<DataType> getFaultTypes();
+
+ /**
+ * @param faultTypes
+ */
+ void setFaultTypes(List<DataType> faultTypes);
+
+ /**
+ * Get the owning interface
+ * @return
+ */
+ Interface getInterface();
+
+ /**
+ * Set the owning interface
+ * @param interfaze
+ */
+ void setInterface(Interface interfaze);
+
+ /**
+ * Indicate if the operation is non-blocking
+ * @return
+ */
+ boolean isNonBlocking();
+
+ /**
+ * Indicate if the operation is an async server operation
+ * @return - true if the operation is an async server operation
+ */
+ boolean isAsyncServer();
+
+ /**
+ * Set the operation to be non-blocking
+ */
+ void setNonBlocking(boolean nonBlocking);
+
+ /**
+ * @return the wrapperInfo
+ */
+ WrapperInfo getWrapper();
+
+ /**
+ * @param wrapperInfo the wrapperInfo to set
+ */
+ void setWrapper(WrapperInfo wrapperInfo);
+
+ /**
+ * @return the wrapperStyle
+ */
+ boolean isWrapperStyle();
+
+ /**
+ * @param wrapperStyle the wrapperStyle to set
+ */
+ void setWrapperStyle(boolean wrapperStyle);
+
+ /**
+ * @deprecated This should be the WrapperInfo.getDataBinding()
+ * Get the databinding for the operation
+ * @return
+ */
+ @Deprecated
+ String getDataBinding();
+
+ /**
+ * @deprecated This should be the WrapperInfo.setDataBinding()
+ * Set the databinding for the operation
+ * @param dataBinding
+ */
+ @Deprecated
+ void setDataBinding(String dataBinding);
+
+ /**
+ * Returns true if the operation is dynamic.
+ *
+ * @return true if the operation is dynamic otherwise false
+ */
+ boolean isDynamic();
+
+ /**
+ * Set if the operation is dynamic
+ * @param b
+ */
+ void setDynamic(boolean b);
+
+ /**
+ * Get the synthesized fault beans for this operation
+ *
+ * @return the fault beans
+ */
+ Map<QName, List<DataType<XMLType>>> getFaultBeans();
+
+ /**
+ * Set the synthesized fault beans for this operation
+ * @param faultBeans
+ */
+ void setFaultBeans(Map<QName, List<DataType<XMLType>>> faultBeans);
+
+ /**
+ * Get a map of attributes assoicated with the operation
+ * @return A map of attributes
+ */
+ Map<Object, Object> getAttributes();
+
+ /**
+ * Implementations must support cloning.
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java
new file mode 100644
index 0000000000..92ac0850e7
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+import java.lang.reflect.Method;
+
+/**
+ * Exception thrown to indicate that a service contract specification contains
+ * an overloaded method.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class OverloadedOperationException extends InvalidInterfaceException {
+ private static final long serialVersionUID = -4658711318608885638L;
+ private final Method operation;
+
+ public OverloadedOperationException(Method operation) {
+ super(operation == null ?
+ null : "[JCA20001] Cannot overload operation " + operation.getName()
+ + " on " + operation.getDeclaringClass().getName()
+ + " as it is a @Remotable interface");
+ this.operation = operation;
+ }
+
+ public Method getOperation() {
+ return operation;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java
new file mode 100644
index 0000000000..12ea22938c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef.impl;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * Representation of the type of data associated with an operation. Data is
+ * represented in two forms: the physical form used by the runtime and a logical
+ * form used by the assembly. The physical form is a Java Type because the
+ * runtime is written in Java. This may be the same form used by the application
+ * but it may not; for example, an application that is performing stream
+ * processing may want a physical form such as an
+ * {@link java.io.InputStream InputStream} to semantically operate on application
+ * data such as a purchase order. The logical description is that used by the
+ * assembly model and is an identifier into some well-known type space; examples
+ * may be a Java type represented by its Class or an XML type represented by its
+ * QName. Every data type may also contain metadata describing the expected
+ * data; for example, it could specify a preferred data binding technology or
+ * the size of a typical instance.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class DataTypeImpl<L> implements DataType<L> {
+ private String dataBinding;
+ private Class<?> physical;
+ private Type genericType;
+ private L logical;
+ private Map<Class<?>, Object> metaDataMap;
+
+ /**
+ * Construct a data type specifying the physical and logical types.
+ *
+ * @param physical the physical class used by the runtime
+ * @param logical the logical type
+ * @see #getLogical()
+ */
+ public DataTypeImpl(Class<?> physical, L logical) {
+ this(null, physical, physical, logical);
+ }
+
+ /**
+ * @param dataBinding
+ * @param physical
+ * @param logical
+ */
+ public DataTypeImpl(String dataBinding, Class<?> physical, L logical) {
+ this(dataBinding, physical, physical, logical);
+ }
+
+ /**
+ * @param dataBinding
+ * @param physical
+ * @param genericType
+ * @param logical
+ */
+ public DataTypeImpl(String dataBinding, Class<?> physical, Type genericType, L logical) {
+ super();
+ this.dataBinding = dataBinding;
+ this.physical = physical;
+ this.genericType = genericType;
+ this.logical = logical;
+ }
+
+ /**
+ * Returns the physical type used by the runtime.
+ *
+ * @return the physical type used by the runtime
+ */
+ public Class<?> getPhysical() {
+ return physical;
+ }
+
+ /**
+ * @param physical the physical to set
+ */
+ public void setPhysical(Class<?> physical) {
+ this.physical = physical;
+ }
+
+ /**
+ * Get the java generic type
+ * @return The java generic type
+ */
+ public Type getGenericType() {
+ return genericType;
+ }
+
+ /**
+ * Set the java generic type
+ * @param genericType
+ */
+ public void setGenericType(Type genericType) {
+ this.genericType = genericType;
+ }
+
+ /**
+ * Returns the logical identifier used by the assembly. The type of this
+ * value identifies the logical type system in use. Known values are:
+ * <ul>
+ * <li>a java.lang.reflect.Type identifies a Java type by name and
+ * ClassLoader; this includes Java Classes as they are specializations of
+ * Type</li>
+ * <li>a javax.xml.namespace.QName identifies an XML type by local name and
+ * namespace</li>
+ * </ul>
+ *
+ * @return the logical type name
+ */
+ public L getLogical() {
+ return logical;
+ }
+
+ /**
+ * @param logical the logical to set
+ */
+ public void setLogical(L logical) {
+ this.logical = logical;
+ }
+
+ public String getDataBinding() {
+ return dataBinding;
+ }
+
+ /**
+ * @param dataBinding the dataBinding to set
+ */
+ public void setDataBinding(String dataBinding) {
+ this.dataBinding = dataBinding;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(physical).append(" ").append(dataBinding).append(" ").append(logical);
+ return sb.toString();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ DataTypeImpl copy = (DataTypeImpl)super.clone();
+ return copy;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((dataBinding == null) ? 0 : dataBinding.hashCode());
+ result = prime * result + ((genericType == null) ? 0 : genericType.hashCode());
+ result = prime * result + ((logical == null) ? 0 : logical.hashCode());
+ result = prime * result + ((physical == null) ? 0 : physical.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final DataTypeImpl other = (DataTypeImpl)obj;
+ if (dataBinding == null) {
+ if (other.dataBinding != null)
+ return false;
+ } else if (!dataBinding.equals(other.dataBinding))
+ return false;
+ if (genericType == null) {
+ if (other.genericType != null)
+ return false;
+ } else if (!genericType.equals(other.genericType))
+ return false;
+ if (logical == null) {
+ if (other.logical != null)
+ return false;
+ } else if (!logical.equals(other.logical))
+ return false;
+ if (physical == null) {
+ if (other.physical != null)
+ return false;
+ } else if (!physical.equals(other.physical))
+ return false;
+ return true;
+ }
+
+ public <T> T getMetaData(Class<T> type) {
+ return metaDataMap == null ? null : type.cast(metaDataMap.get(type));
+ }
+
+ public <T> void setMetaData(Class<T> type, T metaData) {
+ if (metaDataMap == null) {
+ metaDataMap = new ConcurrentHashMap<Class<?>, Object>();
+ }
+ metaDataMap.put(type, metaData);
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java
new file mode 100644
index 0000000000..4fad64ac89
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.impl;
+
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents an interface contract. InterfaceContractImpl
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class InterfaceContractImpl implements InterfaceContract {
+ private Interface callInterface;
+ private Interface callbackInterface;
+
+ public Interface getCallbackInterface() {
+ return callbackInterface;
+ }
+
+ public Interface getInterface() {
+ return callInterface;
+ }
+
+ public void setCallbackInterface(Interface callbackInterface) {
+ this.callbackInterface = callbackInterface;
+ }
+
+ public void setInterface(Interface callInterface) {
+ this.callInterface = callInterface;
+ }
+
+ public InterfaceContract makeUnidirectional(boolean isCallback) {
+ if (!isCallback && callbackInterface == null)
+ return this; // already a unidirectional forward interface contract
+
+ if (isCallback && callInterface == null)
+ return this; // already a unidirectional callback interface contract
+
+ // contract is bidirectional, so create a new unidirectional contract
+ try {
+ InterfaceContract newContract = clone();
+ if (!isCallback) {
+ newContract.setCallbackInterface(null); // create unidirectional forward interface contract
+ } else {
+ newContract.setInterface(null); // create unidirectional callback interface contract
+ }
+ return newContract;
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ return null;
+ }
+ }
+
+ @Override
+ public InterfaceContractImpl clone() throws CloneNotSupportedException {
+ InterfaceContractImpl copy = (InterfaceContractImpl)super.clone();
+ if (this.callbackInterface != null) {
+ copy.callbackInterface = (Interface)this.callbackInterface.clone();
+ }
+ if (this.callInterface != null) {
+ copy.callInterface = (Interface)this.callInterface.clone();
+ }
+ return copy;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((callInterface == null) ? 0 : callInterface.hashCode());
+ result = prime * result + ((callbackInterface == null) ? 0 : callbackInterface.hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final InterfaceContractImpl other = (InterfaceContractImpl)obj;
+ if (callInterface == null) {
+ if (other.callInterface != null) {
+ return false;
+ }
+ } else if (!callInterface.equals(other.callInterface)) {
+ return false;
+ }
+ if (callbackInterface == null) {
+ if (other.callbackInterface != null) {
+ return false;
+ }
+ } else if (!callbackInterface.equals(other.callbackInterface)) {
+ return false;
+ }
+ return true;
+ }
+
+ // By default there is no normailized contract
+ // as only Java needs it
+ public InterfaceContract getNormalizedWSDLContract() {
+ return null;
+ }
+
+ // By default there is no normailized contract
+ // as only Java needs it
+ public void setNormailizedWSDLContract(
+ InterfaceContract wsdlInterfaceContract) {
+ // do nothing
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
new file mode 100644
index 0000000000..8efec798e2
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
@@ -0,0 +1,619 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.impl;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.ContractBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InterfaceContractMapperImpl implements InterfaceContractMapper {
+
+ protected ExtensionPointRegistry registry;
+ protected BuilderExtensionPoint builders;
+ protected ContractBuilder contractBuilder;
+
+ public InterfaceContractMapperImpl(ExtensionPointRegistry registry){
+ this.registry = registry;
+ this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ }
+
+ public boolean isCompatible(DataType source, DataType target, boolean passByValue) {
+ return isCompatible(source, target, passByValue, null);
+ }
+
+ public boolean isCompatible(DataType source, DataType target, boolean passByValue, StringBuffer audit) {
+ if (source == target) {
+ return true;
+ }
+ if (!passByValue) {
+ if (source == null || target == null) {
+ if (audit != null){
+ audit.append("One of either the source or target data types is null for");
+ }
+ return false;
+ }
+ // For local case
+ return target.getPhysical().isAssignableFrom(source.getPhysical());
+ } else {
+ // For remote interfaces where the target is represented with WSDL
+ // the source will have been converted to WSDL so we rely on JAXB mappings
+ // being the same in both cases and just compare the type names directly.
+ // TODO - is this right?
+ XMLType sourceLogicalType = null;
+
+ // There is some nesting of data types (when GeneratedDataType is used) so
+ // dig a bit deeper to find the real data type
+ if (source.getLogical() instanceof DataType<?>){
+ sourceLogicalType = (XMLType)((DataType<?>)source.getLogical()).getLogical();
+ } else {
+ sourceLogicalType = (XMLType)source.getLogical();
+ }
+
+ XMLType targetLogicalType = null;
+
+ if (target.getLogical() instanceof DataType<?>){
+ targetLogicalType = (XMLType)((DataType<?>)target.getLogical()).getLogical();
+ } else {
+ targetLogicalType = (XMLType)target.getLogical();
+ }
+
+ // The logical type seems to be null in some cases, e.g. when the
+ // argument or return type is something like a Map.
+ // TODO - check when some type give rise to a null logical type
+ if (sourceLogicalType.getTypeName() == null ||
+ targetLogicalType.getTypeName() == null) {
+ return true;
+ }
+
+ boolean match = sourceLogicalType.getTypeName().equals(targetLogicalType.getTypeName());
+
+ if (!match){
+
+ QName anyType = new QName("http://www.w3.org/2001/XMLSchema", "anyType");
+ if (sourceLogicalType.getTypeName().equals(anyType) ||
+ targetLogicalType.getTypeName().equals(anyType)){
+ // special case where a Java interface uses a generic type, e.g.
+ // public OMElement getGreetings(OMElement om)
+ // while the provided WSDL uses a specific type. So we assume
+ // that xsd:anyType matched anything
+ match = true;
+ } else {
+ if (audit != null){
+ audit.append("Operation argument types source = " +
+ sourceLogicalType.getTypeName() +
+ " target = " +
+ targetLogicalType.getTypeName() +
+ " don't match for");
+ }
+ }
+ }
+
+ return match;
+ }
+
+ }
+
+ /**
+ * Check that two interface contracts are equal. The contracts are equal if the two contracts have the
+ * same set of operations, with each operation having the same signature, both for forward and callback
+ * interfaces
+ * @param source
+ * @param target
+ * @return
+ */
+ public boolean isMutuallyCompatible(InterfaceContract source, InterfaceContract target) {
+ ExtensionType ext = source.getInterface().getExtensionType();
+ InterfaceContract sourceContract = null;
+
+ // Are the forward interfaces equal?
+ if (isMutuallyCompatible(source.getInterface(), target.getInterface())) {
+ // Is there a Callback interface?
+ if (source.getCallbackInterface() == null && target.getCallbackInterface() == null) {
+ return true;
+ } else {
+ if (isMutuallyCompatible(source.getCallbackInterface(), target.getCallbackInterface())) {
+ return true;
+ } // end if
+ } // end if
+ } // end if
+ return false;
+ } // end method isEqual
+
+ /**
+ * Check that two interfaces are equal. The interfaces are equal if the two interfaces have the
+ * same set of operations, with each operation having the same signature.
+ * @param source
+ * @param target
+ * @return
+ */
+ public boolean isMutuallyCompatible(Interface source, Interface target) {
+ if (source == target) {
+ // Shortcut for performance
+ return true;
+ } // end if
+ if (source == null || target == null) {
+ return false;
+ } // end if
+
+ if (source.isDynamic() || target.isDynamic()) {
+ return true;
+ }
+
+ if (source.isRemotable() != target.isRemotable()) {
+ return false;
+ }
+ if (source.getOperations().size() != target.getOperations().size()) {
+ return false;
+ }
+
+ for (Operation operation : source.getOperations()) {
+ Operation targetOperation = getOperation(target.getOperations(), operation.getName());
+ if (targetOperation == null) {
+ return false;
+ }
+ if (!isCompatible(operation, targetOperation, Compatibility.SUBSET)) {
+ return false;
+ }
+ }
+ return true;
+ } // end method isEqual
+
+ public boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType) {
+ return isCompatible(source, target, compatibilityType, true);
+ }
+
+ public boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType, boolean byValue) {
+ return isCompatible(source, target, compatibilityType, true, null);
+ }
+
+ public boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType, boolean byValue, StringBuffer audit) {
+ if (source == target) {
+ return true;
+ }
+
+ if (source.isDynamic() || target.isDynamic()) {
+ return true;
+ }
+
+ // Check name
+ if (!source.getName().equals(target.getName())) {
+ if (audit != null){
+ audit.append("operation names are not the same source = " +
+ source.getName() +
+ " target = " +
+ target.getName());
+ }
+ return false;
+ }
+
+ if (source.getInterface().isRemotable() != target.getInterface().isRemotable()) {
+ if (audit != null){
+ audit.append("Interfaces have different remote settings source = " +
+ source.getName() +
+ " target = " +
+ target.getName());
+ }
+ return false;
+ }
+
+ boolean passByValue = (source.getInterface().isRemotable()) && byValue;
+
+ // if (source.getInterface().isRemotable()) {
+ // return true;
+ // }
+
+ // FIXME: We need to deal with wrapped<-->unwrapped conversion
+
+ // Check output type
+ DataType<?> sourceOutputType = source.getOutputType();
+ DataType<?> targetOutputType = target.getOutputType();
+
+ boolean checkSourceWrapper = true;
+ List<DataType> sourceInputType = source.getInputType().getLogical();
+ if (source.isWrapperStyle() && source.getWrapper() != null) {
+ sourceInputType = source.getWrapper().getUnwrappedInputType().getLogical();
+ sourceOutputType = source.getWrapper().getUnwrappedOutputType();
+ checkSourceWrapper = false;
+ }
+ boolean checkTargetWrapper = true;
+ List<DataType> targetInputType = target.getInputType().getLogical();
+ if (target.isWrapperStyle() && target.getWrapper() != null) {
+ targetInputType = target.getWrapper().getUnwrappedInputType().getLogical();
+ targetOutputType = target.getWrapper().getUnwrappedOutputType();
+ checkTargetWrapper = false;
+ }
+
+/* TODO - Why are we assuming compatibility if one side is wrapped and the other is not?
+ if (checkSourceWrapper != checkTargetWrapper) {
+ return true;
+ }
+*/
+
+ if (!isCompatible(targetOutputType, sourceOutputType, passByValue, audit)) {
+ if (audit != null){
+ audit.append(" output types");
+ }
+ return false;
+ }
+
+ if (sourceInputType.size() != targetInputType.size()) {
+ if (audit != null){
+ audit.append("different number of input types");
+ }
+ return false;
+ }
+
+ int size = sourceInputType.size();
+ for (int i = 0; i < size; i++) {
+ if (!isCompatible(sourceInputType.get(i), targetInputType.get(i), passByValue, audit)) {
+ if (audit != null){
+ audit.append(" input types");
+ }
+ return false;
+ }
+ }
+
+ // Check fault types
+ for (DataType targetFaultType : target.getFaultTypes()) {
+ // Source fault types must be the same or superset of target fault
+ // types
+ boolean found = true;
+ for (DataType sourceFaultType : source.getFaultTypes()) {
+ found = false;
+ if (isCompatible(targetFaultType, sourceFaultType, passByValue, audit)) {
+ // Target fault type can be covered by the source fault type
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ if (audit != null){
+ audit.append("Fault types incompatible");
+ }
+ return false;
+ }
+ }
+
+ return true;
+ }
+ public boolean isCompatibleByReference(Operation source, Operation target, Compatibility compatibilityType) {
+ return isCompatible(source, target, compatibilityType, false);
+ }
+
+ public boolean isCompatibleByValue(Operation source, Operation target, Compatibility compatibilityType) {
+ return isCompatible(source, target, compatibilityType, true);
+ }
+
+ // FIXME: How to improve the performance for the lookup
+ private Operation getOperation(List<Operation> operations, String name) {
+ for (Operation op : operations) {
+ if (op.getName().equals(name)) {
+ return op;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.tuscany.sca.interfacedef.InterfaceContractMapper#checkCompatibility(org.apache.tuscany.sca.interfacedef.InterfaceContract, org.apache.tuscany.sca.interfacedef.InterfaceContract, org.apache.tuscany.sca.interfacedef.Compatibility, boolean, boolean, java.lang.StringBuffer)
+ * this variant of the checkCompatibility method is intended to supersede the one without an audit argument
+ * Presence of both method variants indicates a state of partial development
+ */
+ public boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target, Compatibility compatibility,
+ boolean ignoreCallback, boolean silent, StringBuffer audit)
+ throws IncompatibleInterfaceContractException {
+
+ if (source == target) {
+ // Shortcut for performance
+ return true;
+ }
+
+ if (source == null || target == null) {
+ return false;
+ }
+
+ if (source.getInterface() == target.getInterface()) {
+ return ignoreCallback
+ || isCallbackCompatible(source, target, silent);
+ }
+
+ if (source.getInterface() == null || target.getInterface() == null) {
+ return false;
+ }
+
+ if (source.getInterface().isDynamic()
+ || target.getInterface().isDynamic()) {
+ return ignoreCallback
+ || isCallbackCompatible(source, target, silent);
+ }
+
+ if (source.getInterface().isRemotable() != target.getInterface()
+ .isRemotable()) {
+ if (!silent) {
+ audit.append("Remotable settings do not match: "+ source + "," + target); // TODO see if serialization is sufficient
+ throw new IncompatibleInterfaceContractException(
+ "Remotable settings do not match", source, target);
+ } else {
+ return false;
+ }
+ }
+
+ for (Operation operation : source.getInterface().getOperations()) {
+ Operation targetOperation = map(target.getInterface(), operation);
+ if (targetOperation == null) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException(
+ "Operation " + operation.getName()
+ + " not found on target", source, target);
+ } else {
+ return false;
+ }
+ }
+
+ if (!silent) {
+ if (audit == null)
+ audit = new StringBuffer();
+ if (!isCompatible(operation, targetOperation,
+ Compatibility.SUBSET, true, audit)) {
+ throw new IncompatibleInterfaceContractException(
+ "Operations called " + operation.getName()
+ + " are not compatible " + audit, source,
+ target);
+ }
+ } else {
+ if (!isCompatible(operation, targetOperation,
+ Compatibility.SUBSET)) {
+ return false;
+ }
+ }
+ }
+
+ return ignoreCallback || isCallbackCompatible(source, target, silent);
+ }
+
+ public boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target,
+ Compatibility compatibility,
+ boolean ignoreCallback,
+ boolean silent) throws IncompatibleInterfaceContractException {
+
+ if (source == target) {
+ // Shortcut for performance
+ return true;
+ }
+
+ if (source == null || target == null) {
+ return false;
+ }
+
+ if (source.getInterface() == target.getInterface()) {
+ return ignoreCallback || isCallbackCompatible(source, target, silent);
+ }
+
+ if (source.getInterface() == null || target.getInterface() == null) {
+ return false;
+ }
+
+ if (source.getInterface().isDynamic() || target.getInterface().isDynamic()) {
+ return ignoreCallback || isCallbackCompatible(source, target, silent);
+ }
+
+ if (source.getInterface().isRemotable() != target.getInterface().isRemotable()) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Remotable settings do not match", source, target);
+ } else {
+ return false;
+ }
+ }
+
+ for (Operation operation : source.getInterface().getOperations()) {
+ Operation targetOperation = map(target.getInterface(), operation);
+ if (targetOperation == null) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Operation " +
+ operation.getName() +
+ " not found on target",
+ source,
+ target);
+ } else {
+ return false;
+ }
+ }
+
+ if (!silent) {
+ StringBuffer audit = new StringBuffer();
+ if (!isCompatible(operation, targetOperation, Compatibility.SUBSET, true, audit)){
+ throw new IncompatibleInterfaceContractException("Operations called " +
+ operation.getName() +
+ " are not compatible " +
+ audit,
+ source,
+ target);
+ }
+ } else {
+ if (!isCompatible(operation, targetOperation, Compatibility.SUBSET)) {
+ return false;
+ }
+ }
+ }
+
+ return ignoreCallback || isCallbackCompatible(source, target, silent);
+ }
+
+
+
+ protected boolean isCallbackCompatible(InterfaceContract source, InterfaceContract target, boolean silent)
+ throws IncompatibleInterfaceContractException {
+ if (source.getCallbackInterface() == null && target.getCallbackInterface() == null) {
+ return true;
+ }
+ if (source.getCallbackInterface() == null || target.getCallbackInterface() == null) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Callback interface doesn't match as one of the callback interfaces is null", source, target);
+ } else {
+ return false;
+ }
+ }
+
+ for (Operation operation : source.getCallbackInterface().getOperations()) {
+ Operation targetOperation =
+ getOperation(target.getCallbackInterface().getOperations(), operation.getName());
+ if (targetOperation == null) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Callback operation not found on target", source,
+ target, null, targetOperation);
+ } else {
+ return false;
+ }
+ }
+ if (!source.getCallbackInterface().isRemotable()) {
+ // FIXME: for remotable operation, only compare name for now
+ if (!operation.equals(targetOperation)) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Target callback operation is not compatible",
+ source, target, operation, targetOperation);
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public boolean isCompatibleSubset(Interface source, Interface target) {
+ if (source == target) {
+ // Shortcut for performance
+ return true;
+ }
+ if (source == null || target == null) {
+ return false;
+ }
+
+ if (source.isDynamic() || target.isDynamic()) {
+ return true;
+ }
+
+ if (source.isRemotable() != target.isRemotable()) {
+ return false;
+ }
+
+ for (Operation operation : source.getOperations()) {
+ Operation targetOperation = getOperation(target.getOperations(), operation.getName());
+ if (targetOperation == null) {
+ return false;
+ }
+ if (!isCompatible(operation, targetOperation, Compatibility.SUBSET)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /*
+ * the variant of isCompatibleSubset with the audit parameter is intended to supersede the other
+ * -- the presence of both indicates a partial development state
+ */
+ public boolean isCompatibleSubset(InterfaceContract source, InterfaceContract target, StringBuffer audit) {
+
+ try {
+ return checkCompatibility(source, target, Compatibility.SUBSET, false, false, audit);
+ } catch (IncompatibleInterfaceContractException e) {
+ return false;
+ }
+ }
+
+ public boolean isCompatibleSubset(InterfaceContract source, InterfaceContract target) {
+
+ try {
+ return checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ } catch (IncompatibleInterfaceContractException e) {
+ return false;
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.InterfaceContractMapper#map(org.apache.tuscany.sca.interfacedef.Interface,
+ * org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ public Operation map(Interface target, Operation source) {
+ // TODO: How to handle the case that source operation is dynamic?
+ if (target == null || target.isDynamic()) {
+ return source;
+ } else if (target.isRemotable()) {
+ for (Operation op : target.getOperations()) {
+ if (op.getName().equals(source.getName())) {
+ return op;
+ }
+ }
+ return null;
+ } else {
+ for (Operation op : target.getOperations()) {
+ if (isCompatible(source, op, Compatibility.SUBSET)) {
+ return op;
+ }
+ }
+ return null;
+ }
+ }
+
+ /**
+ * In various places in the process of an SCA application we match one interface against
+ * another. Sometimes the two interfaces can be presented using different IDLs, for example
+ * Java and WSDL. In this case interfaces are converted so that they are both WSDL1.1 interfaces
+ * and they are then compared. The generated WSDL is cached on the interface object for
+ * any subsequent matching
+ *
+ * @param interfaceA
+ * @param interfaceB
+ */
+/*
+ public void normalizeContractsForComparison(InterfaceContract interfaceA, InterfaceContract interfaceB){
+ // normalize interfaces
+ if (interfaceA.getInterface().getClass() != interfaceB.getInterface().getClass()) {
+ this.contractBuilder = builders.getContractBuilder();
+ if (interfaceA.getInterface() instanceof Interface){
+ contractBuilder.build(interfaceA, null);
+ } else {
+ contractBuilder.build(interfaceB, null);
+ }
+ }
+ }
+*/
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
new file mode 100644
index 0000000000..c56b5545ce
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a service interface.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public class InterfaceImpl implements Interface {
+
+ private Boolean remotable;
+ private boolean conversational;
+ private OperationList operations = new OperationList();
+ private boolean unresolved;
+
+ private ExtensionType type;
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private Map<Object, Object> attributes = new ConcurrentHashMap<Object, Object>();
+
+ public boolean isRemotable() {
+ boolean value = false;
+ if (remotable != null && remotable.booleanValue()) {
+ value = true;
+ }
+ return value;
+ }
+
+ public void setRemotable(boolean remotable) {
+ this.remotable = Boolean.valueOf(remotable);
+ }
+
+ public boolean isRemotableSet() {
+ return remotable == null ? false : true;
+ }
+
+ public List<Operation> getOperations() {
+ return operations;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ /**
+ * @return the conversational
+ */
+ public boolean isConversational() {
+ return conversational;
+ }
+
+ /**
+ * @param conversational the conversational to set
+ */
+ public void setConversational(boolean conversational) {
+ this.conversational = conversational;
+ }
+
+ private class OperationList extends ArrayList<Operation> {
+ private static final long serialVersionUID = -903469106307606099L;
+
+ @Override
+ public Operation set(int index, Operation element) {
+ element.setInterface(InterfaceImpl.this);
+ return super.set(index, element);
+ }
+
+ @Override
+ public void add(int index, Operation element) {
+ element.setInterface(InterfaceImpl.this);
+ super.add(index, element);
+ }
+
+ @Override
+ public boolean add(Operation o) {
+ o.setInterface(InterfaceImpl.this);
+ return super.add(o);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Operation> c) {
+ for (Operation op : c) {
+ op.setInterface(InterfaceImpl.this);
+ }
+ return super.addAll(c);
+ }
+
+ @Override
+ public boolean addAll(int index, Collection<? extends Operation> c) {
+ for (Operation op : c) {
+ op.setInterface(InterfaceImpl.this);
+ }
+ return super.addAll(index, c);
+ }
+
+ }
+
+ @Deprecated
+ public void setDefaultDataBinding(String dataBinding) {
+ for (Operation op : getOperations()) {
+ if (op.getDataBinding() == null) {
+ op.setDataBinding(dataBinding);
+ DataType<List<DataType>> inputType = op.getInputType();
+ if (inputType != null) {
+ for (DataType d : inputType.getLogical()) {
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBinding);
+ }
+ }
+ }
+ DataType outputType = op.getOutputType();
+ if (outputType != null && outputType.getDataBinding() == null) {
+ outputType.setDataBinding(dataBinding);
+ }
+ List<DataType> faultTypes = op.getFaultTypes();
+ if (faultTypes != null) {
+ for (DataType d : faultTypes) {
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBinding);
+ }
+ DataType ft = (DataType) d.getLogical();
+ if (ft.getDataBinding() == null) {
+ ft.setDataBinding(dataBinding);
+ }
+
+ }
+ }
+ if (op.isWrapperStyle()) {
+ WrapperInfo wrapper = op.getWrapper();
+ if (wrapper != null) {
+ DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType();
+ if (unwrappedInputType != null) {
+ for (DataType d : unwrappedInputType.getLogical()) {
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBinding);
+ }
+ }
+ }
+ DataType unwrappedOutputType = wrapper.getUnwrappedOutputType();
+ if (unwrappedOutputType != null && unwrappedOutputType.getDataBinding() == null) {
+ unwrappedOutputType.setDataBinding(dataBinding);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void setDataBinding(DataType dataType, String dataBinding) {
+ if ("java:array".equals(dataType.getDataBinding())) {
+ setDataBinding((DataType)dataType.getLogical(), dataBinding);
+ } else {
+ dataType.setDataBinding(dataBinding);
+ }
+ }
+
+ public void resetDataBinding(String dataBinding) {
+ for (Operation op : getOperations()) {
+ op.setDataBinding(dataBinding);
+ DataType<List<DataType>> inputType = op.getInputType();
+ if (inputType != null) {
+ for (DataType d : inputType.getLogical()) {
+ setDataBinding(d, dataBinding);
+ }
+ }
+ DataType outputType = op.getOutputType();
+ if (outputType != null) {
+ setDataBinding(outputType, dataBinding);
+ }
+ List<DataType> faultTypes = op.getFaultTypes();
+ if (faultTypes != null) {
+ for (DataType d : faultTypes) {
+ setDataBinding(d, dataBinding);
+ setDataBinding((DataType) d.getLogical(), dataBinding);
+ }
+ }
+ if (op.isWrapperStyle()) {
+ WrapperInfo wrapper = op.getWrapper();
+ if (wrapper != null) {
+ DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType();
+ if (unwrappedInputType != null) {
+ for (DataType d : unwrappedInputType.getLogical()) {
+ setDataBinding(d, dataBinding);
+ }
+ }
+ DataType unwrappedOutputType = wrapper.getUnwrappedOutputType();
+ if (unwrappedOutputType != null) {
+ setDataBinding(unwrappedOutputType, dataBinding);
+ }
+ }
+ }
+ }
+ }
+
+ public void resetInterfaceInputTypes(Interface newInterface){
+ for (int i = 0; i < getOperations().size(); i++) {
+ // only remote interfaces only have a data type model defined
+ // and in this case operations cannot be overloaded so match
+ // operations by name
+ Operation oldOperation = getOperations().get(i);
+ Operation newOperation = null;
+
+ for (Operation tmpOperation : newInterface.getOperations()){
+ if (tmpOperation.getName().equals(oldOperation.getName())){
+ newOperation = tmpOperation;
+ }
+ }
+
+ if (newOperation == null){
+ break;
+ }
+
+ // set input types
+ oldOperation.setInputType(newOperation.getInputType());
+
+ // set wrapper
+ if (newOperation.isWrapperStyle()) {
+ oldOperation.setWrapperStyle(true);
+ oldOperation.setWrapper(newOperation.getWrapper());
+ }
+ }
+ }
+
+ public void resetInterfaceOutputTypes(Interface newInterface){
+ for (int i = 0; i < getOperations().size(); i++) {
+ // only remote interfaces only have a data type model defined
+ // and in this case operations cannot be overloaded so match
+ // operations by name
+ Operation oldOperation = getOperations().get(i);
+ Operation newOperation = null;
+
+ for (Operation tmpOperation : newInterface.getOperations()){
+ if (tmpOperation.getName().equals(oldOperation.getName())){
+ newOperation = tmpOperation;
+ }
+ }
+
+ if (newOperation == null){
+ break;
+ }
+
+ // set output types
+ oldOperation.setOutputType(newOperation.getOutputType());
+
+ // set fault types
+ oldOperation.setFaultTypes(newOperation.getFaultTypes());
+
+ // set wrapper
+ if (newOperation.isWrapperStyle()) {
+ oldOperation.setWrapperStyle(true);
+ oldOperation.setWrapper(newOperation.getWrapper());
+ }
+ }
+ }
+
+ public boolean isDynamic() {
+ return false;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ return type;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.type = type;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ InterfaceImpl copy = (InterfaceImpl)super.clone();
+ copy.operations = new OperationList();
+ for (Operation operation : this.operations) {
+ Operation clonedOperation = (Operation)operation.clone();
+ copy.operations.add(clonedOperation);
+ }
+ copy.attributes = new ConcurrentHashMap<Object, Object>();
+ copy.attributes.putAll(attributes);
+ return copy;
+ }
+
+ public Map<Object, Object> getAttributes() {
+ return attributes;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
new file mode 100644
index 0000000000..606782466d
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
@@ -0,0 +1,282 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents an operation on a service interface.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public class OperationImpl implements Operation {
+
+ private String name;
+ private boolean unresolved;
+ private DataType outputType;
+ private DataType<List<DataType>> inputType;
+ private List<DataType> faultTypes;
+ private Interface interfaze;
+ private boolean nonBlocking;
+ private boolean wrapperStyle;
+ private WrapperInfo wrapper;
+ private boolean dynamic;
+
+ private Map<Object, Object> attributes = new ConcurrentHashMap<Object, Object>();
+
+ private Map<QName, List<DataType<XMLType>>> faultBeans;
+
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private ExtensionType type;
+
+ /**
+ * @param name
+ */
+ public OperationImpl() {
+ inputType = new DataTypeImpl<List<DataType>>("idl:input", Object[].class, new ArrayList<DataType>());
+ faultTypes = new ArrayList<DataType>();
+ faultBeans = new HashMap<QName, List<DataType<XMLType>>>();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ /**
+ * @return the faultTypes
+ */
+ public List<DataType> getFaultTypes() {
+ return faultTypes;
+ }
+
+ /**
+ * @param faultTypes the faultTypes to set
+ */
+ public void setFaultTypes(List<DataType> faultTypes) {
+ this.faultTypes = faultTypes;
+ }
+
+ /**
+ * @return the inputType
+ */
+ public DataType<List<DataType>> getInputType() {
+ return inputType;
+ }
+
+ /**
+ * @param inputType the inputType to set
+ */
+ public void setInputType(DataType<List<DataType>> inputType) {
+ this.inputType = inputType;
+ }
+
+ /**
+ * @return the outputType
+ */
+ public DataType getOutputType() {
+ return outputType;
+ }
+
+ /**
+ * @param outputType the outputType to set
+ */
+ public void setOutputType(DataType outputType) {
+ this.outputType = outputType;
+ }
+
+ /**
+ * @return the interface
+ */
+ public Interface getInterface() {
+ return interfaze;
+ }
+
+ /**
+ * @param interfaze the interface to set
+ */
+ public void setInterface(Interface interfaze) {
+ this.interfaze = interfaze;
+ }
+
+ /**
+ * @return the nonBlocking
+ */
+ public boolean isNonBlocking() {
+ return nonBlocking;
+ }
+
+ /**
+ * @param nonBlocking the nonBlocking to set
+ */
+ public void setNonBlocking(boolean nonBlocking) {
+ this.nonBlocking = nonBlocking;
+ }
+
+ /**
+ * @return the wrapperInfo
+ */
+ public WrapperInfo getWrapper() {
+ return wrapper;
+ }
+
+ /**
+ * @param wrapperInfo the wrapperInfo to set
+ */
+ public void setWrapper(WrapperInfo wrapperInfo) {
+ this.wrapper = wrapperInfo;
+ }
+
+ /**
+ * @return the wrapperStyle
+ */
+ public boolean isWrapperStyle() {
+ return wrapperStyle;
+ }
+
+ /**
+ * @param wrapperStyle the wrapperStyle to set
+ */
+ public void setWrapperStyle(boolean wrapperStyle) {
+ this.wrapperStyle = wrapperStyle;
+ }
+
+ public String getDataBinding() {
+ return wrapper != null ? wrapper.getDataBinding() : null;
+ }
+
+ public void setDataBinding(String dataBinding) {
+ if (wrapper != null) {
+ wrapper.setDataBinding(dataBinding);
+ }
+ }
+
+ public boolean isDynamic() {
+ return dynamic;
+ }
+
+ public void setDynamic(boolean b) {
+ this.dynamic = b;
+ }
+
+ public Map<QName, List<DataType<XMLType>>> getFaultBeans() {
+ return faultBeans;
+ }
+
+ public void setFaultBeans(Map<QName, List<DataType<XMLType>>> faultBeans) {
+ this.faultBeans = faultBeans;
+ }
+
+ @Override
+ public OperationImpl clone() throws CloneNotSupportedException {
+ OperationImpl copy = (OperationImpl) super.clone();
+
+ final List<DataType> clonedFaultTypes = new ArrayList<DataType>(this.faultTypes.size());
+ for (DataType t : this.faultTypes) {
+ clonedFaultTypes.add((DataType) t.clone());
+ }
+ copy.faultTypes = clonedFaultTypes;
+
+ List<DataType> clonedLogicalTypes = new ArrayList<DataType>();
+ for (DataType t : inputType.getLogical()) {
+ DataType type = (DataType) t.clone();
+ clonedLogicalTypes.add(type);
+ }
+ DataType<List<DataType>> clonedInputType =
+ new DataTypeImpl<List<DataType>>(inputType.getPhysical(), clonedLogicalTypes);
+ clonedInputType.setDataBinding(inputType.getDataBinding());
+ copy.inputType = clonedInputType;
+
+ if (this.outputType != null) {
+ copy.outputType = (DataType) this.outputType.clone();
+ }
+
+ copy.attributes = new ConcurrentHashMap<Object, Object>();
+ copy.attributes.putAll(attributes);
+
+ // [rfeng] We need to clone the wrapper as it holds the databinding information
+ if (wrapper != null) {
+ copy.wrapper = (WrapperInfo)wrapper.clone();
+ }
+
+ return copy;
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ return type;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.type = type;
+ }
+
+ public Map<Object, Object> getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * Indicates if this operation is an async server style of operation
+ * @return true if the operation is async server style
+ */
+ public boolean isAsyncServer() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java
new file mode 100644
index 0000000000..38e33e33d9
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An abstraction of XML schema elements.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ElementInfo {
+ private final QName name;
+ private final TypeInfo type;
+ private boolean many = false;
+ private boolean nillable = false;
+
+ /**
+ * @param name
+ * @param type
+ */
+ public ElementInfo(QName name, TypeInfo type) {
+ super();
+ this.name = name;
+ this.type = type;
+ }
+
+ /**
+ * @return the name
+ */
+ public QName getQName() {
+ return name;
+ }
+
+ /**
+ * @return the type
+ */
+ public TypeInfo getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Element: ").append(name).append(" ").append(type);
+ return sb.toString();
+ }
+
+ public boolean isMany() {
+ return many;
+ }
+
+ public void setMany(boolean many) {
+ this.many = many;
+ }
+
+ public boolean isNillable() {
+ return nillable;
+ }
+
+ public void setNillable(boolean nillable) {
+ this.nillable = nillable;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final ElementInfo other = (ElementInfo)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ /*
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ */
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java
new file mode 100644
index 0000000000..334c826f86
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The generic java exception to wrap service faults
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class FaultException extends Exception {
+ private static final long serialVersionUID = -8002583655240625792L;
+ private transient Object faultInfo; // FIXME: How to serialize it?
+ private QName faultName;
+
+ /**
+ * @param message
+ * @param faultInfo
+ */
+ public FaultException(String message, Object faultInfo) {
+ super(message);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @param message
+ * @param faultInfo
+ * @param cause
+ */
+ public FaultException(String message, Object faultInfo, Throwable cause) {
+ super(message, cause);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @return the faultInfo
+ */
+ public Object getFaultInfo() {
+ return faultInfo;
+ }
+
+ public QName getFaultName() {
+ return faultName;
+ }
+
+ public void setFaultName(QName logical) {
+ this.faultName = logical;
+ }
+
+ public boolean isMatchingType(Object type) {
+ if (faultName == null) {
+ return false;
+ }
+
+ if ((type instanceof QName) && faultName.equals(type)) {
+ return true;
+ }
+ if (type instanceof XMLType && faultName.equals(((XMLType)type).getElementName())) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
new file mode 100644
index 0000000000..849b922285
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Utility class that can be used to map XSD types to Java classes and Java classes to XSD types.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public final class JavaXMLMapper {
+ public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
+ private static final Map<Class, QName> JAVA2XML = new HashMap<Class, QName>();
+ private static final Map<String, Class> XML2JAVA = new HashMap<String, Class>();
+
+ private JavaXMLMapper() {
+ }
+
+ static {
+ JAVA2XML.put(boolean.class, getTypeName("boolean"));
+ JAVA2XML.put(byte.class, getTypeName("byte"));
+ JAVA2XML.put(short.class, getTypeName("short"));
+ JAVA2XML.put(int.class, getTypeName("int"));
+ JAVA2XML.put(long.class, getTypeName("long"));
+ JAVA2XML.put(float.class, getTypeName("float"));
+ JAVA2XML.put(double.class, getTypeName("double"));
+ JAVA2XML.put(Boolean.class, getTypeName("boolean"));
+ JAVA2XML.put(Byte.class, getTypeName("byte"));
+ JAVA2XML.put(Short.class, getTypeName("short"));
+ JAVA2XML.put(Integer.class, getTypeName("int"));
+ JAVA2XML.put(Long.class, getTypeName("long"));
+ JAVA2XML.put(Float.class, getTypeName("float"));
+ JAVA2XML.put(Double.class, getTypeName("double"));
+ JAVA2XML.put(java.lang.String.class, getTypeName("string"));
+ JAVA2XML.put(java.math.BigInteger.class, getTypeName("integer"));
+ JAVA2XML.put(java.math.BigDecimal.class, getTypeName("decimal"));
+ JAVA2XML.put(java.util.Calendar.class, getTypeName("dateTime"));
+ JAVA2XML.put(java.util.Date.class, getTypeName("dateTime"));
+ JAVA2XML.put(javax.xml.namespace.QName.class, getTypeName("QName"));
+ JAVA2XML.put(java.net.URI.class, getTypeName("string"));
+ JAVA2XML.put(javax.xml.datatype.XMLGregorianCalendar.class, getTypeName("anySimpleType"));
+ JAVA2XML.put(javax.xml.datatype.Duration.class, getTypeName("duration"));
+ JAVA2XML.put(java.lang.Object.class, getTypeName("anyType"));
+ JAVA2XML.put(java.awt.Image.class, getTypeName("base64Binary"));
+ JAVA2XML.put(byte[].class, getTypeName("base64Binary"));
+ // java2XSD.put(javax.activation.DataHandler.class, getTypeName("base64Binary"));
+ JAVA2XML.put(javax.xml.transform.Source.class, getTypeName("base64Binary"));
+ JAVA2XML.put(java.util.UUID.class, getTypeName("string"));
+ }
+
+ static {
+ XML2JAVA.put("string", java.lang.String.class);
+ XML2JAVA.put("integer", java.math.BigInteger.class);
+ XML2JAVA.put("int", int.class);
+ XML2JAVA.put("long", long.class);
+ XML2JAVA.put("short", short.class);
+ XML2JAVA.put("decimal", java.math.BigDecimal.class);
+ XML2JAVA.put("float", float.class);
+ XML2JAVA.put("double", double.class);
+ XML2JAVA.put("boolean", boolean.class);
+ XML2JAVA.put("byte", byte.class);
+ XML2JAVA.put("QName", javax.xml.namespace.QName.class);
+ XML2JAVA.put("dateTime", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("base64Binary", byte[].class);
+ XML2JAVA.put("hexBinary", byte[].class);
+ XML2JAVA.put("unsignedInt", long.class);
+ XML2JAVA.put("unsignedShort", int.class);
+ XML2JAVA.put("unsignedByte", short.class);
+ XML2JAVA.put("time", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("date", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gDay", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gYear", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gYearMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gMonthDay", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("anySimpleType", java.lang.Object.class); // For elements
+ // XML2JAVA.put("anySimpleType", java.lang.String.class); // For
+ // attributes
+ XML2JAVA.put("duration", javax.xml.datatype.Duration.class);
+ XML2JAVA.put("NOTATION", javax.xml.namespace.QName.class);
+ }
+
+ public static Class getJavaType(QName xmlType) {
+ if (URI_2001_SCHEMA_XSD.equals(xmlType.getNamespaceURI())) {
+ return XML2JAVA.get(xmlType.getLocalPart());
+ } else {
+ return null;
+ }
+ }
+
+ private static QName getTypeName(String name) {
+ return new QName(URI_2001_SCHEMA_XSD, name);
+ }
+
+ public static QName getXMLType(Class javaType) {
+ return JAVA2XML.get(javaType);
+ }
+
+ private static String getPackageName(Class<?> cls) {
+ String name = cls.getName();
+ int index = name.lastIndexOf('.');
+ return index == -1 ? "" : name.substring(0, index);
+ }
+
+ public static String getNamespace(Class<?> cls) {
+ String packageName = getPackageName(cls);
+ if ("".equals(packageName)) {
+ return "";
+ }
+ StringBuffer ns = new StringBuffer("http://");
+ String[] names = packageName.split("\\.");
+ for (int i = names.length - 1; i >= 0; i--) {
+ ns.append(names[i]);
+ if (i != 0) {
+ ns.append('.');
+ }
+ }
+ ns.append('/');
+ return ns.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java
new file mode 100644
index 0000000000..abae4e7e38
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An abstraction of XML schema types
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class TypeInfo {
+ private QName name;
+
+ private boolean isSimpleType;
+
+ private TypeInfo baseType;
+
+ /**
+ * @param name
+ * @param isSimpleType
+ */
+ public TypeInfo(QName name, boolean isSimpleType, TypeInfo baseType) {
+ super();
+ this.name = name;
+ this.isSimpleType = isSimpleType;
+ this.baseType = baseType;
+ }
+
+ /**
+ * @return the isSimpleType
+ */
+ public boolean isSimpleType() {
+ return isSimpleType;
+ }
+
+ /**
+ * @return the name
+ */
+ public QName getQName() {
+ return name;
+ }
+
+ /**
+ * @return the baseType
+ */
+ public TypeInfo getBaseType() {
+ return baseType;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Type: ").append(name);
+ return sb.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final TypeInfo other = (TypeInfo)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java
new file mode 100644
index 0000000000..2252434c39
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+
+/**
+ * The "Wrapper Style" WSDL operation is defined by The Java API for XML-Based
+ * Web Services (JAX-WS) 2.0 specification, section 2.3.1.2 Wrapper Style. <p/>
+ * A WSDL operation qualifies for wrapper style mapping only if the following
+ * criteria are met:
+ * <ul>
+ * <li>(i) The operation�s input and output messages (if present) each contain
+ * only a single part
+ * <li>(ii) The input message part refers to a global element declaration whose
+ * localname is equal to the operation name
+ * <li>(iii) The output message part refers to a global element declaration
+ * <li>(iv) The elements referred to by the input and output message parts
+ * (henceforth referred to as wrapper elements) are both complex types defined
+ * using the xsd:sequence compositor
+ * <li>(v) The wrapper elements only contain child elements, they must not
+ * contain other structures such as wildcards (element or attribute),
+ * xsd:choice, substitution groups (element references are not permitted) or
+ * attributes; furthermore, they must not be nillable.
+ * </ul>
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class WrapperInfo implements Cloneable {
+ private ElementInfo inputWrapperElement;
+
+ private ElementInfo outputWrapperElement;
+
+ private List<ElementInfo> inputChildElements;
+
+ private List<ElementInfo> outputChildElements;
+
+ // The data type of the unwrapped input child elements
+ private DataType<List<DataType>> unwrappedInputType;
+
+ // The data type of the unwrapped output child element (we only supports one child)
+ private DataType<XMLType> unwrappedOutputType;
+
+ // The data for the input/output wrappers
+ private String dataBinding;
+
+ // The data type for the input (request) wrapper bean
+ private DataType<XMLType> inputWrapperType;
+ // The data type for the output (response) wrapper bean
+ private DataType<XMLType> outputWrapperType;
+
+ public WrapperInfo(String dataBinding,
+ ElementInfo inputWrapperElement,
+ ElementInfo outputWrapperElement,
+ List<ElementInfo> inputElements,
+ List<ElementInfo> outputElements) {
+ super();
+ this.dataBinding = dataBinding;
+ this.inputWrapperElement = inputWrapperElement;
+ this.outputWrapperElement = outputWrapperElement;
+ this.inputChildElements = inputElements;
+ this.outputChildElements = outputElements;
+ }
+
+ /**
+ * @return the inputElements
+ */
+ public List<ElementInfo> getInputChildElements() {
+ return inputChildElements;
+ }
+
+ /**
+ * @return the inputWrapperElement
+ */
+ public ElementInfo getInputWrapperElement() {
+ return inputWrapperElement;
+ }
+
+ /**
+ * @return the outputElements
+ */
+ public List<ElementInfo> getOutputChildElements() {
+ return outputChildElements;
+ }
+
+ /**
+ * @return the outputWrapperElement
+ */
+ public ElementInfo getOutputWrapperElement() {
+ return outputWrapperElement;
+ }
+
+ /**
+ * @return the unwrappedInputType
+ */
+ public DataType<List<DataType>> getUnwrappedInputType() {
+ if (unwrappedInputType == null) {
+ List<DataType> childTypes = new ArrayList<DataType>();
+ for (ElementInfo element : getInputChildElements()) {
+ DataType type = getDataType(element);
+ childTypes.add(type);
+ }
+ unwrappedInputType = new DataTypeImpl<List<DataType>>("idl:unwrapped.input", Object[].class, childTypes);
+ }
+ return unwrappedInputType;
+ }
+
+ private DataType getDataType(ElementInfo element) {
+ DataType type = null;
+ if (element.isMany()) {
+ DataType logical = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element));
+ type = new DataTypeImpl<DataType>("java:array", Object[].class, logical);
+ } else {
+ type = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element));
+ }
+ return type;
+ }
+
+ /**
+ * @return the unwrappedOutputType
+ */
+ public DataType getUnwrappedOutputType() {
+ if (unwrappedOutputType == null) {
+ List<ElementInfo> elements = getOutputChildElements();
+ if (elements != null && elements.size() > 0) {
+ if (elements.size() > 1) {
+ // We don't support output with multiple parts
+ // throw new IllegalArgumentException("Multi-part output is not supported");
+ }
+ ElementInfo element = elements.get(0);
+
+ unwrappedOutputType = getDataType(element);
+ }
+ }
+ return unwrappedOutputType;
+ }
+
+ public Class<?> getInputWrapperClass() {
+ return inputWrapperType == null ? null : inputWrapperType.getPhysical();
+ }
+
+ public Class<?> getOutputWrapperClass() {
+ return outputWrapperType == null ? null : outputWrapperType.getPhysical();
+ }
+
+ public String getDataBinding() {
+ return dataBinding;
+ }
+
+ public void setDataBinding(String dataBinding) {
+ this.dataBinding = dataBinding;
+ }
+
+ public DataType<XMLType> getInputWrapperType() {
+ return inputWrapperType;
+ }
+
+ public void setInputWrapperType(DataType<XMLType> inputWrapperType) {
+ this.inputWrapperType = inputWrapperType;
+ }
+
+ public DataType<XMLType> getOutputWrapperType() {
+ return outputWrapperType;
+ }
+
+ public void setOutputWrapperType(DataType<XMLType> outputWrapperType) {
+ this.outputWrapperType = outputWrapperType;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ WrapperInfo copy = (WrapperInfo) super.clone();
+ if (inputWrapperType != null) {
+ copy.inputWrapperType = (DataType<XMLType>)inputWrapperType.clone();
+ }
+ if (outputWrapperType != null) {
+ copy.outputWrapperType = (DataType<XMLType>)outputWrapperType.clone();
+ }
+ return copy;
+
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java
new file mode 100644
index 0000000000..fd1b840b17
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The metadata for an XML element or type.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class XMLType {
+ public static final XMLType UNKNOWN = new XMLType(null, null);
+ protected QName element;
+ protected QName type;
+ protected boolean nillable = true;
+ protected boolean many = false;
+
+ /**
+ * @param element
+ */
+ public XMLType(ElementInfo element) {
+ super();
+ this.element = element.getQName();
+ if (element.getType() != null) {
+ this.type = element.getType().getQName();
+ }
+ }
+
+ /**
+ * @param element
+ */
+ public XMLType(TypeInfo type) {
+ this.element = null;
+ this.type = type.getQName();
+ }
+
+ public XMLType(QName element, QName type) {
+ this.element = element;
+ this.type = type;
+ }
+
+ /**
+ * @return the type
+ */
+ public QName getTypeName() {
+ return type;
+ }
+
+ public boolean isElement() {
+ return element != null;
+ }
+
+ public QName getElementName() {
+ return element;
+ }
+
+ public void setElementName(QName element) {
+ this.element = element;
+ }
+
+ public void setTypeName(QName type) {
+ this.type = type;
+ }
+
+ public static XMLType getType(QName type) {
+ return new XMLType(null, type);
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((element == null) ? 0 : element.hashCode());
+ result = PRIME * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final XMLType other = (XMLType)obj;
+ if (element == null) {
+ if (other.element != null) {
+ return false;
+ }
+ } else if (!element.equals(other.element)) {
+ return false;
+ }
+ if (type == null) {
+ if (other.type != null) {
+ return false;
+ }
+ } else if (!type.equals(other.type)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Element: " + element + " Type: " + type;
+ }
+
+ public boolean isNillable() {
+ return nillable;
+ }
+
+ public void setNillable(boolean niable) {
+ this.nillable = niable;
+ }
+
+ public boolean isMany() {
+ return many;
+ }
+
+ public void setMany(boolean many) {
+ this.many = many;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java
new file mode 100644
index 0000000000..f43c428563
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+
+/**
+ * Definition of binding type which extends from sca:binding
+ */
+public interface BindingType extends ExtensionType {
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java
new file mode 100644
index 0000000000..2da41675a1
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy;
+
+import org.apache.tuscany.sca.policy.impl.PolicyFactoryImpl;
+
+/**
+ * A factory for the policy model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultPolicyFactory extends PolicyFactoryImpl implements PolicyFactory {
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java
new file mode 100644
index 0000000000..f8f8a48b06
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Definition of extension type: binding or implementation
+ * @tuscany.spi.extension.asclient
+ */
+public interface ExtensionType {
+ QName BINDING_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "binding");
+ QName IMPLEMENTATION_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "implementation");
+
+ /**
+ * The name of the extension type (binding or implementation). The extension type name
+ * attribute MUST be the QName of an XSD global element definition used for
+ * binding/implementation elements of that type
+ *
+ * @return The QName of this type
+ */
+ QName getType();
+
+ /**
+ * Set the QName for this type
+ * @param type The QName of this type
+ */
+ void setType(QName type);
+
+ QName getBaseType();
+
+ /**
+ * A set of intents. The intents in the alwaysProvides set are always
+ * provided by this extension type, whether the intents are attached
+ * to the using component or not.
+ *
+ * @return A list of intents that are always provided by this type
+ */
+ List<Intent> getAlwaysProvidedIntents();
+
+ /**
+ * a set of intents. The intents in the mayProvide set are provided by this
+ * extension type if the intent in question is attached to the using
+ * component.
+ *
+ * @return A list of intents that may be provided by this type
+ */
+ List<Intent> getMayProvidedIntents();
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java
new file mode 100644
index 0000000000..d142015f57
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+
+/**
+ * Definition of an implementation type which extends from sca:implementation
+ */
+public interface ImplementationType extends ExtensionType {
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java
new file mode 100644
index 0000000000..b2578fab49
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a policy intent. See the Policy Framework specification for a
+ * description of this element.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Intent {
+ enum Type {
+ interaction, implementation
+ };
+
+ /**
+ * Returns the intent name.
+ *
+ * @return the intent name
+ */
+ QName getName();
+
+ /**
+ * Sets the intent name
+ *
+ * @param name the intent name
+ */
+ void setName(QName name);
+
+ /**
+ * Returns the list of SCA constructs that this intent is meant to
+ * configure.
+ *
+ * @return the list of SCA constructs that this intent is meant to configure
+ */
+ List<ExtensionType> getConstrainedTypes();
+
+ /**
+ * Return a list of required intents
+ * @return The list of required intents
+ */
+ List<Intent> getRequiredIntents();
+
+ /**
+ * Returns the list of intents which are mutually exclusive with this intent.
+ *
+ * @return the list of mutually exclusive intents.
+ */
+ List<Intent> getExcludedIntents();
+
+ /**
+ * Returns the list of qualified intents.
+ *
+ * @return the list of qualified intents.
+ */
+ List<Intent> getQualifiedIntents();
+
+ /**
+ * Get the default qualified intent
+ *
+ * @return
+ */
+ Intent getDefaultQualifiedIntent();
+
+ /**
+ * Set the default qualified intent
+ *
+ * @param qualifiedIntent
+ */
+ void setDefaultQualifiedIntent(Intent qualifiedIntent);
+
+ /**
+ * Get the intent type: Interaction or Implementation
+ * @return
+ */
+ Type getType();
+
+ /**
+ * Set the intent type
+ * @param type: Interaction or Implementation
+ */
+ void setType(Type type);
+
+ /**
+ * If this attribute is present and has a value of true it indicates that
+ * the qualified intents defined for this intent are mutually exclusive
+ *
+ * @return
+ */
+ boolean isMutuallyExclusive();
+
+ /**
+ * Set the value of mutuallyExclusive
+ * @param mutuallyExclusive
+ */
+ void setMutuallyExclusive(boolean mutuallyExclusive);
+
+ /**
+ * Returns the intent description.
+ *
+ * @return the intent description
+ */
+ String getDescription();
+
+ /**
+ * Sets the intent description.
+ *
+ * @param description the intent description
+ */
+ void setDescription(String description);
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+
+ /**
+ * Get the parent intent for a qualified intent. If an intent is not qualified,
+ * return null.
+ * @return The parent intent or null if this intent is not qualified
+ */
+ Intent getQualifiableIntent();
+
+ /**
+ * Set the parent intent for a qualified intent
+ * @param intent
+ */
+ void setQualifiableIntent(Intent intent);
+
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
new file mode 100644
index 0000000000..5b401baeb3
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+import java.util.List;
+
+
+/**
+ * Map policies to the qualified intents
+ */
+public interface IntentMap {
+ /**
+ * Returns the intent realized by this intent map.
+ *
+ * @return the intent realized by this intent map
+ */
+ Intent getProvidedIntent();
+
+ /**
+ * Sets the intent realized by this intent map.
+ *
+ * @param providedIntent the intent realized by this intent map
+ */
+ void setProvidedIntent(Intent providedIntent);
+
+ /**
+ * Get a list of qualifiers
+ *
+ * @return A list of qualifiers
+ */
+ List<Qualifier> getQualifiers();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java
new file mode 100644
index 0000000000..ee4f5b5236
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+import java.util.List;
+
+/**
+ * Attach a policySet to a collection of policy subjects
+ */
+public interface PolicyAttachment {
+ PolicySet getPolicySet();
+ void setPolicySet(PolicySet policySet);
+ List<PolicySubject> getPolicySubjects();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.java
new file mode 100644
index 0000000000..6bb7244e05
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy;
+
+/**
+ * Base interface for policy models. Mainly allows policies to hold
+ * other policies
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface PolicyContainer {
+ /**
+ * For complex policy models, such as ws-policy,
+ * a policy provider may only match against one of a
+ * number of child policy models
+ *
+ * @return the matching child policy object or null
+ */
+ <T> Object getChildPolicy(Class<T> policyType);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java
new file mode 100644
index 0000000000..b7de263789
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Interface that will abstract various types of policy specifications
+ * and attachments for example WS-Policy
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface PolicyExpression {
+ /**
+ * Get the QName of the policy expression
+ * @return the QName of the policy expression
+ */
+ QName getName();
+
+ /**
+ * Set the QName of the policy expression
+ * @param name
+ */
+ void setName(QName name);
+
+ /**
+ * Get the policy definition in the type of the specific domain
+ * @return
+ */
+ <T> T getPolicy();
+
+ /**
+ * Set the policy definition
+ * @param expression
+ */
+ <T> void setPolicy(T policy);
+
+ /**
+ *
+ * @param unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+ /**
+ *
+ * @return
+ */
+ boolean isUnresolved();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
new file mode 100644
index 0000000000..b2ac5ca409
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy;
+
+/**
+ * A factory for the policy model.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface PolicyFactory {
+
+ /**
+ * Create a new intent.
+ *
+ * @return a new intent
+ */
+ Intent createIntent();
+
+ /**
+ * Create a new policy set.
+ *
+ * @return a new policy set
+ */
+ PolicySet createPolicySet();
+
+ /**
+ * Create a new intent map.
+ *
+ * @return a new intent map
+ */
+ IntentMap createIntentMap();
+
+ /**
+ * create a new Qualifier
+ *
+ * @return a Qualifier
+ */
+ Qualifier createQualifier();
+
+ /**
+ * Create a new PolicyExpression
+ * @return
+ */
+ PolicyExpression createPolicyExpression();
+
+ ExtensionType createExtensionType();
+ BindingType createBindingType();
+ ImplementationType createImplementationType();
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
new file mode 100644
index 0000000000..a1ae3892e4
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathExpression;
+
+/**
+ * Represents a policy set. See the Policy Framework specification for a
+ * description of this element.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface PolicySet {
+
+ /**
+ * Returns the intent name.
+ *
+ * @return the intent name
+ */
+ QName getName();
+
+ /**
+ * Sets the intent name
+ *
+ * @param name the intent name
+ */
+ void setName(QName name);
+
+ /**
+ * Returns the list of
+ *
+ * @return
+ */
+ List<PolicySet> getReferencedPolicySets();
+
+ /**
+ * Returns the list of provided intents
+ *
+ * @return
+ */
+ List<Intent> getProvidedIntents();
+
+ /**
+ * Returns the list of concrete policies, either WS-Policy policy
+ * attachments, policy references, or policies expressed in another policy
+ * language.
+ *
+ * @return the list of concrete policies
+ */
+ List<PolicyExpression> getPolicies();
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+ /**
+ * Returns the XPath expression that is to be used to evaluate
+ * if this PolicySet applies to specific policy subject
+ *
+ * @return the XPath expression
+ */
+ String getAppliesTo();
+
+ /**
+ * Sets the XPath expression that is to be used to evaluate
+ * if this PolicySet applies to specific policy subject
+ *
+ */
+ void setAppliesTo(String xpath);
+
+ /**
+ * A string which is an XPath 1.0 expression identifying one or more
+ * elements (policy subject) in the Domain. It is used to declare which
+ * set of elements the policySet is actually attached to.
+ *
+ * @return The attachTo XPath
+ */
+ String getAttachTo();
+
+ /**
+ * Set the attachTo XPath
+ * @param xpath
+ */
+ void setAttachTo(String xpath);
+
+ /**
+ * Get the resolved XPathExpression for attachTo
+ * @return
+ */
+ XPathExpression getAttachToXPathExpression();
+
+ /**
+ * Set the resolved XPathExpression for attachTo
+ * @param expression
+ */
+ void setAttachToXPathExpression(XPathExpression expression);
+
+ /**
+ * Returns the policies / policy attachments provided thro intent maps
+ *
+ * @return
+ */
+ List<IntentMap> getIntentMaps();
+
+ /**
+ * Get the XPath expression for the appliesTo attribute
+ * @return the XPath expression for the appliesTo attribute
+ */
+ XPathExpression getAppliesToXPathExpression();
+
+ /**
+ * Set the XPath expression for the appliesTo attribute
+ * @param xpathExpression the XPath expression for the appliesTo attribute
+ */
+ void setAppliesToXPathExpression(XPathExpression xpathExpression);
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java
new file mode 100644
index 0000000000..e585fcf384
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+import java.util.List;
+
+/**
+ * A policy subject is an entity in the assembly with which a policy can be
+ * associated.
+ *
+ * For example, a policy subject can be one of the following:
+ * <ul>
+ * <li>composite
+ * <li>component
+ * <li>implementation
+ * <li>service
+ * <li>reference
+ * <li>binding
+ * <li>interface
+ * </ul>
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface PolicySubject {
+ /**
+ * Get a list of required intents
+ *
+ * @return
+ */
+ List<Intent> getRequiredIntents();
+
+ /**
+ * Get a list of attached policySets
+ *
+ * @return A list of policySets
+ */
+ List<PolicySet> getPolicySets();
+
+ ExtensionType getExtensionType();
+ void setExtensionType(ExtensionType type);
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java
new file mode 100644
index 0000000000..c1862283c7
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+import java.util.List;
+
+/**
+ * A qualifier provides a list of policies for a qualified intent within the IntentMap
+ */
+public interface Qualifier {
+ /**
+ * Get the qualified intent for this qualifier
+ * @return The intent
+ */
+ Intent getIntent();
+
+ /**
+ * Set the qualified intent for this qualifier
+ */
+ void setIntent(Intent intent);
+
+ /**
+ * Get the list of policies provided by this qualifier
+ * @return A list of policies
+ */
+ List<PolicyExpression> getPolicies();
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
new file mode 100644
index 0000000000..1a2a9c5bad
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.BindingType;
+
+/**
+ * Concrete implementation for a BindingType
+ *
+ * @version $Rev$ $Date$
+ */
+public class BindingTypeImpl extends ExtensionTypeImpl implements BindingType {
+ protected BindingTypeImpl() {
+ super();
+ }
+
+ public QName getBaseType() {
+ return BINDING_BASE;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java
new file mode 100644
index 0000000000..97fbc19ced
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+
+/**
+ * Concrete implementation for a BindingType
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensionTypeImpl implements ExtensionType {
+
+ private List<Intent> alwaysProvides = new ArrayList<Intent>();
+ private List<Intent> mayProvide = new ArrayList<Intent>();
+ private QName typeName;
+ private boolean unResolved = true;
+
+ protected ExtensionTypeImpl() {
+
+ }
+
+ public List<Intent> getAlwaysProvidedIntents() {
+ return alwaysProvides;
+ }
+
+ public List<Intent> getMayProvidedIntents() {
+ return mayProvide;
+ }
+
+ public QName getType() {
+ return typeName;
+ }
+
+ public void setType(QName type) {
+ this.typeName = type;
+ }
+
+ public boolean isUnresolved() {
+ return unResolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unResolved = unresolved;
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(getType()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof ExtensionTypeImpl) {
+ if (getType() != null) {
+ return getType().equals(((ExtensionTypeImpl)obj).getType());
+ } else {
+ return ((ExtensionTypeImpl)obj).getType() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return (this.typeName != null) ? getType().toString() : "null";
+ }
+
+ public QName getBaseType() {
+ return null;
+ }
+};
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
new file mode 100644
index 0000000000..5c285e4d95
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.ImplementationType;
+
+/**
+ * Concrete implementation for a Implementation Type
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImplementationTypeImpl extends ExtensionTypeImpl implements ImplementationType {
+ protected ImplementationTypeImpl() {
+ super();
+ }
+
+ public QName getBaseType() {
+ return IMPLEMENTATION_BASE;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
new file mode 100644
index 0000000000..27a77f3ba8
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+
+/**
+ * Represents a policy intent.
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntentImpl implements Intent {
+
+ private QName name;
+ private Type type;
+ private List<ExtensionType> constrainedTypes = new ArrayList<ExtensionType>();
+ private String description;
+ private List<Intent> qualifiedIntents = new ArrayList<Intent>();
+ private Intent defaultQualifiedIntent;
+ private Intent parent;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<Intent> excludedIntents = new ArrayList<Intent>();
+ private boolean mutuallyExclusive;
+ private boolean unresolved = true;
+
+ protected IntentImpl() {
+ }
+
+ public QName getName() {
+ return name;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ public List<ExtensionType> getConstrainedTypes() {
+ return constrainedTypes;
+ }
+
+ public void setConstrainedTypes(List<ExtensionType> constrainedTypes) {
+ this.constrainedTypes = constrainedTypes;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Intent getQualifiableIntent() {
+ return parent;
+ }
+
+ public void setQualifiableIntent(Intent parent) {
+ this.parent = parent;
+ }
+
+ public List<Intent> getQualifiedIntents() {
+ return qualifiedIntents;
+ }
+
+ public void setQualifiedIntents(List<Intent> qualifiedIntents) {
+ this.qualifiedIntents = qualifiedIntents;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public void setRequiredIntents(List<Intent> requiredIntents) {
+ this.requiredIntents = requiredIntents;
+ }
+
+ public List<Intent> getExcludedIntents() {
+ return excludedIntents;
+ }
+
+ public void setExcludedIntents(List<Intent> excludedIntents) {
+ this.excludedIntents = excludedIntents;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public boolean isMutuallyExclusive() {
+ return mutuallyExclusive;
+ }
+
+ public void setMutuallyExclusive(boolean mutuallyExclusive) {
+ this.mutuallyExclusive = mutuallyExclusive;
+ }
+
+ public Intent getDefaultQualifiedIntent() {
+ return defaultQualifiedIntent;
+ }
+
+ public void setDefaultQualifiedIntent(Intent defaultQualifiedIntent) {
+ this.defaultQualifiedIntent = defaultQualifiedIntent;
+ }
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ IntentImpl other = (IntentImpl)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+ public String toString() {
+ return String.valueOf(name);
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java
new file mode 100644
index 0000000000..357b7afab4
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+/**
+ * Represents an intent map.
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntentMapImpl implements IntentMap {
+
+ private boolean unresolved;
+ private Intent providedIntent;
+ private List<Qualifier> qualifiers = new ArrayList<Qualifier>();
+
+ protected IntentMapImpl() {
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public Intent getProvidedIntent() {
+ return providedIntent;
+ }
+
+ public void setProvidedIntent(Intent providedIntent) {
+ this.providedIntent = providedIntent;
+ }
+
+ public List<Qualifier> getQualifiers() {
+ return qualifiers;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ IntentMapImpl other = (IntentMapImpl)obj;
+ if (providedIntent == null) {
+ if (other.providedIntent != null)
+ return false;
+ } else if (!providedIntent.equals(other.providedIntent))
+ return false;
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java
new file mode 100644
index 0000000000..b9f9fa5eb4
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.PolicyExpression;
+
+public class PolicyExpressionImpl implements PolicyExpression {
+ private QName name;
+ private Object policy;
+ private boolean unresolved = true;
+
+ protected PolicyExpressionImpl() {
+ }
+
+ public QName getName() {
+ return name;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getPolicy() {
+ return (T)policy;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ public <T> void setPolicy(T policy) {
+ this.policy = policy;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public String toString() {
+ return String.valueOf(name);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PolicyExpressionImpl other = (PolicyExpressionImpl)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
new file mode 100644
index 0000000000..c67ff1eab8
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.impl;
+
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+/**
+ * A factory for the policy model.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class PolicyFactoryImpl implements PolicyFactory {
+
+ public Intent createIntent() {
+ return new IntentImpl();
+ }
+
+ public PolicySet createPolicySet() {
+ return new PolicySetImpl();
+ }
+
+ public IntentMap createIntentMap() {
+ return new IntentMapImpl();
+ }
+
+ public Qualifier createQualifier() {
+ return new QualifierImpl();
+ }
+
+ public PolicyExpression createPolicyExpression() {
+ return new PolicyExpressionImpl();
+ }
+
+ public BindingType createBindingType() {
+ return new BindingTypeImpl();
+ }
+
+ public ImplementationType createImplementationType() {
+ return new ImplementationTypeImpl();
+ }
+
+ public ExtensionType createExtensionType() {
+ return new ExtensionTypeImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
new file mode 100644
index 0000000000..75d1229cd8
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathExpression;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a policy set.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicySetImpl implements PolicySet {
+
+ private QName name;
+ private String appliesTo;
+ private String attachTo;
+ private List<Intent> providedIntents = new ArrayList<Intent>();
+ private List<PolicySet> referencedPolicySets = new ArrayList<PolicySet>();
+ private boolean unresolved = true;
+
+ private XPathExpression appliesToXPathExpression;
+ private XPathExpression attachToXPathExpression;
+
+ private List<IntentMap> intentMaps = new ArrayList<IntentMap>();
+ private List<PolicyExpression> policies = new ArrayList<PolicyExpression>();
+
+ public QName getName() {
+ return name;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ public String getAppliesTo() {
+ return appliesTo;
+ }
+
+ public void setAppliesTo(String appliesTo) {
+ this.appliesTo = appliesTo;
+ }
+
+ public String getAttachTo() {
+ return attachTo;
+ }
+
+ public void setAttachTo(String attachTo) {
+ this.attachTo = attachTo;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public XPathExpression getAppliesToXPathExpression() {
+ return appliesToXPathExpression;
+ }
+
+ public void setAppliesToXPathExpression(XPathExpression appliesToXPathExpression) {
+ this.appliesToXPathExpression = appliesToXPathExpression;
+ }
+
+ public XPathExpression getAttachToXPathExpression() {
+ return attachToXPathExpression;
+ }
+
+ public void setAttachToXPathExpression(XPathExpression attachToXPathExpression) {
+ this.attachToXPathExpression = attachToXPathExpression;
+ }
+
+ public List<IntentMap> getIntentMaps() {
+ return intentMaps;
+ }
+
+ public List<Intent> getProvidedIntents() {
+ return providedIntents;
+ }
+
+ public List<PolicySet> getReferencedPolicySets() {
+ return referencedPolicySets;
+ }
+
+ public List<PolicyExpression> getPolicies() {
+ return policies;
+ }
+
+ public String toString() {
+ return String.valueOf(name);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PolicySetImpl other = (PolicySetImpl)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java
new file mode 100644
index 0000000000..102bea8d41
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+public class QualifierImpl implements Qualifier {
+ private Intent intent;
+ private List<PolicyExpression> policies = new ArrayList<PolicyExpression>();
+
+ protected QualifierImpl() {
+ }
+
+ public Intent getIntent() {
+ return intent;
+ }
+
+ public List<PolicyExpression> getPolicies() {
+ return policies;
+ }
+
+ public void setIntent(Intent intent) {
+ this.intent = intent;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java
new file mode 100644
index 0000000000..8a4adb3d7f
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * A utility that helps to navigate the policy model
+ * @tuscany.spi.extension.asclient
+ */
+public class PolicyHelper {
+ public PolicySet getPolicySet(PolicySubject subject, QName policySetName) {
+ for (PolicySet ps : subject.getPolicySets()) {
+ if (ps.getName().equals(policySetName)) {
+ return ps;
+ }
+ }
+ return null;
+ }
+
+ public Intent getIntent(Definitions subject, QName intentName) {
+ for (Intent i : subject.getIntents()) {
+ if (i.getName().equals(intentName)) {
+ return i;
+ }
+ }
+ return null;
+ }
+
+ public PolicySet getPolicySet(Definitions subject, QName policySetName) {
+ for (PolicySet ps : subject.getPolicySets()) {
+ if (ps.getName().equals(policySetName)) {
+ return ps;
+ }
+ }
+ return null;
+ }
+
+ public Intent getIntent(PolicySubject subject, QName intentName) {
+ for (Intent i : subject.getRequiredIntents()) {
+ if (i.getName().equals(intentName)) {
+ return i;
+ }
+ }
+ return null;
+ }
+
+ public Collection<PolicyExpression> getPolicyExpressions(PolicySubject subject, QName policyName) {
+ Collection<PolicyExpression> policies = new ArrayList<PolicyExpression>();
+ for (PolicySet ps : subject.getPolicySets()) {
+ for (PolicyExpression exp : ps.getPolicies()) {
+ if (exp.getName().equals(policyName)) {
+ policies.add(exp);
+ }
+ }
+ }
+ return policies;
+ }
+
+ public Collection<Object> getPolicies(PolicySubject subject, QName policyName) {
+ Collection<Object> policies = new ArrayList<Object>();
+ for (PolicySet ps : subject.getPolicySets()) {
+ for (PolicyExpression exp : ps.getPolicies()) {
+ if (exp.getName().equals(policyName)) {
+ policies.add(exp.getPolicy());
+ }
+ }
+ }
+ return policies;
+ }
+
+ public static PolicySet getPolicySet(Binding wsBinding, QName intentName) {
+ PolicySet returnPolicySet = null;
+
+ if (wsBinding instanceof PolicySubject) {
+ PolicySubject policiedBinding = (PolicySubject)wsBinding;
+ for (PolicySet policySet : policiedBinding.getPolicySets()) {
+ for (Intent intent : policySet.getProvidedIntents()) {
+ if (intent.getName().equals(intentName)) {
+ returnPolicySet = policySet;
+ break;
+ }
+ }
+ }
+ }
+
+ return returnPolicySet;
+ }
+
+ public static boolean isIntentRequired(Binding wsBinding, QName intent) {
+ if (wsBinding instanceof PolicySubject) {
+ List<Intent> intents = ((PolicySubject)wsBinding).getRequiredIntents();
+ for (Intent i : intents) {
+ if (intent.equals(i.getName())) {
+ return true;
+ }
+ }
+ }
+ return getPolicySet(wsBinding, intent) != null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
new file mode 100644
index 0000000000..20189eae98
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.assembly.DefaultAssemblyFactory
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory
new file mode 100644
index 0000000000..6e24d0bcfd
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.assembly.impl.SCABindingFactoryImpl
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint
new file mode 100644
index 0000000000..61171ac041
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.assembly.builder.DefaultBuilderExtensionPoint
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory
new file mode 100644
index 0000000000..c1cb41d967
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org.apache.tuscany.sca.definitions.DefaultDefinitionsFactory
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper
new file mode 100644
index 0000000000..e2da378609
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl
+
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory
new file mode 100644
index 0000000000..6ff07189e1
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.policy.DefaultPolicyFactory
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties
new file mode 100644
index 0000000000..8ded10c9db
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties
@@ -0,0 +1,327 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+# C.1 Mandatory Items
+ASM13001=\
+An SCA runtime MUST reject a composite file that does not conform to the sca-core.xsd, sca-interface-wsdl.xsd, sca-implementation-composite.xsd and sca-binding-sca.xsd schema.
+ASM13002=\
+An SCA runtime MUST reject a contribution file that does not conform to the sca-contribution.xsd schema.
+ASM13003=\
+An SCA runtime MUST reject a definitions file that does not conform to the sca-definitions.xsd schema.
+ASM40001=\
+The extension of a componentType side file name MUST be .componentType.
+ASM40002=\
+If present, the @constrainingType attribute of a <componentType/> element MUST reference a <constrainingType/> element in the Domain through its QName.
+ASM40003=\
+The @name attribute of a <service/> child element of a <componentType/> MUST be unique amongst the service elements of that <componentType/>.
+ASM40004=\
+The @name attribute of a <reference/> child element of a <componentType/> MUST be unique amongst the reference elements of that <componentType/>.
+ASM40005=\
+The @name attribute of a <property/> child element of a <componentType/> MUST be unique amongst the property elements of that <componentType/>.
+ASM40006=\
+If @wiredByImpl is set to "true", then any reference targets configured for this reference MUST be ignored by the runtime.
+ASM40007=\
+The value of the property @type attribute MUST be the QName of an XML schema type.
+ASM40008=\
+The value of the property @element attribute MUST be the QName of an XSD global element.
+ASM40009=\
+The SCA runtime MUST ensure that any implementation default property value is replaced by a value for that property explicitly set by a component using that implementation.
+ASM40010=\
+A single property element MUST NOT contain both a @type attribute and an @element attribute.
+ASM40011=\
+When the componentType has @mustSupply="true" for a property element, a component using the implementation MUST supply a value for the property since the implementation has no default value for the property.
+ASM50001=\
+The @name attribute of a <component/> child element of a <composite/> MUST be unique amongst the component elements of that <composite/>
+ASM50002=\
+The @name attribute of a service element of a <component/> MUST be unique amongst the service elements of that <component/>
+ASM50003=\
+The @name attribute of a service element of a <component/> MUST match the @name attribute of a service element of the componentType of the <implementation/> child element of the component.
+ ASM50004=\
+If an interface is declared for a component service, the interface MUST provide a compatible subset of the interface declared for the equivalent service in the componentType of the implementation
+ ASM50005=\
+If no binding elements are specified for the service, then the bindings specified for the equivalent service in the componentType of the implementation MUST be used, but if the componentType also has no bindings specified, then <binding.sca/> MUST be used as the binding. If binding elements are specified for the service, then those bindings MUST be used and they override any bindings specified for the equivalent service in the componentType of the implementation.
+ASM50006=\
+If the callback element is present and contains one or more binding child elements, then those bindings MUST be used for the callback.
+ASM50007=\
+The @name attribute of a reference element of a <component/> MUST be unique amongst the reference elements of that <component/>
+
+ASM50008=\
+The @name attribute of a reference element of a <component/> MUST match the @name attribute of a reference element of the componentType of the <implementation/> child element of the component.
+ASM50009=\
+The value of multiplicity for a component reference MUST only be equal or further restrict any value for the multiplicity of the reference with the same name in the componentType of the implementation, where further restriction means 0..n to 0..1 or 1..n to 1..1.
+ASM50010=\
+If @wiredByImpl="true" is set for a reference, then the reference MUST NOT be wired statically within a composite, but left unwired.
+ ASM50011=\
+If an interface is declared for a component reference, the interface MUST provide a compatible superset of the interface declared for the equivalent reference in the componentType of the implementation.
+ASM50012=\
+If no binding elements are specified for the reference, then the bindings specified for the equivalent reference in the componentType of the implementation MUST be used. If binding elements are specified for the reference, then those bindings MUST be used and they override any bindings specified for the equivalent reference in the componentType of the implementation.
+ASM50013=\
+If @wiredByImpl="true", other methods of specifying the target service MUST NOT be used.
+ASM50014=\
+If @autowire="true", the autowire procedure MUST only be used if no target is identified by any of the other ways listed above. It is not an error if @autowire="true" and a target is also defined through some other means, however in this case the autowire procedure MUST NOT be used.
+ASM50015=\
+If a binding element has a value specified for a target service using its @uri attribute, the binding element MUST NOT identify target services using binding specific attributes or elements.
+ASM50016=\
+It is possible that a particular binding type uses more than a simple URI for the address of a target service. In cases where a reference element has a binding subelement that uses more than simple URI, the @uri attribute of the binding element MUST NOT be used to identify the target service - in this case binding specific attributes and/or child elements MUST be used.
+ASM50018=\
+A reference with multiplicity 0..1 or 0..n MAY have no target service defined.
+ASM50019=\
+A reference with multiplicity 0..1 or 1..1 MUST NOT have more that one target service defined.
+ASM50020=\
+A reference with multiplicity 1..1 or 1..n MUST have at least one target service defined.
+ASM50021=\
+A reference with multiplicity 0..n or 1..n MAY have one or more target services defined.
+ASM50022=\
+Where it is detected that the rules for the number of target services for a reference have been violated, either at deployment or at execution time, an SCA Runtime MUST raise an error no later than when the reference is invoked by the component implementation.
+ASM50025=\
+Where a component reference is promoted by a composite reference, the promotion MUST be treated from a multiplicity perspective as providing 0 or more target services for the component reference, depending upon the further configuration of the composite reference. These target services are in addition to any target services identified on the component reference itself, subject to the rules relating to multiplicity.
+ASM50026=\
+If a reference has a value specified for one or more target services in its @target attribute, there MUST NOT be any child <binding/> elements declared for that reference.
+ASM50027=\
+If the @value attribute of a component property element is declared, the type of the property MUST be an XML Schema simple type and the @value attribute MUST contain a single value of that type.
+ASM50028=\
+If the value subelement of a component property is specified, the type of the property MUST be an XML Schema simple type or an XML schema complex type.
+ASM50029=\
+If a component property value is declared using a child element of the <property/> element, the type of the property MUST be an XML Schema global element and the declared child element MUST be an instance of that global element.
+ASM50030=\
+A <component/> element MUST NOT contain two <property/> subelements with the same value of the @name attribute.
+ASM50031=\
+The @name attribute of a property element of a <component/> MUST be unique amongst the property elements of that <component/>.
+ASM50032
+If a property is single-valued, the <value/> subelement MUST NOT occur more than once.
+ASM50033=\
+A property <value/> subelement MUST NOT be used when the @value attribute is used to specify the value for that property.
+ASM50034=\
+If any <wire/> element with its @replace attribute set to "true" has a particular reference specified in its @source attribute, the value of the @target attribute for that reference MUST be ignored and MUST NOT be used to define target services for that reference.
+ASM50035=\
+A single property element MUST NOT contain both a @type attribute and an @element attribute.
+ASM50036=\
+The property type specified for the property element of a component MUST be compatible with the type of the property with the same @name declared in the component type of the implementation used by the component. If no type is declared in the component property element, the type of the property declared in the componentType of the implementation MUST be used.
+ASM50037=\
+The @name attribute of a property element of a <component/> MUST match the @name attribute of a property element of the componentType of the <implementation/> child element of the component.
+ASM50038=\
+In these cases where the types of two property elements are matched, the types declared for the two <property/> elements MUST be compatible
+ASM50039=\
+A reference with multiplicity 0..1 MUST have no more than one target service defined.
+ASM50040=\
+A reference with multiplicity 1..1 MUST have exactly one target service defined.
+ASM50041=\
+A reference with multiplicity 1..n MUST have at least one target service defined.
+ASM50042=\
+If a component reference has @multiplicity 0..1 or 1..1 and @nonOverridable==true, then the component reference MUST NOT be promoted by any composite reference.
+ASM60001=\
+A composite @name attribute value MUST be unique within the namespace of the composite.
+ASM60002=\
+@local="true" for a composite means that all the components within the composite MUST run in the same operating system process.
+ASM60003=\
+The name of a composite <service/> element MUST be unique across all the composite services in the composite.
+ASM60004=\
+A composite <service/> element's @promote attribute MUST identify one of the component services within that composite.
+ASM60005=\
+If a composite service interface is specified it MUST be the same or a compatible subset of the interface provided by the promoted component service.
+ASM60006=\
+The name of a composite <reference/> element MUST be unique across all the composite references in the composite.
+ASM60007=\
+Each of the URIs declared by a composite reference's @promote attribute MUST identify a component reference within the composite.
+ASM60008=\
+the interfaces of the component references promoted by a composite reference MUST be the same, or if the composite reference itself declares an interface then each of the component reference interfaces MUST be a compatible subset of the composite reference interface..
+ASM60009=\
+the intents declared on a composite reference and on the component references which it promoites MUST NOT be mutually exclusive.
+ASM60010=\
+If any intents in the set which apply to a composite reference are mutually exclusive then the SCA runtime MUST raise an error.
+ASM60011=\
+The value specified for the @multiplicity attribute of a composite reference MUST be compatible with the multiplicity specified on each of the component references which it promotes, i.e. the multplicity of the composite reference MUST be equal to or further restrict the multiplicity of the component reference, except for the case where all the promoted component references have at least one target declared in which case a composite reference of 0..1 is compatble with component references of 1..1 and composite reference of 0..n is compatible with component references of 1..n.
+ASM60012=\
+If a composite reference has an interface specified, it MUST provide an interface which is the same or which is a compatible superset of the interface(s) declared by the promoted component reference(s).
+ASM60013=\
+If no interface is declared on a composite reference, the interface from one of its promoted component references MUST be used for the component type associated with the composite.
+ASM60014=\
+The @name attribute of a composite property MUST be unique amongst the properties of the same composite.
+ASM60022=\
+For each component reference for which autowire is enabled, the SCA runtime MUST search within the composite for target services which have an interface that is a compatible superset of the interface of the reference.
+ASM60024=\
+The intents, and policies applied to the service MUST be compatible with those on the reference when using autowire to wire a reference - so that wiring the reference to the service will not cause an error due to policy mismatch
+ASM60025=\
+for an autowire reference with multiplicity 0..1 or 1..1, the SCA runtime MUST wire the reference to one of the set of valid target services chosen from the set in a runtime-dependent fashion
+ASM60026=\
+for an autowire reference with multiplicity 0..n or 1..n, the reference MUST be wired to all of the set of valid target services
+ASM60027=\
+for an autowire reference with multiplicity 0..1 or 0..n, if the SCA runtime finds no valid target service, there is no problem - no services are wired and the SCA runtime MUST NOT raise an error
+ASM60028=\
+for an autowire reference with multiplicity 1..1 or 1..n, if the SCA runtime finds no valid target services an error MUST be raised by the SCA runtime since the reference is intended to be wired
+ASM60030=\
+The @name attribute of an <implementation.composite/> element MUST contain the QName of a composite in the SCA Domain.
+ASM60031=\
+The SCA runtime MUST raise an error if the composite resulting from the inclusion of one composite into another is invalid.
+ASM60032=\
+For a composite used as a component implementation, each composite service offered by the composite MUST promote a component service of a component that is within the composite.
+ASM60033=\
+For a composite used as a component implementation, every component reference of components within the composite with a multiplicity of 1..1 or 1..n MUST be wired or promoted.
+ASM60034=\
+For a composite used as a component implementation, all properties of components within the composite, where the underlying component implementation specifies "mustSupply=true" for the property, MUST either specify a value for the property or source the value from a composite property.
+ASM60035=\
+All the component references promoted by a single composite reference MUST have the same value for @wiredByImpl.
+ASM60036=\
+If the @wiredByImpl attribute is not specified on the composite reference, the default value is "true" if all of the promoted component references have a wiredByImpl value of "true", and the default value is "false" if all the promoted component references have a wiredByImpl value of "false". If the @wiredByImpl attribute is specified, its value MUST be "true" if all of the promoted component references have a wiredByImpl value of "true", and its value MUST be "false" if all the promoted component references have a wiredByImpl value of "false".
+ASM60037=\
+<include/> processing MUST take place before the processing of the @promote attribute of a composite reference is performed.
+ASM60038=\
+<include/> processing MUST take place before the processing of the @promote attribute of a composite service is performed.
+ASM60039=\
+<include/> processing MUST take place before the @source and @target attributes of a wire are resolved.
+ASM60040=\
+A single property element MUST NOT contain both a @type attribute and an @element attribute.
+ASM60041=\
+If the included composite has the value true for the attribute @local then the including composite MUST have the same value for the @local attribute, else it is an error.
+ASM60042=\
+The @name attribute of an include element MUST be the QName of a composite in the SCA Domain.
+ASM60043=\
+The interface declared by the target of a wire MUST be a compatible superset of the interface declared by the source of the wire.
+ASM60044=\
+If the composite reference promotes multiple component references with different multiplicities, there is no default value for the @multiplicity attribute of the composite reference and a value for @multiplicity MUST be specified.
+ASM70001=\
+The constrainingType specifies the services, references and properties that MUST be provided by the implementation of the component to which the constrainingType is attached.
+ASM70002=\
+If the configuration of the component or its implementation does not conform to the constrainingType specified on the component element, the SCA runtime MUST raise an error.
+ASM70003=\
+The @name attribute of the constraining type MUST be unique in the SCA Domain.
+ASM70004=\
+When an implementation is constrained by a constrainingType its component type MUST contain all the services, references and properties specified in the constrainingType.
+ASM70005=\
+An implementation that is constrained by a constrainingType MUST NOT contain additional references with @multiplicity=1..1 or @multiplicity=1..n or additional properties with @mustSupply=true
+ASM70006=\
+Additional services, references and properties provided by the implementation which are not declared in the constrainingType associated with a component MUST NOT be configured in any way by the containing composite.
+ASM70007=\
+When an implementation is constrained by a constrainingType and the constrainingType declares an interface for a service or for a reference, then the component type of the implementation MUST contain a declaration of a compatiible interface for that service or reference.
+ASM80001=\
+The interface.wsdl @interface attribute MUST reference a portType of a WSDL 1.1 document.
+ASM80002=\
+Remotable service Interfaces MUST NOT make use of method or operation overloading.
+ASM80003=\
+If a remotable service is called locally or remotely, the SCA container MUST ensure sure that no modification of input messages by the service or post-invocation modifications to return messages are seen by the caller.
+ASM80004=\
+If a reference is defined using a bidirectional interface element, the client component implementation using the reference calls the referenced service using the interface. The client MUST provide an implementation of the callback interface.
+ASM80005=\
+Either both interfaces of a bidirectional service MUST be remotable, or both MUST be local. A bidirectional service MUST NOT mix local and remote services.
+ASM80008=\
+Any service or reference that uses an interface marked with intents MUST implicitly add those intents to its own @requires list.
+ASM80009=\
+In a bidirectional interface, the service interface can have more than one operation defined, and the callback interface can also have more than one operation defined. SCA runtimes MUST allow an invocation of any operation on the service interface to be followed by zero, one or many invocations of any of the operations on the callback interface.
+ASM80010=\
+Whenever an interface document declaring a callback interface is used in the declaration of an <interface/> element in SCA, it MUST be treated as being bidirectional with the declared callback interface.
+ASM80011=\
+If an <interface/> element references an interface document which declares a callback interface and also itself contains a declaration of a callback interface, the two callback interfaces MUST be compatible.
+ASM80016=\
+The interface.wsdl @callbackInterface attribute, if present, MUST reference a portType of a WSDL 1.1 document.
+ASM80017=\
+WSDL interfaces are always remotable and therefore an <interface.wsdl/> element MUST NOT contain remotable="false".
+ASM90001=\
+For a binding of a reference the @uri attribute defines the target URI of the reference. This MUST be either the componentName/serviceName for a wire to an endpoint within the SCA Domain, or the accessible address of some service endpoint either inside or outside the SCA Domain (where the addressing scheme is defined by the type of the binding).
+ASM90002=\
+When a service or reference has multiple bindings, only one binding can have the default @name value; all others MUST have a @name value specified that is unique within the service or reference.
+ASM90003=\
+If a reference has any bindings, they MUST be resolved, which means that each binding MUST include a value for the @uri attribute or MUST otherwise specify an endpoint. The reference MUST NOT be wired using other SCA mechanisms.
+ ASM90004=\
+To wire to a specific binding of a target service the syntax "componentName/serviceName/bindingName" MUST be used.
+ASM10001=\
+all of the QNames for the definitions contained in definitions.xml files MUST be unique within the Domain.
+ASM10002=\
+An SCA runtime MUST make available to the Domain all the artifacts contained within the definitions.xml files in the Domain.
+ASM10003=\
+An SCA runtime MUST reject a definitions.xml file that does not conform to the sca-definitions.xsd schema.
+ASM12001=\
+For any contribution packaging it MUST be possible to present the artifacts of the packaging to SCA as a hierarchy of resources based off of a single root
+ASM12005=\
+Where present, artifact-related or packaging-related artifact resolution mechanisms MUST be used by the SCA runtime to resolve artifact dependencies.
+ASM12006=\
+SCA requires that all runtimes MUST support the ZIP packaging format for contributions.
+ASM12009=\
+if there is ever a conflict between two indirect dependent contributions, then the conflict MUST be resolved by an explicit entry in the dependent contribution list.
+ASM12010=\
+Where present, non-SCA artifact resolution mechanisms MUST be used by the SCA runtime in precendence to the SCA mechanisms.
+ ASM12011=\
+If one of the non-SCA artifact resolution mechanisms is present, but there is a failure to find the resource indicated when using the mechanism (e.g. the URI is incorrect or invalid, say) the SCA runtime MUST raise an error and MUST NOT attempt to use SCA resolution mechanisms as an alternative.
+ASM12012=\
+The value of @autowire for the logical Domain composite MUST be autowire="false".
+ASM12013=\
+For components at the Domain level, with references for which @autowire="true" applies, the behaviour of the SCA runtime for a given Domain MUST take ONE of the 3 following forms:\
+1) The SCA runtime disallows deployment of any components with autowire references. In this case, the SCA runtime MUST raise an exception at the point where the component is deployed.\
+2) The SCA runtime evaluates the target(s) for the reference at the time that the component is deployed and does not update those targets when later deployment actions occur. \
+3) The SCA runtime re-evaluates the target(s) for the reference dynamically as later deployment actions occur resulting in updated reference targets which match the new Domain configuration. How the reconfiguration of the reference takes place is described by the relevant client and implementation specifications.
+ASM12015=\
+Where components are updated by deployment actions (their configuration is changed in some way, which includes changing the wires of component references), the new configuration MUST apply to all new instances of those components once the update is complete.
+ASM12017=\
+Where a component that is the target of a wire is removed, without the wire being changed, then future invocations of the reference that use that wire SHOULD fail with a ServiceUnavailable fault. If the wire is the result of the autowire process, the SCA runtime MUST:\
+* either cause future invocation of the target component's services to fail with a ServiceUnavailable fault\
+* or alternatively, if an alternative target component is available that satisfies the autowire process, update the reference of the source component
+ASM12020=\
+Where a component is added to the Domain that is a potential target for a domain level component reference where that reference is marked as @autowire=true, the SCA runtime MUST:\
+- either update the references for the source component once the new component is running. \
+- or alternatively, defer the updating of the references of the source component until the source component is stopped and restarted.
+ASM12021=\
+The SCA runtime MUST raise an error if an artifact cannot be resolved using these mechanisms, if present.
+ASM12022=\
+There can be multiple import declarations for a given namespace. Where multiple import declarations are made for the same namespace, all the locations specified MUST be searched in lexical order.
+ASM12023=\
+When a contribution contains a reference to an artifact from a namespace that is declared in an import statement of the contribution, if the SCA artifact resolution mechanism is used to resolve the artifact, the SCA runtime MUST resolve artifacts in the following order:\
+1. from the locations identified by the import statement(s) for the namespace. Locations MUST NOT be searched recursively in order to locate artifacts (i.e. only a one-level search is performed).\
+2. from the contents of the contribution itself.
+ASM12024=\
+The SCA runtime MUST ignore local definitions of an artifact if the artifact is found through resolving an import statement.
+ASM12025=\
+The SCA runtime MUST raise an error if an artifact cannot be resolved by using artifact-related or packaging-related artifact resolution mechanisms, if present, by searching locations identified by the import statements of the contribution, if present, and by searching the contents of the contribution.
+ASM12026=\
+An SCA runtime MUST make the <import/> and <export/> elements found in the META-INF/sca-contribution.xml and META-INF/sca-contribution-generated.xml files available for the SCA artifact resolution process.
+ASM12027=\
+An SCA runtime MUST reject files that do not conform to the schema declared in sca-contribution.xsd.
+ASM12028=\
+An SCA runtime MUST merge the contents of sca-contribution-generated.xml into the contents of sca-contribution.xml, with the entries in sca-contribution.xml taking priority if there are any conflicting declarations.
+ASM12031=\
+When a contribution uses an artifact contained in another contribution through SCA artifact resolution, if that artifact itself has dependencies on other artifacts, the SCA runtime MUST resolve these dependencies in the context of the contribution containing the artifact, not in the context of the original contribution.
+ASM14003=\
+Where errors are only detected at runtime, when the error is detected an error MUST be raised to the component that is attempting the activity concerned with the error.
+
+# C.2 Non-mandatory Items
+ASM60021=\
+For the case of an un-wired reference with multiplicity 1..1 or 1..n the deployment process provided by an SCA runtime SHOULD issue a warning.
+ASM12002=\
+Within any contribution packaging A directory resource SHOULD exist at the root of the hierarchy named META-INF
+ASM12003=\
+Within any contribution packaging a document SHOULD exist directly under the META-INF directory named sca-contribution.xml which lists the SCA Composites within the contribution that are runnable.
+ASM12007=\
+Implementations of SCA MAY also raise an error if there are conflicting names exported from multiple contributions.
+ASM12008=\
+An SCA runtime MAY provide the contribution operation functions (install Contribution, update Contribution, add Deployment Composite, update Deployment Composite, remove Contribution).
+ASM12014=\
+Where <wire/> elements are added, removed or replaced by deployment actions, the components whose references are affected by those deployment actions MAY have their references updated by the SCA runtime dynamically without the need to stop and start those components.
+ASM12016=\
+An SCA runtime MAY choose to maintain existing instances with the old configuration of components updated by deployment actions, but an SCA runtime MAY choose to stop and discard existing instances of those components.
+ASM12018=\
+Where a component that is the target of a wire is updated, future invocations of that reference SHOULD use the updated component.
+ASM12029=\
+An SCA runtime MAY deploy the composites in <deployable/> elements found in the META-INF/sca-contribution.xml and META-INF/sca-contribution-generated.xml files.
+ASM12030=\
+For XML definitions, which are identified by QNames, the @namespace attribute of the export element SHOULD be the namespace URI for the exported definitions.
+ASM14001=\
+An SCA runtime SHOULD detect errors at deployment time where those errors can be found through static analysis.
+ASM14002=\
+The SCA runtime SHOULD prevent deployment of contributions that are in error, and raise the error to the process performing the deployment (e.g. write a message to an interactive console or write a message to a log file).
+ASM14004=\
+When an error that could have been detected through static analysis is detected and raised at runtime for a component, the component SHOULD NOT be run until the error is fixed.
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
new file mode 100644
index 0000000000..fe92f5eab3
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
@@ -0,0 +1,83 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+DuplicateComponentName = [ASM50001] Duplicate component name: Composite = {0} Component = {1}
+DuplicateComponentServiceName = Duplicate component service name: Component = {0} Service = {1}
+DuplicateComponentReferenceName = Duplicate component reference name: Component = {0} Reference = {1}
+DuplicateComponentPropertyName = Duplicate component property name: Component = {0} Property = {1}
+NoComponentImplementation = No implementation for component: Component = {0}
+ServiceNotFoundForComponentService = Component type service not found for component service (missing @Remotable annotation?): Component = {0} Service = {1}
+UnresolvedComponentImplementation = [ASM60030,JCI50004,JCI80001] Component implementation not resolved: Component = {0} Uri = {1}
+DuplicateImplementationPropertyName = [ASM40005,ASM60014] Duplicate implementation property name: Component = {0} Property = {1}
+DuplicateImplementationServiceName = [ASM40003,ASM60003,JCA90045] Duplicate implementation service name: Component = {0} Service = {1}
+DuplicateImplementationReferenceName = [ASM40004,ASM50007,ASM60006] Duplicate implementation reference name: Component = {0} Reference = {1}
+PropertyNotFound = [ASM50031] Property not found for component property: Component = {0} Property = {1}
+PropertyMustSupplyIncompatible = Component property mustSupply attribute incompatible with property: Component = {0} Property = {1}
+PropertyMustSupplyNull = [ASM40011,ASM60034] No value configured on a mustSupply property: Component = {0} Property = {1}
+PropertyOverrideManyAttribute = Component property many attribute incompatible with property: Component = {0} Property = {1}
+ReferenceNotFoundForComponentReference = [ASM50008] Component type reference not found for component reference: Component = {0} Reference = {1}
+CompositeReferenceIncompatibleMultiplicity = [ASM60011] Composite reference multiplicity incompatible with component reference multiplicity: Composite = {0} Composite reference = {1} Component reference = {2}
+ReferenceIncompatibleMultiplicity = [ASM50009] Component reference multiplicity incompatible with reference multiplicity: Component = {0} Reference = {1}
+ReferenceIncompatibleInterface = Incompatible interfaces on component reference and target: Composite = {0} Reference = {1} Service = {2}
+ReferencePromotionIncompatibleInterface = Promoted reference interface incompatible with promoting reference: Promoting interface = {0} Promoted = {1}
+ReferencePromotionInterfacesNotEqual = Peer promoted references not equal: First interface = {0} second interface = {1}
+ReferenceIncompatibleComponentInterface = [JCA30001,JCA30002,JCA30003,JCA90046] Component reference interface incompatible with implementation reference interface: Component = {0} Reference = {1} {2}
+ServiceIncompatibleComponentInterface = [ASM50004,JCA30002,JCI80001] Component service interface incompatible with implementation service interface: Component = {0} Service = {1} {2}
+MultipleBindingsForService = Multiple bindings with the same name for a service: Service = {0} Binding name = {1}
+MultipleBindingsForReference = Multiple bindings with the same name for a reference: Reference = {0} Binding name = {1}
+ReferenceWithoutTargets = [ASM60033] No targets for reference: Composite = {0} Reference = {1}
+PromotedReferenceNotFound = [ASM60007] Promoted component reference not found: Composite = {0} Reference = {1}
+PromotedServiceNotFound = [ASM60004,ASM60032] Promoted component service not found: Composite = {0} Service = {1}
+NoSCABindingAvailableForUnresolvedService = A local service cannot be found for reference {0} target {1} and there is no SCA binding available to represent the unresolved target
+NoMatchingBinding = Component reference {0} does not have a binding which matches the bindings of service {1}
+NoMatchingCallbackBinding = Component reference {0} does not have a callback binding which matches the callback bindings of service {1}
+ReferenceEndPointMixWithTarget = [ASM50026] Composite {0} Component {1} Reference {2} must not specify endpoints using both target attribute and with a binding child element
+CompositeAlreadyIncluded = Composite {0} has already been included.
+ComponentReferenceMoreWire = Component reference {0} has more than one wires
+WireTargetNotFound = Wire target not found : {0}
+WireSourceNotFound = Wire source not found : {0}
+WireIncompatibleInterface = Incompatible interfaces on wire source and target : source = {0} target = {1}
+ComponentIncompatibleInterface = Incompatible interfaces on component reference and target : reference = {0} target = {1}
+TooManyReferenceTargets = [ASM50022] Too many targets on reference: {0}
+ReferenceInterfaceNotSubSet = [ASM60008,ASM60013] Interface of composite reference {0} must be compatible with the interface declared by promoted component reference. {1}
+ServiceInterfaceNotSubSet = Interface of composite service {0} must be subset of the interface declared by promoted component service. {1}
+NoComponentReferenceTarget = [ASM60028] No target services found for the component reference to be autowired: {0}
+NoTypeForComponentProperty = No type specified on component property: Component = {0} Property = {1}
+URLSyntaxException = URLSyntaxException when creating binding URI at component = {0} service = {1} binding = {2}
+IllegalCompositeIncusion = Local Composite {0} cannot include a non-local composite {1}
+PropertySourceNotFound = The property source {0} for property {1} in component {2} cannot be resolved to a composite property
+PropertySourceValueInvalid = The property source {0} for property {1} in component {2} has an invalid value. It should start with $ followed by the name of a composite property
+PropertySourceXPathInvalid = The property source {0} for property {1} in component {2} has an invalid XPath expression. The following error was returned while processing the XPath expression: {3}
+PropertyFileValueInvalid = The property file {0} for property {1} in component {2} is an invalid value. The following error was returned while processing the file name: {3}
+PolicyRelatedException = Policy Related Exception occured due to : {0}
+IntentNotFound = Intent {0} is not defined in SCA definitions
+PolicySetNotFound = PolicySet {0} is not defined in SCA definitions
+MutuallyExclusiveIntents = [POL40009,ASM60009,ASM60010] Intent {0} and {1} are mutually exclusive
+PropertyXpathExpressionReturnedNull = The property XPath expression for component {0} property {1} expression {2} did not match anything in the source property
+PropertyHasManyValues = [ASM50032] The property component {0} property {1} has many values but its "many" attribute is set to false
+PropertXSDTypesDontMatch = [ASM_5036] The property component {0} property {1} has XSD type {2} while its component type property has the XSD type {3}
+PropertXSDElementsDontMatch = [ASM_5036] The property component {0} property {1} has XSD element {2} while its component type property has the XSD element {3}
+IntentNotSatisfied = The intent {0} associated with policy subject {1} has no matching policy set
+URIFoundOnServiceSCABinding = [ASM90005] The SCA binding {0} on component {1} service {2} should not have a URI and the URI is currently set to {3}
+CompositeReferencePromotesNonOverridableReference = [ASM50042] Composite reference promotes component reference with 1..1 multiplicity and nonOverridable flag set true: Composite = {0} Composite reference = {1} Component reference = {2}
+PropertyValueDoesNotMatchSimpleType = [ASM50027] The property {0} on component {1} has a value which does not match the simple type {2} with which it is associated
+PropertyValueDoesNotMatchComplexType = [ASM50038] The property {0} on component {1} has a value which does not match the complex type {2} with which it is associated. Validation reported {3}
+PropertyValueDoesNotMatchElement = [ASM50029] The property {0} on component {1} has a value which does not match the element {2} with which it is associated. Validation reported {3}
+EPRIncompatibleInterface = [BWS20007] The reference interface is incompatible with the interface of the reference binding {0}
+EPIncompatibleInterface = [BWS20007] The service interface is incompatible with the interface of the service binding {0}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties
new file mode 100644
index 0000000000..b94d37ba2d
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties
@@ -0,0 +1,30 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+DuplicateComponentName = Nome del componente duplicato: Composite = {0} Component = {1}
+DuplicateComponentServiceName = Nome del servizio del componente duplicato: Component = {0} Service = {1}
+DuplicateComponentReferenceName = Nome del reference del componente duplicato: Component = {0} Reference = {1}
+DuplicateComponentPropertyName = Nome della property del componente duplicato: Component = {0} Property = {1}
+NoComponentImplementation = Implementazione insistente per il componente: Component = {0}
+ServiceNotFoundForComponentService = Servizio non trovato per il componente: Component = {0} Service = {1}
+UnresolvedComponentImplementation = Implementazione del componente non trovata: Component = {0} Uri = {1}
+DuplicateImplementationPropertyName = Nome della property del componente duplicata: Component = {0} Property = {1}
+DuplicateImplementationReferenceName = Nome del riferimento duplicato: Component = {0} Reference = {1}
+PropertyNotFound = Property non trovata per il componente: Component = {0} Property = {1}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties
new file mode 100644
index 0000000000..d3905035b9
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties
@@ -0,0 +1,25 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+DuplicateIntent = [ASM10001,POL30002] Duplicate intent {0} found in domain
+DuplicatePolicysSet = Duplicate policy set {0} found in domain
+DuplicateImplementationType = Duplicate implementation type {0} found in domain
+DuplicateBindingType = [POL40020] Duplicate binding type {0} found in domain
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java
new file mode 100644
index 0000000000..20fd74d46e
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import javax.xml.namespace.QName;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test building of assembly model instances using the assembly factory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AssemblyFactoryTestCase {
+
+ private static AssemblyFactory assemblyFactory;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ assemblyFactory = new DefaultAssemblyFactory();
+ }
+
+ @Test
+ public void testCreateComponent() {
+ createComponent("AccountServiceComponent1");
+ }
+
+ @Test
+ public void testCreateComponentType() {
+ createComponentType();
+ }
+
+ @Test
+ public void testCreateComposite() {
+ createComposite();
+ }
+
+ /**
+ * Create a composite
+ */
+ Composite createComposite() {
+ Composite c = assemblyFactory.createComposite();
+
+ Component c1 = createComponent("AccountServiceComponent1");
+ c.getComponents().add(c1);
+ Component c2 = createComponent("AccountServiceComponent2");
+ c.getComponents().add(c2);
+
+ Wire w = assemblyFactory.createWire();
+ w.setSource(c1.getReferences().get(0));
+ w.setTarget(c2.getServices().get(0));
+ c.getWires().add(w);
+
+ CompositeService cs = assemblyFactory.createCompositeService();
+ cs.setName("AccountService");
+ cs.setPromotedService(c1.getServices().get(0));
+ cs.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ c.getServices().add(cs);
+ cs.getBindings().add(new TestBinding(assemblyFactory));
+
+ CompositeReference cr = assemblyFactory.createCompositeReference();
+ cr.setName("StockQuoteService");
+ cr.getPromotedReferences().add(c2.getReferences().get(1));
+ cr.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ c.getReferences().add(cr);
+ cr.getBindings().add(new TestBinding(assemblyFactory));
+
+ return c;
+ }
+
+ /**
+ * Create a new component
+ */
+ Component createComponent(String name) {
+ Component c = assemblyFactory.createComponent();
+ c.setName(name);
+
+ Implementation i = new TestImplementation(assemblyFactory);
+ c.setImplementation(i);
+
+ ComponentProperty p = assemblyFactory.createComponentProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ p.setProperty(i.getProperties().get(0));
+ c.getProperties().add(p);
+
+ ComponentReference ref1 = assemblyFactory.createComponentReference();
+ ref1.setName("accountDataService");
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ ref1.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ref1.setReference(i.getReferences().get(0));
+ c.getReferences().add(ref1);
+ ref1.getBindings().add(new TestBinding(assemblyFactory));
+
+ ComponentReference ref2 = assemblyFactory.createComponentReference();
+ ref2.setName("stockQuoteService");
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ref2.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ref2.setReference(i.getReferences().get(1));
+ c.getReferences().add(ref2);
+ ref2.getBindings().add(new TestBinding(assemblyFactory));
+
+ ComponentService s = assemblyFactory.createComponentService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ s.setService(i.getServices().get(0));
+ c.getServices().add(s);
+ s.getBindings().add(new TestBinding(assemblyFactory));
+
+ return c;
+ }
+
+ /**
+ * Create a new component type
+ *
+ * @return
+ */
+ ComponentType createComponentType() {
+ ComponentType ctype = assemblyFactory.createComponentType();
+
+ Property p = assemblyFactory.createProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ ctype.getProperties().add(p);
+
+ Reference ref1 = assemblyFactory.createReference();
+ ref1.setName("accountDataService");
+ ref1.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref1);
+ ref1.getBindings().add(new TestBinding(assemblyFactory));
+
+ Reference ref2 = assemblyFactory.createReference();
+ ref2.setName("stockQuoteService");
+ ref2.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref2);
+ ref2.getBindings().add(new TestBinding(assemblyFactory));
+
+ Service s = assemblyFactory.createService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ctype.getServices().add(s);
+ s.getBindings().add(new TestBinding(assemblyFactory));
+
+ return ctype;
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java
new file mode 100644
index 0000000000..a09f7af06c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.impl.BindingImpl;
+
+/**
+ * A test interface model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestBinding extends BindingImpl implements Binding {
+ private final static QName TYPE = new QName("http://test", "binding.test");
+
+ public TestBinding(AssemblyFactory factory) {
+ super(TYPE);
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public String getURI() {
+ return "http://test";
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java
new file mode 100644
index 0000000000..6777c33ff1
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+
+/**
+ * A test component implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestImplementation extends ImplementationImpl implements Implementation {
+ public TestImplementation(AssemblyFactory factory) {
+ super(new QName("http://test", "implementation.test"));
+ Property p = factory.createProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ getProperties().add(p);
+
+ Reference ref1 = factory.createReference();
+ ref1.setName("accountDataService");
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ getReferences().add(ref1);
+ ref1.getBindings().add(new TestBinding(factory));
+
+ Reference ref2 = factory.createReference();
+ ref2.setName("stockQuoteService");
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ref2.setInterfaceContract(new TestInterfaceContract(factory));
+ getReferences().add(ref2);
+ ref2.getBindings().add(new TestBinding(factory));
+
+ Service s = factory.createService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(factory));
+ getServices().add(s);
+ s.getBindings().add(new TestBinding(factory));
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java
new file mode 100644
index 0000000000..dbe0cb8225
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceImpl;
+
+/**
+ * A test interface model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestInterface extends InterfaceImpl implements Interface {
+
+ public TestInterface(AssemblyFactory factory) {
+
+ setRemotable(true);
+
+ Operation operation = new TestOperation();
+ operation.setName("test");
+ getOperations().add(operation);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java
new file mode 100644
index 0000000000..24be8a3e7d
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractImpl;
+
+/**
+ * A test interface contract model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestInterfaceContract extends InterfaceContractImpl implements InterfaceContract {
+
+ public TestInterfaceContract(AssemblyFactory factory) {
+
+ TestInterface testInterface = new TestInterface(factory);
+ setInterface(testInterface);
+
+ TestInterface testCallbackInterface = new TestInterface(factory);
+ setCallbackInterface(testCallbackInterface);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java
new file mode 100644
index 0000000000..d94a7e93a3
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+
+/**
+ * A test operation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestOperation extends OperationImpl {
+
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java
new file mode 100644
index 0000000000..603d393e5c
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java
@@ -0,0 +1,396 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef.impl;
+
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * TODO some tests commented out due to DataType.equals() needing to be strict
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContractCompatibilityTestCase {
+
+ private InterfaceContractMapper mapper;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ mapper = utilities.getUtility(InterfaceContractMapper.class);
+ }
+
+ @Test
+ public void testNoOperation() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ InterfaceContract target = new MockContract("FooContract");
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ @Test
+ public void testBasic() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ Operation opSource1 = newOperation("op1");
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+ InterfaceContract target = new MockContract("FooContract");
+ Operation opSource2 = newOperation("op1");
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opSource2);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ @Test
+ public void testBasicIncompatibleOperationNames() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ Operation opSource1 = newOperation("op1");
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+ InterfaceContract target = new MockContract("FooContract");
+ Operation opSource2 = newOperation("op2");
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op2", opSource2);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ try {
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ fail();
+ } catch (IncompatibleInterfaceContractException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testInputTypes() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ List<DataType> sourceInputTypes = new ArrayList<DataType>();
+ sourceInputTypes.add(new DataTypeImpl<Type>(Object.class, Object.class));
+ DataType<List<DataType>> inputType = new DataTypeImpl<List<DataType>>(String.class, sourceInputTypes);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setInputType(inputType);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ List<DataType> targetInputTypes = new ArrayList<DataType>();
+ targetInputTypes.add(new DataTypeImpl<Type>(Object.class, Object.class));
+ DataType<List<DataType>> targetInputType = new DataTypeImpl<List<DataType>>(String.class, targetInputTypes);
+
+ Operation opTarget = newOperation("op1");
+ opTarget.setInputType(targetInputType);
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ @Test
+ public void testIncompatibleInputTypes() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ List<DataType> sourceInputTypes = new ArrayList<DataType>();
+ sourceInputTypes.add(new DataTypeImpl<Type>(Integer.class, Integer.class));
+ DataType<List<DataType>> inputType = new DataTypeImpl<List<DataType>>(String.class, sourceInputTypes);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setInputType(inputType);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ List<DataType> targetInputTypes = new ArrayList<DataType>();
+ targetInputTypes.add(new DataTypeImpl<Type>(String.class, String.class));
+ DataType<List<DataType>> targetInputType = new DataTypeImpl<List<DataType>>(String.class, targetInputTypes);
+
+ Operation opTarget = newOperation("op1");
+ opTarget.setInputType(targetInputType);
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ try {
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ fail();
+ } catch (IncompatibleInterfaceContractException e) {
+ // expected
+ }
+ }
+
+ /**
+ * Verifies source input types can be super types of the target
+ */
+ @Test
+ public void testSourceSuperTypeInputCompatibility() throws Exception {
+ // InterfaceContract source = new MockContract("FooContract");
+ // List<DataType> sourceInputTypes = new ArrayList<DataType>();
+ // sourceInputTypes.add(new DataTypeImpl<Type>(Object.class,
+ // Object.class));
+ // DataType<List<DataType>> inputType = new
+ // DataTypeImpl<List<DataType>>(String.class, sourceInputTypes);
+ // Operation opSource1 = newOperationImpl("op1", inputType, null, null,
+ // false, null);
+ // Map<String, Operation> sourceOperations = new HashMap<String,
+ // Operation>();
+ // sourceOperations.put("op1", opSource1);
+ // source.getInterface().getOperations().addAll(sourceOperations.values());
+ //
+ // InterfaceContract target = new MockContract("FooContract");
+ // List<DataType> targetInputTypes = new ArrayList<DataType>();
+ // targetInputTypes.add(new DataTypeImpl<Type>(String.class,
+ // String.class));
+ // DataType<List<DataType>> targetInputType =
+ // new DataTypeImpl<List<DataType>>(String.class, targetInputTypes);
+ //
+ // Operation opTarget = newOperationImpl("op1", targetInputType, null,
+ // null, false, null);
+ // Map<String, Operation> targetOperations = new HashMap<String,
+ // Operation>();
+ // targetOperations.put("op1", opTarget);
+ // target.getInterface().getOperations().addAll(targetOperations.values());
+ // wireService.checkCompatibility(source, target, false);
+ }
+
+ @Test
+ public void testOutputTypes() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ DataType sourceOutputType = new DataTypeImpl<Type>(String.class, String.class);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setOutputType(sourceOutputType);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ DataType targetOutputType = new DataTypeImpl<Type>(String.class, String.class);
+ Operation opTarget = newOperation("op1");
+ opTarget.setOutputType(targetOutputType);
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ /**
+ * Verifies a return type that is a supertype of of the target is compatible
+ */
+ @Test
+ public void testSupertypeOutputTypes() throws Exception {
+ // InterfaceContract source = new MockContract("FooContract");
+ // DataType sourceOutputType = new DataTypeImpl<Type>(Object.class,
+ // Object.class);
+ // Operation opSource1 = newOperationImpl("op1", null,
+ // sourceOutputType, null, false, null);
+ // Map<String, Operation> sourceOperations = new HashMap<String,
+ // Operation>();
+ // sourceOperations.put("op1", opSource1);
+ // source.getInterface().getOperations().addAll(sourceOperations.values());
+ //
+ // InterfaceContract target = new MockContract("FooContract");
+ // DataType targetOutputType = new DataTypeImpl<Type>(String.class,
+ // String.class);
+ // Operation opTarget = newOperationImpl("op1", null, targetOutputType,
+ // null, false, null);
+ // Map<String, Operation> targetOperations = new HashMap<String,
+ // Operation>();
+ // targetOperations.put("op1", opTarget);
+ // target.getInterface().getOperations().addAll(targetOperations.values());
+ // wireService.checkCompatibility(source, target, false);
+ }
+
+ @Test
+ public void testIncompatibleOutputTypes() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ DataType sourceOutputType = new DataTypeImpl<Type>(String.class, String.class);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setOutputType(sourceOutputType);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ DataType targetOutputType = new DataTypeImpl<Type>(Integer.class, Integer.class);
+ Operation opTarget = newOperation("op1");
+ opTarget.setOutputType(targetOutputType);
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ try {
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ fail();
+ } catch (IncompatibleInterfaceContractException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testFaultTypes() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ DataType sourceFaultType = new DataTypeImpl<Type>(String.class, String.class);
+ List<DataType> sourceFaultTypes = new ArrayList<DataType>();
+ sourceFaultTypes.add(0, sourceFaultType);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setFaultTypes(sourceFaultTypes);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ DataType targetFaultType = new DataTypeImpl<Type>(String.class, String.class);
+ List<DataType> targetFaultTypes = new ArrayList<DataType>();
+ targetFaultTypes.add(0, targetFaultType);
+
+ Operation opTarget = newOperation("op1");
+ opTarget.setFaultTypes(targetFaultTypes);
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ @Test
+ public void testSourceFaultTargetNoFaultCompatibility() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ DataType sourceFaultType = new DataTypeImpl<Type>(String.class, String.class);
+ List<DataType> sourceFaultTypes = new ArrayList<DataType>();
+ sourceFaultTypes.add(0, sourceFaultType);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setFaultTypes(sourceFaultTypes);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ Operation opTarget = newOperation("op1");
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ /**
+ * Verifies a source's fault which is a supertype of the target's fault are
+ * compatible
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testFaultSuperTypes() throws Exception {
+ // InterfaceContract source = new MockContract("FooContract");
+ // DataType sourceFaultType = new DataTypeImpl<Type>(Exception.class,
+ // Exception.class);
+ // List<DataType> sourceFaultTypes = new ArrayList<DataType>();
+ // sourceFaultTypes.add(0, sourceFaultType);
+ // Operation opSource1 = newOperationImpl("op1", null, null,
+ // sourceFaultTypes, false, null);
+ // Map<String, Operation> sourceOperations = new HashMap<String,
+ // Operation>();
+ // sourceOperations.put("op1", opSource1);
+ // source.getInterface().getOperations().addAll(sourceOperations.values());
+ //
+ // InterfaceContract target = new MockContract("FooContract");
+ // DataType targetFaultType = new
+ // DataTypeImpl<Type>(TuscanyException.class, TuscanyException.class);
+ // List<DataType> targetFaultTypes = new ArrayList<DataType>();
+ // targetFaultTypes.add(0, targetFaultType);
+ //
+ // Operation opTarget = newOperationImpl("op1", null, null,
+ // targetFaultTypes, false, null);
+ // Map<String, Operation> targetOperations = new HashMap<String,
+ // Operation>();
+ // targetOperations.put("op1", opTarget);
+ // target.getInterface().getOperations().addAll(targetOperations.values());
+ // wireService.checkCompatibility(source, target, false);
+ }
+
+ /**
+ * Verifies a source's faults which are supertypes and a superset of the
+ * target's faults are compatible
+ */
+ @Test
+ public void testFaultSuperTypesAndSuperset() throws Exception {
+ // InterfaceContract source = new MockContract("FooContract");
+ // DataType sourceFaultType = new DataTypeImpl<Type>(Exception.class,
+ // Exception.class);
+ // DataType sourceFaultType2 = new
+ // DataTypeImpl<Type>(RuntimeException.class, RuntimeException.class);
+ // List<DataType> sourceFaultTypes = new ArrayList<DataType>();
+ // sourceFaultTypes.add(0, sourceFaultType);
+ // sourceFaultTypes.add(1, sourceFaultType2);
+ // Operation opSource1 = newOperationImpl("op1", null, null,
+ // sourceFaultTypes, false, null);
+ // Map<String, Operation> sourceOperations = new HashMap<String,
+ // Operation>();
+ // sourceOperations.put("op1", opSource1);
+ // source.getInterface().getOperations().addAll(sourceOperations.values());
+ //
+ // InterfaceContract target = new MockContract("FooContract");
+ // DataType targetFaultType = new
+ // DataTypeImpl<Type>(TuscanyException.class, TuscanyException.class);
+ // List<DataType> targetFaultTypes = new ArrayList<DataType>();
+ // targetFaultTypes.add(0, targetFaultType);
+ //
+ // Operation opTarget = newOperationImpl("op1", null, null,
+ // targetFaultTypes, false, null);
+ // Map<String, Operation> targetOperations = new HashMap<String,
+ // Operation>();
+ // targetOperations.put("op1", opTarget);
+ // target.getInterface().getOperations().addAll(targetOperations.values());
+ // wireService.checkCompatibility(source, target, false);
+ }
+
+ private static class MockInterface extends InterfaceImpl {
+
+ }
+
+ private class MockContract<T> extends InterfaceContractImpl {
+ public MockContract() {
+ }
+
+ public MockContract(String interfaceClass) {
+ Interface jInterface = new MockInterface();
+ setInterface(jInterface);
+ }
+ }
+
+ private static Operation newOperation(String name) {
+ Operation operation = new OperationImpl();
+ operation.setName(name);
+ return operation;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java
new file mode 100644
index 0000000000..d1faa5cf2b
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.impl;
+
+
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InterfaceContractTestCase {
+ private InterfaceContract contract;
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ contract = new MockInterfaceContract();
+ Interface i1 = new MockInterface();
+ contract.setInterface(i1);
+ Operation op1 = newOperation("op1");
+ i1.getOperations().add(op1);
+ Interface i2 = new MockInterface();
+ contract.setCallbackInterface(i2);
+ Operation callbackOp1 = newOperation("callbackOp1");
+ i2.getOperations().add(callbackOp1);
+ }
+
+ @Test
+ public void testClone() throws Exception {
+ InterfaceContract copy = (InterfaceContract) contract.clone();
+ Assert.assertNotNull(copy);
+ Assert.assertNotSame(copy.getCallbackInterface(), contract.getCallbackInterface());
+ Assert.assertNotSame(copy.getInterface(), contract.getInterface());
+ }
+
+ private static class MockInterfaceContract extends InterfaceContractImpl implements InterfaceContract {
+ }
+
+ private static class MockInterface extends InterfaceImpl implements Interface {
+ }
+
+ private static Operation newOperation(String name) {
+ Operation operation = new OperationImpl();
+ operation.setName(name);
+ return operation;
+ }
+}
diff --git a/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java
new file mode 100644
index 0000000000..2775c4ac71
--- /dev/null
+++ b/sandbox/sebastien/java/dynamic/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.xml.namespace.QName;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test building of policy model instances using the policy factory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyFactoryTestCase {
+
+ PolicyFactory factory;
+
+ @Before
+ public void setUp() throws Exception {
+ factory = new DefaultPolicyFactory();
+ }
+
+ @Test
+ public void testCreateIntent() {
+ Intent intent = factory.createIntent();
+ intent.setName(new QName("http://test", "reliability"));
+ assertEquals(intent.getName(), new QName("http://test", "reliability"));
+ }
+
+ @Test
+ public void testCreatePolicySet() {
+ PolicySet policySet = factory.createPolicySet();
+ policySet.setName(new QName("http://test", "reliability"));
+ assertEquals(policySet.getName(), new QName("http://test", "reliability"));
+ }
+}