summaryrefslogtreecommitdiffstats
path: root/sandbox/ant/sca/trunk/modules/assembly
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/LICENSE205
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/META-INF/MANIFEST.MF58
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/NOTICE6
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/pom.xml132
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/BaseAssemblyProcessor.java759
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ComponentTypeProcessor.java383
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java1031
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/Constants.java99
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ConstrainingTypeProcessor.java275
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/PolicySubjectProcessor.java253
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor21
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor21
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver20
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/assembly-xml-validation-messages.properties29
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java143
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/MultiplicityReadWriteTestCase.java86
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadAllTestCase.java151
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java225
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadTestCase.java91
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyAttributeTestCase.java135
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyElementTestCase.java149
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteLocalCompositeTestCase.java102
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java171
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolveTestCase.java103
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestAttributeProcessor.java61
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestPolicyProcessor.java82
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingFactoryImpl.java35
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingImpl.java186
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WireTestCase.java148
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteAllTestCase.java158
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteNamespacesTestCase.java95
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Calculator.composite59
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorComponent.constrainingType34
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorImpl.componentType31
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/JavaScriptReference.composite37
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Multiplicity.composite30
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/NestedCalculator.composite29
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/RMIBindingTest.composite43
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllCalculator.composite123
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllDivide.composite56
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllPolicyCalculator.composite126
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/another_test_definitions.xml96
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/local.composite27
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/test_definitions.xml206
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/LICENSE205
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/META-INF/MANIFEST.MF39
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/NOTICE6
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/pom.xml125
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java906
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java130
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java95
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java381
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java202
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java83
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java1047
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java101
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java127
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeModelResolver.java83
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java273
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java254
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java252
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor21
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor21
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver20
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/assembly-xml-validation-messages.properties29
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java151
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java86
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java151
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java224
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java91
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java132
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java147
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java100
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java171
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java103
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java61
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java82
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java35
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java186
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java148
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java158
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java95
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite59
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType34
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType31
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite32
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite29
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite44
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite127
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite56
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite125
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml96
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite27
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml206
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/LICENSE281
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/META-INF/MANIFEST.MF13
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/NOTICE23
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/pom.xml30
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema18
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-all.xsd32
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-ejb.xsd43
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-sca.xsd23
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-webservice.xsd34
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-contributions.xsd65
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-core.xsd348
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-definitions.xsd25
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-bpel.xsd43
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-composite.xsd23
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-java.xsd24
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-jee.xsd23
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-web.xsd24
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-interface-java.xsd23
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-interface-wsdl.xsd23
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-policy.xsd77
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca.xsd23
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-dwr.xsd41
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-http.xsd41
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-jsonrpc.xsd41
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-rmi.xsd40
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-implementation-node.xsd43
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca.xsd35
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/wsdli.xsd34
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/LICENSE281
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/META-INF/MANIFEST.MF13
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/NOTICE23
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/pom.xml31
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema18
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-1.1-cd03.xsd33
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd02.xsd167
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd02.xsd160
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd03.xsd20
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd02.xsd36
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd03.xsd86
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd02.xsd35
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd02.xsd35
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd03.xsd518
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd03.xsd31
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd02.xsd31
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd02.xsd57
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd03.xsd26
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd02.xsd54
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd01.xsd27
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd02.xsd41
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd02.xsd42
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd03.xsd29
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd03.xsd29
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd02.xsd105
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd02.xml243
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd41
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd41
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd41
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd40
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-node.xsd43
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd33
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/wsdli.xsd34
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/LICENSE205
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/META-INF/MANIFEST.MF44
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/NOTICE6
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/pom.xml57
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java77
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java122
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java43
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java28
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java169
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java43
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java64
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java43
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java39
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java132
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java88
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java109
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java59
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java79
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java124
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java44
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java56
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java72
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java95
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java31
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.java109
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference2.java126
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java44
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java65
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java27
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java49
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java29
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java66
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java40
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java87
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java27
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java36
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java41
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java85
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java29
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java39
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java42
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java44
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java33
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java51
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java45
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java51
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java145
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java80
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java43
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java616
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java395
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java74
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java430
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java165
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java165
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java187
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java78
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java135
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java105
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java76
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java536
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java212
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java123
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java119
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java309
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java232
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java232
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java94
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java74
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java202
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java83
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationException.java38
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java428
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtil.java273
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java213
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java207
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java88
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java93
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java46
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java36
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java130
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java45
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java77
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java67
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java148
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java93
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java111
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java71
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java135
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java162
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java57
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java62
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java108
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java88
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.java138
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java157
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java49
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java62
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java60
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java59
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java126
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java98
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java105
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory18
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointFactory18
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder35
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint18
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/resources/assembly-validation-messages.properties62
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/main/resources/assembly-validation-messages_it.properties30
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java214
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java45
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java61
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java42
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java41
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java30
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java132
-rw-r--r--sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtilTestCase.java229
272 files changed, 30143 insertions, 0 deletions
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/LICENSE b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/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/ant/sca/trunk/modules/assembly-xml-osoa/META-INF/MANIFEST.MF b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ac08036811
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/META-INF/MANIFEST.MF
@@ -0,0 +1,58 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.assembly.xml.osoa;version="2.0.0";
+ uses:="org.apache.tuscany.sca.definitions,
+ javax.xml.transform.dom,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.policy,
+ javax.xml.namespace,
+ org.apache.tuscany.sca.contribution.java,
+ javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.policy.util,
+ org.apache.tuscany.sca.assembly,
+ javax.xml.parsers,
+ org.apache.tuscany.sca.contribution,
+ org.apache.tuscany.sca.monitor,
+ org.w3c.dom,
+ org.apache.tuscany.sca.interfacedef,
+ org.apache.tuscany.sca.contribution.namespace,
+ javax.xml.xpath,
+ javax.xml.transform,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.interfacedef.impl"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA 1.0 (OSOA) XML Assembly Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397124328
+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.validation;resolution:=optional,
+ javax.xml.xpath,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.assembly.xml.osoa;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.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.policy.util;version="2.0.0",
+ org.w3c.dom,
+ org.xml.sax;resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.assembly.xml.osoa
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/NOTICE b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/pom.xml b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/pom.xml
new file mode 100644
index 0000000000..b22c700ead
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/pom.xml
@@ -0,0 +1,132 @@
+<?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-osoa</artifactId>
+ <name>Apache Tuscany SCA Assembly XML Model based on OSOA Spec</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-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-definitions</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy</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-contribution-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-namespace</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-java</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-definitions-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd-osoa</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/BaseAssemblyProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/BaseAssemblyProcessor.java
new file mode 100644
index 0000000000..4bb4d84316
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/BaseAssemblyProcessor.java
@@ -0,0 +1,759 @@
+/*
+ * 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.osoa;
+
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MANY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MULTIPLICITY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MUST_SUPPLY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.NAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ONE_N;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ONE_ONE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SCA10_NS;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TARGET;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TYPE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ZERO_N;
+import static org.apache.tuscany.sca.assembly.xml.osoa.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.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
+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.ContributionWriteException;
+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.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+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;
+ private Monitor monitor;
+
+ /**
+ * Constructs a new BaseArtifactProcessor.
+ * @param assemblyFactory
+ * @param policyFactory
+ */
+ @SuppressWarnings("unchecked")
+ protected BaseAssemblyProcessor(AssemblyFactory assemblyFactory,
+ PolicyFactory policyFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ StAXArtifactProcessor extensionProcessor,
+ Monitor monitor) {
+ this.assemblyFactory = assemblyFactory;
+ this.policyFactory = policyFactory;
+ this.documentBuilderFactory = documentBuilderFactory;
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ this.monitor = monitor;
+ }
+
+ /**
+ * @param modelFactories
+ * @param staxProcessor
+ * @param monitor
+ */
+ protected BaseAssemblyProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor,
+ Monitor monitor) {
+ 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);
+ this.monitor = monitor;
+ }
+
+ /**
+ * Marshals warnings into the monitor
+ *
+ * @param message
+ * @param model
+ * @param messageParameters
+ */
+ protected void warning(String message, Object model, String... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "assembly-xml-validation-messages",
+ Severity.WARNING,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Marshals errors into the monitor
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "assembly-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Marshals exceptions into the monitor
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "assembly-xml-validation-messages",
+ 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 {
+ writeStart(writer, SCA10_NS, name, attrs);
+ }
+
+ /**
+ * Start a document.
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void writeStartDocument(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
+ writer.writeStartDocument();
+ writer.setDefaultNamespace(SCA10_NS);
+ writeStart(writer, SCA10_NS, name, attrs);
+ writer.writeDefaultNamespace(SCA10_NS);
+ }
+
+ /**
+ * Read list of reference targets
+ * @param reference
+ * @param reader
+ */
+ protected void readTargets(Reference reference, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, 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;
+ }
+
+ /**
+ * Returns the value of a constrainingType attribute.
+ * @param reader
+ * @return
+ */
+ protected ConstrainingType readConstrainingType(XMLStreamReader reader) {
+ QName constrainingTypeName = getQName(reader, Constants.CONSTRAINING_TYPE);
+ if (constrainingTypeName != null) {
+ ConstrainingType constrainingType = assemblyFactory.createConstrainingType();
+ constrainingType.setName(constrainingTypeName);
+ constrainingType.setUnresolved(true);
+ return constrainingType;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Reads an abstract property element.
+ * @param property
+ * @param reader
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ */
+ protected void readAbstractProperty(AbstractProperty property, XMLStreamReader reader) 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));
+ }
+
+ /**
+ * Resolve an implementation.
+ * @param implementation
+ * @param resolver
+ * @return
+ * @throws ContributionResolveException
+ */
+ protected Implementation resolveImplementation(Implementation implementation, ModelResolver resolver)
+ throws ContributionResolveException {
+ if (implementation != null) {
+ if (implementation.isUnresolved()) {
+ implementation = resolver.resolveModel(Implementation.class, implementation);
+
+ // Lazily resolve implementations
+ if (implementation.isUnresolved()) {
+ extensionProcessor.resolve(implementation, resolver);
+ if (!implementation.isUnresolved()) {
+ resolver.addModel(implementation);
+ }
+ }
+ }
+ }
+ 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
+ */
+ protected <C extends Contract> void resolveContracts(List<C> contracts, ModelResolver resolver)
+ throws ContributionResolveException {
+ resolveContracts(null, contracts, resolver);
+ }
+
+ /**
+ * 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
+ */
+ protected <C extends Contract> void resolveContracts(Base parent, List<C> contracts, ModelResolver resolver)
+ 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);
+ }
+
+ // Resolve bindings
+ for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
+ Binding binding = contract.getBindings().get(i);
+ extensionProcessor.resolve(binding, resolver);
+
+ }
+
+ // 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);
+ }
+ }
+ }
+ }
+
+ /**
+ * 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
+ */
+ protected <C extends AbstractContract> void resolveAbstractContracts(List<C> contracts, ModelResolver resolver)
+ throws ContributionResolveException {
+ for (AbstractContract contract : contracts) {
+
+ // Resolve the interface contract
+ InterfaceContract interfaceContract = contract.getInterfaceContract();
+ if (interfaceContract != null) {
+ extensionProcessor.resolve(interfaceContract, resolver);
+ }
+ }
+ }
+
+ /**
+ * Returns a constrainingType attribute.
+ * @param componentType
+ * @return
+ */
+ protected XAttr writeConstrainingType(ComponentType componentType) {
+ ConstrainingType constrainingType = componentType.getConstrainingType();
+ if (constrainingType != null)
+ return new XAttr(Constants.CONSTRAINING_TYPE, constrainingType.getName());
+ else
+ return null;
+ }
+
+ /**
+ * Read a property value into a DOM document.
+ * @param element
+ * @param type
+ * @param reader
+ * @return
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ * @throws ParserConfigurationException
+ */
+ protected Document readPropertyValue(QName element, QName type, XMLStreamReader reader) 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("ContributionReadException", documentBuilderFactory, ce);
+ throw ce;
+ }
+
+ // root element has no namespace and local name "value"
+ Element root = document.createElementNS(null, "value");
+ 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);
+
+ loadElement(reader, root);
+ 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.next()) {
+ case XMLStreamConstants.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 XMLStreamConstants.CDATA:
+ current.appendChild(document.createCDATASection(reader.getText()));
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ current.appendChild(document.createTextNode(reader.getText()));
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ // if we are back at the root then we are done
+ if (current == root) {
+ return;
+ }
+
+ // pop the element off the stack
+ current = current.getParentNode();
+ }
+ }
+ }
+
+ /**
+ * 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());
+ }
+ }
+ }
+ }
+
+ protected void addInheritedIntents(List<Intent> sourceList, List<Intent> targetList) {
+ if (sourceList != null) {
+ targetList.addAll(sourceList);
+ }
+ }
+
+ protected void addInheritedPolicySets(List<PolicySet> sourceList, List<PolicySet> targetList) {
+ if (sourceList != null) {
+ targetList.addAll(sourceList);
+ }
+ }
+
+ /**
+ *
+ * @param reader
+ * @param elementName
+ * @param estensibleElement
+ * @param extensionAttributeProcessor
+ * @throws ContributionReadException
+ * @throws XMLStreamException
+ */
+ protected void readExtendedAttributes(XMLStreamReader reader,
+ QName elementName,
+ Extensible estensibleElement,
+ StAXAttributeProcessor extensionAttributeProcessor)
+ throws ContributionReadException, XMLStreamException {
+ for (int a = 0; a < reader.getAttributeCount(); a++) {
+ QName attributeName = reader.getAttributeName(a);
+ if (attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) {
+ if (!elementName.getNamespaceURI().equals(attributeName.getNamespaceURI())) {
+ Object attributeValue = extensionAttributeProcessor.read(attributeName, reader);
+ Extension attributeExtension;
+ if (attributeValue instanceof Extension) {
+ attributeExtension = (Extension)attributeValue;
+ } else {
+ attributeExtension = assemblyFactory.createExtension();
+ attributeExtension.setAttribute(true);
+ attributeExtension.setQName(attributeName);
+ attributeExtension.setValue(attributeValue);
+ }
+ estensibleElement.getAttributeExtensions().add(attributeExtension);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param attributeModel
+ * @param writer
+ * @param extensibleElement
+ * @param extensionAttributeProcessor
+ * @throws ContributionWriteException
+ * @throws XMLStreamException
+ */
+ protected void writeExtendedAttributes(XMLStreamWriter writer,
+ Extensible extensibleElement,
+ StAXAttributeProcessor extensionAttributeProcessor)
+ throws ContributionWriteException, XMLStreamException {
+ for (Extension extension : extensibleElement.getAttributeExtensions()) {
+ if (extension.isAttribute()) {
+ extensionAttributeProcessor.write(extension, writer);
+ }
+ }
+ }
+
+ /*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/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ComponentTypeProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ComponentTypeProcessor.java
new file mode 100644
index 0000000000..643f5ab78d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ComponentTypeProcessor.java
@@ -0,0 +1,383 @@
+/*
+ * 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.osoa;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CALLBACK;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CALLBACK_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPONENT_TYPE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPONENT_TYPE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.IMPLEMENTATION;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MANY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MUST_SUPPLY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.NAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.OPERATION_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TYPE;
+
+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.assembly.xml.osoa.BaseAssemblyProcessor;
+import org.apache.tuscany.sca.assembly.xml.osoa.Constants;
+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.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.monitor.Monitor;
+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,
+ Monitor monitor) {
+ super(modelFactories, extensionProcessor, monitor);
+ }
+
+ public ComponentType read(XMLStreamReader reader) 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();
+ componentType.setConstrainingType(readConstrainingType(reader));
+
+ } 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);
+ policyProcessor.readPolicies(property, reader);
+
+ // Read the property value
+ Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
+ 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 {
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader);
+ 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("XMLStreamException", reader, ex);
+ }
+
+ return componentType;
+ }
+
+ public void write(ComponentType componentType, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ // Write <componentType> element
+ writeStartDocument(writer, COMPONENT_TYPE,
+ writeConstrainingType(componentType));
+
+ // 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);
+ }
+
+ for (Binding binding: service.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ if (service.getCallback() != null) {
+ Callback callback = service.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ for (Binding binding: callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+ for (Object extension: callback.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ for (Object extension: service.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+
+ for (Binding binding: reference.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK,
+ policyProcessor.writePolicies(callback));
+
+ for (Binding binding: callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+ for (Object extension: callback.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ for (Object extension: reference.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extension elements
+ if (componentType instanceof Extensible) {
+ for (Object extension: ((Extensible)componentType).getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+ }
+
+ // 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) throws ContributionResolveException {
+
+ // Resolve component type services and references
+ resolveContracts(componentType.getServices(), resolver);
+ resolveContracts(componentType.getReferences(), resolver);
+ }
+
+ public QName getArtifactType() {
+ return COMPONENT_TYPE_QNAME;
+ }
+
+ public Class<ComponentType> getModelType() {
+ return ComponentType.class;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java
new file mode 100644
index 0000000000..bfdd9fdac7
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java
@@ -0,0 +1,1031 @@
+/*
+ * 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.osoa;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.AUTOWIRE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CALLBACK;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CALLBACK_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPONENT;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPONENT_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPOSITE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPOSITE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.FILE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.IMPLEMENTATION_COMPOSITE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.IMPLEMENTATION_COMPOSITE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.INCLUDE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.INCLUDE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.LOCAL;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MANY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MUST_SUPPLY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.NAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROMOTE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SCA10_NS;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SOURCE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TARGET;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TARGET_NAMESPACE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TYPE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.URI;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.WIRE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.WIRED_BY_IMPL;
+import static org.apache.tuscany.sca.assembly.xml.osoa.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.XPath;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+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.ConstrainingType;
+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.contribution.Artifact;
+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.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.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.w3c.dom.Document;
+
+/**
+ * A composite processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<Composite> {
+ private XPathFactory xPathFactory;
+ private PolicyFactory intentAttachPointTypeFactory;
+ private StAXAttributeProcessor<Object> extensionAttributeProcessor;
+ private ContributionFactory contributionFactory;
+
+
+ /**
+ * Construct a new composite processor
+ *
+ * @param extensionPoints
+ * @param extensionProcessor
+ */
+ public CompositeProcessor(ExtensionPointRegistry extensionPoints,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor,
+ Monitor monitor) {
+
+ this(modelFactories(extensionPoints),
+ extensionProcessor,
+ extensionAttributeProcessor,
+ monitor(extensionPoints));
+
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
+ }
+
+ /**
+ * Constructs a new composite processor
+ *
+ * @param modelFactories
+ * @param extensionProcessor
+ * @param monitor
+ */
+ private CompositeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor,
+ Monitor monitor) {
+
+ super(modelFactories, extensionProcessor, monitor);
+ this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.xPathFactory = modelFactories.getFactory(XPathFactory.class);
+ this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
+
+ }
+
+ public Composite read(XMLStreamReader reader) 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;
+
+ 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(SCA10_NS);
+
+ composite.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
+
+ if(!isSet(reader, TARGET_NAMESPACE)){
+ // spec says that a composite must have a namespace
+ warning("NoCompositeNamespace", composite, composite.getName().toString());
+ }
+
+ if(isSet(reader, AUTOWIRE)) {
+ composite.setAutowire(getBoolean(reader, AUTOWIRE));
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, composite, extensionAttributeProcessor);
+
+ composite.setLocal(getBoolean(reader, LOCAL));
+ composite.setConstrainingType(readConstrainingType(reader));
+ policyProcessor.readPolicies(composite, reader);
+
+ } else if (INCLUDE_QNAME.equals(name)) {
+
+ // Read an <include>
+ include = assemblyFactory.createComposite();
+ include.setName(getQName(reader, NAME));
+ include.setURI(getString(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);
+
+ 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 = getString(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);
+
+ composite.getServices().add(compositeService);
+ policyProcessor.readPolicies(contract, reader);
+ }
+
+ } 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));
+ }
+ readTargets(componentReference, reader);
+ componentReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, componentReference, extensionAttributeProcessor);
+
+ 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 = reader.getAttributeValue(null, 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("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);
+
+ composite.getReferences().add(compositeReference);
+ policyProcessor.readPolicies(contract, reader);
+ }
+
+ } else if (PROPERTY_QNAME.equals(name)) {
+ if (component != null) {
+
+ // Read a <component><property>
+ componentProperty = assemblyFactory.createComponentProperty();
+ property = componentProperty;
+ String source = getString(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 = source + "/";
+ index = source.length() - 1;
+ }
+ source = source.substring(index + 1);
+ if ("".equals(source)) {
+ source = ".";
+ }
+ }
+ XPath xpath = xPathFactory.newXPath();
+ xpath.setNamespaceContext(reader.getNamespaceContext());
+ try {
+ componentProperty.setSourceXPathExpression(xpath.compile(source));
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", xpath, ce);
+ //throw ce;
+ }
+ }
+ componentProperty.setFile(getString(reader, FILE));
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, componentProperty, extensionAttributeProcessor);
+
+ policyProcessor.readPolicies(property, reader);
+ readAbstractProperty(componentProperty, reader);
+
+ // Read the property value
+ Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
+ property.setValue(value);
+
+ component.getProperties().add(componentProperty);
+ } else {
+
+ // Read a <composite><property>
+ property = assemblyFactory.createProperty();
+ policyProcessor.readPolicies(property, reader);
+ readAbstractProperty(property, reader);
+
+ // Read the property value
+ Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
+ 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(getString(reader, URI));
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, component, extensionAttributeProcessor);
+
+ component.setConstrainingType(readConstrainingType(reader));
+ 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(getString(reader, SOURCE));
+ wire.setSource(source);
+
+ ComponentService target = assemblyFactory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(getString(reader, TARGET));
+ wire.setTarget(target);
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, wire, extensionAttributeProcessor);
+
+ composite.getWires().add(wire);
+ policyProcessor.readPolicies(wire, reader);
+
+ } else if (CALLBACK_QNAME.equals(name)) {
+
+ // Read a <callback>
+ callback = assemblyFactory.createCallback();
+ contract.setCallback(callback);
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, callback, extensionAttributeProcessor);
+
+ policyProcessor.readPolicies(callback, reader);
+
+ } 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);
+
+ component.setImplementation(implementation);
+ policyProcessor.readPolicies(implementation, reader);
+ } else {
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader);
+ if (extension != null) {
+ if (extension instanceof InterfaceContract) {
+
+ // <service><interface> and
+ // <reference><interface>
+ if (contract != null) {
+ contract.setInterfaceContract((InterfaceContract)extension);
+ } else {
+ if (name.getNamespaceURI().equals(SCA10_NS)) {
+ error("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).setType(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(SCA10_NS)) {
+ error("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).setType(implType);
+ }
+ // <component><implementation>
+ if (component != null) {
+ component.setImplementation((Implementation)extension);
+ } else {
+ if (name.getNamespaceURI().equals(SCA10_NS)) {
+ error("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("XMLStreamException", reader, ex);
+ }
+
+ return composite;
+ }
+
+ public void write(Composite composite, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ // Write <composite> element
+ writeStartDocument(writer,
+ COMPOSITE,
+ writeConstrainingType(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);
+
+ // 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);
+
+ 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);
+
+
+ // Write service interface
+ extensionProcessor.write(service.getInterfaceContract(), writer);
+
+ // Write bindings
+ for (Binding binding : service.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // 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);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write extensions
+ for (Object extension : callback.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extension : service.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+
+ // 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);
+
+ writeEnd(writer);
+ } else {
+ extensionProcessor.write(component.getImplementation(), writer);
+ }
+
+ for (Object extension : component.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ // 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);
+
+ // Write service interface
+ extensionProcessor.write(service.getInterfaceContract(), writer);
+
+ // Write bindings
+ for (Binding binding : service.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // 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);
+
+ // Write bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write extensions
+ for (Object extension : callback.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extension : service.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write <reference> elements
+ for (ComponentReference reference : component.getReferences()) {
+ writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()),
+ new XAttr(AUTOWIRE, reference.getAutowire()),
+ writeMultiplicity(reference),
+ writeTargets(reference),
+ policyProcessor.writePolicies(reference));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, reference, extensionAttributeProcessor);
+
+ // Write reference interface
+ extensionProcessor.write(reference.getInterfaceContract(), writer);
+
+ // Write bindings
+ for (Binding binding : reference.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write callback
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write extensions
+ for (Object extensions : callback.getExtensions()) {
+ extensionProcessor.write(extensions, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extensions : reference.getExtensions()) {
+ extensionProcessor.write(extensions, writer);
+ }
+
+ 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);
+
+ // Write property value
+ writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : property.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+
+ // Write reference interface
+ extensionProcessor.write(reference.getInterfaceContract(), writer);
+
+ // Write bindings
+ for (Binding binding : reference.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write <callback> element
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK);
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write extensions
+ for (Object extension : callback.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extension : reference.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+
+ // Write property value
+ writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : property.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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()));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, wire, extensionAttributeProcessor);
+
+ // Write extensions
+ for (Object extension : wire.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+ writeEnd(writer);
+ }
+
+ for (Object extension : composite.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(Composite composite, ModelResolver resolver) throws ContributionResolveException {
+
+ // Resolve constraining type
+ ConstrainingType constrainingType = composite.getConstrainingType();
+ if (constrainingType != null) {
+ constrainingType = resolver.resolveModel(ConstrainingType.class, constrainingType);
+ composite.setConstrainingType(constrainingType);
+ }
+
+ // 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) {
+ include = resolver.resolveModel(Composite.class, include);
+ composite.getIncludes().set(i, include);
+ }
+ }
+
+ // Resolve extensions
+ for (Object extension : composite.getExtensions()) {
+ if (extension != null) {
+ extensionProcessor.resolve(extension, resolver);
+ }
+ }
+
+ //Resolve composite services and references
+ resolveContracts(composite, composite.getServices(), resolver);
+ resolveContracts(composite, composite.getReferences(), resolver);
+
+ // Resolve component implementations, services and references
+ for (Component component : composite.getComponents()) {
+ constrainingType = component.getConstrainingType();
+ if (constrainingType != null) {
+ constrainingType = resolver.resolveModel(ConstrainingType.class, constrainingType);
+ component.setConstrainingType(constrainingType);
+ }
+
+ //resolve component services and references
+ resolveContracts(component, component.getServices(), resolver);
+ resolveContracts(component, component.getReferences(), resolver);
+
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ if (componentProperty.getFile() != null) {
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(componentProperty.getFile());
+ artifact = resolver.resolveModel(Artifact.class, artifact);
+ if (artifact.getLocation() != null) {
+ componentProperty.setFile(artifact.getLocation());
+ }
+ }
+ }
+
+ //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);
+
+ 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);
+ }
+ }
+ }
+
+ 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);
+ }
+
+ /**
+ * Returns the monitor to use.
+ *
+ * @param extensionPoints
+ * @return
+ */
+ private static Monitor monitor(ExtensionPointRegistry extensionPoints) {
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ if (utilities != null) {
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ if (monitorFactory != null) {
+ return monitorFactory.createMonitor();
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/Constants.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/Constants.java
new file mode 100644
index 0000000000..797d0bb47a
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/Constants.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.osoa;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.osoa.Constants;
+
+/**
+ * Constants used in SCA assembly XML files.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Constants {
+ String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
+ String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
+
+ String COMPONENT_TYPE = "componentType";
+ QName COMPONENT_TYPE_QNAME = new QName(SCA10_NS, COMPONENT_TYPE);
+
+ String SERVICE = "service";
+ QName SERVICE_QNAME = new QName(SCA10_NS, SERVICE);
+
+ String REFERENCE = "reference";
+ QName REFERENCE_QNAME = new QName(SCA10_NS, REFERENCE);
+
+ String PROPERTY = "property";
+ QName PROPERTY_QNAME = new QName(SCA10_NS, PROPERTY);
+
+ String CONSTRAINING_TYPE = "constrainingType";
+ QName CONSTRAINING_TYPE_QNAME = new QName(SCA10_NS, CONSTRAINING_TYPE);
+
+ String COMPOSITE = "composite";
+ QName COMPOSITE_QNAME = new QName(SCA10_NS, COMPOSITE);
+
+ String INCLUDE = "include";
+ QName INCLUDE_QNAME = new QName(SCA10_NS, INCLUDE);
+
+ String COMPONENT = "component";
+ QName COMPONENT_QNAME = new QName(SCA10_NS, COMPONENT);
+
+ String WIRE = "wire";
+ QName WIRE_QNAME = new QName(SCA10_NS, WIRE);
+
+ String OPERATION = "operation";
+ QName OPERATION_QNAME = new QName(SCA10_NS, OPERATION);
+
+ String CALLBACK = "callback";
+ QName CALLBACK_QNAME = new QName(SCA10_NS, CALLBACK);
+
+ String IMPLEMENTATION_COMPOSITE = "implementation.composite";
+ QName IMPLEMENTATION_COMPOSITE_QNAME = new QName(SCA10_NS, IMPLEMENTATION_COMPOSITE);
+
+ String IMPLEMENTATION = "implementation";
+ QName IMPLEMENTATION_QNAME = new QName(SCA10_NS, IMPLEMENTATION);
+
+ String BINDING_SCA = "binding.sca";
+ QName BINDING_SCA_QNAME = new QName(Constants.SCA10_NS, BINDING_SCA);
+
+ String NAME = "name";
+ String TARGET_NAMESPACE = "targetNamespace";
+ String LOCAL = "local";
+ String AUTOWIRE = "autowire";
+ 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";
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ConstrainingTypeProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ConstrainingTypeProcessor.java
new file mode 100644
index 0000000000..125ee2970e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ConstrainingTypeProcessor.java
@@ -0,0 +1,275 @@
+/*
+ * 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.osoa;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CONSTRAINING_TYPE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CONSTRAINING_TYPE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MANY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MUST_SUPPLY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.NAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.OPERATION_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TARGET_NAMESPACE;
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TYPE;
+
+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.AbstractContract;
+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.ConstrainingType;
+import org.apache.tuscany.sca.assembly.xml.osoa.BaseAssemblyProcessor;
+import org.apache.tuscany.sca.assembly.xml.osoa.Constants;
+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.StAXArtifactProcessor;
+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.monitor.Monitor;
+import org.w3c.dom.Document;
+
+/**
+ * A constrainingType processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<ConstrainingType> {
+
+ /**
+ * Constructs a new constrainingType processor.
+ *
+ * @param modelFactories
+ * @param extensionProcessor
+ */
+ public ConstrainingTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor extensionProcessor,
+ Monitor monitor) {
+ super(modelFactories, extensionProcessor, monitor);
+ }
+
+ public ConstrainingType read(XMLStreamReader reader) throws ContributionReadException {
+ ConstrainingType constrainingType = null;
+ AbstractService abstractService = null;
+ AbstractReference abstractReference = null;
+ AbstractProperty abstractProperty = null;
+ AbstractContract abstractContract = null;
+ QName name = null;
+
+ try {
+ // Read the constrainingType document
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+
+ case START_ELEMENT:
+ name = reader.getName();
+
+ // Read a <constrainingType>
+ if (Constants.CONSTRAINING_TYPE_QNAME.equals(name)) {
+ constrainingType = assemblyFactory.createConstrainingType();
+ constrainingType.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
+ policyProcessor.readPolicies(constrainingType, reader);
+
+ } else if (Constants.SERVICE_QNAME.equals(name)) {
+
+ // Read a <service>
+ abstractService = assemblyFactory.createAbstractService();
+ abstractContract = abstractService;
+ abstractService.setName(getString(reader, Constants.NAME));
+ constrainingType.getServices().add(abstractService);
+ policyProcessor.readPolicies(abstractService, reader);
+
+ } else if (Constants.REFERENCE_QNAME.equals(name)) {
+
+ // Read a <reference>
+ abstractReference = assemblyFactory.createAbstractReference();
+ abstractContract = abstractReference;
+ abstractReference.setName(getString(reader, Constants.NAME));
+ readMultiplicity(abstractReference, reader);
+ constrainingType.getReferences().add(abstractReference);
+ policyProcessor.readPolicies(abstractReference, reader);
+
+ } else if (Constants.PROPERTY_QNAME.equals(name)) {
+
+ // Read a <property>
+ abstractProperty = assemblyFactory.createAbstractProperty();
+ readAbstractProperty(abstractProperty, reader);
+
+ // Read the property value
+ Document value = readPropertyValue(abstractProperty.getXSDElement(), abstractProperty.getXSDType(), reader);
+ abstractProperty.setValue(value);
+
+ constrainingType.getProperties().add(abstractProperty);
+ policyProcessor.readPolicies(abstractProperty, reader);
+
+ } else if (OPERATION_QNAME.equals(name)) {
+
+ // Read an <operation>
+ Operation operation = new OperationImpl();
+ operation.setName(getString(reader, NAME));
+ operation.setUnresolved(true);
+ policyProcessor.readPolicies(abstractContract, operation, reader);
+
+ } else {
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader);
+ if (extension instanceof InterfaceContract) {
+
+ // <service><interface> and <reference><interface>
+ abstractContract.setInterfaceContract((InterfaceContract)extension);
+ } else {
+
+ // Add the extension element to the current element
+ if (abstractContract != null) {
+ abstractContract.getExtensions().add(extension);
+ } else {
+ constrainingType.getExtensions().add(extension);
+ }
+
+ }
+ }
+ break;
+
+ case END_ELEMENT:
+ name = reader.getName();
+
+ // Clear current state when reading reaching end element
+ if (SERVICE_QNAME.equals(name)) {
+ abstractService = null;
+ abstractContract = null;
+ } else if (REFERENCE_QNAME.equals(name)) {
+ abstractReference = null;
+ abstractContract = null;
+ } else if (PROPERTY_QNAME.equals(name)) {
+ abstractProperty = null;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ }
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error("XMLStreamException", reader, ex);
+ }
+
+ return constrainingType;
+ }
+
+ public void write(ConstrainingType constrainingType, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ // Write <constrainingType> element
+ writeStartDocument(writer, CONSTRAINING_TYPE,
+ new XAttr(TARGET_NAMESPACE, constrainingType.getName().getNamespaceURI()),
+ new XAttr(NAME, constrainingType.getName().getLocalPart()),
+ policyProcessor.writePolicies(constrainingType));
+
+ // Write <service> elements
+ for (AbstractService service : constrainingType.getServices()) {
+ writeStart(writer, SERVICE, new XAttr(NAME, service.getName()),
+ policyProcessor.writePolicies(service));
+
+ extensionProcessor.write(service.getInterfaceContract(), writer);
+
+ for (Object extension: service.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write <reference> elements
+ for (AbstractReference reference : constrainingType.getReferences()) {
+ writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()),
+ writeMultiplicity(reference),
+ policyProcessor.writePolicies(reference));
+
+ extensionProcessor.write(reference.getInterfaceContract(), writer);
+
+ for (Object extension: reference.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write <property> elements
+ for (AbstractProperty abstractProperty : constrainingType.getProperties()) {
+ writeStart(writer,
+ PROPERTY,
+ new XAttr(NAME, abstractProperty.getName()),
+ new XAttr(MUST_SUPPLY, abstractProperty.isMustSupply()),
+ new XAttr(MANY, abstractProperty.isMany()),
+ new XAttr(TYPE, abstractProperty.getXSDType()),
+ new XAttr(ELEMENT, abstractProperty.getXSDElement()),
+ policyProcessor.writePolicies(abstractProperty));
+
+ // Write property value
+ writePropertyValue(abstractProperty.getValue(), abstractProperty.getXSDElement(), abstractProperty.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : abstractProperty.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extension elements
+ for (Object extension: constrainingType.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(ConstrainingType constrainingType, ModelResolver resolver) throws ContributionResolveException {
+ // Resolve component type services and references
+ resolveAbstractContracts(constrainingType.getServices(), resolver);
+ resolveAbstractContracts(constrainingType.getReferences(), resolver);
+ }
+
+ public QName getArtifactType() {
+ return CONSTRAINING_TYPE_QNAME;
+ }
+
+ public Class<ConstrainingType> getModelType() {
+ return ConstrainingType.class;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/PolicySubjectProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/PolicySubjectProcessor.java
new file mode 100644
index 0000000000..adb8655447
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/PolicySubjectProcessor.java
@@ -0,0 +1,253 @@
+/*
+ * 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.osoa;
+
+import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.POLICY_SETS;
+import static org.apache.tuscany.sca.assembly.xml.osoa.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.assembly.xml.osoa.Constants;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+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$
+ */
+public class PolicySubjectProcessor extends BaseStAXArtifactProcessor {
+
+ private PolicyFactory policyFactory;
+
+ public PolicySubjectProcessor(PolicyFactory policyFactory) {
+ this.policyFactory = policyFactory;
+ }
+
+ /**
+ * Read policy intents associated with an operation.
+ * @param attachPoint
+ * @param operation
+ * @param reader
+ */
+ private void readIntents(Object attachPoint, Operation operation, XMLStreamReader reader) {
+ if (!(attachPoint instanceof PolicySubject))
+ return;
+ PolicySubject intentAttachPoint = (PolicySubject)attachPoint;
+ 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 attachPoint
+ * @param operation
+ * @param reader
+ */
+ public void readPolicies(Object attachPoint, Operation operation, XMLStreamReader reader) {
+ readIntents(attachPoint, operation, reader);
+ readPolicySets(attachPoint, operation, reader);
+ }
+
+ /**
+ * Reads policy intents and policy sets.
+ * @param attachPoint
+ * @param reader
+ */
+ public void readPolicies(Object attachPoint, XMLStreamReader reader) {
+ readPolicies(attachPoint, null, reader);
+ }
+
+ /**
+ * Reads policy sets associated with an operation.
+ * @param attachPoint
+ * @param operation
+ * @param reader
+ */
+ private void readPolicySets(Object attachPoint, Operation operation, XMLStreamReader reader) {
+ if (!(attachPoint instanceof PolicySubject)) {
+ return;
+ }
+ PolicySubject policySubject = (PolicySubject)attachPoint;
+ 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 attachPoint
+ * @return
+ */
+ XAttr writePolicies(Object attachPoint) throws XMLStreamException {
+ return writePolicies(attachPoint, (Operation)null);
+ }
+
+ /**
+ * Write policies
+ * @param attachPoint
+ * @return
+ */
+ public void writePolicyAttributes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException {
+ writePolicyAttributes(attachPoint, (Operation)null, writer);
+ }
+
+ /**
+ * Write policies
+ * @param attachPoint
+ * @return
+ */
+ public void writePolicyPrefixes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException {
+ writePolicyPrefixes(attachPoint, (Operation)null, writer);
+ }
+
+ /**
+ * Write policies associated with an operation
+ * @param attachPoint
+ * @param operation
+ * @return
+ */
+ XAttr writePolicies(Object attachPoint, Operation operation) {
+ List<XAttr> attrs =new ArrayList<XAttr>();
+ attrs.add(writeIntents(attachPoint, operation));
+ attrs.add(writePolicySets(attachPoint, operation));
+ return new XAttr(null, attrs);
+ }
+
+ /**
+ * Write policies
+ * @param attachPoint
+ * @return
+ */
+ public void writePolicyAttributes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException {
+ XAttr attr = writePolicies(attachPoint, operation);
+ attr.write(writer);
+ }
+
+ /**
+ * Write policies
+ * @param attachPoint
+ * @return
+ */
+ public void writePolicyPrefixes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException {
+ XAttr attr = writePolicies(attachPoint, operation);
+ attr.writePrefix(writer);
+ }
+
+ /**
+ * Write policy intents associated with an operation.
+ * @param attachPoint
+ * @param operation
+ */
+ private XAttr writeIntents(Object attachPoint, Operation operation) {
+ if (!(attachPoint instanceof PolicySubject)) {
+ return null;
+ }
+ PolicySubject intentAttachPoint = (PolicySubject)attachPoint;
+ 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 attachPoint
+ * @param operation
+ */
+ private XAttr writePolicySets(Object attachPoint, Operation operation) {
+ if (!(attachPoint instanceof PolicySubject)) {
+ return null;
+ }
+ PolicySubject policySetAttachPoint = (PolicySubject)attachPoint;
+ 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 attachPoint, ModelResolver resolver) {
+ if ( attachPoint instanceof PolicySubject ) {
+ PolicySubject policySetAttachPoint = (PolicySubject)attachPoint;
+
+ 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);
+ 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);
+ resolvedPolicySets.add(resolvedPolicySet);
+ }
+ policySetAttachPoint.getPolicySets().clear();
+ policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets);
+ }
+ }
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..e778ab7e3c
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.osoa.ComponentTypeProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#componentType,model=org.apache.tuscany.sca.assembly.ComponentType
+org.apache.tuscany.sca.assembly.xml.osoa.ConstrainingTypeProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#constrainingType,model=org.apache.tuscany.sca.assembly.ConstrainingType
+org.apache.tuscany.sca.assembly.xml.osoa.CompositeProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#composite,model=org.apache.tuscany.sca.assembly.Composite
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
new file mode 100644
index 0000000000..a363691a51
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
@@ -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.
+
+# Implementation class for the artifact processor extension
+# org.apache.tuscany.sca.assembly.xml.osoa.ComponentTypeDocumentProcessor;type=.componentType,model=org.apache.tuscany.sca.assembly.ComponentType
+# org.apache.tuscany.sca.assembly.xml.osoa.ConstrainingTypeDocumentProcessor;type=.constrainingType,model=org.apache.tuscany.sca.assembly.ConstrainingType
+# org.apache.tuscany.sca.assembly.xml.osoa.CompositeDocumentProcessor;type=.composite,model=org.apache.tuscany.sca.assembly.Composite
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..05c965f40e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -0,0 +1,20 @@
+# 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.osoa.CompositeModelResolver;model=org.apache.tuscany.sca.assembly.Composite
+# org.apache.tuscany.sca.assembly.xml.osoa.ConstrainingTypeModelResolver;model=org.apache.tuscany.sca.assembly.ConstrainingType
+# org.apache.tuscany.sca.assembly.xml.osoa.ComponentTypeModelResolver;model=org.apache.tuscany.sca.assembly.ComponentType
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/assembly-xml-validation-messages.properties b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/assembly-xml-validation-messages.properties
new file mode 100644
index 0000000000..8cc5e5a5ec
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/main/resources/assembly-xml-validation-messages.properties
@@ -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.
+#
+#
+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}
+ContributionWriteException = ContributionWriteException occured due to : {0}
+XMLStreamException = XMLStreamException occured due to : {0}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java
new file mode 100644
index 0000000000..4262571a9a
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.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.osoa;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+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.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BuildPolicyTestCase {
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static ModelResolver resolver;
+ private static CompositeBuilder compositeBuilder;
+ private static Composite composite;
+ private static Monitor monitor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+ compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ List<Definitions> policyDefinitions = new ArrayList<Definitions>();
+ resolver = new DefaultModelResolver();
+
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ monitor = monitorFactory.createMonitor();
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(extensionPoints);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+
+ URL url = BuildPolicyTestCase.class.getResource("CalculatorComponent.constrainingType");
+ URI uri = URI.create("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ url = BuildPolicyTestCase.class.getResource("TestAllPolicyCalculator.composite");
+ uri = URI.create("TestAllCalculator.constrainingType");
+ composite = (Composite)documentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+
+ url = BuildPolicyTestCase.class.getResource("another_test_definitions.xml");
+ uri = URI.create("another_test_definitions.xml");
+ Definitions definitions = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(definitions);
+ policyDefinitions.add(definitions);
+
+ documentProcessor.resolve(definitions, resolver);
+ documentProcessor.resolve(composite, resolver);
+
+ compositeBuilder.build(composite, null, monitor);
+ }
+
+ @Test
+ @Ignore("The inheritance will be calculated differently in OASIS SCA")
+ public void testPolicyIntentInheritance() throws Exception {
+ String namespaceUri = "http://test";
+
+ PolicySubject policiedComposite = (PolicySubject)composite;
+ assertEquals(policiedComposite.getRequiredIntents().size(), 1);
+ assertEquals(policiedComposite.getRequiredIntents().get(0).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
+
+ //1 defined for composite, 2 defined for the service, 1 defined and 3 inherited for the promoted service (4)
+ assertEquals(composite.getServices().get(0).getRequiredIntents().size(), 7);
+ //1 from the operation defined in this service and 2 from the operation defined in the promoted service
+ assertEquals(composite.getServices().get(0).getRequiredIntents().get(3).getName(), new QName(namespaceUri, "tuscanyIntent_3"));
+ //bindings will have only 2 intents since duplications will be cut out
+ assertEquals(((PolicySubject)composite.getServices().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
+
+ assertEquals(composite.getReferences().get(0).getRequiredIntents().size(), 5);
+ assertEquals(composite.getReferences().get(0).getRequiredIntents().get(1).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
+ assertEquals(((PolicySubject)composite.getReferences().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
+
+ assertEquals(composite.getComponents().get(0).getRequiredIntents().size(), 3);
+ assertEquals(composite.getComponents().get(0).getRequiredIntents().get(2).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
+ assertEquals(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().size(), 4);
+ assertEquals(composite.getComponents().get(0).getServices().get(0).getCallback().getRequiredIntents().size(), 4);
+ assertEquals(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().size(), 5);
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/MultiplicityReadWriteTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/MultiplicityReadWriteTestCase.java
new file mode 100644
index 0000000000..5d9b8e4556
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/MultiplicityReadWriteTestCase.java
@@ -0,0 +1,86 @@
+/*
+ * 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.osoa;
+
+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.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;
+
+
+ @Before
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null);
+ }
+
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Multiplicity.composite");
+ Composite composite = staxProcessor.read(is, Composite.class);
+
+ verifyComposite(composite);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ bos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ composite = staxProcessor.read(bis, Composite.class);
+
+ 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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadAllTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadAllTestCase.java
new file mode 100644
index 0000000000..4d981b8c4d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/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.osoa;
+
+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.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;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is));
+ assertNotNull(composite);
+ assertEquals(composite.getName(), new QName("http://calc", "TestAllCalculator"));
+ assertEquals(composite.getConstrainingType().getName(), new QName("http://calc", "CalculatorComponent"));
+ 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.getConstrainingType().getName(), new QName("http://calc",
+ "CalculatorComponent"));
+ 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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..e3f35d6f9b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java
@@ -0,0 +1,225 @@
+/*
+ * 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.osoa;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URL;
+
+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.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor;
+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.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.junit.BeforeClass;
+import org.junit.Test;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadDocumentTestCase {
+ private static final String TUSCANY_10_XSD = "tuscany-sca.xsd";
+
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static ModelResolver resolver;
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
+
+ resolver = new DefaultModelResolver();
+ }
+
+ @Test
+ public void testValidateAssembly() throws Exception {
+
+ SchemaFactory schemaFactory;
+ try {
+ schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ } catch (Error e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ } catch (Exception e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ }
+ Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD));
+ ValidatorHandler handler = schema.newValidatorHandler();
+
+ 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 testValidateImplementation() throws Exception {
+
+ SchemaFactory schemaFactory;
+ try {
+ schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ } catch (Error e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ } catch (Exception e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ }
+ Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD));
+ ValidatorHandler handler = schema.newValidatorHandler();
+
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ URL url = getClass().getResource("JavaScriptReference.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 {
+
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
+ schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD).toString());
+ XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
+ DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry());
+ factories.addFactory(validatingInputFactory);
+
+ CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(factories , staxProcessor, null);
+
+ URL url = getClass().getResource("JavaScriptReference.composite");
+ URI uri = URI.create("JavaScriptReference.composite");
+ Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+ }
+
+ @Test
+ public void testValidateBinding() throws Exception {
+
+ SchemaFactory schemaFactory;
+ try {
+ schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ } catch (Error e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ } catch (Exception e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ }
+ Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD));
+ ValidatorHandler handler = schema.newValidatorHandler();
+
+ 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 {
+
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
+ schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD).toString());
+ XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
+ DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry());
+ factories.addFactory(validatingInputFactory);
+ CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(factories , staxProcessor, null);
+
+ URL url = getClass().getResource("RMIBindingTest.composite");
+ URI uri = URI.create("RMIBindingTest.composite");
+ Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+
+ URL url = getClass().getResource("CalculatorComponent.constrainingType");
+ URI uri = URI.create("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.constrainingType");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+
+ documentProcessor.resolve(composite, resolver);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ @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);
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+
+ documentProcessor.resolve(composite, resolver);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadTestCase.java
new file mode 100644
index 0000000000..98b8c81533
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadTestCase.java
@@ -0,0 +1,91 @@
+/*
+ * 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.osoa;
+
+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.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;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null);
+ }
+
+
+ @Test
+ public void testReadComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+ }
+
+ @Test
+ public void testReadConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+
+ }
+
+ @Test
+ public void testReadCompositeAndWireIt() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyAttributeTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyAttributeTestCase.java
new file mode 100644
index 0000000000..b86907579e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyAttributeTestCase.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.xml.osoa;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+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.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.Ignore;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadWriteAnyAttributeTestCase {
+
+ private static final QName EXTENDED_ATTRIBUTE = new QName("http://test", "customAttribute");
+
+ private static final String XML = "<?xml version='1.0' encoding='UTF-8'?>"+
+ "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" " +
+ "xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" " +
+ "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;
+
+
+ /**
+ * 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();
+ 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(), null);
+ }
+
+ /**
+ * Read and Write a composite that has a extended attribute
+ * and a particular attribute processor
+ * @throws Exception
+ */
+ @Test
+ @Ignore("TBF: The processor needs to write the xml based on the QName of the elements")
+ public void testReadWriteCompositeWithAttributeProcessor() throws Exception {
+ init(new TestAttributeProcessor());
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML));
+ Composite composite = (Composite) staxProcessor.read(reader);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // 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
+ @Ignore("TBF: The processor needs to write the xml based on the QName of the elements")
+ public void testDefaultReadWriteComposite() throws Exception {
+ init(null);
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML));
+ Composite composite = (Composite) staxProcessor.read(reader);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // 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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyElementTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyElementTestCase.java
new file mode 100644
index 0000000000..d15bce9544
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyElementTestCase.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.xml.osoa;
+
+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.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://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" 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://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" 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://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://temp\" name=\"aaaa\" autowire=\"false\">" +
+ "<component name=\"unknownImpl\">" +
+ "<implementation.unknown class=\"raymond\" />" +
+ "<service name=\"service\" requires=\"\">" +
+ "<binding.ws />" +
+ "</service>" +
+ "</component>" +
+ "</composite>";
+
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, XMLOutputFactory.newInstance(), null);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ @Ignore("TBF: The processor needs to write the xml based on the QName of the elements")
+ public void testReadWriteExtendedRecursiveElement() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_RECURSIVE_EXTENDED_ELEMENT));
+ Composite composite = (Composite)staxProcessor.read(reader);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // 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
+ @Ignore("TBF: The processor needs to write the xml based on the QName of the elements")
+ public void testReadWriteUnknwonImpl() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_UNKNOWN_IMPL));
+ Composite composite = (Composite)staxProcessor.read(reader);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // 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);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // 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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteLocalCompositeTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteLocalCompositeTestCase.java
new file mode 100644
index 0000000000..77a199acc9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteLocalCompositeTestCase.java
@@ -0,0 +1,102 @@
+/*
+ * 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.osoa;
+
+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.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.Ignore;
+import org.junit.Test;
+
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadWriteLocalCompositeTestCase {
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+
+ private static final String LOCAL_COMPOSITE_XML = "<?xml version='1.0' encoding='UTF-8'?>"+
+ "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://localcalc\" name=\"LocalCalculator\" local=\"true\">"+
+ "</composite>";
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ 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(), null);
+ }
+
+ @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);
+ assertNotNull(composite);
+ assertTrue(composite.isLocal());
+ is.close();
+ }
+
+ @Test
+ @Ignore("TBF: The processor needs to write the xml based on the QName of the elements")
+ public void testWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("local.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite) staxProcessor.read(reader);
+ assertNotNull(composite);
+ assertTrue(composite.isLocal());
+ is.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ System.out.println(bos.toString());
+
+ assertEquals(LOCAL_COMPOSITE_XML, bos.toString());
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java
new file mode 100644
index 0000000000..2d2a703bcc
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.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.assembly.xml.osoa;
+
+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.assembly.ConstrainingType;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+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;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ resolver = new DefaultModelResolver();
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ // Create StAX processors
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+
+ URL url = getClass().getResource("CalculatorComponent.constrainingType");
+ URI uri = URI.create("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.constrainingType");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+
+ url = getClass().getResource("test_definitions.xml");
+ uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+
+ preResolvePolicyTests(composite);
+ documentProcessor.resolve(scaDefns, resolver);
+ documentProcessor.resolve(composite, resolver);
+
+ // Comment out the post resolving test
+ // postResolvePolicyTests(composite);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ 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);
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+
+ documentProcessor.resolve(composite, resolver);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolveTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolveTestCase.java
new file mode 100644
index 0000000000..628cc6acd6
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolveTestCase.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.osoa;
+
+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.assembly.ConstrainingType;
+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;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ resolver = new DefaultModelResolver();
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ StAXArtifactProcessor<ConstrainingType> constrainingTypeReader = staxProcessors.getProcessor(Constants.CONSTRAINING_TYPE_QNAME);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ConstrainingType constrainingType = constrainingTypeReader.read(reader);
+ is.close();
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ StAXArtifactProcessor<Composite> compositeReader = staxProcessors.getProcessor(Constants.COMPOSITE_QNAME);
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeReader.read(reader);
+ is.close();
+ assertNotNull(composite);
+
+ compositeReader.resolve(composite, resolver);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ StAXArtifactProcessor<Composite> compositeReader = staxProcessors.getProcessor(Constants.COMPOSITE_QNAME);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite nestedComposite = compositeReader.read(reader);
+ is.close();
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeReader.read(reader);
+ is.close();
+
+ compositeReader.resolve(composite, resolver);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestAttributeProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestAttributeProcessor.java
new file mode 100644
index 0000000000..173b987693
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestAttributeProcessor.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.xml.osoa;
+
+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.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) throws ContributionReadException, XMLStreamException {
+ return reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart());
+ }
+
+ public void write(String value, XMLStreamWriter writer) 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) throws ContributionResolveException {
+
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestPolicyProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestPolicyProcessor.java
new file mode 100644
index 0000000000..911b8b3ffd
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestPolicyProcessor.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.osoa;
+
+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.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) throws ContributionReadException, XMLStreamException {
+ return new MockPolicyImplOne();
+ }
+
+ public void write(PolicyExpression arg0, XMLStreamWriter arg1) throws ContributionWriteException,
+ XMLStreamException {
+ }
+
+ public Class<PolicyExpression> getModelType() {
+ return PolicyExpression.class;
+ }
+
+ public void resolve(PolicyExpression arg0, ModelResolver arg1) 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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingFactoryImpl.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingFactoryImpl.java
new file mode 100644
index 0000000000..15ca297369
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/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.osoa;
+
+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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingImpl.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingImpl.java
new file mode 100644
index 0000000000..5645a6b1c9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingImpl.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.xml.osoa;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+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.ComponentService;
+import org.apache.tuscany.sca.assembly.OptimizableBinding;
+import org.apache.tuscany.sca.assembly.SCABinding;
+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, OptimizableBinding, PolicySubject {
+ private String name;
+ private String uri;
+ private List<Object> extensions = new ArrayList<Object>();
+
+ private Component targetComponent;
+ private ComponentService targetComponentService;
+ private Binding targetBinding;
+
+ 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();
+ }
+
+ /**
+ * @return the targetComponent
+ */
+ public Component getTargetComponent() {
+ return targetComponent;
+ }
+
+ /**
+ * @param targetComponent the targetComponent to set
+ */
+ public void setTargetComponent(Component targetComponent) {
+ this.targetComponent = targetComponent;
+ }
+
+ /**
+ * @return the targetComponentService
+ */
+ public ComponentService getTargetComponentService() {
+ return targetComponentService;
+ }
+
+ /**
+ * @param targetComponentService the targetComponentService to set
+ */
+ public void setTargetComponentService(ComponentService targetComponentService) {
+ this.targetComponentService = targetComponentService;
+ }
+
+ /**
+ * @return the targetBinding
+ */
+ public Binding getTargetBinding() {
+ return targetBinding;
+ }
+
+ /**
+ * @param targetBinding the targetBinding to set
+ */
+ public void setTargetBinding(Binding targetBinding) {
+ this.targetBinding = targetBinding;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ // TODO Auto-generated method stub
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ // TODO Auto-generated method stub
+ return requiredIntents;
+ }
+
+ public ExtensionType getType() {
+ // TODO Auto-generated method stub
+ return bindingType;
+ }
+
+ public void setType(ExtensionType type) {
+ this.bindingType = type;
+ }
+
+ private class TestSCABindingType implements ExtensionType {
+ private QName name = new QName("http://www.osoa.org/xmlns/sca/1.0","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) {
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WireTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WireTestCase.java
new file mode 100644
index 0000000000..ffc1ce9aa0
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WireTestCase.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.xml.osoa;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+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.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+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 CompositeBuilder compositeBuilder;
+ private static Monitor monitor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
+ resolver = new DefaultModelResolver();
+
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ monitor = monitorFactory.createMonitor();
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+ compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ConstrainingType constrainingType = (ConstrainingType)staxProcessor.read(reader);
+ is.close();
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader);
+ is.close();
+ assertNotNull(composite);
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+
+ policyDefinitionsProcessor.resolve(scaDefns, resolver);
+
+ staxProcessor.resolve(composite, resolver);
+ compositeBuilder.build(composite, null, monitor);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite nestedComposite = (Composite)staxProcessor.read(reader);
+ is.close();
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader);
+ is.close();
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+
+ policyDefinitionsProcessor.resolve(scaDefns, resolver);
+
+ staxProcessor.resolve(composite, resolver);
+ compositeBuilder.build(composite, null, monitor);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteAllTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteAllTestCase.java
new file mode 100644
index 0000000000..c7d18f94ec
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteAllTestCase.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.osoa;
+
+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.ConstrainingType;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+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.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+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 CompositeBuilder compositeBuilder;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static Monitor monitor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null);
+ resolver = new DefaultModelResolver();
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+ compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ monitor = monitorFactory.createMonitor();
+
+ 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);
+
+ verifyComposite(composite);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ bos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ composite = staxProcessor.read(bis, Composite.class);
+
+ verifyComposite(composite);
+
+ }
+
+ @Test
+ public void testReadWireWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = staxProcessor.read(is, Composite.class);
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+ policyDefinitionsProcessor.resolve(scaDefns, resolver);
+
+ staxProcessor.resolve(composite, resolver);
+ compositeBuilder.build(composite, null, monitor);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ }
+
+ @Test
+ public void testReadWriteComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ ComponentType componentType = staxProcessor.read(is, ComponentType.class);
+ staxProcessor.resolve(componentType, resolver);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(componentType, bos);
+ }
+
+ @Test
+ public void testReadWriteConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = staxProcessor.read(is, ConstrainingType.class);
+ staxProcessor.resolve(constrainingType, resolver);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(constrainingType, bos);
+ }
+
+ 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://www.osoa.org/xmlns/sca/1.0", "MyComplexPropertyValue1"));
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteNamespacesTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteNamespacesTestCase.java
new file mode 100644
index 0000000000..66ddf3b003
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteNamespacesTestCase.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.xml.osoa;
+
+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.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;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ 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(Constants.COMPOSITE_QNAME);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+
+ // Read
+ InputStream is = getClass().getResourceAsStream("NestedCalculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeProcessor.read(reader);
+ 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);
+ System.out.println(bos);
+
+ // Read again
+ is = new ByteArrayInputStream(bos.toByteArray());
+ reader = inputFactory.createXMLStreamReader(is);
+ composite = compositeProcessor.read(reader);
+
+ // Compare
+ component = composite.getComponents().get(0);
+ implementation = (Composite)component.getImplementation();
+
+ assertEquals(qname, implementation.getName());
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Calculator.composite b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Calculator.composite
new file mode 100644
index 0000000000..614489d2d5
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/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://www.osoa.org/xmlns/sca/1.0"
+ 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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorComponent.constrainingType b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorComponent.constrainingType
new file mode 100644
index 0000000000..d6ec9b0ff0
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorComponent.constrainingType
@@ -0,0 +1,34 @@
+<?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.
+-->
+<constrainingType xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="CalculatorComponent">
+
+ <service name="CalculatorService">
+ <interface.java class="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService" multiplicity="1..1">
+ <interface.java class="calculator.DivideService" />
+ </reference>
+
+</constrainingType>
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorImpl.componentType b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorImpl.componentType
new file mode 100644
index 0000000000..299eb8c197
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/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://www.osoa.org/xmlns/sca/1.0">
+
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService">
+ <interface.java interface="calculator.DivideService" />
+ </reference>
+
+</componentType>
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/JavaScriptReference.composite b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/JavaScriptReference.composite
new file mode 100644
index 0000000000..308ad8754b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/JavaScriptReference.composite
@@ -0,0 +1,37 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ name="JavaScriptReference">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ </component>
+
+ <component name="ReferenceComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/references/reference.js"/>
+ <reference name="ref" target="TargetComponent" />
+ </component>
+
+ <component name="TargetComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.references.HelloWorldTarget"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Multiplicity.composite b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Multiplicity.composite
new file mode 100644
index 0000000000..369cbc00bf
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Multiplicity.composite
@@ -0,0 +1,30 @@
+<?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://www.osoa.org/xmlns/sca/1.0" name="composite1" targetNamespace="http://temp">
+ <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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/NestedCalculator.composite b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/NestedCalculator.composite
new file mode 100644
index 0000000000..6f71f0a7f1
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/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://www.osoa.org/xmlns/sca/1.0"
+ 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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/RMIBindingTest.composite b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/RMIBindingTest.composite
new file mode 100644
index 0000000000..2a0bcf0f76
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/RMIBindingTest.composite
@@ -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.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ 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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllCalculator.composite b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllCalculator.composite
new file mode 100644
index 0000000000..c52c8f79a9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllCalculator.composite
@@ -0,0 +1,123 @@
+<?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" constrainingType="tns:CalculatorComponent" local="true" name="TestAllCalculator" policySets="sns:SecureReliablePolicy"
+ requires="cns:confidentiality" targetNamespace="http://calc" xmlns:tns="http://calc"
+ xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osoa.org/xmlns/sca/1.0 http://www.osoa.org/xmlns/sca/1.0 "
+ 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" constrainingType="tns:CalculatorComponent"
+ 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">
+ <ext:testExtension/>
+ <MyComplexPropertyValue1 xsi:type="foo:MyComplexType" attr="bar">
+ <foo:a>AValue</foo:a>
+ <bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
+ </MyComplexPropertyValue1>
+ <MyComplexPropertyValue2 xsi:type="foo:MyComplexType" attr="zing">
+ <foo:a>BValue</foo:a>
+ <bar:b xmlns:bar="http://bar">BoringURI</bar:b>
+ </MyComplexPropertyValue2>
+ </property>
+
+ <property name="prop2" xmlns:foo="http://foo" mustSupply="true" element="MyComplexPropertyValue1"/>
+
+</composite>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllDivide.composite b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllDivide.composite
new file mode 100644
index 0000000000..d59e69209d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/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"
+ constrainingType="tns:Calculator"
+ local="true"
+ name="TestAllDivide"
+ policySets="" requires=""
+ targetNamespace="http://calc"
+ xmlns:tns="http://calc"
+ xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osoa.org/xmlns/sca/1.0 http://www.osoa.org/xmlns/sca/1.0 ">
+
+ <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" constrainingType="tns:CalculatorServiceComponent" 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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllPolicyCalculator.composite b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllPolicyCalculator.composite
new file mode 100644
index 0000000000..d0f66676e0
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllPolicyCalculator.composite
@@ -0,0 +1,126 @@
+<?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" constrainingType="tns:CalculatorComponent" local="true" name="TestAllCalculator"
+ requires="cns:tuscanyIntent_1" targetNamespace="http://calc" xmlns:tns="http://calc"
+ xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osoa.org/xmlns/sca/1.0 http://www.osoa.org/xmlns/sca/1.0 "
+ 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" constrainingType="tns:CalculatorComponent"
+ 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">
+ <ext:testExtension/>
+ <MyComplexPropertyValue1 xsi:type="foo:MyComplexType" attr="bar">
+ <foo:a>AValue</foo:a>
+ <bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
+ </MyComplexPropertyValue1>
+ <MyComplexPropertyValue2 xsi:type="foo:MyComplexType" attr="zing">
+ <foo:a>BValue</foo:a>
+ <bar:b xmlns:bar="http://bar">BoringURI</bar:b>
+ </MyComplexPropertyValue2>
+ </property>
+
+</composite>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/another_test_definitions.xml b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/another_test_definitions.xml
new file mode 100644
index 0000000000..be694f289f
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/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://www.osoa.org/xmlns/sca/1.0">
+
+<!-- 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/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/local.composite b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/local.composite
new file mode 100644
index 0000000000..abeab18a92
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://localcalc"
+ xmlns:test="http://testlocal"
+ targetNamespace="http://localcalc"
+ name="LocalCalculator"
+ local="true">
+
+</composite>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/test_definitions.xml b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/test_definitions.xml
new file mode 100644
index 0000000000..4616d07262
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/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://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+
+ <!-- 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://www.osoa.org/xmlns/sca/1.0" 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://www.osoa.org/xmlns/sca/1.0" 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://www.osoa.org/xmlns/sca/1.0" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <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://www.osoa.org/xmlns/sca/1.0" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="message">
+ <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://www.osoa.org/xmlns/sca/1.0">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://www.osoa.org/xmlns/sca/1.0" 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://www.osoa.org/xmlns/sca/1.0" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <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://www.osoa.org/xmlns/sca/1.0" 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/ant/sca/trunk/modules/assembly-xml/LICENSE b/sandbox/ant/sca/trunk/modules/assembly-xml/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly-xml/META-INF/MANIFEST.MF b/sandbox/ant/sca/trunk/modules/assembly-xml/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..25cd7c4695
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/META-INF/MANIFEST.MF
@@ -0,0 +1,39 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.assembly.xml;uses:="org.apache.
+ tuscany.sca.definitions,javax.xml.transform.dom,org.apache.tuscany.sc
+ a.core,org.apache.tuscany.sca.policy,javax.xml.namespace,org.apache.t
+ uscany.sca.contribution.java,javax.xml.stream,org.apache.tuscany.sca.
+ contribution.resolver,org.apache.tuscany.sca.policy.util,org.apache.t
+ uscany.sca.assembly,javax.xml.parsers,org.apache.tuscany.sca.contribu
+ tion,org.apache.tuscany.sca.monitor,org.w3c.dom,org.apache.tuscany.sc
+ a.interfacedef,org.apache.tuscany.sca.contribution.namespace,javax.xm
+ l.xpath,javax.xml.transform,org.apache.tuscany.sca.contribution.proce
+ ssor,org.apache.tuscany.sca.interfacedef.impl";version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA XML Assembly Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397124328
+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.xpath,org.apac
+ he.tuscany.sca.assembly;version="2.0.0",org.apache.tuscany.sca.assembly
+ .xml;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.tus
+ cany.sca.contribution.namespace;version="2.0.0",org.apache.tuscany.sca.
+ contribution.processor;version="2.0.0",org.apache.tuscany.sca.contribut
+ ion.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.s
+ ca.interfacedef;version="2.0.0",org.apache.tuscany.sca.interfacedef.imp
+ l;version="2.0.0",org.apache.tuscany.sca.monitor;version="2.0.0",org.apac
+ he.tuscany.sca.policy;version="2.0.0",org.apache.tuscany.sca.policy.uti
+ l;version="2.0.0",org.w3c.dom,org.xml.sa
+ x;resolution:=optional,javax.xml
+ .validation;resolution:=optional,org.apache.tuscany.sca.assembly.buil
+ der;version="2.0.0";resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.assembly.xml
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/NOTICE b/sandbox/ant/sca/trunk/modules/assembly-xml/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/pom.xml b/sandbox/ant/sca/trunk/modules/assembly-xml/pom.xml
new file mode 100644
index 0000000000..21170b24e3
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/pom.xml
@@ -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.
+-->
+<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-definitions</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy</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-contribution-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-namespace</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-java</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-definitions-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
new file mode 100644
index 0000000000..03a087a5ec
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
@@ -0,0 +1,906 @@
+/*
+ * 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.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
+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.ContributionWriteException;
+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.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+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;
+ private Monitor monitor;
+
+ /**
+ * Constructs a new BaseArtifactProcessor.
+ * @param assemblyFactory
+ * @param policyFactory
+ */
+ @SuppressWarnings("unchecked")
+ protected BaseAssemblyProcessor(AssemblyFactory assemblyFactory,
+ PolicyFactory policyFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ StAXArtifactProcessor extensionProcessor,
+ Monitor monitor) {
+ this.assemblyFactory = assemblyFactory;
+ this.policyFactory = policyFactory;
+ this.documentBuilderFactory = documentBuilderFactory;
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ this.monitor = monitor;
+ }
+
+ /**
+ * @param modelFactories
+ * @param staxProcessor
+ * @param monitor
+ */
+ protected BaseAssemblyProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor,
+ Monitor monitor) {
+ 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);
+ this.monitor = monitor;
+ }
+
+ /**
+ * Marshals warnings into the monitor
+ *
+ * @param message
+ * @param model
+ * @param messageParameters
+ */
+ protected void warning(String message, Object model, String... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "assembly-xml-validation-messages",
+ Severity.WARNING,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Marshals errors into the monitor
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "assembly-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Marshals exceptions into the monitor
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "assembly-xml-validation-messages",
+ 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 {
+ writeStart(writer, SCA11_NS, name, attrs);
+ }
+
+ /**
+ * Start a document.
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void writeStartDocument(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
+ writer.writeStartDocument();
+ writer.setDefaultNamespace(SCA11_NS);
+ writeStart(writer, SCA11_NS, name, attrs);
+ writer.writeDefaultNamespace(SCA11_NS);
+ }
+
+ /**
+ * Read list of reference targets
+ * @param reference
+ * @param reader
+ */
+ protected void readTargets(Reference reference, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, 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;
+ }
+
+ /**
+ * Returns the value of a constrainingType attribute.
+ * @param reader
+ * @return
+ */
+ protected ConstrainingType readConstrainingType(XMLStreamReader reader) {
+ QName constrainingTypeName = getQName(reader, Constants.CONSTRAINING_TYPE);
+ if (constrainingTypeName != null) {
+ ConstrainingType constrainingType = assemblyFactory.createConstrainingType();
+ constrainingType.setName(constrainingTypeName);
+ constrainingType.setUnresolved(true);
+ return constrainingType;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Reads an abstract property element.
+ * @param property
+ * @param reader
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ */
+ protected void readAbstractProperty(AbstractProperty property, XMLStreamReader reader) 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));
+
+ }
+
+ /**
+ * Resolve an implementation.
+ * @param implementation
+ * @param resolver
+ * @return
+ * @throws ContributionResolveException
+ */
+ protected Implementation resolveImplementation(Implementation implementation, ModelResolver resolver)
+ throws ContributionResolveException {
+ if (implementation != null) {
+ if (implementation.isUnresolved()) {
+ implementation = resolver.resolveModel(Implementation.class, implementation);
+
+ // Lazily resolve implementations
+ if (implementation.isUnresolved()) {
+ extensionProcessor.resolve(implementation, resolver);
+ if (!implementation.isUnresolved()) {
+ resolver.addModel(implementation);
+ }
+ }
+ }
+ }
+ 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
+ */
+ protected <C extends Contract> void resolveContracts(List<C> contracts, ModelResolver resolver)
+ throws ContributionResolveException {
+ resolveContracts(null, contracts, resolver);
+ }
+
+ /**
+ * 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
+ */
+ protected <C extends Contract> void resolveContracts(Base parent, List<C> contracts, ModelResolver resolver)
+ 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);
+ }
+
+ // Resolve bindings
+ for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
+ Binding binding = contract.getBindings().get(i);
+ extensionProcessor.resolve(binding, resolver);
+
+ }
+
+ // 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);
+ }
+ }
+ }
+ }
+
+ /**
+ * 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
+ */
+ protected <C extends AbstractContract> void resolveAbstractContracts(List<C> contracts, ModelResolver resolver)
+ throws ContributionResolveException {
+ for (AbstractContract contract : contracts) {
+
+ // Resolve the interface contract
+ InterfaceContract interfaceContract = contract.getInterfaceContract();
+ if (interfaceContract != null) {
+ extensionProcessor.resolve(interfaceContract, resolver);
+ }
+ }
+ }
+
+ /**
+ * Returns a constrainingType attribute.
+ * @param componentType
+ * @return
+ */
+ protected XAttr writeConstrainingType(ComponentType componentType) {
+ ConstrainingType constrainingType = componentType.getConstrainingType();
+ if (constrainingType != null)
+ return new XAttr(Constants.CONSTRAINING_TYPE, constrainingType.getName());
+ else
+ return null;
+ }
+
+ /*
+ protected List<Extension> readPropertyValue(XMLStreamReader reader) throws XMLStreamException,
+ ContributionReadException {
+ List<Extension> values = new ArrayList<Extension>();
+ 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) {
+ Extension ext = assemblyFactory.createExtension();
+ ext.setValue(valueAttr);
+ ext.setQName(VALUE_QNAME);
+ ext.setAttribute(true);
+ values.add(ext);
+ }
+
+ 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;
+ // Read <value>
+ if (VALUE_QNAME.equals(name)) {
+ Object value = extensionProcessor.read(reader);
+ // Assume the value is the XMLStreamReader for the content
+ Extension ext = assemblyFactory.createExtension();
+ ext.setValue(value);
+ ext.setQName(name);
+ values.add(ext);
+ } else {
+ // Global elements
+ // FIXME: do we want to check if the element mataches property.element
+ Object value = extensionProcessor.read(reader);
+ Extension ext = assemblyFactory.createExtension();
+ ext.setValue(value);
+ ext.setQName(name);
+ values.add(ext);
+ }
+ 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)) {
+ return values;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return values;
+ }
+ }
+ }
+ */
+
+ /**
+ * Read a property value into a DOM document.
+ * @param element
+ * @param type
+ * @param reader
+ * @return
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ * @throws ParserConfigurationException
+ */
+ protected Document readPropertyValue(QName element, QName type, XMLStreamReader reader) 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("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 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;
+ // Read <value>
+ if (VALUE_QNAME.equals(name)) {
+ loadElement(reader, root);
+ } 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 the text as an <value>
+ 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());
+ }
+ }
+ }
+ }
+
+ protected void addInheritedIntents(List<Intent> sourceList, List<Intent> targetList) {
+ if (sourceList != null) {
+ targetList.addAll(sourceList);
+ }
+ }
+
+ protected void addInheritedPolicySets(List<PolicySet> sourceList, List<PolicySet> targetList) {
+ if (sourceList != null) {
+ targetList.addAll(sourceList);
+ }
+ }
+
+ /**
+ *
+ * @param reader
+ * @param elementName
+ * @param estensibleElement
+ * @param extensionAttributeProcessor
+ * @throws ContributionReadException
+ * @throws XMLStreamException
+ */
+ protected void readExtendedAttributes(XMLStreamReader reader,
+ QName elementName,
+ Extensible estensibleElement,
+ StAXAttributeProcessor extensionAttributeProcessor)
+ throws ContributionReadException, XMLStreamException {
+ for (int a = 0; a < reader.getAttributeCount(); a++) {
+ QName attributeName = reader.getAttributeName(a);
+ if (attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) {
+ if (!elementName.getNamespaceURI().equals(attributeName.getNamespaceURI())) {
+ Object attributeValue = extensionAttributeProcessor.read(attributeName, reader);
+ Extension attributeExtension;
+ if (attributeValue instanceof Extension) {
+ attributeExtension = (Extension)attributeValue;
+ } else {
+ attributeExtension = assemblyFactory.createExtension();
+ attributeExtension.setQName(attributeName);
+ attributeExtension.setAttribute(true);
+ attributeExtension.setValue(attributeValue);
+ }
+ estensibleElement.getAttributeExtensions().add(attributeExtension);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param attributeModel
+ * @param writer
+ * @param extensibleElement
+ * @param extensionAttributeProcessor
+ * @throws ContributionWriteException
+ * @throws XMLStreamException
+ */
+ protected void writeExtendedAttributes(XMLStreamWriter writer,
+ Extensible extensibleElement,
+ StAXAttributeProcessor extensionAttributeProcessor)
+ throws ContributionWriteException, XMLStreamException {
+ for (Extension extension : extensibleElement.getAttributeExtensions()) {
+ if (extension.isAttribute()) {
+ extensionAttributeProcessor.write(extension, writer);
+ }
+ }
+ }
+
+ /*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/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java
new file mode 100644
index 0000000000..969115cf4c
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.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 java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+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 XMLInputFactory inputFactory;
+
+ /**
+ * Constructs a new componentType processor.
+ * @param modelFactories
+ * @param staxProcessor
+ */
+ public ComponentTypeDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor,
+ Monitor monitor) {
+ super(modelFactories, staxProcessor, monitor);
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ }
+
+ public ComponentType read(URL contributionURL, URI uri, URL url) throws ContributionReadException {
+ InputStream urlStream = null;
+ try {
+
+ // Create a stream reader
+ URLConnection connection = url.openConnection();
+ connection.setUseCaches(false);
+ urlStream = connection.getInputStream();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
+ reader.nextTag();
+
+ // Reader the componentType model
+ ComponentType componentType = (ComponentType)extensionProcessor.read(reader);
+ 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("ContributionReadException", inputFactory, ce);
+ throw ce;
+ } catch (IOException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("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) throws ContributionResolveException {
+ extensionProcessor.resolve(componentType, resolver);
+ }
+
+ public String getArtifactType() {
+ return ".componentType";
+ }
+
+ public Class<ComponentType> getModelType() {
+ return ComponentType.class;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java
new file mode 100644
index 0000000000..166bba8757
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.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.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.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) {
+ ComponentType componentType = (ComponentType)resolved;
+ map.put(componentType.getURI(), componentType);
+ }
+
+ public Object removeModel(Object resolved) {
+ return map.remove(((ComponentType)resolved).getURI());
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+
+ //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);
+ if (!resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return (T)unresolved;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
new file mode 100644
index 0000000000..0ea78177ff
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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 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.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.monitor.Monitor;
+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,
+ Monitor monitor) {
+ super(modelFactories, extensionProcessor, monitor);
+ }
+
+ public ComponentType read(XMLStreamReader reader) 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();
+ componentType.setConstrainingType(readConstrainingType(reader));
+
+ } 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);
+ policyProcessor.readPolicies(property, reader);
+
+ // Read the property value
+ Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
+ 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 {
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader);
+ 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("XMLStreamException", reader, ex);
+ }
+
+ return componentType;
+ }
+
+ public void write(ComponentType componentType, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ // Write <componentType> element
+ writeStartDocument(writer, COMPONENT_TYPE,
+ writeConstrainingType(componentType));
+
+ // 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);
+ }
+
+ for (Binding binding: service.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ if (service.getCallback() != null) {
+ Callback callback = service.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ for (Binding binding: callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+ for (Object extension: callback.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ for (Object extension: service.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+
+ for (Binding binding: reference.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK,
+ policyProcessor.writePolicies(callback));
+
+ for (Binding binding: callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+ for (Object extension: callback.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ for (Object extension: reference.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extension elements
+ if (componentType instanceof Extensible) {
+ for (Object extension: ((Extensible)componentType).getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+ }
+
+ // 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) throws ContributionResolveException {
+
+ // Resolve component type services and references
+ resolveContracts(componentType.getServices(), resolver);
+ resolveContracts(componentType.getReferences(), resolver);
+ }
+
+ public QName getArtifactType() {
+ return COMPONENT_TYPE_QNAME;
+ }
+
+ public Class<ComponentType> getModelType() {
+ return ComponentType.class;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
new file mode 100644
index 0000000000..b6182e3950
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
@@ -0,0 +1,202 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+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.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.util.PolicyComputationUtils;
+
+/**
+ * A composite processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<Composite> {
+ private XMLInputFactory inputFactory;
+ private DocumentBuilderFactory documentBuilderFactory;
+ private List scaDefnSink;
+ private Collection<PolicySet> domainPolicySets = null;
+ private int scaDefnsCount = 0;
+
+ /**
+ * Constructs a new composite processor.
+ * @param modelFactories
+ * @param staxProcessor
+ */
+ public CompositeDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor,
+ Monitor monitor) {
+ super(modelFactories, staxProcessor, monitor);
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ this.documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
+ }
+
+ public Composite read(URL contributionURL, URI uri, URL url) throws ContributionReadException {
+ InputStream scdlStream = null;
+ try {
+ URLConnection connection = url.openConnection();
+ connection.setUseCaches(false);
+ scdlStream = connection.getInputStream();
+ } catch (IOException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", url, ce);
+ throw ce;
+ }
+ return read(uri, scdlStream);
+ }
+
+ public Composite read(URI uri, InputStream scdlStream) throws ContributionReadException {
+ try {
+/*
+ if (scaDefnSink != null ) {
+ fillDomainPolicySets(scaDefnSink);
+ }
+*/
+
+ Composite composite = null;
+
+ byte[] transformedArtifactContent;
+ try {
+ if ( domainPolicySets != null ) {
+ transformedArtifactContent =
+ PolicyComputationUtils.addApplicablePolicySets(scdlStream, domainPolicySets, documentBuilderFactory);
+ scdlStream = new ByteArrayInputStream(transformedArtifactContent);
+ }
+ } catch ( IOException e ) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", scdlStream, ce);
+ throw ce;
+ } catch ( Exception e ) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", scdlStream, ce);
+ //throw ce;
+ }
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(scdlStream);
+
+ reader.nextTag();
+
+ // Read the composite model
+ composite = (Composite)extensionProcessor.read(reader);
+ if (composite != null) {
+ composite.setURI(uri.toString());
+ }
+
+ // For debugging purposes, write it back to XML
+// if (composite != null) {
+// try {
+// ByteArrayOutputStream bos = new ByteArrayOutputStream();
+// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+// extensionProcessor.write(composite, 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 composite;
+
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", inputFactory, ce);
+ throw ce;
+ } finally {
+ try {
+ if (scdlStream != null) {
+ scdlStream.close();
+ scdlStream = null;
+ }
+ } catch (IOException ioe) {
+ //ignore
+ }
+ }
+ }
+
+ public void resolve(Composite composite, ModelResolver resolver) throws ContributionResolveException {
+ if (composite != null)
+ extensionProcessor.resolve(composite, resolver);
+ }
+
+ public String getArtifactType() {
+ return ".composite";
+ }
+
+ public Class<Composite> getModelType() {
+ return Composite.class;
+ }
+
+ /*
+ * TODO - remove - definitions information is now aggregated in the
+ * systems definitions contribution and we need to add
+ * applicable policy sets once all composites have been read
+ private void fillDomainPolicySets(List scaDefnsSink) {
+ Map<QName, PolicySet> domainPolicySetMap = null;
+ if ( scaDefnsSink.size() > scaDefnsCount ) {
+ //if ( !scaDefnsSink.isEmpty() ) {
+ domainPolicySetMap = new Hashtable<QName, PolicySet>();
+
+ if ( domainPolicySets != null ) {
+ for ( PolicySet policySet : domainPolicySets ) {
+ domainPolicySetMap.put(policySet.getName(), policySet);
+ }
+ }
+
+ for ( Object object : scaDefnsSink ) {
+ if ( object instanceof Definitions ) {
+ for ( PolicySet policySet : ((Definitions)object).getPolicySets() ) {
+ domainPolicySetMap.put( policySet.getName(), policySet);
+ }
+ }
+ }
+ domainPolicySets = domainPolicySetMap.values();
+ //scaDefnsSink.clear();
+ scaDefnsCount = scaDefnsSink.size();
+ }
+ }
+ */
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java
new file mode 100644
index 0000000000..62ed95cb01
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.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 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.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * 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) {
+ Composite composite = (Composite)resolved;
+ map.put(composite.getName(), composite);
+ }
+
+ public Object removeModel(Object resolved) {
+ return map.remove(((Composite)resolved).getName());
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+
+ // Lookup a definition for the given namespace
+ QName qname = ((Composite)unresolved).getName();
+ Composite resolved = (Composite) map.get(qname);
+ if (resolved != null) {
+ return modelClass.cast(resolved);
+ }
+
+ // No definition found, 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);
+ if (!resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+ }
+ return (T)unresolved;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
new file mode 100644
index 0000000000..7a2eba494f
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
@@ -0,0 +1,1047 @@
+/*
+ * 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.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.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.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.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.XPath;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+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.ConstrainingType;
+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.contribution.Artifact;
+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.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.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.w3c.dom.Document;
+
+/**
+ * A composite processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<Composite> {
+ private XPathFactory xPathFactory;
+ private PolicyFactory intentAttachPointTypeFactory;
+ private StAXAttributeProcessor<Object> extensionAttributeProcessor;
+ private ContributionFactory contributionFactory;
+
+
+ /**
+ * Construct a new composite processor
+ *
+ * @param extensionPoints
+ * @param extensionProcessor
+ */
+ public CompositeProcessor(ExtensionPointRegistry extensionPoints,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor,
+ Monitor monitor) {
+
+ this(modelFactories(extensionPoints),
+ extensionProcessor,
+ extensionAttributeProcessor,
+ monitor(extensionPoints));
+
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
+ }
+
+ /**
+ * Constructs a new composite processor
+ *
+ * @param modelFactories
+ * @param extensionProcessor
+ * @param monitor
+ */
+ private CompositeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor,
+ Monitor monitor) {
+
+ super(modelFactories, extensionProcessor, monitor);
+ this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.xPathFactory = modelFactories.getFactory(XPathFactory.class);
+ this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
+
+ }
+
+ public Composite read(XMLStreamReader reader) 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;
+
+ 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(getString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
+
+ if(!isSet(reader, TARGET_NAMESPACE)){
+ // spec says that a composite must have a namespace
+ warning("NoCompositeNamespace", composite, composite.getName().toString());
+ }
+
+ if(isSet(reader, AUTOWIRE)) {
+ composite.setAutowire(getBoolean(reader, AUTOWIRE));
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, composite, extensionAttributeProcessor);
+
+ composite.setLocal(getBoolean(reader, LOCAL));
+ composite.setConstrainingType(readConstrainingType(reader));
+ policyProcessor.readPolicies(composite, reader);
+
+ } else if (INCLUDE_QNAME.equals(name)) {
+
+ // Read an <include>
+ include = assemblyFactory.createComposite();
+ include.setName(getQName(reader, NAME));
+ include.setURI(getString(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);
+
+ 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 = getString(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);
+
+ composite.getServices().add(compositeService);
+ policyProcessor.readPolicies(contract, reader);
+ }
+
+ } 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);
+
+ 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 = reader.getAttributeValue(null, 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("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);
+
+ composite.getReferences().add(compositeReference);
+ policyProcessor.readPolicies(contract, reader);
+ }
+
+ } else if (PROPERTY_QNAME.equals(name)) {
+ if (component != null) {
+
+ // Read a <component><property>
+ componentProperty = assemblyFactory.createComponentProperty();
+ property = componentProperty;
+ String source = getString(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 = source + "/";
+ index = source.length() - 1;
+ }
+ source = source.substring(index + 1);
+ if ("".equals(source)) {
+ source = ".";
+ }
+ }
+ XPath xpath = xPathFactory.newXPath();
+ xpath.setNamespaceContext(reader.getNamespaceContext());
+ try {
+ componentProperty.setSourceXPathExpression(xpath.compile(source));
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", xpath, ce);
+ //throw ce;
+ }
+ }
+ componentProperty.setFile(getString(reader, FILE));
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, componentProperty, extensionAttributeProcessor);
+
+ policyProcessor.readPolicies(property, reader);
+ readAbstractProperty(componentProperty, reader);
+
+ // Read the property value
+ Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
+ property.setValue(value);
+
+ component.getProperties().add(componentProperty);
+ } else {
+
+ // Read a <composite><property>
+ property = assemblyFactory.createProperty();
+ policyProcessor.readPolicies(property, reader);
+ readAbstractProperty(property, reader);
+
+ // Read the property value
+ Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
+ 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(getString(reader, URI));
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, component, extensionAttributeProcessor);
+
+ component.setConstrainingType(readConstrainingType(reader));
+ 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(getString(reader, SOURCE));
+ wire.setSource(source);
+
+ ComponentService target = assemblyFactory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(getString(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);
+
+ composite.getWires().add(wire);
+ policyProcessor.readPolicies(wire, reader);
+
+ } else if (CALLBACK_QNAME.equals(name)) {
+
+ // Read a <callback>
+ callback = assemblyFactory.createCallback();
+ contract.setCallback(callback);
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, callback, extensionAttributeProcessor);
+
+ policyProcessor.readPolicies(callback, reader);
+
+ } 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);
+
+ component.setImplementation(implementation);
+ policyProcessor.readPolicies(implementation, reader);
+ } else {
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader);
+ 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("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).setType(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("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).setType(implType);
+ }
+ // <component><implementation>
+ if (component != null) {
+ component.setImplementation((Implementation)extension);
+ } else {
+ if (name.getNamespaceURI().equals(SCA11_NS)) {
+ error("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("XMLStreamException", reader, ex);
+ }
+
+ return composite;
+ }
+
+ public void write(Composite composite, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ // Write <composite> element
+ writeStartDocument(writer,
+ COMPOSITE,
+ writeConstrainingType(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);
+
+ // 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);
+
+ 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);
+
+
+ // Write service interface
+ extensionProcessor.write(service.getInterfaceContract(), writer);
+
+ // Write bindings
+ for (Binding binding : service.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // 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);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write extensions
+ for (Object extension : callback.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extension : service.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+
+ // 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);
+
+ writeEnd(writer);
+ } else {
+ extensionProcessor.write(component.getImplementation(), writer);
+ }
+
+ for (Object extension : component.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ // 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);
+
+ // Write service interface
+ extensionProcessor.write(service.getInterfaceContract(), writer);
+
+ // Write bindings
+ for (Binding binding : service.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // 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);
+
+ // Write bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write extensions
+ for (Object extension : callback.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extension : service.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+
+ // Write reference interface
+ extensionProcessor.write(reference.getInterfaceContract(), writer);
+
+ // Write bindings
+ for (Binding binding : reference.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write callback
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write extensions
+ for (Object extensions : callback.getExtensions()) {
+ extensionProcessor.write(extensions, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extensions : reference.getExtensions()) {
+ extensionProcessor.write(extensions, writer);
+ }
+
+ 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);
+
+ // Write property value
+ writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : property.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+
+ // Write reference interface
+ extensionProcessor.write(reference.getInterfaceContract(), writer);
+
+ // Write bindings
+ for (Binding binding : reference.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write <callback> element
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK);
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer);
+ }
+
+ // Write extensions
+ for (Object extension : callback.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extension : reference.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+
+ // Write property value
+ writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : property.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ 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);
+
+ // Write extensions
+ for (Object extension : wire.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+ writeEnd(writer);
+ }
+
+ for (Object extension : composite.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(Composite composite, ModelResolver resolver) throws ContributionResolveException {
+
+ // Resolve constraining type
+ ConstrainingType constrainingType = composite.getConstrainingType();
+ if (constrainingType != null) {
+ constrainingType = resolver.resolveModel(ConstrainingType.class, constrainingType);
+ composite.setConstrainingType(constrainingType);
+ }
+
+ // 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) {
+ include = resolver.resolveModel(Composite.class, include);
+ composite.getIncludes().set(i, include);
+ }
+ }
+
+ // Resolve extensions
+ for (Object extension : composite.getExtensions()) {
+ if (extension != null) {
+ extensionProcessor.resolve(extension, resolver);
+ }
+ }
+
+ //Resolve composite services and references
+ resolveContracts(composite, composite.getServices(), resolver);
+ resolveContracts(composite, composite.getReferences(), resolver);
+
+ // Resolve component implementations, services and references
+ for (Component component : composite.getComponents()) {
+ constrainingType = component.getConstrainingType();
+ if (constrainingType != null) {
+ constrainingType = resolver.resolveModel(ConstrainingType.class, constrainingType);
+ component.setConstrainingType(constrainingType);
+ }
+
+ //resolve component services and references
+ resolveContracts(component, component.getServices(), resolver);
+ resolveContracts(component, component.getReferences(), resolver);
+
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ if (componentProperty.getFile() != null) {
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(componentProperty.getFile());
+ artifact = resolver.resolveModel(Artifact.class, artifact);
+ if (artifact.getLocation() != null) {
+ componentProperty.setFile(artifact.getLocation());
+ }
+ }
+ }
+
+ //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);
+
+ 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);
+ }
+ }
+ }
+
+ 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);
+ }
+
+ /**
+ * Returns the monitor to use.
+ *
+ * @param extensionPoints
+ * @return
+ */
+ private static Monitor monitor(ExtensionPointRegistry extensionPoints) {
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ if (utilities != null) {
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ if (monitorFactory != null) {
+ return monitorFactory.createMonitor();
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java
new file mode 100644
index 0000000000..ce8b461a27
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.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.assembly.xml;
+
+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/200903";
+ 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 CONSTRAINING_TYPE = "constrainingType";
+ QName CONSTRAINING_TYPE_QNAME = new QName(SCA11_NS, CONSTRAINING_TYPE);
+
+ 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";
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java
new file mode 100644
index 0000000000..401fa7123e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java
@@ -0,0 +1,127 @@
+/*
+ * 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 java.net.URLConnection;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+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 contrainingType content handler.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<ConstrainingType> {
+ private XMLInputFactory inputFactory;
+
+ /**
+ * Constructs a new constrainingType processor.
+ * @param modelFactories
+ * @param staxProcessor
+ */
+ public ConstrainingTypeDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor,
+ Monitor monitor) {
+ super(modelFactories, staxProcessor, monitor);
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ }
+
+ public ConstrainingType read(URL contributionURL, URI uri, URL url) throws ContributionReadException {
+ InputStream urlStream = null;
+ try {
+
+ // Create a stream reader
+ URLConnection connection = url.openConnection();
+ connection.setUseCaches(false);
+ urlStream = connection.getInputStream();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
+ reader.nextTag();
+
+ // Read the constrainingType model
+ ConstrainingType constrainingType = (ConstrainingType)extensionProcessor.read(reader);
+
+ // For debugging purposes, write it back to XML
+// if (constrainingType != null) {
+// try {
+// ByteArrayOutputStream bos = new ByteArrayOutputStream();
+// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+// extensionProcessor.write(constrainingType, 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 constrainingType;
+
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", inputFactory, ce);
+ throw ce;
+ } catch (IOException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", inputFactory, ce);
+ throw ce;
+ } finally {
+ try {
+ if (urlStream != null) {
+ urlStream.close();
+ urlStream = null;
+ }
+ } catch (IOException ioe) {
+ //ignore
+ }
+ }
+ }
+
+ public void resolve(ConstrainingType constrainingType, ModelResolver resolver) throws ContributionResolveException {
+ extensionProcessor.resolve(constrainingType, resolver);
+ }
+
+ public String getArtifactType() {
+ return ".constrainingType";
+ }
+
+ public Class<ConstrainingType> getModelType() {
+ return ConstrainingType.class;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeModelResolver.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeModelResolver.java
new file mode 100644
index 0000000000..d73ce5ab66
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeModelResolver.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 java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+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.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * A Model Resolver for ConstrainingType models.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeModelResolver implements ModelResolver {
+
+ private Contribution contribution;
+ private Map<QName, ConstrainingType> map = new HashMap<QName, ConstrainingType>();
+
+ public ConstrainingTypeModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ }
+
+ public void addModel(Object resolved) {
+ ConstrainingType composite = (ConstrainingType)resolved;
+ map.put(composite.getName(), composite);
+ }
+
+ public Object removeModel(Object resolved) {
+ return map.remove(((ConstrainingType)resolved).getName());
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+
+ // Lookup a definition for the given namespace
+ QName qname = ((ConstrainingType)unresolved).getName();
+ ConstrainingType resolved = (ConstrainingType) map.get(qname);
+ if (resolved != null) {
+ return modelClass.cast(resolved);
+ }
+
+ // No definition found, 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(ConstrainingType.class, (ConstrainingType)unresolved);
+ if (!resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+ }
+ return (T)unresolved;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java
new file mode 100644
index 0000000000..34c4bc9909
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java
@@ -0,0 +1,273 @@
+/*
+ * 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.CONSTRAINING_TYPE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.CONSTRAINING_TYPE_QNAME;
+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.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.TARGET_NAMESPACE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TYPE;
+
+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.AbstractContract;
+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.ConstrainingType;
+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.StAXArtifactProcessor;
+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.monitor.Monitor;
+import org.w3c.dom.Document;
+
+/**
+ * A constrainingType processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<ConstrainingType> {
+
+ /**
+ * Constructs a new constrainingType processor.
+ *
+ * @param modelFactories
+ * @param extensionProcessor
+ */
+ public ConstrainingTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor extensionProcessor,
+ Monitor monitor) {
+ super(modelFactories, extensionProcessor, monitor);
+ }
+
+ public ConstrainingType read(XMLStreamReader reader) throws ContributionReadException {
+ ConstrainingType constrainingType = null;
+ AbstractService abstractService = null;
+ AbstractReference abstractReference = null;
+ AbstractProperty abstractProperty = null;
+ AbstractContract abstractContract = null;
+ QName name = null;
+
+ try {
+ // Read the constrainingType document
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+
+ case START_ELEMENT:
+ name = reader.getName();
+
+ // Read a <constrainingType>
+ if (Constants.CONSTRAINING_TYPE_QNAME.equals(name)) {
+ constrainingType = assemblyFactory.createConstrainingType();
+ constrainingType.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
+ policyProcessor.readPolicies(constrainingType, reader);
+
+ } else if (Constants.SERVICE_QNAME.equals(name)) {
+
+ // Read a <service>
+ abstractService = assemblyFactory.createAbstractService();
+ abstractContract = abstractService;
+ abstractService.setName(getString(reader, Constants.NAME));
+ constrainingType.getServices().add(abstractService);
+ policyProcessor.readPolicies(abstractService, reader);
+
+ } else if (Constants.REFERENCE_QNAME.equals(name)) {
+
+ // Read a <reference>
+ abstractReference = assemblyFactory.createAbstractReference();
+ abstractContract = abstractReference;
+ abstractReference.setName(getString(reader, Constants.NAME));
+ readMultiplicity(abstractReference, reader);
+ constrainingType.getReferences().add(abstractReference);
+ policyProcessor.readPolicies(abstractReference, reader);
+
+ } else if (Constants.PROPERTY_QNAME.equals(name)) {
+
+ // Read a <property>
+ abstractProperty = assemblyFactory.createAbstractProperty();
+ readAbstractProperty(abstractProperty, reader);
+
+ // Read the property value
+ Document value = readPropertyValue(abstractProperty.getXSDElement(), abstractProperty.getXSDType(), reader);
+ abstractProperty.setValue(value);
+
+ constrainingType.getProperties().add(abstractProperty);
+ policyProcessor.readPolicies(abstractProperty, reader);
+
+ } else if (OPERATION_QNAME.equals(name)) {
+
+ // Read an <operation>
+ Operation operation = new OperationImpl();
+ operation.setName(getString(reader, NAME));
+ operation.setUnresolved(true);
+ policyProcessor.readPolicies(abstractContract, operation, reader);
+
+ } else {
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader);
+ if (extension instanceof InterfaceContract) {
+
+ // <service><interface> and <reference><interface>
+ abstractContract.setInterfaceContract((InterfaceContract)extension);
+ } else {
+
+ // Add the extension element to the current element
+ if (abstractContract != null) {
+ abstractContract.getExtensions().add(extension);
+ } else {
+ constrainingType.getExtensions().add(extension);
+ }
+
+ }
+ }
+ break;
+
+ case END_ELEMENT:
+ name = reader.getName();
+
+ // Clear current state when reading reaching end element
+ if (SERVICE_QNAME.equals(name)) {
+ abstractService = null;
+ abstractContract = null;
+ } else if (REFERENCE_QNAME.equals(name)) {
+ abstractReference = null;
+ abstractContract = null;
+ } else if (PROPERTY_QNAME.equals(name)) {
+ abstractProperty = null;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ }
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error("XMLStreamException", reader, ex);
+ }
+
+ return constrainingType;
+ }
+
+ public void write(ConstrainingType constrainingType, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ // Write <constrainingType> element
+ writeStartDocument(writer, CONSTRAINING_TYPE,
+ new XAttr(TARGET_NAMESPACE, constrainingType.getName().getNamespaceURI()),
+ new XAttr(NAME, constrainingType.getName().getLocalPart()),
+ policyProcessor.writePolicies(constrainingType));
+
+ // Write <service> elements
+ for (AbstractService service : constrainingType.getServices()) {
+ writeStart(writer, SERVICE, new XAttr(NAME, service.getName()),
+ policyProcessor.writePolicies(service));
+
+ extensionProcessor.write(service.getInterfaceContract(), writer);
+
+ for (Object extension: service.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write <reference> elements
+ for (AbstractReference reference : constrainingType.getReferences()) {
+ writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()),
+ writeMultiplicity(reference),
+ policyProcessor.writePolicies(reference));
+
+ extensionProcessor.write(reference.getInterfaceContract(), writer);
+
+ for (Object extension: reference.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write <property> elements
+ for (AbstractProperty abstractProperty : constrainingType.getProperties()) {
+ writeStart(writer,
+ PROPERTY,
+ new XAttr(NAME, abstractProperty.getName()),
+ new XAttr(MUST_SUPPLY, abstractProperty.isMustSupply()),
+ new XAttr(MANY, abstractProperty.isMany()),
+ new XAttr(TYPE, abstractProperty.getXSDType()),
+ new XAttr(ELEMENT, abstractProperty.getXSDElement()),
+ policyProcessor.writePolicies(abstractProperty));
+
+ // Write property value
+ writePropertyValue(abstractProperty.getValue(), abstractProperty.getXSDElement(), abstractProperty.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : abstractProperty.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extension elements
+ for (Object extension: constrainingType.getExtensions()) {
+ extensionProcessor.write(extension, writer);
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(ConstrainingType constrainingType, ModelResolver resolver) throws ContributionResolveException {
+ // Resolve component type services and references
+ resolveAbstractContracts(constrainingType.getServices(), resolver);
+ resolveAbstractContracts(constrainingType.getReferences(), resolver);
+ }
+
+ public QName getArtifactType() {
+ return CONSTRAINING_TYPE_QNAME;
+ }
+
+ public Class<ConstrainingType> getModelType() {
+ return ConstrainingType.class;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java
new file mode 100644
index 0000000000..e525cc677a
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java
@@ -0,0 +1,254 @@
+/*
+ * 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.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.policy.PolicySubject;
+
+/**
+ * Default Model Processor for beans.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultBeanModelProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor {
+
+ private QName artifactType;
+ private Class<Implementation> 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<Implementation> modelClass,
+ Object modelFactory,
+ Monitor monitor) {
+ super(modeFactories, null, monitor);
+ 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 Object read(XMLStreamReader reader) 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 = 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 model;
+
+ } catch (Exception e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", reader, ce);
+ throw ce;
+ }
+ }
+
+ public void write(Object bean, XMLStreamWriter writer) 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("ContributionWriteException", writer, ce);
+ throw ce;
+ }
+ }
+
+ public void resolve(Object bean, ModelResolver resolver) 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);
+ 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());
+ implementation.setConstrainingType(componentType.getConstrainingType());
+
+ 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<?> getModelType() {
+ return modelClass;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
new file mode 100644
index 0000000000..d69f30aceb
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
@@ -0,0 +1,252 @@
+/*
+ * 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.resolver.ModelResolver;
+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$
+ */
+public class PolicySubjectProcessor extends BaseStAXArtifactProcessor {
+
+ private PolicyFactory policyFactory;
+
+ public PolicySubjectProcessor(PolicyFactory policyFactory) {
+ this.policyFactory = policyFactory;
+ }
+
+ /**
+ * Read policy intents associated with an operation.
+ * @param attachPoint
+ * @param operation
+ * @param reader
+ */
+ private void readIntents(Object attachPoint, Operation operation, XMLStreamReader reader) {
+ if (!(attachPoint instanceof PolicySubject))
+ return;
+ PolicySubject intentAttachPoint = (PolicySubject)attachPoint;
+ 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 attachPoint
+ * @param operation
+ * @param reader
+ */
+ public void readPolicies(Object attachPoint, Operation operation, XMLStreamReader reader) {
+ readIntents(attachPoint, operation, reader);
+ readPolicySets(attachPoint, operation, reader);
+ }
+
+ /**
+ * Reads policy intents and policy sets.
+ * @param attachPoint
+ * @param reader
+ */
+ public void readPolicies(Object attachPoint, XMLStreamReader reader) {
+ readPolicies(attachPoint, null, reader);
+ }
+
+ /**
+ * Reads policy sets associated with an operation.
+ * @param attachPoint
+ * @param operation
+ * @param reader
+ */
+ private void readPolicySets(Object attachPoint, Operation operation, XMLStreamReader reader) {
+ if (!(attachPoint instanceof PolicySubject)) {
+ return;
+ }
+ PolicySubject policySubject = (PolicySubject)attachPoint;
+ 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 attachPoint
+ * @return
+ */
+ XAttr writePolicies(Object attachPoint) throws XMLStreamException {
+ return writePolicies(attachPoint, (Operation)null);
+ }
+
+ /**
+ * Write policies
+ * @param attachPoint
+ * @return
+ */
+ public void writePolicyAttributes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException {
+ writePolicyAttributes(attachPoint, (Operation)null, writer);
+ }
+
+ /**
+ * Write policies
+ * @param attachPoint
+ * @return
+ */
+ public void writePolicyPrefixes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException {
+ writePolicyPrefixes(attachPoint, (Operation)null, writer);
+ }
+
+ /**
+ * Write policies associated with an operation
+ * @param attachPoint
+ * @param operation
+ * @return
+ */
+ XAttr writePolicies(Object attachPoint, Operation operation) {
+ List<XAttr> attrs =new ArrayList<XAttr>();
+ attrs.add(writeIntents(attachPoint, operation));
+ attrs.add(writePolicySets(attachPoint, operation));
+ return new XAttr(null, attrs);
+ }
+
+ /**
+ * Write policies
+ * @param attachPoint
+ * @return
+ */
+ public void writePolicyAttributes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException {
+ XAttr attr = writePolicies(attachPoint, operation);
+ attr.write(writer);
+ }
+
+ /**
+ * Write policies
+ * @param attachPoint
+ * @return
+ */
+ public void writePolicyPrefixes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException {
+ XAttr attr = writePolicies(attachPoint, operation);
+ attr.writePrefix(writer);
+ }
+
+ /**
+ * Write policy intents associated with an operation.
+ * @param attachPoint
+ * @param operation
+ */
+ private XAttr writeIntents(Object attachPoint, Operation operation) {
+ if (!(attachPoint instanceof PolicySubject)) {
+ return null;
+ }
+ PolicySubject intentAttachPoint = (PolicySubject)attachPoint;
+ 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 attachPoint
+ * @param operation
+ */
+ private XAttr writePolicySets(Object attachPoint, Operation operation) {
+ if (!(attachPoint instanceof PolicySubject)) {
+ return null;
+ }
+ PolicySubject policySetAttachPoint = (PolicySubject)attachPoint;
+ 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 attachPoint, ModelResolver resolver) {
+ if ( attachPoint instanceof PolicySubject ) {
+ PolicySubject policySetAttachPoint = (PolicySubject)attachPoint;
+
+ 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);
+ 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);
+ resolvedPolicySets.add(resolvedPolicySet);
+ }
+ policySetAttachPoint.getPolicySets().clear();
+ policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets);
+ }
+ }
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..1da30f637c
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.ComponentTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#componentType,model=org.apache.tuscany.sca.assembly.ComponentType
+org.apache.tuscany.sca.assembly.xml.ConstrainingTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#constrainingType,model=org.apache.tuscany.sca.assembly.ConstrainingType
+org.apache.tuscany.sca.assembly.xml.CompositeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#composite,model=org.apache.tuscany.sca.assembly.Composite
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
new file mode 100644
index 0000000000..403c049b48
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
@@ -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.
+
+# 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.ConstrainingTypeDocumentProcessor;type=.constrainingType,model=org.apache.tuscany.sca.assembly.ConstrainingType
+org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor;type=.composite,model=org.apache.tuscany.sca.assembly.Composite
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..ecc34942f1
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -0,0 +1,20 @@
+# 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.ConstrainingTypeModelResolver;model=org.apache.tuscany.sca.assembly.ConstrainingType
+org.apache.tuscany.sca.assembly.xml.ComponentTypeModelResolver;model=org.apache.tuscany.sca.assembly.ComponentType
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/assembly-xml-validation-messages.properties b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/assembly-xml-validation-messages.properties
new file mode 100644
index 0000000000..8cc5e5a5ec
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/main/resources/assembly-xml-validation-messages.properties
@@ -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.
+#
+#
+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}
+ContributionWriteException = ContributionWriteException occured due to : {0}
+XMLStreamException = XMLStreamException occured due to : {0}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java
new file mode 100644
index 0000000000..f624f77b81
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.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.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+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.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $
+ */
+public class BuildPolicyTestCase {
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static ModelResolver resolver;
+ private static CompositeBuilder compositeBuilder;
+ private static Composite composite;
+ private static Monitor monitor;
+
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ /*
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+ compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ List<Definitions> policyDefinitions = new ArrayList<Definitions>();
+ resolver = new DefaultModelResolver();
+
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ monitor = monitorFactory.createMonitor();
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(extensionPoints);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+
+ URL url = BuildPolicyTestCase.class.getResource("CalculatorComponent.constrainingType");
+ URI uri = URI.create("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ url = BuildPolicyTestCase.class.getResource("TestAllPolicyCalculator.composite");
+ uri = URI.create("TestAllCalculator.constrainingType");
+ composite = (Composite)documentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+
+ url = BuildPolicyTestCase.class.getResource("another_test_definitions.xml");
+ uri = URI.create("another_test_definitions.xml");
+ Definitions definitions = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(definitions);
+ policyDefinitions.add(definitions);
+
+ documentProcessor.resolve(definitions, resolver);
+ documentProcessor.resolve(composite, resolver);
+
+ compositeBuilder.build(composite, null, monitor);
+ */
+ }
+
+ //@Test
+ @Ignore("The inheritance will be calculated differently in OASIS SCA")
+ public void testPolicyIntentInheritance() throws Exception {
+ String namespaceUri = "http://test";
+
+ PolicySubject policiedComposite = (PolicySubject)composite;
+ assertEquals(policiedComposite.getRequiredIntents().size(), 1);
+ assertEquals(policiedComposite.getRequiredIntents().get(0).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
+
+ //1 defined for composite, 2 defined for the service, 1 defined and 3 inherited for the promoted service (4)
+ assertEquals(composite.getServices().get(0).getRequiredIntents().size(), 7);
+ //1 from the operation defined in this service and 2 from the operation defined in the promoted service
+ assertEquals(composite.getServices().get(0).getRequiredIntents().get(3).getName(), new QName(namespaceUri, "tuscanyIntent_3"));
+ //bindings will have only 2 intents since duplications will be cut out
+ assertEquals(((PolicySubject)composite.getServices().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
+
+ assertEquals(composite.getReferences().get(0).getRequiredIntents().size(), 5);
+ assertEquals(composite.getReferences().get(0).getRequiredIntents().get(1).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
+ assertEquals(((PolicySubject)composite.getReferences().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
+
+ assertEquals(composite.getComponents().get(0).getRequiredIntents().size(), 3);
+ assertEquals(composite.getComponents().get(0).getRequiredIntents().get(2).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
+ assertEquals(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().size(), 4);
+ assertEquals(composite.getComponents().get(0).getServices().get(0).getCallback().getRequiredIntents().size(), 4);
+ assertEquals(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().size(), 5);
+ }
+
+ @Test
+ public void testDummy() throws Exception {
+
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java
new file mode 100644
index 0000000000..4e74c55949
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java
@@ -0,0 +1,86 @@
+/*
+ * 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.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;
+
+
+ @Before
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null);
+ }
+
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Multiplicity.composite");
+ Composite composite = staxProcessor.read(is, Composite.class);
+
+ verifyComposite(composite);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ bos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ composite = staxProcessor.read(bis, Composite.class);
+
+ 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/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
new file mode 100644
index 0000000000..54d8f3d260
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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.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;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is));
+ assertNotNull(composite);
+ assertEquals(composite.getName(), new QName("http://calc", "TestAllCalculator"));
+ assertEquals(composite.getConstrainingType().getName(), new QName("http://calc", "CalculatorComponent"));
+ 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.getConstrainingType().getName(), new QName("http://calc",
+ "CalculatorComponent"));
+ 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/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..e1d1794f3c
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
@@ -0,0 +1,224 @@
+/*
+ * 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 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.assembly.ConstrainingType;
+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.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.junit.BeforeClass;
+import org.junit.Test;
+import org.xml.sax.InputSource;
+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;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
+
+ resolver = new DefaultModelResolver();
+ }
+
+ @Test
+ public void testValidateAssembly() throws Exception {
+
+ SchemaFactory schemaFactory;
+ try {
+ schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ } catch (Error e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ } catch (Exception e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ }
+ Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD));
+ ValidatorHandler handler = schema.newValidatorHandler();
+
+ 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 testValidateImplementation() throws Exception {
+
+ SchemaFactory schemaFactory;
+ try {
+ schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ } catch (Error e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ } catch (Exception e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ }
+ Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD));
+ ValidatorHandler handler = schema.newValidatorHandler();
+
+ 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 {
+
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
+ schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString());
+ XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
+ DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry());
+ factories.addFactory(validatingInputFactory);
+
+ CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(factories , staxProcessor, null);
+
+ URL url = getClass().getResource("Calculator.composite");
+ URI uri = URI.create("Calculator.composite");
+ Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+ }
+
+ @Test
+ public void testValidateBinding() throws Exception {
+
+ SchemaFactory schemaFactory;
+ try {
+ schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ } catch (Error e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ } catch (Exception e) {
+ // Some old JDKs don't support XMLSchema validation
+ return;
+ }
+ Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD));
+ ValidatorHandler handler = schema.newValidatorHandler();
+
+ 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 {
+
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
+ schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString());
+ XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
+ DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry());
+ factories.addFactory(validatingInputFactory);
+ CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(factories , staxProcessor, null);
+
+ URL url = getClass().getResource("RMIBindingTest.composite");
+ URI uri = URI.create("RMIBindingTest.composite");
+ Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+
+ URL url = getClass().getResource("CalculatorComponent.constrainingType");
+ URI uri = URI.create("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.constrainingType");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+
+ documentProcessor.resolve(composite, resolver);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ @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);
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+
+ documentProcessor.resolve(composite, resolver);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java
new file mode 100644
index 0000000000..beeb6feaea
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java
@@ -0,0 +1,91 @@
+/*
+ * 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.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;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null);
+ }
+
+
+ @Test
+ public void testReadComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+ }
+
+ @Test
+ public void testReadConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+
+ }
+
+ @Test
+ public void testReadCompositeAndWireIt() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java
new file mode 100644
index 0000000000..a4f0da5ae9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+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.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 QName EXTENDED_ATTRIBUTE = new QName("http://test", "customAttribute");
+
+ private static final String XML = "<?xml version='1.0' encoding='UTF-8'?>"+
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" " +
+ "xmlns:ns1=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" " +
+ "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;
+
+
+ /**
+ * 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();
+ 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(), null);
+ }
+
+ /**
+ * 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);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // 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);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // 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/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java
new file mode 100644
index 0000000000..256c706035
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.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.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.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/200903\" xmlns:ns1=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" 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/200903\" xmlns:ns1=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" 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/200903\" xmlns:ns1=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" targetNamespace=\"http://temp\" name=\"aaaa\" autowire=\"false\">" +
+ "<component name=\"unknownImpl\">" +
+ "<implementation.unknown class=\"raymond\" />" +
+ "<service name=\"service\" requires=\"\">" +
+ "<binding.ws />" +
+ "</service>" +
+ "</component>" +
+ "</composite>";
+
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, XMLOutputFactory.newInstance(), null);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testReadWriteExtendedRecursiveElement() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_RECURSIVE_EXTENDED_ELEMENT));
+ Composite composite = (Composite)staxProcessor.read(reader);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // 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);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // 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);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // 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/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java
new file mode 100644
index 0000000000..6c8aa9acc9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.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.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.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: 711584 $ $Date: 2008-11-05 15:07:03 +0000 (Wed, 05 Nov 2008) $
+ */
+public class ReadWriteLocalCompositeTestCase {
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+
+ private static final String LOCAL_COMPOSITE_XML = "<?xml version='1.0' encoding='UTF-8'?>"+
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns1=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" targetNamespace=\"http://localcalc\" name=\"LocalCalculator\" local=\"true\">"+
+ "</composite>";
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ 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(), null);
+ }
+
+ @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);
+ 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);
+ assertNotNull(composite);
+ assertTrue(composite.isLocal());
+ is.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ System.out.println(bos.toString());
+
+ assertEquals(LOCAL_COMPOSITE_XML, bos.toString());
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
new file mode 100644
index 0000000000..c4519ef338
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.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.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.assembly.ConstrainingType;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+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: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $
+ */
+public class ResolvePolicyTestCase {
+
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static ModelResolver resolver;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ resolver = new DefaultModelResolver();
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ // Create StAX processors
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+
+ URL url = getClass().getResource("CalculatorComponent.constrainingType");
+ URI uri = URI.create("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.constrainingType");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+
+ url = getClass().getResource("test_definitions.xml");
+ uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+
+ preResolvePolicyTests(composite);
+ documentProcessor.resolve(scaDefns, resolver);
+ documentProcessor.resolve(composite, resolver);
+
+ // Comment out the post resolving test
+ // postResolvePolicyTests(composite);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ 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);
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+
+ documentProcessor.resolve(composite, resolver);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java
new file mode 100644
index 0000000000..cc8a88f3d5
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.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 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.assembly.ConstrainingType;
+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;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ resolver = new DefaultModelResolver();
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ StAXArtifactProcessor<ConstrainingType> constrainingTypeReader = staxProcessors.getProcessor(ConstrainingType.class);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ConstrainingType constrainingType = constrainingTypeReader.read(reader);
+ is.close();
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ StAXArtifactProcessor<Composite> compositeReader = staxProcessors.getProcessor(Composite.class);
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeReader.read(reader);
+ is.close();
+ assertNotNull(composite);
+
+ compositeReader.resolve(composite, resolver);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ @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);
+ is.close();
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeReader.read(reader);
+ is.close();
+
+ compositeReader.resolve(composite, resolver);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java
new file mode 100644
index 0000000000..1a100c25b1
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.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.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.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) throws ContributionReadException, XMLStreamException {
+ return reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart());
+ }
+
+ public void write(String value, XMLStreamWriter writer) 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) throws ContributionResolveException {
+
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..e1a149494d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.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 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.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) throws ContributionReadException, XMLStreamException {
+ return new MockPolicyImplOne();
+ }
+
+ public void write(PolicyExpression arg0, XMLStreamWriter arg1) throws ContributionWriteException,
+ XMLStreamException {
+ }
+
+ public Class<PolicyExpression> getModelType() {
+ return PolicyExpression.class;
+ }
+
+ public void resolve(PolicyExpression arg0, ModelResolver arg1) 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/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java
new file mode 100644
index 0000000000..c423df6f7d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
new file mode 100644
index 0000000000..d41881dc37
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.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.xml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+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.ComponentService;
+import org.apache.tuscany.sca.assembly.OptimizableBinding;
+import org.apache.tuscany.sca.assembly.SCABinding;
+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, OptimizableBinding, PolicySubject {
+ private String name;
+ private String uri;
+ private List<Object> extensions = new ArrayList<Object>();
+
+ private Component targetComponent;
+ private ComponentService targetComponentService;
+ private Binding targetBinding;
+
+ 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();
+ }
+
+ /**
+ * @return the targetComponent
+ */
+ public Component getTargetComponent() {
+ return targetComponent;
+ }
+
+ /**
+ * @param targetComponent the targetComponent to set
+ */
+ public void setTargetComponent(Component targetComponent) {
+ this.targetComponent = targetComponent;
+ }
+
+ /**
+ * @return the targetComponentService
+ */
+ public ComponentService getTargetComponentService() {
+ return targetComponentService;
+ }
+
+ /**
+ * @param targetComponentService the targetComponentService to set
+ */
+ public void setTargetComponentService(ComponentService targetComponentService) {
+ this.targetComponentService = targetComponentService;
+ }
+
+ /**
+ * @return the targetBinding
+ */
+ public Binding getTargetBinding() {
+ return targetBinding;
+ }
+
+ /**
+ * @param targetBinding the targetBinding to set
+ */
+ public void setTargetBinding(Binding targetBinding) {
+ this.targetBinding = targetBinding;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ // TODO Auto-generated method stub
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ // TODO Auto-generated method stub
+ return requiredIntents;
+ }
+
+ public ExtensionType getType() {
+ // TODO Auto-generated method stub
+ return bindingType;
+ }
+
+ public void setType(ExtensionType type) {
+ this.bindingType = type;
+ }
+
+ private class TestSCABindingType implements ExtensionType {
+ private QName name = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903","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) {
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java
new file mode 100644
index 0000000000..5235df5037
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.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.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+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.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+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 CompositeBuilder compositeBuilder;
+ private static Monitor monitor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
+ resolver = new DefaultModelResolver();
+
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ monitor = monitorFactory.createMonitor();
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+ compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ConstrainingType constrainingType = (ConstrainingType)staxProcessor.read(reader);
+ is.close();
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader);
+ is.close();
+ assertNotNull(composite);
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+
+ policyDefinitionsProcessor.resolve(scaDefns, resolver);
+
+ staxProcessor.resolve(composite, resolver);
+ compositeBuilder.build(composite, null, monitor);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite nestedComposite = (Composite)staxProcessor.read(reader);
+ is.close();
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader);
+ is.close();
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+
+ policyDefinitionsProcessor.resolve(scaDefns, resolver);
+
+ staxProcessor.resolve(composite, resolver);
+ compositeBuilder.build(composite, null, monitor);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
new file mode 100644
index 0000000000..cf86aec6f4
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.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 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.ConstrainingType;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+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.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+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 CompositeBuilder compositeBuilder;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static Monitor monitor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null);
+ resolver = new DefaultModelResolver();
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+ compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ monitor = monitorFactory.createMonitor();
+
+ 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);
+
+ verifyComposite(composite);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ bos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ composite = staxProcessor.read(bis, Composite.class);
+
+ verifyComposite(composite);
+
+ }
+
+ @Test
+ public void testReadWireWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = staxProcessor.read(is, Composite.class);
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+ policyDefinitionsProcessor.resolve(scaDefns, resolver);
+
+ staxProcessor.resolve(composite, resolver);
+ compositeBuilder.build(composite, null, monitor);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ }
+
+ @Test
+ public void testReadWriteComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ ComponentType componentType = staxProcessor.read(is, ComponentType.class);
+ staxProcessor.resolve(componentType, resolver);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(componentType, bos);
+ }
+
+ @Test
+ public void testReadWriteConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = staxProcessor.read(is, ConstrainingType.class);
+ staxProcessor.resolve(constrainingType, resolver);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(constrainingType, bos);
+ }
+
+ 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/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java
new file mode 100644
index 0000000000..dedd0d0660
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.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.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.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;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ 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);
+ 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);
+ System.out.println(bos);
+
+ // Read again
+ is = new ByteArrayInputStream(bos.toByteArray());
+ reader = inputFactory.createXMLStreamReader(is);
+ composite = compositeProcessor.read(reader);
+
+ // Compare
+ component = composite.getComponents().get(0);
+ implementation = (Composite)component.getImplementation();
+
+ assertEquals(qname, implementation.getName());
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
new file mode 100644
index 0000000000..961a40b841
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903"
+ 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/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType
new file mode 100644
index 0000000000..9a43d44377
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType
@@ -0,0 +1,34 @@
+<?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.
+-->
+<constrainingType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="CalculatorComponent">
+
+ <service name="CalculatorService">
+ <interface.java class="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService" multiplicity="1..1">
+ <interface.java class="calculator.DivideService" />
+ </reference>
+
+</constrainingType>
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
new file mode 100644
index 0000000000..2f4518a42c
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903">
+
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService">
+ <interface.java interface="calculator.DivideService" />
+ </reference>
+
+</componentType>
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite
new file mode 100644
index 0000000000..d713a381f9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903"
+ 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/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite
new file mode 100644
index 0000000000..bf3676c585
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903"
+ 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/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite
new file mode 100644
index 0000000000..9f40faa806
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903"
+ 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/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
new file mode 100644
index 0000000000..65e709f9b1
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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" constrainingType="tns:CalculatorComponent" 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/200903" 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/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903 "
+ 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" constrainingType="tns:CalculatorComponent"
+ 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/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite
new file mode 100644
index 0000000000..998a49226b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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"
+ constrainingType="tns:Calculator"
+ local="true"
+ name="TestAllDivide"
+ policySets="" requires=""
+ targetNamespace="http://calc"
+ xmlns:tns="http://calc"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903 ">
+
+ <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" constrainingType="tns:CalculatorServiceComponent" 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/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
new file mode 100644
index 0000000000..661270d341
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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" constrainingType="tns:CalculatorComponent" local="true" name="TestAllCalculator"
+ requires="cns:tuscanyIntent_1" targetNamespace="http://calc" xmlns:tns="http://calc"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" 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/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903 "
+ 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" constrainingType="tns:CalculatorComponent"
+ 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/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml
new file mode 100644
index 0000000000..bb1f3118ce
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903">
+
+<!-- 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/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite
new file mode 100644
index 0000000000..6aa2ab4979
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903"
+ xmlns:calc="http://localcalc"
+ xmlns:test="http://testlocal"
+ targetNamespace="http://localcalc"
+ name="LocalCalculator"
+ local="true">
+
+</composite>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml b/sandbox/ant/sca/trunk/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml
new file mode 100644
index 0000000000..c59fb3537b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <!-- 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/200903" 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/200903" 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/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <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/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="message">
+ <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/200903">
+ <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/200903" 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/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <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/200903" 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/ant/sca/trunk/modules/assembly-xsd-osoa/LICENSE b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/LICENSE
new file mode 100644
index 0000000000..646cd58e09
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/LICENSE
@@ -0,0 +1,281 @@
+
+ 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 SCA Collaboration license:
+
+License for the Service Component Architecture JavaDoc, Interface Definition files and XSD files.
+
+Permission to copy, make derivative works of, and distribute the Service Component Architecture
+JavaDoc, Interface Definition Files and XSD files in any medium without fee or royalty as part
+of a compliant implementation of the Service Component Architecture Specification is hereby granted.
+The Service Components Architecture Specification may be found at the following location:
+
+ http://www.osoa.org/download/attachments/35/SCA_AssemblyModel_V100.pdf
+
+THE SERVICE COMPONENT ARCHITECTURE SPECIFICATION AND THE JAVADOC, INTERFACE DEFINITION FILES AND XSD FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC, INTERFACE DEFINITION FILES AND XSD FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE COMPONENT ARCHITECTURE SPECIFICATION OR THE JAVADOC, INTERFACE DEFINTION FILES OR XSD FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Component Architecture Specification and the
+JavaDoc, Interface Definition Files and XSD Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+===============================================================================
+
+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.
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/META-INF/MANIFEST.MF b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..371ec3aa46
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Assembly Model XML Schemas
+Bnd-LastModified: 1225397088359
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+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.osoa
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/NOTICE b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/NOTICE
new file mode 100644
index 0000000000..91c3b75575
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/NOTICE
@@ -0,0 +1,23 @@
+${pom.name}
+Copyright (c) 2005 - 2009 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 SCA Collaboration license
+(see the LICENSE file contained in this distribution), with the following
+copyright:
+
+(c) Copyright SCA Collaboration 2006, 2007
+
+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
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/pom.xml b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/pom.xml
new file mode 100644
index 0000000000..88c55f9bdd
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/pom.xml
@@ -0,0 +1,30 @@
+<?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-osoa</artifactId>
+ <name>Apache Tuscany SCA Assembly Model XSD Files based on OSOA spec</name>
+</project>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..69b2701e30
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
@@ -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.
+#
+tuscany-sca.xsd \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-all.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-all.xsd
new file mode 100644
index 0000000000..68455a3474
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-all.xsd
@@ -0,0 +1,32 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+
+ <include schemaLocation="sca.xsd"/>
+
+ <include schemaLocation="sca-binding-ejb.xsd"/>
+
+ <include schemaLocation="sca-implementation-bpel.xsd"/>
+ <include schemaLocation="sca-implementation-jee.xsd"/>
+ <include schemaLocation="sca-implementation-web.xsd"/>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-ejb.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-ejb.xsd
new file mode 100644
index 0000000000..26bedfcce5
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-ejb.xsd
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+ <include schemaLocation="sca-core.xsd"/>
+
+ <element name="binding.ejb" type="sca:EJBSessionBeanBinding"
+ substitutionGroup="sca:binding" />
+
+ <simpleType name="BeanType">
+ <restriction base="string">
+ <enumeration value="stateless"/>
+ <enumeration value="stateful"/>
+ </restriction>
+ </simpleType>
+
+ <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="NCName" use="optional"/>
+ <attribute name="session-type" type="sca:BeanType" use="optional" default="stateless"/>
+ <attribute name="ejb-version" type="sca:VersionValue" use="optional" default="EJB2"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-sca.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-sca.xsd
new file mode 100644
index 0000000000..02703402ef
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-sca.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <element name="binding.sca" type="sca:SCABinding"
+ substitutionGroup="sca:binding"/>
+ <complexType name="SCABinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-webservice.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-webservice.xsd
new file mode 100644
index 0000000000..2dd44f8e06
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-binding-webservice.xsd
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
+ xmlns:wsa="http://www.w3.org/2004/12/addressing"
+ elementFormDefault="qualified">
+
+ <import namespace="http://www.w3.org/2004/08/wsdl-instance"
+ schemaLocation="wsdli.xsd" />
+ <!-- import namespace="http://www.w3.org/2005/08/addressing"
+ schemaLocation="ws-addr.xsd" /-->
+
+ <include schemaLocation="sca-core.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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-contributions.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-contributions.xsd
new file mode 100644
index 0000000000..caf5d8010f
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-contributions.xsd
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2007 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <element name="contribution" type="sca:ContributionType"/>
+ <complexType name="ContributionType">
+ <sequence>
+ <element name="deployable" type="sca:DeployableType" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="sca:import" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="sca:export" minOccurs="0" maxOccurs="unbounded"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="DeployableType">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="composite" type="QName" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <element name="import" type="sca:ImportType"/>
+ <complexType name="ImportType">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="namespace" type="string" use="required"/>
+ <attribute name="location" type="anyURI" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <element name="export" type="sca:ExportType"/>
+ <complexType name="ExportType">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="namespace" type="string" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <element name="import.resource" type="sca:ImportResourceType" substitutionGroup="sca:import"/>
+ <complexType name="ImportResourceType">
+ <complexContent>
+ <extension base="sca:ImportType">
+ <attribute name="uri" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="export.resource" type="sca:ExportResourceType" substitutionGroup="sca:export"/>
+ <complexType name="ExportResourceType">
+ <complexContent>
+ <extension base="sca:ExportType">
+ <attribute name="uri" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-core.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-core.xsd
new file mode 100644
index 0000000000..f03d0eab01
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-core.xsd
@@ -0,0 +1,348 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <element name="componentType" type="sca:ComponentType"/>
+ <complexType name="ComponentType">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="1">
+ <element ref="sca:implementation"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="service" type="sca:ComponentService" />
+ <element name="reference" type="sca:ComponentReference"/>
+ <element name="property" type="sca:Property"/>
+ </choice>
+ <!--
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ -->
+ </sequence>
+ <attribute name="constrainingType" type="QName" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="composite" type="sca:Composite"/>
+ <complexType name="Composite">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="include" type="sca:Include"/>
+ <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"/>
+ <!-- <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> -->
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="targetNamespace" type="anyURI" use="optional"/>
+ <attribute name="local" type="boolean" use="optional" default="false"/>
+ <attribute name="autowire" type="boolean" use="optional" default="false"/>
+ <attribute name="constrainingType" type="QName" use="optional"/>
+ <attribute name="requires" type="sca:listOfQNames" use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Service">
+ <sequence>
+ <element ref="sca:interface" minOccurs="0" maxOccurs="1" />
+ <element name="operation" type="sca:Operation" minOccurs="0"
+ maxOccurs="unbounded" />
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:binding" />
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ <element ref="sca:callback" minOccurs="0" maxOccurs="1" />
+ <!--
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ -->
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="promote" type="anyURI" use="required" />
+ <attribute name="requires" type="sca:listOfQNames" use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax" />
+ </complexType>
+
+ <element name="interface" type="sca:Interface" abstract="true" />
+ <complexType name="Interface" abstract="true"/>
+
+ <complexType name="Reference">
+ <sequence>
+ <element ref="sca:interface" minOccurs="0" maxOccurs="1" />
+ <element name="operation" type="sca:Operation" minOccurs="0"
+ maxOccurs="unbounded" />
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:binding" />
+ <any namespace="##other" processContents="lax" />
+ </choice>
+ <element ref="sca:callback" minOccurs="0" maxOccurs="1" />
+ <!--
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ -->
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <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="promote" type="sca:listOfAnyURIs" use="required" />
+ <attribute name="requires" type="sca:listOfQNames" use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax" />
+ </complexType>
+
+ <complexType name="SCAPropertyBase" mixed="true">
+ <!-- mixed="true" to handle simple type -->
+ <sequence>
+ <any namespace="##any" processContents="lax" minOccurs="0"
+ maxOccurs="1" />
+ <!-- NOT an extension point; This xsd:any exists to accept
+ the element-based or complex type property
+ i.e. no element-based extension point under "sca:property" -->
+ </sequence>
+ </complexType>
+
+ <!-- complex type for sca:property declaration -->
+ <complexType name="Property" mixed="true">
+ <complexContent>
+ <extension base="sca:SCAPropertyBase">
+ <!-- extension defines the place to hold default value -->
+ <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" default="false"
+ use="optional"/>
+ <attribute name="mustSupply" type="boolean" default="false"
+ use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ <!-- an extension point ; attribute-based only -->
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="PropertyValue" mixed="true">
+ <complexContent>
+ <extension base="sca:SCAPropertyBase">
+ <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" default="false"
+ use="optional"/>
+ <attribute name="source" type="string" use="optional"/>
+ <attribute name="file" type="anyURI" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ <!-- an extension point ; attribute-based only -->
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="binding" type="sca:Binding" abstract="true"/>
+ <complexType name="Binding" abstract="true">
+ <sequence>
+ <element name="operation" type="sca:Operation" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="uri" type="anyURI" use="optional"/>
+ <attribute name="name" type="QName" use="optional"/>
+ <attribute name="requires" type="sca:listOfQNames" use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames" use="optional"/>
+ </complexType>
+
+ <element name="bindingType" type="sca:BindingType"/>
+ <complexType name="BindingType">
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax" />
+ </sequence>
+ <attribute name="type" type="QName" use="required"/>
+ <attribute name="alwaysProvides" type="sca:listOfQNames" use="optional"/>
+ <attribute name="mayProvide" type="sca:listOfQNames" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="callback" type="sca:Callback"/>
+ <complexType name="Callback">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:binding"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ <attribute name="requires" type="sca:listOfQNames" use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Component">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="1">
+ <element ref="sca:implementation"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="service" type="sca:ComponentService"/>
+ <element name="reference" type="sca:ComponentReference"/>
+ <element name="property" type="sca:PropertyValue" />
+ </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" default="false"/>
+ <attribute name="constrainingType" type="QName" use="optional"/>
+ <attribute name="requires" type="sca:listOfQNames" use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="ComponentService">
+ <sequence>
+ <element ref="sca:interface" minOccurs="0" maxOccurs="1"/>
+ <element name="operation" type="sca:Operation" minOccurs="0"
+ maxOccurs="unbounded" />
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:binding" />
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ <element ref="sca:callback" minOccurs="0" maxOccurs="1"/>
+ <!--
+ <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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="ComponentReference">
+ <sequence>
+ <element ref="sca:interface" minOccurs="0" maxOccurs="1" />
+ <element name="operation" type="sca:Operation" minOccurs="0"
+ maxOccurs="unbounded" />
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:binding" />
+ <any namespace="##other" processContents="lax" />
+ </choice>
+ <element ref="sca:callback" minOccurs="0" maxOccurs="1" />
+ <!--
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ -->
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="target" type="sca:listOfAnyURIs" use="optional"/>
+ <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="##any" processContents="lax" />
+ </complexType>
+
+ <element name="implementation" type="sca:Implementation"
+ abstract="true" />
+ <complexType name="Implementation" abstract="true">
+ <attribute name="requires" type="sca:listOfQNames" use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames" use="optional"/>
+ </complexType>
+
+ <element name="implementationType" type="sca:ImplementationType"/>
+ <complexType name="ImplementationType">
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax" />
+ </sequence>
+ <attribute name="type" type="QName" use="required"/>
+ <attribute name="alwaysProvides" type="sca:listOfQNames" use="optional"/>
+ <attribute name="mayProvide" type="sca:listOfQNames" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Wire">
+ <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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="include" type="sca:Include"/>
+ <complexType name="Include">
+ <attribute name="name" type="QName"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Operation">
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="requires" type="sca:listOfQNames" use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="constrainingType" type="sca:ConstrainingType"/>
+ <complexType name="ConstrainingType">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="service" type="sca:ComponentService"/>
+ <element name="reference" type="sca:ComponentReference"/>
+ <element name="property" type="sca:Property" />
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="targetNamespace" type="anyURI"/>
+ <attribute name="requires" type="sca:listOfQNames" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+
+ <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>
+
+ <!-- Global attribute definition for @requires to permit use of intents
+ within WSDL documents -->
+ <attribute name="requires" type="sca:listOfQNames"/>
+
+ <!-- Global attribute defintion for @endsConversation to mark operations
+ as ending a conversation -->
+ <attribute name="endsConversation" type="boolean" default="false"/>
+
+ <simpleType name="listOfQNames">
+ <list itemType="QName"/>
+ </simpleType>
+
+ <simpleType name="listOfAnyURIs">
+ <list itemType="anyURI"/>
+ </simpleType>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-definitions.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-definitions.xsd
new file mode 100644
index 0000000000..0249882a92
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-definitions.xsd
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2007 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+ <include schemaLocation="sca-policy.xsd"/>
+
+ <element name="definitions">
+ <complexType>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:intent"/>
+ <element ref="sca:policySet"/>
+ <element ref="sca:binding"/>
+ <element ref="sca:bindingType"/>
+ <element ref="sca:implementationType"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </choice>
+ <attribute name="targetNamespace" type="anyURI" use="optional"/>
+ </complexType>
+ </element>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-bpel.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-bpel.xsd
new file mode 100644
index 0000000000..87b443fb36
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-bpel.xsd
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006 -->
+<xsd:schema xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified">
+
+ <xsd:include schemaLocation="sca-core.xsd" />
+
+ <xsd:element name="implementation.bpel" type="BpelImplementation"
+ substitutionGroup="implementation" />
+
+ <xsd:complexType name="BpelImplementation">
+ <xsd:complexContent>
+ <xsd:extension base="Implementation">
+ <xsd:sequence>
+ <xsd:any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="process" type="xsd:QName" use="required" />
+ <xsd:anyAttribute namespace="##any" processContents="lax" />
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:element name="interface.partnerLinkType" type="BpelPartnerLinkType"
+ substitutionGroup="interface" />
+
+ <xsd:complexType name="BpelPartnerLinkType">
+ <xsd:complexContent>
+ <xsd:extension base="Interface">
+ <xsd:sequence>
+ <xsd:any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="type" type="xsd:QName" use="required" />
+ <xsd:attribute name="serviceRole" type="xsd:NCName" use="optional" />
+ <xsd:anyAttribute namespace="##any" processContents="lax" />
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+</xsd:schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-composite.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-composite.xsd
new file mode 100644
index 0000000000..99669bc672
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-composite.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+ <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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-java.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-java.xsd
new file mode 100644
index 0000000000..f9d8171b8e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-java.xsd
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-jee.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-jee.xsd
new file mode 100644
index 0000000000..83e6bb75bf
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-jee.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <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="##any" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-web.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-web.xsd
new file mode 100644
index 0000000000..a1adf10fd9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-implementation-web.xsd
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <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="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-interface-java.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-interface-java.xsd
new file mode 100644
index 0000000000..81f939bdb4
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-interface-java.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-interface-wsdl.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-interface-wsdl.xsd
new file mode 100644
index 0000000000..c1fdfd8f3c
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-interface-wsdl.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-policy.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-policy.xsd
new file mode 100644
index 0000000000..2c4875f36c
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca-policy.xsd
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <element name="intent" type="sca:Intent"/>
+ <complexType name="Intent">
+ <sequence>
+ <element name="description" type="string" minOccurs="0" maxOccurs="1" />
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="QName" 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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <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="QName" use="required"/>
+ <attribute name="provides" type="sca:listOfQNames" use="optional"/>
+ <attribute name="appliesTo" type="string" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="PolicySetReference">
+ <attribute name="name" type="QName" use="required"/>
+ <anyAttribute namespace="##any" 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"/>
+ <attribute name="default" type="string" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Qualifier">
+ <choice minOccurs="1" maxOccurs="unbounded">
+ <element name="intentMap" type="sca:IntentMap"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ <attribute name="name" type="string" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="allow" type="sca:Allow"/>
+ <complexType name="Allow">
+ <attribute name="roles" type="string" use="required"/>
+ </complexType>
+
+ <element name="permitAll" type="sca:PermitAll"/>
+ <complexType name="PermitAll"/>
+
+ <element name="denyAll" type="sca:DenyAll"/>
+ <complexType name="DenyAll"/>
+
+ <element name="runAs" type="sca:RunAs"/>
+ <complexType name="RunAs">
+ <attribute name="role" type="string" use="required"/>
+ </complexType>
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca.xsd
new file mode 100644
index 0000000000..a177816cdd
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/sca.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <include schemaLocation="sca-interface-java.xsd"/>
+ <include schemaLocation="sca-interface-wsdl.xsd"/>
+
+ <include schemaLocation="sca-implementation-java.xsd"/>
+ <include schemaLocation="sca-implementation-composite.xsd"/>
+
+ <include schemaLocation="sca-binding-webservice.xsd"/>
+ <include schemaLocation="sca-binding-sca.xsd"/>
+
+ <include schemaLocation="sca-contributions.xsd"/>
+
+ <include schemaLocation="sca-definitions.xsd"/>
+ <include schemaLocation="sca-policy.xsd"/>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-dwr.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-dwr.xsd
new file mode 100644
index 0000000000..788571de7b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-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.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <import namespace="http://www.osoa.org/xmlns/sca/1.0" schemaLocation="sca-core.xsd"/>
+
+ <element name="binding.dwr" type="t:DWRBinding"/>
+
+ <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/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-http.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-http.xsd
new file mode 100644
index 0000000000..bd36a8f52f
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-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.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <import namespace="http://www.osoa.org/xmlns/sca/1.0" schemaLocation="sca-core.xsd"/>
+
+ <element name="binding.http" type="t:HTTPBinding"/>
+
+ <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/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-jsonrpc.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-jsonrpc.xsd
new file mode 100644
index 0000000000..bacfdda781
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-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.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <import namespace="http://www.osoa.org/xmlns/sca/1.0" schemaLocation="sca-core.xsd"/>
+
+ <element name="binding.jsonrpc" type="t:JSONRPCBinding"/>
+
+ <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/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-rmi.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-binding-rmi.xsd
new file mode 100644
index 0000000000..26be6feae5
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-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.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <import namespace="http://www.osoa.org/xmlns/sca/1.0" schemaLocation="sca-core.xsd"/>
+
+ <element name="binding.rmi" type="t:RMIBinding"/>
+
+ <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/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-implementation-node.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-implementation-node.xsd
new file mode 100644
index 0000000000..1b5c8aece2
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca-implementation-node.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.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <import namespace="http://www.osoa.org/xmlns/sca/1.0" schemaLocation="sca-core.xsd"/>
+
+ <element name="implementation.node" type="t:NodeImplementation"/>
+
+ <complexType name="NodeImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##targetNamespace" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="uri" type="string" use="required"/>
+ <attribute name="composite" type="QName" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca.xsd
new file mode 100644
index 0000000000..4557cda947
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/tuscany-sca.xsd
@@ -0,0 +1,35 @@
+<?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.0">
+
+ <import namespace="http://www.w3.org/2004/08/wsdl-instance" schemaLocation="wsdli.xsd"/>
+
+ <import namespace="http://www.osoa.org/xmlns/sca/1.0" schemaLocation="sca-all.xsd"/>
+
+ <include schemaLocation="tuscany-sca-binding-dwr.xsd"/>
+ <include schemaLocation="tuscany-sca-binding-http.xsd"/>
+ <include schemaLocation="tuscany-sca-binding-jsonrpc.xsd"/>
+ <include schemaLocation="tuscany-sca-binding-jms.xsd"/>
+ <include schemaLocation="tuscany-sca-binding-rmi.xsd"/>
+
+ <include schemaLocation="tuscany-sca-implementation-node.xsd"/>
+ <include schemaLocation="tuscany-sca-implementation-resource.xsd"/>
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/wsdli.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/wsdli.xsd
new file mode 100644
index 0000000000..79af5e9363
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd-osoa/src/main/resources/wsdli.xsd
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "http://www.w3.org/2001/XMLSchema.dtd"-->
+<!-- $Id: wsdl-instance.xsd,v 1.1 2004/08/03 16:02:04 hugo Exp $ -->
+<!--
+ W3C XML Schema defined in the Web Services Description (WSDL)
+ Version 2.0 specification
+ http://www.w3.org/TR/wsdl20
+
+ 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
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance" targetNamespace="http://www.w3.org/2004/08/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/ant/sca/trunk/modules/assembly-xsd/LICENSE b/sandbox/ant/sca/trunk/modules/assembly-xsd/LICENSE
new file mode 100644
index 0000000000..646cd58e09
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/LICENSE
@@ -0,0 +1,281 @@
+
+ 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 SCA Collaboration license:
+
+License for the Service Component Architecture JavaDoc, Interface Definition files and XSD files.
+
+Permission to copy, make derivative works of, and distribute the Service Component Architecture
+JavaDoc, Interface Definition Files and XSD files in any medium without fee or royalty as part
+of a compliant implementation of the Service Component Architecture Specification is hereby granted.
+The Service Components Architecture Specification may be found at the following location:
+
+ http://www.osoa.org/download/attachments/35/SCA_AssemblyModel_V100.pdf
+
+THE SERVICE COMPONENT ARCHITECTURE SPECIFICATION AND THE JAVADOC, INTERFACE DEFINITION FILES AND XSD FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC, INTERFACE DEFINITION FILES AND XSD FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE COMPONENT ARCHITECTURE SPECIFICATION OR THE JAVADOC, INTERFACE DEFINTION FILES OR XSD FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Component Architecture Specification and the
+JavaDoc, Interface Definition Files and XSD Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+===============================================================================
+
+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.
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/META-INF/MANIFEST.MF b/sandbox/ant/sca/trunk/modules/assembly-xsd/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..7d6d0951f4
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Assembly Model XML Schemas
+Bnd-LastModified: 1225397088359
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+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
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/NOTICE b/sandbox/ant/sca/trunk/modules/assembly-xsd/NOTICE
new file mode 100644
index 0000000000..91c3b75575
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/NOTICE
@@ -0,0 +1,23 @@
+${pom.name}
+Copyright (c) 2005 - 2009 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 SCA Collaboration license
+(see the LICENSE file contained in this distribution), with the following
+copyright:
+
+(c) Copyright SCA Collaboration 2006, 2007
+
+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
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/pom.xml b/sandbox/ant/sca/trunk/modules/assembly-xsd/pom.xml
new file mode 100644
index 0000000000..8193461b62
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..5007705d41
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
@@ -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.
+#
+tuscany-sca-1.1.xsd \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-1.1-cd03.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-1.1-cd03.xsd
new file mode 100644
index 0000000000..d93cbd6c6b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-1.1-cd03.xsd
@@ -0,0 +1,33 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <include schemaLocation="sca-core-1.1-cd03.xsd"/>
+
+ <include schemaLocation="sca-interface-java-1.1-cd03.xsd"/>
+ <include schemaLocation="sca-interface-wsdl-1.1-cd03.xsd"/>
+ <include schemaLocation="sca-interface-cpp-1.1-cd02.xsd"/>
+ <include schemaLocation="sca-interface-c-1.1-cd02.xsd"/>
+
+ <include schemaLocation="sca-implementation-java-1.1-cd01.xsd"/>
+ <include schemaLocation="sca-implementation-composite-1.1-cd03.xsd"/>
+ <include schemaLocation="sca-implementation-cpp-1.1-cd02.xsd"/>
+ <include schemaLocation="sca-implementation-c-1.1-cd02.xsd"/>
+ <include schemaLocation="sca-implementation-bpel-1.1-cd02.xsd"/>
+
+ <include schemaLocation="sca-binding-ws-1.1-cd02.xsd"/>
+ <include schemaLocation="sca-binding-jms-1.1-cd02.xsd"/>
+ <include schemaLocation="sca-binding-jca-1.1-cd02.xsd"/>
+ <include schemaLocation="sca-binding-sca-1.1-cd03.xsd"/>
+
+ <include schemaLocation="sca-definitions-1.1-cd03.xsd"/>
+ <include schemaLocation="sca-policy-1.1-cd02.xsd"/>
+
+ <include schemaLocation="sca-contribution-1.1-cd03.xsd"/>
+ <include schemaLocation="sca-contribution-cpp-1.1-cd02.xsd"/>
+ <include schemaLocation="sca-contribution-c-1.1-cd02.xsd"/>
+
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd02.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd02.xsd
new file mode 100644
index 0000000000..490c9659f4
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd02.xsd
@@ -0,0 +1,167 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.xsd" />
+
+ <complexType name="JCABinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element name="jca.outbound.connection"
+ type="sca:JCAOutboundConnection"
+ minOccurs="0" />
+ <element name="jca.inbound.connection"
+ type="sca:JCAInboundConnection"
+ minOccurs="0" />
+ <element name="jca.outbound.interaction"
+ type="sca:JCAOutboundInteraction"
+ minOccurs="0" />
+ <element name="jca.inbound.interaction"
+ 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"/>
+ <anyAttribute namespace="##any" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <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="##any" 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>
+ </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>
+ </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>
+ </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="##any" 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:CreateResource" use="optional"
+ default="ifnotexist" />
+ <anyAttribute namespace="##any" 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:CreateResource" use="optional"
+ default="ifnotexist" />
+ <anyAttribute namespace="##any" 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="##any" 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="##any" 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="##any" 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="##any" processContents="lax" />
+ </complexType>
+ <element name="binding.jca" type="sca:JCABinding"
+ substitutionGroup="sca:binding" />
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd02.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd02.xsd
new file mode 100644
index 0000000000..6a898c7e7b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd02.xsd
@@ -0,0 +1,160 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.xsd"/>
+
+ <complexType name="JMSBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element name="destination" type="sca:JMSDestination" minOccurs="0"/>
+ <element name="connectionFactory" type="sca:JMSConnectionFactory"/>
+ <element name="activationSpec" type="sca:JMSActivationSpec"/>
+
+ <element name="response" type="sca:JMSResponse" minOccurs="0"/>
+ <element name="headers" type="sca:JMSHeaders" minOccurs="0"/>
+ <element name="subscriptionHeaders" type="sca:JMSSubscriptionHeaders" 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"/>
+ <anyAttribute/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <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:CreateResource"
+ 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:CreateResource"
+ 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:CreateResource"
+ use="optional" default="ifnotexist"/>
+ </complexType>
+
+ <complexType name="JMSResponse">
+ <sequence>
+ <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="JMSType" type="string"/>
+ <attribute name="JMSDeliveryMode">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="PERSISTENT"/>
+ <enumeration value="NON_PERSISTENT"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="JMSTimeToLive" type="long"/>
+ <attribute name="JMSPriority">
+ <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="JMSSubscriptionHeaders">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="JMSSelector" 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>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd03.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd03.xsd
new file mode 100644
index 0000000000..7a6d1a903b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd03.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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd02.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd02.xsd
new file mode 100644
index 0000000000..17ce185d14
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd02.xsd
@@ -0,0 +1,36 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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-cd03.xsd"/>
+
+ <element name="binding.ws" type="sca:WebServiceBinding"
+ substitutionGroup="sca:binding"/>
+
+ <complexType name="WebServiceBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element name="endpointReference" type="wsa:EndpointReferenceType"
+ 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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd03.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd03.xsd
new file mode 100644
index 0000000000..17c2dd8285
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd03.xsd
@@ -0,0 +1,86 @@
+<?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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.xsd"/>
+
+ <!-- Contribution -->
+ <element name="contribution" type="sca:ContributionType"/>
+ <complexType name="ContributionType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element name="deployable" type="sca:DeployableType"
+ 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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd02.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd02.xsd
new file mode 100644
index 0000000000..4397834520
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd02.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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-contribution-1.1-cd03.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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd02.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd02.xsd
new file mode 100644
index 0000000000..2271b780ee
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd02.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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-contribution-1.1-cd03.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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd03.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd03.xsd
new file mode 100644
index 0000000000..6c9e75c9df
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd03.xsd
@@ -0,0 +1,518 @@
+<?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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <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>
+ <attribute name="constrainingType" type="QName" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Composite -->
+ <element name="composite" type="sca:Composite"/>
+ <complexType name="Composite">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element name="include" type="anyURI" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <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="constrainingType" type="QName" use="optional"/>
+ <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" />
+ <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"/>
+ </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">
+ <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="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="promote" type="sca:listOfAnyURIs"
+ use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Property -->
+ <complexType name="SCAPropertyBase" mixed="true">
+ <sequence>
+ <any namespace="##any" processContents="lax" minOccurs="0"/>
+ <!-- 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="requires" type="sca:listOfQNames" use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames" use="optional"/>
+ </complexType>
+
+ <complexType name="Property" mixed="true">
+ <complexContent mixed="true">
+ <extension base="sca:SCAPropertyBase">
+ <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="mustSupply" type="boolean" use="optional"
+ default="false"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ <!-- extension defines the place to hold default value -->
+ <!-- an extension point ; attribute-based only -->
+ </complexContent>
+ </complexType>
+
+ <!-- ConstrainingProperty is equivalent to the Property type but removes
+ the capability to contain a value -->
+ <complexType name="ConstrainingProperty" mixed="true">
+ <complexContent mixed="true">
+ <restriction base="sca:Property">
+ <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="mustSupply" type="boolean" use="optional"
+ default="false"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+ <complexType name="PropertyValue" mixed="true">
+ <complexContent mixed="true">
+ <extension base="sca:SCAPropertyBase">
+ <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="source" type="string" use="optional"/>
+ <attribute name="file" type="anyURI" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ <!-- an extension point ; attribute-based only -->
+ </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" />
+ </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"/>
+ <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"/>
+ <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"/>
+ <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="0"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="service" type="sca:ComponentService"/>
+ <element name="reference" type="sca:ComponentReference"/>
+ <element name="property" type="sca:PropertyValue"/>
+ </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="constrainingType" type="QName" 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>
+
+ <!-- Constraining Service -->
+ <complexType name="ConstrainingService">
+ <complexContent>
+ <restriction base="sca:ComponentService">
+ <sequence>
+ <element ref="sca:interface" minOccurs="0" maxOccurs="1" />
+ <element ref="sca:callback" minOccurs="0" maxOccurs="1" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ </restriction>
+ </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>
+
+ <!-- Constraining Reference -->
+ <complexType name="ConstrainingReference">
+ <complexContent>
+ <restriction base="sca:ComponentReference">
+ <sequence>
+ <element ref="sca:interface" minOccurs="0" maxOccurs="1" />
+ <element ref="sca:callback" minOccurs="0" maxOccurs="1" />
+ <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="wiredByImpl" type="boolean" use="optional"
+ default="false"/>
+ <attribute name="multiplicity" type="sca:Multiplicity"
+ use="optional" default="1..1"/>
+ </restriction>
+ </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"/>
+ <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="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">
+ <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>
+
+ <!-- Constraining Type -->
+ <element name="constrainingType" type="sca:ConstrainingType"/>
+ <complexType name="ConstrainingType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="service" type="sca:ConstrainingService"/>
+ <element name="reference"
+ type="sca:ConstrainingReference"/>
+ <element name="property" type="sca:ConstrainingProperty"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="targetNamespace" type="anyURI"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- 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"/>
+
+ <!-- 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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd03.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd03.xsd
new file mode 100644
index 0000000000..0feadcddcd
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd03.xsd
@@ -0,0 +1,31 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.xsd"/>
+ <include schemaLocation="sca-policy-1.1-cd02.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:binding"/>
+ <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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd02.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd02.xsd
new file mode 100644
index 0000000000..3c19424a83
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd02.xsd
@@ -0,0 +1,31 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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-cd03.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="##any" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd02.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd02.xsd
new file mode 100644
index 0000000000..11e191f0ed
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd02.xsd
@@ -0,0 +1,57 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.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="scope" type="sca:CImplementationScope"
+ use="optional" />
+ <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" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="CImplementationScope">
+ <restriction base="string">
+ <enumeration value="stateless" />
+ <enumeration value="composite" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="CImplementationFunction">
+ <attribute name="name" type="NCName" use="required" />
+ <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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd03.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd03.xsd
new file mode 100644
index 0000000000..050f456386
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd03.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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd02.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd02.xsd
new file mode 100644
index 0000000000..771186a91d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd02.xsd
@@ -0,0 +1,54 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.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" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="CPPImplementationScope">
+ <restriction base="string">
+ <enumeration value="stateless" />
+ <enumeration value="composite" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="CPPImplementationFunction">
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="allowsPassByReference" type="boolean"
+ use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd01.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd01.xsd
new file mode 100644
index 0000000000..52c92e8259
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd01.xsd
@@ -0,0 +1,27 @@
+<?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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd02.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd02.xsd
new file mode 100644
index 0000000000..f2c7d2034f
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd02.xsd
@@ -0,0 +1,41 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.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" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="CFunction">
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="oneWay" 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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd02.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd02.xsd
new file mode 100644
index 0000000000..c214f7c37b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd02.xsd
@@ -0,0 +1,42 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.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" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="CPPFunction">
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="oneWay" type="boolean" use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd03.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd03.xsd
new file mode 100644
index 0000000000..6acbe6cf1c
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd03.xsd
@@ -0,0 +1,29 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd03.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd03.xsd
new file mode 100644
index 0000000000..f3abba888e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd03.xsd
@@ -0,0 +1,29 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.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"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd02.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd02.xsd
new file mode 100644
index 0000000000..b3de95509e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd02.xsd
@@ -0,0 +1,105 @@
+<?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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd03.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="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="IntentQualifier">
+ <sequence>
+ <element name="description" type="string" minOccurs="0"
+ maxOccurs="1" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="default" type="boolean" use="optional"
+ default="false"/>
+ </complexType>
+
+ <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="required"/>
+ <attribute name="attachTo" type="string" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="policySetAttachment"
+ type="sca:PolicySetAttachment"/>
+ <complexType name="PolicySetAttachment">
+ <attribute name="name" type="QName" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="PolicySetReference">
+ <attribute name="name" type="QName" use="required"/>
+ <anyAttribute namespace="##any" 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="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Qualifier">
+ <choice minOccurs="1" maxOccurs="unbounded">
+ <element name="intentMap" type="sca:IntentMap"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ <attribute name="name" type="string" use="required"/>
+ <anyAttribute namespace="##any" 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>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd02.xml b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd02.xml
new file mode 100644
index 0000000000..2e96713233
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd02.xml
@@ -0,0 +1,243 @@
+<?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:xml="http://www.w3.org/XML/1998/namespace"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <!-- Security related intents -->
+ <intent name="serverAuthentication" constrains="sca:binding"
+ intentType="interaction">
+ <description>
+ Communication through the binding requires that the
+ server is authenticated by the client
+ </description>
+ <qualifier name="transport" default="true"/>
+ <qualifier name="message"/>
+ </intent>
+
+ <intent name="clientAuthentication" constrains="sca:binding"
+ intentType="interaction">
+ <description>
+ Communication through the binding requires that the
+ client is authenticated by the server
+ </description>
+ <qualifier name="transport" default="true"/>
+ <qualifier name="message"/>
+ </intent>
+
+ <intent name="authentication" requires="clientAuthentication">
+ <description>
+ A convenience intent to help migration
+ </description>
+ </intent>
+
+ <intent name="mutualAuthentication"
+ requires="clientAuthentication serverAuthentication">
+ <description>
+ Communication through the binding requires that the
+ client and server to authenticate each other
+ </description>
+ </intent>
+
+ <intent name="confidentiality" constrains="sca:binding"
+ intentType="interaction">
+ <description>
+ Communication through the binding prevents unauthorized
+ users from reading the messages
+ </description>
+ <qualifier name="transport" default="true"/>
+ <qualifier name="message"/>
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding"
+ intentType="interaction">
+ <description>
+ Communication through the binding prevents tampering
+ with the messages sent between the client and the service.
+ </description>
+ <qualifier name="transport" default="true"/>
+ <qualifier name="message"/>
+ </intent>
+
+ <intent name="authorization" constrains="sca:implementation"
+ intentType="implementation">
+ <description>
+ Ensures clients are authorized to use services.
+ </description>
+ <qualifier name="fineGrain" default="true"/>
+ </intent>
+
+
+ <!-- Reliable messaging related intents -->
+ <intent name="atLeastOnce" constrains="sca:binding"
+ intentType="interaction">
+ <description>
+ This intent is used to indicate that a message sent
+ by a client is always delivered to the component.
+ </description>
+ </intent>
+
+ <intent name="atMostOnce" constrains="sca:binding"
+ intentType="interaction">
+ <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.
+ </description>
+ </intent>
+
+ <intent name="exactlyOnce" requires="atLeastOnce atMostOnce"
+ constrains="sca:binding" intentType="interaction">
+ <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.
+ </description>
+ </intent>
+
+ <intent name="ordered" appliesTo="sca:binding"
+ intentType="interaction">
+ <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.
+ </description>
+ </intent>
+
+ <!-- Transaction related intents -->
+ <intent name="managedTransaction" excludes="sca:noManagedTransaction"
+ mutuallyExclusive="true" constrains="sca:implementation"
+ intentType="implementation">
+ <description>
+ A managed transaction environment is necessary in order to
+ run the component. The specific type of managed transaction
+ needed is not constrained.
+ </description>
+ <qualifier name="global" default="true">
+ <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.
+ </description>
+ </qualifier>
+ <qualifier name="local">
+ <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.
+ </description>
+ </qualifier>
+ </intent>
+
+ <intent name="noManagedTransaction" excludes="sca:managedTransaction"
+ constrains="sca:implementation" intentType="implementation">
+ <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.
+ </description>
+ </intent>
+
+ <intent name="transactedOneWay" excludes="sca:immediateOneWay"
+ constrains="sca:binding" intentType="implementation">
+ <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.
+ </description>
+ </intent>
+
+ <intent name="immediateOneWay" excludes="transactedOneWay"
+ constrains="sca:binding" intentType="implementation">
+ <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.
+ </description>
+ </intent>
+
+ <intent name="propagatesTransaction" excludes="suspendsTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <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.
+ </description>
+ </intent>
+
+ <intent name="suspendsTransaction" excludes="propagatesTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <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.
+ </description>
+ </intent>
+
+ <intent name="managedSharedTransaction"
+ requires="managedTransaction.global propagatesTransaction">
+ <description>
+ Used to indicate that the component requires both the
+ managedTransaction.global and the propagatesTransactions
+ intents
+ </description>
+ </intent>
+
+ <!-- Miscellaneous intents -->
+ <intent name="asyncInvocation" constrains="sca:Binding"
+ intentType="interaction">
+ <description>
+ Indicates that request/response operations for the
+ interface of this wire are "long running" and must be
+ treated as two separate message transmissions
+ </description>
+ </intent>
+
+ <intent name="SOAP" constrains="sca:binding" intentType="interaction">
+ <description>
+ Specifies that the SOAP messaging model is used for delivering
+ messages.
+ </description>
+ <qualifier name="1_1" default="true"/>
+ <qualifier name="1_2"/>
+ </intent>
+
+ <intent name="JMS" constrains="sca:binding" intentType="interaction">
+ <description>
+ Requires that the messages are delivered and received via the
+ JMS API.
+ </description>
+ </intent>
+
+ <intent name="noListener" constrains="sca:binding"
+ intentType="interaction">
+ <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.
+ </description>
+ </intent>
+
+</sca:definitions>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd
new file mode 100644
index 0000000000..bb3ad00cd7
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd03.xsd"/>
+
+ <element name="binding.dwr" type="t:DWRBinding"/>
+
+ <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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd
new file mode 100644
index 0000000000..32f2a51276
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd03.xsd"/>
+
+ <element name="binding.http" type="t:HTTPBinding"/>
+
+ <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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd
new file mode 100644
index 0000000000..68dea85a12
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd03.xsd"/>
+
+ <element name="binding.jsonrpc" type="t:JSONRPCBinding"/>
+
+ <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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd
new file mode 100644
index 0000000000..fadf94fffe
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/200903"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd03.xsd"/>
+
+ <element name="binding.rmi" type="t:RMIBinding"/>
+
+ <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/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-node.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-node.xsd
new file mode 100644
index 0000000000..e90d9a0fa5
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-node.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/200903"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd03.xsd"/>
+
+ <element name="implementation.node" type="t:NodeImplementation"/>
+
+ <complexType name="NodeImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##targetNamespace" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="uri" type="string" use="required"/>
+ <attribute name="composite" type="QName" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd
new file mode 100644
index 0000000000..d3a2711ee0
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd
@@ -0,0 +1,33 @@
+<?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/2004/08/wsdl-instance" schemaLocation="wsdli.xsd"/>
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd03.xsd"/>
+
+ <include schemaLocation="tuscany-sca-1.1-binding-dwr.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-rmi.xsd"/>
+
+ <include schemaLocation="tuscany-sca-1.1-implementation-node.xsd"/>
+</schema> \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/wsdli.xsd b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/wsdli.xsd
new file mode 100644
index 0000000000..79af5e9363
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly-xsd/src/main/resources/wsdli.xsd
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "http://www.w3.org/2001/XMLSchema.dtd"-->
+<!-- $Id: wsdl-instance.xsd,v 1.1 2004/08/03 16:02:04 hugo Exp $ -->
+<!--
+ W3C XML Schema defined in the Web Services Description (WSDL)
+ Version 2.0 specification
+ http://www.w3.org/TR/wsdl20
+
+ 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
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance" targetNamespace="http://www.w3.org/2004/08/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/ant/sca/trunk/modules/assembly/LICENSE b/sandbox/ant/sca/trunk/modules/assembly/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/META-INF/MANIFEST.MF b/sandbox/ant/sca/trunk/modules/assembly/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..06b5451177
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/META-INF/MANIFEST.MF
@@ -0,0 +1,44 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.assembly;uses:="javax.xml.xpath
+ ,org.apache.tuscany.sca.assembly.impl,org.apache.tuscany.sca.policy,o
+ rg.apache.tuscany.sca.interfacedef,javax.xml.namespace";version="2.0.0"
+ ,org.apache.tuscany.sca.assembly.impl;uses:="javax.xml.xpath,org.apac
+ he.tuscany.sca.assembly,org.apache.tuscany.sca.policy,org.apache.tusc
+ any.sca.interfacedef,javax.xml.namespace";version="2.0.0",org.apache.tu
+ scany.sca.assembly.builder;uses:="org.apache.tuscany.sca.assembly,org
+ .apache.tuscany.sca.definitions,org.apache.tuscany.sca.core,org.apach
+ e.tuscany.sca.monitor,org.apache.tuscany.sca.interfacedef,org.apache.
+ tuscany.sca.extensibility";version="2.0.0"
+Private-Package: org.apache.tuscany.sca.assembly.builder.impl;version=
+ "2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Assembly Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397097203
+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.namespace,
+ javax.xml.parsers,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.sax,
+ 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.util;version="2.0.0",
+ org.w3c.dom,
+ org.xml.sax
+Bundle-SymbolicName: org.apache.tuscany.sca.assembly
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly/NOTICE b/sandbox/ant/sca/trunk/modules/assembly/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly/pom.xml b/sandbox/ant/sca/trunk/modules/assembly/pom.xml
new file mode 100644
index 0000000000..f5b8657ef5
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/pom.xml
@@ -0,0 +1,57 @@
+<?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-policy</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-definitions</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java
new file mode 100644
index 0000000000..0a14b5658e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.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;
+
+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$
+ */
+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 isCallback();
+
+ /**
+ * Sets a flag indicating whether this is a callback contract.
+ *
+ * @param isCallback true for a callback contract, false otherwise
+ */
+ void setIsCallback(boolean isCallback);
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java
new file mode 100644
index 0000000000..fcad39d8cb
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.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;
+
+import javax.xml.namespace.QName;
+
+/**
+ * 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);
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java
new file mode 100644
index 0000000000..a9ef26bbb9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java
new file mode 100644
index 0000000000..9ae511c07b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
new file mode 100644
index 0000000000..cfba7bdc8d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
@@ -0,0 +1,169 @@
+/*
+ * 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$
+ */
+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 constraining type.
+ *
+ * @return a new constraining type
+ */
+ ConstrainingType createConstrainingType();
+
+ /**
+ * 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
+ */
+ Endpoint2 createEndpoint();
+
+ /**
+ * Create a new endpoint reference
+ *
+ * @return a new endpoint reference
+ */
+ EndpointReference2 createEndpointReference();
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java
new file mode 100644
index 0000000000..76511d351d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.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;
+
+
+/**
+ * Base interface for all assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Base {
+
+ /**
+ * 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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java
new file mode 100644
index 0000000000..0423e0b128
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.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.assembly;
+
+
+
+/**
+ * Represents a binding.
+ *
+ * @version $Rev$ $Date$
+ */
+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
+ */
+ Object clone() throws CloneNotSupportedException;
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java
new file mode 100644
index 0000000000..b0bfdec6d7
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.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;
+
+
+/**
+ * TODO RRB experiment.
+ * Represents a binding implemented using Request/Response binding chains
+ * Used to test the RRB idea hence no integrated into the Binding interface, yet
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BindingRRB extends Binding {
+
+ WireFormat getRequestWireFormat();
+
+ void setRequestWireFormat(WireFormat wireFormat);
+
+ WireFormat getResponseWireFormat();
+
+ void setResponseWireFormat(WireFormat wireFormat);
+
+ OperationSelector getOperationSelector();
+
+ void setOperationSelector(OperationSelector operationSelector);
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java
new file mode 100644
index 0000000000..d34ec7d01f
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.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;
+
+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();
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
new file mode 100644
index 0000000000..7386fc8583
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.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 org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a component. A component is a configured instance of an
+ * implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+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();
+
+ /**
+ * Returns a list of services exposed by the component.
+ *
+ * @return a list of services exposed by the component
+ */
+ List<ComponentService> getServices();
+
+ /**
+ * Returns a list of properties for the component.
+ *
+ * @return a list of properties
+ */
+ List<ComponentProperty> getProperties();
+
+ /**
+ * Returns a constraining type defining the shape of the component.
+ *
+ * @return a constraining type
+ */
+ ConstrainingType getConstrainingType();
+
+ /**
+ * Sets a constraining type defining the shape of the component.
+ *
+ * @param constrainingType the constraining type
+ */
+ void setConstrainingType(ConstrainingType constrainingType);
+
+ /**
+ * 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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java
new file mode 100644
index 0000000000..13d19b1757
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.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;
+
+import javax.xml.xpath.XPathExpression;
+
+/**
+ * Represents a configured property of a component.
+ *
+ * @version $Rev$ $Date$
+ */
+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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java
new file mode 100644
index 0000000000..fa31657d0f
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.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;
+
+import java.util.List;
+
+
+
+/**
+ * An instance of a reference associated with a particular component.
+ *
+ * @version $Rev$ $Date$
+ */
+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);
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java
new file mode 100644
index 0000000000..65945692f1
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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$
+ */
+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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java
new file mode 100644
index 0000000000..9fb3b92102
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java
@@ -0,0 +1,79 @@
+/*
+ * 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$
+ */
+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();
+
+ /**
+ * Returns the list of reference types that are used.
+ *
+ * @return the list of reference types that are used
+ */
+ List<Reference> getReferences();
+
+ /**
+ * Returns the list of properties that can be set.
+ *
+ * @return the list of properties that can be set
+ */
+ List<Property> getProperties();
+
+ /**
+ * Returns a constraining type defining the shape of the implementation.
+ *
+ * @return a constraining type
+ */
+ ConstrainingType getConstrainingType();
+
+ /**
+ * Sets a constraining type defining the shape of the implementation.
+ *
+ * @param constrainingType the constraining type to set
+ */
+ void setConstrainingType(ConstrainingType constrainingType);
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java
new file mode 100644
index 0000000000..12542297b3
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java
@@ -0,0 +1,124 @@
+/*
+ * 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 {
+
+ /**
+ * 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 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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java
new file mode 100644
index 0000000000..9defd8f66c
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java
new file mode 100644
index 0000000000..7143f571f9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java
@@ -0,0 +1,56 @@
+/*
+ * 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$
+ */
+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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java
new file mode 100644
index 0000000000..74c2e70d30
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.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.assembly;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * A constrainingType provides the "shape" for a component and its
+ * implementation. Any component configuration that points to a constrainingType
+ * is constrained by this shape. The constrainingType specifies the services,
+ * references and properties that must be implemented.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ConstrainingType extends Base, Extensible, PolicySubject {
+
+ /**
+ * Returns the name of the constrainingType.
+ *
+ * @return the name of the constrainingType
+ */
+ QName getName();
+
+ /**
+ * Sets the name of the constrainingType.
+ *
+ * @param name the name of the constrainingType
+ */
+ void setName(QName name);
+
+ /**
+ * Returns a list of services that are offered.
+ *
+ * @return a list of services that are offered
+ */
+ List<AbstractService> getServices();
+
+ /**
+ * Returns the list of references that are used.
+ *
+ * @return the list of references that are used
+ */
+ List<AbstractReference> getReferences();
+
+ /**
+ * Returns the list of properties that can be set.
+ *
+ * @return the list of properties that can be set
+ */
+ List<AbstractProperty> getProperties();
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
new file mode 100644
index 0000000000..54d6347301
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.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;
+
+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$
+ */
+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);
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java
new file mode 100644
index 0000000000..5dd256e3c4
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.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 org.apache.tuscany.sca.assembly.impl.AssemblyFactoryImpl;
+
+/**
+ * A factory for the assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultAssemblyFactory extends AssemblyFactoryImpl implements AssemblyFactory {
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.java
new file mode 100644
index 0000000000..5aa19ddb45
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.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;
+
+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$
+ */
+public interface Endpoint2 extends Base, PolicySubject, Cloneable {
+
+ /**
+ * Supports endpoint cloning
+ *
+ * @return endpoint
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * 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 getInterfaceContract();
+
+ /**
+ * Sets the interface contract defining the interface
+ *
+ * @param interfaceContract the interface contract
+ */
+ void setInterfaceContract(InterfaceContract interfaceContract);
+
+ /**
+ * Get the service's callback endpoint references that
+ * represent endpoint references from which callbacks
+ * originate
+ *
+ * @return callbackEndpoint the reference callback endpoint
+ */
+ List<EndpointReference2> getCallbackEndpointReferences();
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference2.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference2.java
new file mode 100644
index 0000000000..a207f81727
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference2.java
@@ -0,0 +1,126 @@
+/*
+ * 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;
+
+/**
+ * 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$
+ */
+public interface EndpointReference2 extends Base, PolicySubject, Cloneable {
+
+ /**
+ * 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
+ */
+ Endpoint2 getTargetEndpoint();
+
+ /**
+ * Set the target endpoint model object
+ *
+ * @param endpoint the target endpoint
+ */
+ void setTargetEndpoint(Endpoint2 targetEndpoint);
+
+ /**
+ * Returns the interface contract defining the interface
+ *
+ * @return the interface contract
+ */
+ InterfaceContract getInterfaceContract();
+
+ /**
+ * Sets the interface contract defining the interface
+ *
+ * @param interfaceContract the interface contract
+ */
+ void setInterfaceContract(InterfaceContract interfaceContract);
+
+ /**
+ * Get the reference callback endpoint that
+ * represents that target endpoint to which callback
+ * messages will be directed
+ *
+ * @return callbackEndpoint the reference callback endpoint
+ */
+ Endpoint2 getCallbackEndpoint();
+
+ /**
+ * Set the reference callback endpoint
+ *
+ * @param callbackEndpoint the reference callback endpoint
+ */
+ void setCallbackEndpoint(Endpoint2 callbackEndpoint);
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java
new file mode 100644
index 0000000000..90d6745f35
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.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;
+
+/**
+ * Base interface for extensible assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java
new file mode 100644
index 0000000000..4d5b1a2ecd
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.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.assembly;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Base interface for storing contents of extensible assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
new file mode 100644
index 0000000000..720a6801a2
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.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.assembly;
+
+/**
+ * Represents a component implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Implementation extends ComponentType {
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java
new file mode 100644
index 0000000000..5d15ce9938
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.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;
+
+/**
+ * Enumeration for multiplicity. Defines the number of wires that can connect a
+ * reference to target services.
+ *
+ * @version $Rev$ $Date$
+ */
+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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java
new file mode 100644
index 0000000000..6770e87ee1
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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$
+ */
+public interface OperationSelector extends Base, Cloneable {
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java
new file mode 100644
index 0000000000..98ff92f15b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.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;
+
+/**
+ * Represent a reference binding that supports optimized SCA local wiring between component
+ * references and services
+ *
+ * @version $Rev$ $Date$
+ *
+ */
+public interface OptimizableBinding extends Binding, Cloneable {
+
+ /**
+ * @param component
+ */
+ void setTargetComponent(Component component);
+
+ /**
+ * @param service
+ */
+ void setTargetComponentService(ComponentService service);
+
+ /**
+ * @param binding
+ */
+ void setTargetBinding(Binding binding);
+
+ /**
+ * @return
+ */
+ Binding getTargetBinding();
+
+ /**
+ * @return
+ */
+ Component getTargetComponent();
+
+ /**
+ * @return
+ */
+ ComponentService getTargetComponentService();
+
+ /**
+ * Clone the binding
+ * @return
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java
new file mode 100644
index 0000000000..986e1f12e4
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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$
+ */
+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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
new file mode 100644
index 0000000000..34b2607b30
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.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.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$
+ */
+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 a boolean value, "false" by default, which indicates whether
+ * the configuration of this reference is a promotion override for
+ * another more deeply nested reference.
+ *
+ * @return true if the reference is a promotion override
+ */
+ boolean isPromotionOverride();
+
+ /**
+ * Sets a boolean value, "false" by default, which indicates whether
+ * the configuration of this reference is a promotion override for
+ * another more deeply nested reference.
+ *
+ * @param promotionOverride whether the reference is a promotion override
+ */
+ void setPromotionOverride(boolean promotionOverride);
+
+ /**
+ * 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<EndpointReference2> getEndpointReferences();
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java
new file mode 100644
index 0000000000..2cf04277cd
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.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.assembly;
+
+/**
+ * Represents an SCA binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SCABinding extends Binding {
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java
new file mode 100644
index 0000000000..0abfd13d10
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.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;
+
+
+/**
+ * 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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java
new file mode 100644
index 0000000000..88ef8c5d6e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.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 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$
+ */
+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<Endpoint2> getEndpoints();
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java
new file mode 100644
index 0000000000..e1eb26f0c1
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java
new file mode 100644
index 0000000000..d8c530585e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.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 a wireFormat.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WireFormat extends Base, Cloneable {
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java
new file mode 100644
index 0000000000..97708f9ef5
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.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;
+
+/**
+ * Represent a binding that has been added automatically to the model rather
+ * than being specified by the user through the composite file
+ *
+ * @version $Rev$ $Date$
+ *
+ */
+public interface AutomaticBinding extends Cloneable {
+
+ /**
+ * @param isAutomatic
+ */
+ void setIsAutomatic(boolean isAutomatic);
+
+ /**
+ * @return isAutomatic
+ */
+ boolean getIsAutomatic();
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java
new file mode 100644
index 0000000000..7bac630d5b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.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.builder;
+
+import org.apache.tuscany.sca.assembly.AbstractContract;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A builder that handles any build-time configuration needed by bindings.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BindingBuilder {
+
+ /**
+ * Configure a binding.
+ *
+ * @param component The component for the binding's service or reference
+ * @param contract The binding's service or reference
+ */
+ void build(Component component, AbstractContract contract, Binding binding, Monitor monitor);
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java
new file mode 100644
index 0000000000..37ad8af0b3
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.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.builder;
+
+/**
+ * An extension that can be implemented by bindings to provide a binding builder.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BindingBuilderExtension {
+
+ /**
+ * Returns the binding builder.
+ *
+ * @return the binding builder
+ */
+ BindingBuilder getBuilder();
+
+ /**
+ * Sets the binding builder.
+ *
+ * @param builder the binding builder
+ */
+ void setBuilder(BindingBuilder builder);
+
+}
+
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java
new file mode 100644
index 0000000000..d2fae4d24a
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.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.builder;
+
+import org.apache.tuscany.sca.assembly.Component;
+
+/**
+ * Interface for Component Pre Processors.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ComponentPreProcessor {
+
+ void preProcess(Component component);
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java
new file mode 100644
index 0000000000..8a18f74b2b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * 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
+ */
+ String getID();
+
+ /**
+ * Build a composite.
+ *
+ * @param composite
+ * @param definitions
+ * @param monitor
+ * @throws CompositeBuilderException
+ */
+ void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException;
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java
new file mode 100644
index 0000000000..5a2015f55e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java
new file mode 100644
index 0000000000..a2d6b34db5
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.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;
+
+/**
+ * An extension point for Composite builders.
+ *
+ * @version $Rev: $ $Date: $
+ */
+public interface CompositeBuilderExtensionPoint {
+
+ /**
+ * 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);
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java
new file mode 100644
index 0000000000..d9b9763475
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.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.assembly.builder;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+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.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * Default implementation of a provider factory extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderExtensionPoint {
+
+ private ExtensionPointRegistry registry;
+ private final Map<String, CompositeBuilder> builders = new HashMap<String, CompositeBuilder>();
+ private boolean loaded;
+
+ public DefaultCompositeBuilderExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ 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);
+ }
+
+ /**
+ * 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
+ Set<ServiceDeclaration> builderDeclarations;
+ ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance();
+ 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);
+ }
+ }
+
+ /**
+ * A wrapper around a composite builder allowing lazy
+ * loading and initialization of implementation providers.
+ */
+ private static class LazyCompositeBuilder implements CompositeBuilder {
+
+ private FactoryExtensionPoint factories;
+ private InterfaceContractMapper mapper;
+ private String id;
+ private ServiceDeclaration builderDeclaration;
+ private CompositeBuilder builder;
+ private CompositeBuilderExtensionPoint builders;
+
+ private LazyCompositeBuilder(String id, ServiceDeclaration factoryDeclaration,
+ CompositeBuilderExtensionPoint 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 void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ getBuilder().build(composite, definitions, monitor);
+ }
+
+ 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) {
+ Constructor<CompositeBuilder> constructor = builderClass.getConstructor(CompositeBuilderExtensionPoint.class, FactoryExtensionPoint.class, InterfaceContractMapper.class);
+ builder = constructor.newInstance(builders, factories, mapper);
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java
new file mode 100644
index 0000000000..20a17e1bd0
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java
@@ -0,0 +1,80 @@
+/*
+ * 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 org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Service;
+
+/**
+ * A builder that handles the configuration of the components inside a
+ * composite and the wiring of component references to component services.
+ *
+ * @version $Rev: 563358 $ $Date: 2007-08-07 01:26:27 +0100 (Tue, 07 Aug 2007) $
+ */
+public interface DomainBuilder {
+
+ /**
+ * Wire up the references and service in a domain returning a list
+ * of the composites that have changed
+ *
+ * @param domainLevelCompsite
+ * @return a list of change composites
+ * @throws CompositeBuilderException
+ */
+ List<Composite> wireDomain(Composite domainLevelComposite);
+
+ /**
+ * Locates the referenced service and updates the URI on the identified binding
+ *
+ * @param domainLevelComposite
+ * @param referenceName
+ * @param bindingClassName
+ * @param URI
+ */
+ void updateDomainLevelServiceURI(Composite domainLevelComposite, String referenceName, String bindingClassName, String URI);
+
+ /**
+ * Get the component name out of the reference name that might look like Component/Service
+ *
+ * @param referenceName
+ * @return
+ */
+ String getComponentNameFromReference(String referenceName);
+
+ /**
+ * Get the service name out of the reference name that might look like Component/Service
+ *
+ * @param referenceName
+ * @return
+ */
+ String getServiceNameFromReference(String referenceName);
+
+ /**
+ * Find the service object given a reference name
+ *
+ * @param composite
+ * @param referenceName
+ * @return
+ */
+ Service findServiceForReference(Composite composite, String referenceName);
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java
new file mode 100644
index 0000000000..1f62606a83
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.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.builder;
+
+import org.apache.tuscany.sca.assembly.EndpointReference2;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A builder that handles the configuration of endpoint references
+ * It collects together the logic so that it can be used at build time
+ * or later on during late binding scenarios
+ *
+ * @version $Rev$ $Date$
+ */
+public interface EndpointReferenceBuilder {
+
+ /**
+ * Build an endpoint reference matching reference bindings
+ * with service bindings.
+ *
+ * @param endpointReference
+ * @param monitor
+ */
+ void build(EndpointReference2 endpointReference, Monitor monitor);
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java
new file mode 100644
index 0000000000..6720aecb50
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java
@@ -0,0 +1,616 @@
+/*
+ * 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.impl;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactory;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.AutomaticBinding;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+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.PolicySubject;
+
+/**
+ * Base class for Builder implementations
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseBuilderImpl implements CompositeBuilder {
+ protected static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ protected static final String BINDING_SCA = "binding.sca";
+ protected static final QName BINDING_SCA_QNAME = new QName(SCA11_NS, BINDING_SCA);
+
+ protected AssemblyFactory assemblyFactory;
+ protected SCABindingFactory scaBindingFactory;
+ protected InterfaceContractMapper interfaceContractMapper;
+ protected DocumentBuilderFactory documentBuilderFactory;
+ protected TransformerFactory transformerFactory;
+
+
+ protected BaseBuilderImpl(AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ TransformerFactory transformerFactory,
+ InterfaceContractMapper interfaceContractMapper) {
+ this.assemblyFactory = assemblyFactory;
+ this.scaBindingFactory = scaBindingFactory;
+ this.documentBuilderFactory = documentBuilderFactory;
+ this.transformerFactory = transformerFactory;
+ this.interfaceContractMapper = interfaceContractMapper;
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param monitor
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void warning(Monitor monitor, String message, Object model, String... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param monitor
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(Monitor monitor, String message, Object model, String... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem = null;
+ problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Index components inside a composite
+ *
+ * @param composite
+ * @param componentServices
+
+ */
+ protected void indexComponents(Composite composite,
+ Map<String, Component> components) {
+ for (Component component : composite.getComponents()) {
+ // Index components by name
+ components.put(component.getName(), component);
+ }
+ }
+
+ /**
+ * Index services inside a composite
+ *
+ * @param composite
+ * @param componentServices
+ */
+ protected void indexServices(Composite composite,
+ Map<String, ComponentService> componentServices) {
+
+ for (Component component : composite.getComponents()) {
+
+ ComponentService nonCallbackService = null;
+ int nonCallbackServiceCount = 0;
+
+ for (ComponentService componentService : component.getServices()) {
+ // Index component services by component name / service name
+ String uri = component.getName() + '/' + componentService.getName();
+ componentServices.put(uri, componentService);
+
+ // count how many non-callback there are
+ if (!componentService.isCallback()) {
+
+ if (nonCallbackServiceCount == 0) {
+ nonCallbackService = componentService;
+ }
+ nonCallbackServiceCount++;
+ }
+ }
+ if (nonCallbackServiceCount == 1) {
+ // If we have a single non callback service, index it by
+ // component name as well
+ componentServices.put(component.getName(), nonCallbackService);
+ }
+ }
+ }
+
+
+ /**
+ * Index components, services and references inside a composite.
+ * @param composite
+ * @param components
+ * @param componentServices
+ * @param componentReferences
+ */
+ protected void indexComponentsServicesAndReferences(Composite composite,
+ Map<String, Component> components,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences) {
+
+ for (Component component : composite.getComponents()) {
+
+ // Index components by name
+ components.put(component.getName(), component);
+
+ ComponentService nonCallbackService = null;
+ int nonCallbackServices = 0;
+ for (ComponentService componentService : component.getServices()) {
+
+ // Index component services by component name / service name
+ String uri = component.getName() + '/' + componentService.getName();
+ componentServices.put(uri, componentService);
+
+ // TODO - EPR - $promoted$ no longer used but it doesn't do any harm here
+ boolean promotedService = false;
+ if (componentService.getName() != null && componentService.getName().indexOf("$promoted$") > -1) {
+ promotedService = true;
+ }
+
+ // count how many non-callback, non-promoted services there are
+ // if there is only one the component name also acts as the service name
+ if ((!componentService.isCallback()) && (!promotedService)) {
+
+ // Check how many non callback non-promoted services we have
+ if (nonCallbackServices == 0) {
+ nonCallbackService = componentService;
+ }
+ nonCallbackServices++;
+ }
+
+ }
+
+ if (nonCallbackServices == 1) {
+ // If we have a single non callback service, index it by
+ // component name as well
+ componentServices.put(component.getName(), nonCallbackService);
+ }
+
+ // Index references by component name / reference name
+ for (ComponentReference componentReference : component.getReferences()) {
+ String uri = component.getName() + '/' + componentReference.getName();
+ componentReferences.put(uri, componentReference);
+ }
+ }
+ }
+
+ protected void indexComponentPropertiesServicesAndReferences(
+ Component component,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences,
+ Map<String, ComponentProperty> componentProperties, Monitor monitor) {
+ for (ComponentService componentService : component.getServices()) {
+ if (componentServices.containsKey(componentService.getName())) {
+ warning(monitor, "DuplicateComponentServiceName", component,
+ component.getName(), componentService.getName());
+ } else {
+ componentServices.put(componentService.getName(),
+ componentService);
+ }
+ }
+ for (ComponentReference componentReference : component.getReferences()) {
+ if (componentReferences.containsKey(componentReference.getName())) {
+ warning(monitor, "DuplicateComponentReferenceName", component,
+ component.getName(), componentReference.getName());
+ } else {
+ componentReferences.put(componentReference.getName(),
+ componentReference);
+ }
+ }
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ if (componentProperties.containsKey(componentProperty.getName())) {
+ warning(monitor, "DuplicateComponentPropertyName", component,
+ component.getName(), componentProperty.getName());
+ } else {
+ componentProperties.put(componentProperty.getName(),
+ componentProperty);
+ }
+ }
+
+ }
+
+ protected void indexImplementationPropertiesServicesAndReferences(
+ Component component, Map<String, Service> services,
+ Map<String, Reference> references,
+ Map<String, Property> properties, Monitor monitor) {
+ // First check that the component has a resolved implementation
+ Implementation implementation = component.getImplementation();
+ if (implementation == null) {
+ // A component must have an implementation
+ warning(monitor, "NoComponentImplementation", component, component
+ .getName());
+
+ } else if (implementation.isUnresolved()) {
+
+ // The implementation must be fully resolved
+ warning(monitor, "UnresolvedComponentImplementation", component,
+ component.getName(), implementation.getURI());
+
+ } else {
+
+ // Index properties, services and references, also check for
+ // duplicates
+ for (Property property : implementation.getProperties()) {
+ if (properties.containsKey(property.getName())) {
+ warning(monitor, "DuplicateImplementationPropertyName",
+ component, component.getName(), property.getName());
+ } else {
+ properties.put(property.getName(), property);
+ }
+ }
+ for (Service service : implementation.getServices()) {
+ if (services.containsKey(service.getName())) {
+ warning(monitor, "DuplicateImplementationServiceName",
+ component, component.getName(), service.getName());
+ } else {
+ services.put(service.getName(), service);
+ }
+ }
+ for (Reference reference : implementation.getReferences()) {
+ if (references.containsKey(reference.getName())) {
+ warning(monitor, "DuplicateImplementationReferenceName",
+ component, component.getName(), reference.getName());
+ } else {
+ references.put(reference.getName(), reference);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Reconcile component properties and the properties defined by the
+ * component type.
+ *
+ * @param component
+ * @param properties
+ * @param componentProperties
+ * @param problems
+ */
+ protected void reconcileProperties(Component component,
+ Map<String, Property> properties,
+ Map<String, ComponentProperty> componentProperties,
+ Monitor monitor) {
+
+ // Connect component properties to their properties
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ Property property = properties.get(componentProperty.getName());
+ if (property != null) {
+ componentProperty.setProperty(property);
+ } else {
+ warning(monitor, "PropertyNotFound", component, component.getName(), componentProperty.getName());
+ }
+ }
+
+ // Create component properties for all properties
+ if (component.getImplementation() != null) {
+ for (Property property : component.getImplementation().getProperties()) {
+ if (!componentProperties.containsKey(property.getName())) {
+ ComponentProperty componentProperty = assemblyFactory.createComponentProperty();
+ componentProperty.setName(property.getName());
+ componentProperty.setMany(property.isMany());
+ componentProperty.setXSDElement(property.getXSDElement());
+ componentProperty.setXSDType(property.getXSDType());
+ componentProperty.setProperty(property);
+ component.getProperties().add(componentProperty);
+ }
+ }
+ }
+
+ // Reconcile component properties and their properties
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ Property property = componentProperty.getProperty();
+ if (property != null) {
+
+ // Check that a component property does not override the
+ // mustSupply attribute
+ if (!property.isMustSupply() && componentProperty.isMustSupply()) {
+ warning(monitor, "PropertyMustSupplyIncompatible", component, component.getName(), componentProperty.getName());
+ }
+
+ // Default to the mustSupply attribute specified on the property
+ if (!componentProperty.isMustSupply())
+ componentProperty.setMustSupply(property.isMustSupply());
+
+ // Default to the value specified on the property
+ if (componentProperty.getValue() == null) {
+ componentProperty.setValue(property.getValue());
+ }
+
+ // Override the property value for the composite
+ if(component.getImplementation() instanceof Composite) {
+ property.setValue(componentProperty.getValue());
+ }
+
+ // Check that a value is supplied
+ if (componentProperty.getValue() == null && property.isMustSupply()) {
+ warning(monitor, "PropertyMustSupplyNull", component, component.getName(), componentProperty.getName());
+ }
+
+ // Check that a a component property does not override the
+ // many attribute
+ if (!property.isMany() && componentProperty.isMany()) {
+
+ warning(monitor, "PropertyOverrideManyAttribute", component, component.getName(), componentProperty.getName());
+ }
+
+ // Default to the many attribute defined on the property
+ componentProperty.setMany(property.isMany());
+
+ // Default to the type and element defined on the property
+ if (componentProperty.getXSDType() == null) {
+ componentProperty.setXSDType(property.getXSDType());
+ }
+ if (componentProperty.getXSDElement() == null) {
+ componentProperty.setXSDElement(property.getXSDElement());
+ }
+
+ // Check that a type or element are specified
+ if (componentProperty.getXSDElement() == null && componentProperty.getXSDType() == null) {
+ warning(monitor, "NoTypeForComponentProperty", component, component.getName(), componentProperty.getName());
+ }
+ }
+ }
+ }
+
+ /**
+ * Reconcile component references with the references defined on the
+ * component type.
+ *
+ * @param component
+ * @param references
+ * @param componentReferences
+ * @param monitor
+ */
+ protected void reconcileReferences(Component component,
+ Map<String, Reference> references,
+ Map<String, ComponentReference> componentReferences,
+ Monitor monitor) {
+
+ // Connect each component reference to the corresponding reference
+ for (ComponentReference componentReference : component.getReferences()) {
+ if (componentReference.getReference() != null || componentReference.isCallback()) {
+ continue;
+ }
+ Reference reference = references.get(componentReference.getName());
+ if (reference != null) {
+ componentReference.setReference(reference);
+ } else {
+ if (!componentReference.getName().startsWith("$self$.")) {
+ error(monitor, "ReferenceNotFound", component, component.getName(), componentReference.getName());
+ }
+ }
+ }
+
+ // Create a component reference for each reference
+ if (component.getImplementation() != null) {
+ for (Reference reference : component.getImplementation().getReferences()) {
+ if (!componentReferences.containsKey(reference.getName())) {
+ ComponentReference componentReference =
+ assemblyFactory.createComponentReference();
+ componentReference.setIsCallback(reference.isCallback());
+ componentReference.setName(reference.getName());
+ componentReference.setReference(reference);
+ component.getReferences().add(componentReference);
+ }
+ }
+ }
+
+ // Reconcile each component reference with its reference
+ for (ComponentReference componentReference : component.getReferences()) {
+ Reference reference = componentReference.getReference();
+ if (reference != null) {
+ // Reconcile multiplicity
+ if (componentReference.getMultiplicity() != null) {
+ if (!ReferenceConfigurationUtil.isValidMultiplicityOverride(reference.getMultiplicity(),
+ componentReference
+ .getMultiplicity())) {
+ warning(monitor, "ReferenceIncompatibleMultiplicity", component, component.getName(), componentReference.getName());
+ }
+ } else {
+ componentReference.setMultiplicity(reference.getMultiplicity());
+ }
+
+ // Reconcile interface
+ InterfaceContract interfaceContract = reference.getInterfaceContract();
+ if (componentReference.getInterfaceContract() != null) {
+ if (interfaceContract != null && !componentReference.getInterfaceContract().equals(reference
+ .getInterfaceContract())) {
+ if (!interfaceContractMapper.isCompatible(componentReference.getInterfaceContract(),
+ interfaceContract)) {
+ warning(monitor, "ReferenceIncompatibleComponentInterface", component, component.getName(), componentReference.getName());
+ }
+ }
+ } else {
+ componentReference.setInterfaceContract(interfaceContract);
+ }
+
+ // Reconcile bindings
+ if (componentReference.getBindings().isEmpty()) {
+ componentReference.getBindings().addAll(reference.getBindings());
+ }
+
+ // Reconcile callback bindings
+ if (componentReference.getCallback() == null) {
+ componentReference.setCallback(reference.getCallback());
+ if (componentReference.getCallback() == null) {
+ // Create an empty callback to avoid null check
+ componentReference.setCallback(assemblyFactory.createCallback());
+ }
+
+ } else if (componentReference.getCallback().getBindings().isEmpty() && reference
+ .getCallback() != null) {
+ componentReference.getCallback().getBindings().addAll(reference.getCallback()
+ .getBindings());
+ }
+
+ // Propagate autowire setting from the component
+ if (componentReference.getAutowire() == null) {
+ componentReference.setAutowire(component.getAutowire());
+ }
+
+ // Reconcile targets
+ if (componentReference.getTargets().isEmpty()) {
+ componentReference.getTargets().addAll(reference.getTargets());
+ }
+ }
+ }
+ }
+
+ /**
+ * Reconcile component services and services defined on the component type.
+ *
+ * @param component
+ * @param services
+ * @param componentServices
+ * @param monitor
+ */
+ protected void reconcileServices(Component component,
+ Map<String, Service> services,
+ Map<String, ComponentService> componentServices,
+ Monitor monitor) {
+
+ // Connect each component service to the corresponding service
+ for (ComponentService componentService : component.getServices()) {
+ if (componentService.getService() != null || componentService.isCallback()) {
+ continue;
+ }
+ Service service = services.get(componentService.getName());
+ if (service != null) {
+ componentService.setService(service);
+ } else {
+ warning(monitor, "ServiceNotFoundForComponentService", component, component.getName(), componentService.getName());
+ }
+ }
+
+ // Create a component service for each service
+ if (component.getImplementation() != null) {
+ for (Service service : component.getImplementation().getServices()) {
+ if (!componentServices.containsKey(service.getName())) {
+ ComponentService componentService = assemblyFactory.createComponentService();
+ componentService.setIsCallback(service.isCallback());
+ String name = service.getName();
+ componentService.setName(name);
+ componentService.setService(service);
+ component.getServices().add(componentService);
+ componentServices.put(name, componentService);
+ }
+ }
+ }
+
+ //Reconcile each component service with its service
+ for (ComponentService componentService : component.getServices()) {
+ Service service = componentService.getService();
+ if (service != null) {
+ // Reconcile interface
+ InterfaceContract interfaceContract = service.getInterfaceContract();
+ if (componentService.getInterfaceContract() != null) {
+ if (interfaceContract != null && !componentService.getInterfaceContract().equals(interfaceContract)) {
+ if (!interfaceContractMapper.isCompatible(componentService.getInterfaceContract(),
+ interfaceContract)) {
+ warning(monitor, "ServiceIncompatibleComponentInterface", component, component.getName(), componentService.getName());
+ }
+ }
+ } else {
+ componentService.setInterfaceContract(interfaceContract);
+ }
+
+ // Reconcile bindings
+ if (componentService.getBindings().isEmpty()) {
+ componentService.getBindings().addAll(service.getBindings());
+ }
+
+ // Reconcile callback bindings
+ if (componentService.getCallback() == null) {
+ componentService.setCallback(service.getCallback());
+ if (componentService.getCallback() == null) {
+ // Create an empty callback to avoid null check
+ componentService.setCallback(assemblyFactory.createCallback());
+ }
+ } else if (componentService.getCallback().getBindings().isEmpty() && service
+ .getCallback() != null) {
+ componentService.getCallback().getBindings().addAll(service.getCallback()
+ .getBindings());
+ }
+ }
+ }
+ }
+
+ protected SCABinding createSCABinding(Definitions definitions) {
+ SCABinding scaBinding = scaBindingFactory.createSCABinding();
+
+ // mark the bindings that are added automatically so that they can
+ // be disregarded for overriding purposes
+ if (scaBinding instanceof AutomaticBinding){
+ ((AutomaticBinding)scaBinding).setIsAutomatic(true);
+ }
+
+ if ( definitions != null ) {
+ for ( ExtensionType attachPointType : definitions.getBindingTypes() ) {
+ if ( attachPointType.getType().equals(BINDING_SCA_QNAME)) {
+ ((PolicySubject)scaBinding).setType(attachPointType);
+ }
+ }
+ }
+
+ return scaBinding;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java
new file mode 100644
index 0000000000..812e06942a
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java
@@ -0,0 +1,395 @@
+/*
+ * 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.impl;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactory;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.ComponentPreProcessor;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that handles the configuration of components.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implements CompositeBuilder {
+
+ @Deprecated
+ public ComponentConfigurationBuilderImpl(AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ InterfaceContractMapper interfaceContractMapper) {
+ super(assemblyFactory, scaBindingFactory,
+ null, null,
+ interfaceContractMapper);
+ }
+
+ public ComponentConfigurationBuilderImpl(AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ TransformerFactory transformerFactory,
+ InterfaceContractMapper interfaceContractMapper) {
+ super(assemblyFactory, scaBindingFactory,
+ documentBuilderFactory, transformerFactory,
+ interfaceContractMapper);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentConfigurationBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ configureComponents(composite, definitions, monitor);
+ }
+
+ /**
+ * Configure components in the composite.
+ *
+ * @param composite
+ * @param monitor
+ */
+ protected void configureComponents(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ configureComponents(composite, null, definitions, monitor);
+ configureSourcedProperties(composite, null);
+ }
+
+ /**
+ * Configure components in the composite.
+ *
+ * @param composite
+ * @param uri
+ * @param problems
+ */
+ private void configureComponents(Composite composite, String uri, Definitions definitions, Monitor monitor) {
+ String parentURI = uri;
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+
+ // Initialize component URI
+ String componentURI;
+ if (parentURI == null) {
+ componentURI = component.getName();
+ } else {
+ componentURI = URI.create(parentURI + '/').resolve(component.getName()).toString();
+ }
+ component.setURI(componentURI);
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // Process nested composite
+ configureComponents((Composite)implementation, componentURI, definitions, monitor);
+ }
+ }
+
+ // Initialize service bindings
+ List<Service> compositeServices = composite.getServices();
+ for (Service service : compositeServices) {
+ // Set default binding names
+
+ // Create default SCA binding
+ if (service.getBindings().isEmpty()) {
+ SCABinding scaBinding = createSCABinding(definitions);
+ service.getBindings().add(scaBinding);
+ }
+ }
+
+ // Initialize reference bindings
+ for (Reference reference : composite.getReferences()) {
+ // Create default SCA binding
+ if (reference.getBindings().isEmpty()) {
+ SCABinding scaBinding = createSCABinding(definitions);
+ reference.getBindings().add(scaBinding);
+ }
+ }
+
+ // Initialize all component services and references
+ Map<String, Component> components = new HashMap<String, Component>();
+ for (Component component : composite.getComponents()) {
+
+ // Index all components and check for duplicates
+ if (components.containsKey(component.getName())) {
+ error(monitor, "DuplicateComponentName", component, composite.getName().toString(), component.getName());
+ } else {
+ components.put(component.getName(), component);
+ }
+
+ // Propagate the autowire flag from the composite to components
+ if (component.getAutowire() == null) {
+ component.setAutowire(composite.getAutowire());
+ }
+
+ if (component.getImplementation() instanceof ComponentPreProcessor) {
+ ((ComponentPreProcessor)component.getImplementation()).preProcess(component);
+ }
+
+ // Index properties, services and references
+ Map<String, Service> services = new HashMap<String, Service>();
+ Map<String, Reference> references = new HashMap<String, Reference>();
+ Map<String, Property> properties = new HashMap<String, Property>();
+ indexImplementationPropertiesServicesAndReferences(component,
+ services,
+ references,
+ properties,
+ monitor);
+
+ // Index component services, references and properties
+ // Also check for duplicates
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ Map<String, ComponentProperty> componentProperties = new HashMap<String, ComponentProperty>();
+ indexComponentPropertiesServicesAndReferences(component,
+ componentServices,
+ componentReferences,
+ componentProperties,
+ monitor);
+
+ // Reconcile component services/references/properties and
+ // implementation services/references and create component
+ // services/references/properties for the services/references
+ // declared by the implementation
+ reconcileServices(component, services, componentServices, monitor);
+ reconcileReferences(component, references, componentReferences, monitor);
+ reconcileProperties(component, properties, componentProperties, monitor);
+
+ // Configure or create callback services for component's references
+ // with callbacks
+ configureCallbackServices(component, componentServices);
+
+ // Configure or create callback references for component's services
+ // with callbacks
+ configureCallbackReferences(component, componentReferences);
+
+ // Initialize service bindings
+ for (ComponentService componentService : component.getServices()) {
+
+ // Create default SCA binding
+ if (componentService.getBindings().isEmpty()) {
+ SCABinding scaBinding = createSCABinding(definitions);
+ componentService.getBindings().add(scaBinding);
+ }
+ }
+
+ // Initialize reference bindings
+ for (ComponentReference componentReference : component.getReferences()) {
+
+ // Create default SCA binding
+ if (componentReference.getBindings().isEmpty()) {
+ SCABinding scaBinding = createSCABinding(definitions);
+ componentReference.getBindings().add(scaBinding);
+ }
+ }
+ }
+ }
+
+ /**
+ * For all the references with callbacks, create a corresponding callback
+ * service.
+ *
+ * @param component
+ */
+ private void configureCallbackServices(Component component,
+ Map<String, ComponentService> componentServices) {
+ for (ComponentReference reference : component.getReferences()) {
+ if (reference.getInterfaceContract() != null && // can be null in
+ // unit tests
+ reference.getInterfaceContract().getCallbackInterface() != null) {
+ ComponentService service =
+ componentServices.get(reference.getName());
+ if (service == null) {
+ service = createCallbackService(component, reference);
+ }
+ if (reference.getCallback() != null) {
+ if (service.getBindings().isEmpty()) {
+ service.getBindings().addAll(reference.getCallback().getBindings());
+ }
+ }
+ reference.setCallbackService(service);
+ }
+ }
+ }
+
+ /**
+ * Create a callback service for a component reference
+ *
+ * @param component
+ * @param reference
+ */
+ private ComponentService createCallbackService(Component component, ComponentReference reference) {
+ ComponentService componentService = assemblyFactory.createComponentService();
+ componentService.setIsCallback(true);
+ componentService.setName(reference.getName());
+ try {
+ InterfaceContract contract =
+ (InterfaceContract)reference.getInterfaceContract().clone();
+ contract.setInterface(contract.getCallbackInterface());
+ contract.setCallbackInterface(null);
+ componentService.setInterfaceContract(contract);
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ }
+ Reference implReference = reference.getReference();
+ if (implReference != null) {
+ Service implService = assemblyFactory.createService();
+ implService.setName(implReference.getName());
+ try {
+ InterfaceContract implContract =
+ (InterfaceContract)implReference.getInterfaceContract().clone();
+ implContract.setInterface(implContract.getCallbackInterface());
+ implContract.setCallbackInterface(null);
+ implService.setInterfaceContract(implContract);
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ }
+ componentService.setService(implService);
+ }
+ component.getServices().add(componentService);
+ return componentService;
+ }
+
+ /**
+ * For all the services with callbacks, create a corresponding callback
+ * reference.
+ *
+ * @param component
+ */
+ private void configureCallbackReferences(Component component,
+ Map<String, ComponentReference> componentReferences) {
+ for (ComponentService service : component.getServices()) {
+ if (service.getInterfaceContract() != null && // can be null in
+ // unit tests
+ service.getInterfaceContract().getCallbackInterface() != null) {
+ ComponentReference reference =
+ componentReferences.get(service.getName());
+ if (reference == null) {
+ reference = createCallbackReference(component, service);
+ }
+ if (service.getCallback() != null) {
+ if (reference.getBindings().isEmpty()) {
+ reference.getBindings().addAll(service.getCallback().getBindings());
+ }
+ }
+ service.setCallbackReference(reference);
+ }
+ }
+ }
+
+ /**
+ * Create a callback reference for a component service
+ *
+ * @param component
+ * @param service
+ */
+ private ComponentReference createCallbackReference(Component component, ComponentService service) {
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setIsCallback(true);
+ componentReference.setName(service.getName());
+ try {
+ InterfaceContract contract = (InterfaceContract)service.getInterfaceContract().clone();
+ contract.setInterface(contract.getCallbackInterface());
+ contract.setCallbackInterface(null);
+ componentReference.setInterfaceContract(contract);
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ }
+ Service implService = service.getService();
+ if (implService != null) {
+ Reference implReference = assemblyFactory.createReference();
+ implReference.setName(implService.getName());
+ try {
+ InterfaceContract implContract =
+ (InterfaceContract)implService.getInterfaceContract().clone();
+ implContract.setInterface(implContract.getCallbackInterface());
+ implContract.setCallbackInterface(null);
+ implReference.setInterfaceContract(implContract);
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ }
+ componentReference.setReference(implReference);
+ }
+ component.getReferences().add(componentReference);
+ return componentReference;
+ }
+
+ /**
+ * @param composite
+ */
+ private void configureSourcedProperties(Composite composite, List<ComponentProperty> propertySettings) {
+ // Resolve properties
+ Map<String, Property> compositeProperties = new HashMap<String, Property>();
+ ComponentProperty componentProperty = null;
+ for (Property p : composite.getProperties()) {
+ componentProperty = getComponentPropertyByName(p.getName(), propertySettings);
+ if (componentProperty != null) {
+ compositeProperties.put(p.getName(), componentProperty);
+ } else {
+ compositeProperties.put(p.getName(), p);
+ }
+ }
+
+ for (Component component : composite.getComponents()) {
+ try {
+ PropertyConfigurationUtil.sourceComponentProperties(compositeProperties, component,
+ documentBuilderFactory, transformerFactory);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Implementation impl = component.getImplementation();
+ if (impl instanceof Composite) {
+ configureSourcedProperties((Composite)impl, component.getProperties());
+ }
+ }
+ }
+
+ private ComponentProperty getComponentPropertyByName(String propertyName, List<ComponentProperty> properties) {
+ if (properties != null) {
+ for (ComponentProperty aProperty : properties) {
+ if (aProperty.getName().equals(propertyName)) {
+ return aProperty;
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java
new file mode 100644
index 0000000000..734b373f11
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.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.assembly.builder.impl;
+
+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.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that performs any additional building steps that
+ * component reference bindings may need. Used for WSDL generation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentReferenceBindingBuilderImpl implements CompositeBuilder {
+
+ public ComponentReferenceBindingBuilderImpl() {
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ buildReferenceBindings(composite, monitor);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentReferenceBindingBuilder";
+ }
+
+ private void buildReferenceBindings(Composite composite, Monitor monitor) {
+
+ // find all the component reference bindings (starting at top level)
+ for (Component component : composite.getComponents()) {
+ for (ComponentReference componentReference : component.getReferences()) {
+ for (Binding binding : componentReference.getBindings()) {
+ if (binding instanceof BindingBuilderExtension) {
+ ((BindingBuilderExtension)binding).getBuilder().build(component, componentReference, binding, monitor);
+ }
+ }
+ }
+ }
+
+ // build bindings recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ buildReferenceBindings((Composite)implementation, monitor);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java
new file mode 100644
index 0000000000..c56541a273
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java
@@ -0,0 +1,430 @@
+/*
+ * 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.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.Endpoint2;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
+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.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that creates endpoint reference models.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderImpl implements CompositeBuilder {
+
+
+ public ComponentReferenceEndpointReferenceBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) {
+ super(assemblyFactory, null, null, null, interfaceContractMapper);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentReferenceEndpointReferenceBuilder";
+ }
+
+ /**
+ * Create endpoint references for all component references.
+ *
+ * @param composite
+ */
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException
+ {
+ // process top level composite references
+ // TODO - I don't think OASIS allows for these
+ //
+ //processCompositeReferences(composite);
+
+ // process component services
+ processComponentReferences(composite, monitor);
+ }
+
+ private void processCompositeReferences(Composite composite) {
+ // TODO do we need this for OASIS?
+ }
+
+ private void processComponentReferences(Composite composite, Monitor monitor) {
+
+ // index all of the components in the composite
+ Map<String, Component> components = new HashMap<String, Component>();
+ indexComponents(composite, components);
+
+ // index all of the services in the composite
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ indexServices(composite, componentServices);
+
+ // create endpoint references for each component's references
+ for (Component component : composite.getComponents()) {
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ processComponentReferences((Composite)implementation, monitor);
+ }
+
+ // create endpoint references to represent the component reference
+ for (ComponentReference reference : component.getReferences()) {
+
+ createReferenceEndpointReferences(composite, component, reference, components, componentServices, monitor);
+
+ // fix up links between endpoints and endpoint references that represent callbacks
+ for (ComponentService service : component.getServices()){
+ if ((service.getInterfaceContract() != null) &&
+ (service.getInterfaceContract().getCallbackInterface() != null)){
+ if ( reference.getName().equals(service.getName())){
+ for ( Endpoint2 endpoint : service.getEndpoints()){
+ endpoint.getCallbackEndpointReferences().addAll(reference.getEndpointReferences());
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void createReferenceEndpointReferences(Composite composite,
+ Component component,
+ ComponentReference reference,
+ Map<String, Component> components,
+ Map<String, ComponentService> componentServices,
+ Monitor monitor)
+ {
+ if (reference.getAutowire() == Boolean.TRUE &&
+ reference.getTargets().isEmpty()) {
+
+ // Find suitable targets in the current composite for an
+ // autowired reference
+ Multiplicity multiplicity = reference.getMultiplicity();
+ for (Component targetComponent : composite.getComponents()) {
+
+ // prevent autowire connecting to self
+ boolean skipSelf = false;
+ for (ComponentReference targetComponentReference : targetComponent.getReferences()) {
+ if (reference == targetComponentReference) {
+ skipSelf = true;
+ }
+ }
+
+ if (!skipSelf) {
+ for (ComponentService targetComponentService : targetComponent.getServices()) {
+ if (reference.getInterfaceContract() == null ||
+ interfaceContractMapper.isCompatible(reference.getInterfaceContract(),
+ targetComponentService.getInterfaceContract())) {
+ // create endpoint reference
+ EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
+ endpointRef.setComponent(component);
+ endpointRef.setReference(reference);
+ endpointRef.setUnresolved(false);
+
+ // create dummy endpoint. This will be replaced when policies
+ // are matched and bindings are configured later
+ Endpoint2 endpoint = assemblyFactory.createEndpoint();
+ endpoint.setComponent(targetComponent);
+ endpoint.setService(targetComponentService);
+ endpoint.setUnresolved(true);
+ endpointRef.setTargetEndpoint(endpoint);
+
+ reference.getEndpointReferences().add(endpointRef);
+
+ if (multiplicity == Multiplicity.ZERO_ONE ||
+ multiplicity == Multiplicity.ONE_ONE) {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (multiplicity == Multiplicity.ONE_N ||
+ multiplicity == Multiplicity.ONE_ONE) {
+ if (reference.getEndpointReferences().size() == 0) {
+ warning(monitor,
+ "NoComponentReferenceTarget",
+ reference,
+ reference.getName());
+ }
+ }
+
+ } else if (!reference.getTargets().isEmpty()) {
+
+ // Check that the component reference does not mix the use of
+ // endpoint references specified via the target attribute with
+ // the presence of binding elements
+ if (reference.getBindings().size() > 0) {
+ warning(monitor, "ReferenceEndPointMixWithTarget",
+ composite, reference.getName());
+ }
+
+ // Resolve targets specified on the component reference
+ for (ComponentService target : reference.getTargets()) {
+
+ String targetName = target.getName();
+ ComponentService targetComponentService = componentServices.get(targetName);
+
+ Component targetComponent;
+ int s = targetName.indexOf('/');
+ if (s == -1) {
+ targetComponent = components.get(targetName);
+ } else {
+ targetComponent = components.get(targetName.substring(0, s));
+ }
+
+ if (targetComponentService != null) {
+
+ // Check that the target component service provides
+ // a superset of the component reference interface
+ if (reference.getInterfaceContract() == null ||
+ interfaceContractMapper.isCompatible(reference.getInterfaceContract(),
+ targetComponentService.getInterfaceContract())) {
+
+ // create endpoint reference
+ EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
+ endpointRef.setComponent(component);
+ endpointRef.setReference(reference);
+ endpointRef.setUnresolved(false);
+
+ // create dummy endpoint. This will be replaced when policies
+ // are matched and bindings are configured later
+ Endpoint2 endpoint = assemblyFactory.createEndpoint();
+ endpoint.setComponent(targetComponent);
+ endpoint.setService(targetComponentService);
+ endpoint.setUnresolved(true);
+ endpointRef.setTargetEndpoint(endpoint);
+
+ reference.getEndpointReferences().add(endpointRef);
+ } else {
+ warning(monitor,
+ "ReferenceIncompatibleInterface",
+ composite,
+ composite.getName().toString(),
+ reference.getName(),
+ targetName);
+ }
+ } else {
+ // add an unresolved endpoint reference
+ EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
+ endpointRef.setComponent(component);
+ endpointRef.setReference(reference);
+ endpointRef.setUnresolved(true);
+
+ // create an unresolved endpoint to go with it
+ Endpoint2 endpoint = assemblyFactory.createEndpoint();
+ endpoint.setUnresolved(true);
+ endpointRef.setTargetEndpoint(endpoint);
+
+ warning(monitor,
+ "ComponentReferenceTargetNotFound",
+ composite,
+ composite.getName().toString(),
+ targetName);
+ }
+ }
+ } else if ((reference.getReference() != null)
+ && (!reference.getReference().getTargets().isEmpty())) {
+
+ // Resolve targets from the corresponding reference in the
+ // componentType
+ for (ComponentService target : reference.getReference().getTargets()) {
+
+ String targetName = target.getName();
+ ComponentService targetComponentService = componentServices.get(targetName);
+
+ Component targetComponent;
+ int s = targetName.indexOf('/');
+ if (s == -1) {
+ targetComponent = components.get(targetName);
+ } else {
+ targetComponent = components.get(targetName.substring(0, s));
+ }
+
+ if (targetComponentService != null) {
+
+ // Check that the target component service provides
+ // a superset of the component reference interface
+ if (reference.getInterfaceContract() == null ||
+ interfaceContractMapper.isCompatible(reference.getInterfaceContract(),
+ targetComponentService.getInterfaceContract())) {
+
+ // create endpoint reference
+ EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
+ endpointRef.setComponent(component);
+ endpointRef.setReference(reference);
+ endpointRef.setUnresolved(false);
+
+ // create dummy endpoint. This will be replaced when policies
+ // are matched and bindings are configured later
+ Endpoint2 endpoint = assemblyFactory.createEndpoint();
+ endpoint.setComponent(targetComponent);
+ endpoint.setService(targetComponentService);
+ endpoint.setUnresolved(true);
+ endpointRef.setTargetEndpoint(endpoint);
+
+ reference.getEndpointReferences().add(endpointRef);
+ } else {
+ warning(monitor,
+ "ReferenceIncompatibleInterface",
+ composite,
+ composite.getName().toString(),
+ reference.getName(),
+ targetName);
+ }
+ } else {
+ // add an unresolved endpoint reference
+ EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
+ endpointRef.setComponent(component);
+ endpointRef.setReference(reference);
+ endpointRef.setUnresolved(true);
+
+ // create an unresolved endpoint to go with it
+ Endpoint2 endpoint = assemblyFactory.createEndpoint();
+ endpoint.setUnresolved(true);
+ endpointRef.setTargetEndpoint(endpoint);
+
+ warning(monitor,
+ "ComponentReferenceTargetNotFound",
+ composite,
+ composite.getName().toString(),
+ targetName);
+ }
+ }
+ }
+
+
+ // if no endpoints have found so far the bindings become targets.
+ if (reference.getEndpointReferences().isEmpty()) {
+ for (Binding binding : reference.getBindings()) {
+
+ String uri = binding.getURI();
+
+ // user hasn't put a uri on the binding so it's not a target
+ // name
+ if (uri == null) {
+ // create endpoint reference for manually configured bindings
+ EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
+ endpointRef.setComponent(component);
+ endpointRef.setReference(reference);
+ endpointRef.setBinding(binding);
+ endpointRef.setTargetEndpoint(null);
+ endpointRef.setUnresolved(false);
+
+ // create a resolved endpoint to signify that this
+ // reference is pointing at some unwired endpoint
+ Endpoint2 endpoint = assemblyFactory.createEndpoint();
+ endpoint.setUnresolved(false);
+ endpointRef.setTargetEndpoint(endpoint);
+
+ reference.getEndpointReferences().add(endpointRef);
+
+ continue;
+ }
+
+ // user might have put a local target name in the uri
+ // see if it refers to a target we know about
+ // - if it does the reference binding will be matched with a
+ // service binding
+ // - if it doesn't it is assumed to be an external reference
+ Component targetComponent = null;
+ ComponentService targetComponentService = null;
+
+
+ if (uri.startsWith("/")) {
+ uri = uri.substring(1);
+ }
+
+ // Resolve the target component and service
+ targetComponentService = componentServices.get(uri);
+ int s = uri.indexOf('/');
+ if (s == -1) {
+ targetComponent = components.get(uri);
+ } else {
+ targetComponent = components.get(uri.substring(0, s));
+ }
+
+ // if the binding URI matches a component in the
+ // composite then configure an endpoint reference with this component as
+ // the target. If not then the binding URI will be assumed to reference an
+ // external service
+ if (targetComponentService != null) {
+
+ // Check that the target component service provides
+ // a superset of the component reference interface
+ if (reference.getInterfaceContract() == null ||
+ interfaceContractMapper.isCompatible(reference.getInterfaceContract(),
+ targetComponentService.getInterfaceContract())) {
+ // create enpoint reference
+ EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
+ endpointRef.setComponent(component);
+ endpointRef.setReference(reference);
+ endpointRef.setBinding(binding);
+ endpointRef.setUnresolved(false);
+
+ // create dummy endpoint. This will be replaced when policies
+ // are matched and bindings are configured later
+ Endpoint2 endpoint = assemblyFactory.createEndpoint();
+ endpoint.setComponent(targetComponent);
+ endpoint.setService(targetComponentService);
+ endpoint.setUnresolved(true);
+ endpointRef.setTargetEndpoint(endpoint);
+
+ reference.getEndpointReferences().add(endpointRef);
+ } else {
+ warning(monitor,
+ "ReferenceIncompatibleInterface",
+ composite,
+ composite.getName().toString(),
+ reference.getName(),
+ uri);
+ }
+ } else {
+ // create endpoint reference for manually configured bindings
+ EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
+ endpointRef.setComponent(component);
+ endpointRef.setReference(reference);
+ endpointRef.setBinding(binding);
+ endpointRef.setTargetEndpoint(null);
+ endpointRef.setUnresolved(false);
+
+ // create a resolved endpoint to signify that this
+ // reference is pointing at some unwired endpoint
+ Endpoint2 endpoint = assemblyFactory.createEndpoint();
+ endpoint.setUnresolved(false);
+ endpointRef.setTargetEndpoint(endpoint);
+
+ reference.getEndpointReferences().add(endpointRef);
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java
new file mode 100644
index 0000000000..eb06f67f8e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.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.builder.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that handles the creation of promoted composite services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public ComponentReferencePromotionBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ configureNestedCompositeReferences(composite, monitor);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentReferencePromotionBuilder";
+ }
+
+ /**
+ * Push down reference configuration into nested composites.
+ *
+ * @param composite
+ * @param problems
+ */
+ private void configureNestedCompositeReferences(Composite composite, Monitor monitor) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ configureNestedCompositeReferences((Composite)implementation, monitor);
+ }
+ }
+
+ // Process component references declared on components in this composite
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ for (ComponentReference componentReference : component.getReferences()) {
+ Reference implReference = componentReference.getReference();
+ if (implReference != null && implReference instanceof CompositeReference) {
+
+ // If the component reference is wired, it is a promotion override
+ if (!componentReference.getEndpointReferences().isEmpty()) {
+ componentReference.setPromotionOverride(true);
+ }
+
+ // If the component reference is a promotion override, override the
+ // configuration of the promoted reference
+ if (componentReference.isPromotionOverride()) {
+ CompositeReference compositeReference = (CompositeReference)implReference;
+ List<ComponentReference> promotedReferences =
+ ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference);
+ for (ComponentReference promotedReference : promotedReferences) {
+ ReferenceConfigurationUtil.reconcileReferenceBindings(
+ componentReference, promotedReference, assemblyFactory, monitor);
+ if (componentReference.getInterfaceContract() != null && // can be null in unit tests
+ componentReference.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
+ if (promotedReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().clear();
+ } else {
+ promotedReference.setCallback(assemblyFactory.createCallback());
+ }
+ if (scaCallbackBinding != null) {
+ promotedReference.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ if (componentReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().addAll(componentReference
+ .getCallback().getBindings());
+ }
+ }
+ /* TODO - let endpoint references worry about target service
+ // Wire the promoted reference to the actual non-composite component services
+ if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE) {
+ // promotedReference.getTargets().clear();
+ }
+ for (ComponentService target : componentReference.getTargets()) {
+ if (target.getService() instanceof CompositeService) {
+
+ // Wire to the actual component service
+ // promoted by a composite service
+ CompositeService compositeService = (CompositeService)target.getService();
+ // Find the promoted component service
+ ComponentService componentService =
+ ServiceConfigurationUtil.getPromotedComponentService(compositeService);
+ if (componentService != null) {
+ promotedReference.getTargets().add(componentService);
+ }
+ } else {
+
+ // Wire to a non-composite target service
+ promotedReference.getTargets().add(target);
+ }
+ }
+*/
+ }
+ }
+ }
+ }
+ } else {
+/* TODO - let endpoint references worry about target servicep
+ for (ComponentReference componentReference : component.getReferences()) {
+
+ // Wire the component reference to the actual
+ // non-composite component services
+ List<ComponentService> targets = componentReference.getTargets();
+ for (int i = 0, n = targets.size(); i < n; i++) {
+ ComponentService target = targets.get(i);
+ if (target.getService() instanceof CompositeService) {
+
+ // Wire to the actual component service
+ // promoted by a composite service
+ CompositeService compositeService = (CompositeService)target.getService();
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ targets.set(i, componentService);
+ }
+ }
+ }
+ }
+*/
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java
new file mode 100644
index 0000000000..5552fda286
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.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.builder.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that handles the creation of promoted composite services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public ComponentReferencePromotionWireBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ wireCompositeReferences(composite, monitor);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentReferencePromotionWireBuilder";
+ }
+
+ /**
+ * Wire composite references in nested composites.
+ *
+ * @param composite
+ * @param problems
+ */
+ private void wireCompositeReferences(Composite composite, Monitor monitor) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ wireCompositeReferences((Composite)implementation, monitor);
+ }
+ }
+
+ // Process component references declared on components in this composite
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ for (ComponentReference componentReference : component.getReferences()) {
+ Reference implReference = componentReference.getReference();
+ if (implReference != null && implReference instanceof CompositeReference) {
+
+ // If the component reference is wired, it is a promotion override
+ if (!componentReference.getEndpointReferences().isEmpty()) {
+ componentReference.setPromotionOverride(true);
+ }
+
+ // If the component reference is a promotion override, override the
+ // configuration of the promoted reference
+ if (componentReference.isPromotionOverride()) {
+ CompositeReference compositeReference = (CompositeReference)implReference;
+ List<ComponentReference> promotedReferences =
+ ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference);
+ for (ComponentReference promotedReference : promotedReferences) {
+ ReferenceConfigurationUtil.reconcileReferenceBindings(
+ componentReference, promotedReference, assemblyFactory, monitor);
+ if (componentReference.getInterfaceContract() != null && // can be null in unit tests
+ componentReference.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
+ if (promotedReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().clear();
+ } else {
+ promotedReference.setCallback(assemblyFactory.createCallback());
+ }
+ if (scaCallbackBinding != null) {
+ promotedReference.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ if (componentReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().addAll(componentReference
+ .getCallback().getBindings());
+ }
+ }
+ /* TODO - let endpoint references worry about target service
+ // Wire the promoted reference to the actual non-composite component services
+ if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE) {
+ // promotedReference.getTargets().clear();
+ }
+ for (ComponentService target : componentReference.getTargets()) {
+ if (target.getService() instanceof CompositeService) {
+
+ // Wire to the actual component service
+ // promoted by a composite service
+ CompositeService compositeService = (CompositeService)target.getService();
+ // Find the promoted component service
+ ComponentService componentService =
+ ServiceConfigurationUtil.getPromotedComponentService(compositeService);
+ if (componentService != null) {
+ promotedReference.getTargets().add(componentService);
+ }
+ } else {
+
+ // Wire to a non-composite target service
+ promotedReference.getTargets().add(target);
+ }
+ }
+*/
+ }
+ }
+ }
+ }
+ } else {
+/* TODO - let endpoint references worry about target servicep
+ for (ComponentReference componentReference : component.getReferences()) {
+
+ // Wire the component reference to the actual
+ // non-composite component services
+ List<ComponentService> targets = componentReference.getTargets();
+ for (int i = 0, n = targets.size(); i < n; i++) {
+ ComponentService target = targets.get(i);
+ if (target.getService() instanceof CompositeService) {
+
+ // Wire to the actual component service
+ // promoted by a composite service
+ CompositeService compositeService = (CompositeService)target.getService();
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ targets.set(i, componentService);
+ }
+ }
+ }
+ }
+*/
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java
new file mode 100644
index 0000000000..fb2b34ac98
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java
@@ -0,0 +1,187 @@
+/*
+ * 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.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Wire;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that wires component references.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implements CompositeBuilder {
+
+ public ComponentReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) {
+ super(assemblyFactory, null, null, null, interfaceContractMapper);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentReferenceWireBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ wireComponentReferences(composite, monitor);
+ }
+
+ /**
+ * Wire component references to component services and connect promoted
+ * services/references to component services/references inside a composite.
+ *
+ * @param composite
+ */
+ protected void wireComponentReferences(Composite composite, Monitor monitor) {
+
+ // Wire nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ wireComponentReferences((Composite)implementation, monitor);
+ }
+ }
+
+ // Index components, services and references
+ Map<String, Component> components = new HashMap<String, Component>();
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences);
+
+ // Connect component references as described in wires
+ connectWires(composite, componentServices, componentReferences, monitor);
+
+
+ // Validate that references are wired or promoted, according
+ // to their multiplicity
+ for (ComponentReference componentReference : componentReferences.values()) {
+ if (!ReferenceConfigurationUtil.validateMultiplicityAndTargets(componentReference.getMultiplicity(), componentReference
+ .getTargets(), componentReference.getBindings())) {
+ if (componentReference.getTargets().isEmpty()) {
+
+ // No warning if the reference is promoted out of the current composite
+ boolean promoted = false;
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ if (compositeReference.getPromotedReferences().contains(componentReference)) {
+ promoted = true;
+ break;
+ }
+ }
+ if (!promoted && !componentReference.isCallback()) {
+ warning(monitor, "ReferenceWithoutTargets", composite, composite.getName().toString(), componentReference.getName());
+ }
+ } else {
+ warning(monitor, "TooManyReferenceTargets", composite, componentReference.getName());
+ }
+ }
+ }
+
+ // Finally clear the original reference target lists as we now have
+ // bindings to represent the targets
+ // for (ComponentReference componentReference : componentReferences.values()) {
+ // componentReference.getTargets().clear();
+ // }
+ }
+
+ /**
+ * Resolve wires and connect the sources to their targets
+ *
+ * @param composite
+ * @param componentServices
+ * @param componentReferences
+ * @param problems
+ */
+ private void connectWires(Composite composite,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences,
+ Monitor monitor) {
+
+ // For each wire, resolve the source reference, the target service, and
+ // add it to the list of targets of the reference
+ List<Wire> wires = composite.getWires();
+ for (int i = 0, n = wires.size(); i < n; i++) {
+ Wire wire = wires.get(i);
+
+ ComponentReference resolvedReference;
+ ComponentService resolvedService;
+
+ // Resolve the source reference
+ ComponentReference source = wire.getSource();
+ if (source != null && source.isUnresolved()) {
+ resolvedReference = componentReferences.get(source.getName());
+ if (resolvedReference != null) {
+ wire.setSource(resolvedReference);
+ } else {
+ warning(monitor, "WireSourceNotFound", composite, source.getName());
+ }
+ } else {
+ resolvedReference = wire.getSource();
+ }
+
+ // Resolve the target service
+ ComponentService target = wire.getTarget();
+ if (target != null && target.isUnresolved()) {
+ resolvedService = componentServices.get(target.getName());
+ if (resolvedService != null) {
+ wire.setTarget(target);
+ } else {
+ warning(monitor, "WireTargetNotFound", composite, source.getName());
+ }
+ } else {
+ resolvedService = wire.getTarget();
+ }
+
+ // Add the target service to the list of targets of the
+ // reference
+ if (resolvedReference != null && resolvedService != null) {
+ // Check that the target component service provides
+ // a superset of
+ // the component reference interface
+ if (resolvedReference.getInterfaceContract() == null || interfaceContractMapper
+ .isCompatible(resolvedReference.getInterfaceContract(), resolvedService.getInterfaceContract())) {
+
+ //resolvedReference.getTargets().add(resolvedService);
+ resolvedReference.getTargets().add(wire.getTarget());
+ } else {
+ warning(monitor, "WireIncompatibleInterface", composite, source.getName(), target.getName());
+ }
+ }
+ }
+
+ // Clear the list of wires
+ composite.getWires().clear();
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java
new file mode 100644
index 0000000000..c725ea8947
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.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.builder.impl;
+
+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.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that performs any additional building steps that
+ * component service bindings may need. Used for WSDL generation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentServiceBindingBuilderImpl implements CompositeBuilder {
+
+ public ComponentServiceBindingBuilderImpl() {
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentServiceBindingBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ buildServiceBindings(composite, monitor);
+ }
+
+ private void buildServiceBindings(Composite composite, Monitor monitor) {
+
+ // build bindings recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ buildServiceBindings((Composite)implementation, monitor);
+ }
+ }
+
+ // find all the component service bindings
+ for (Component component : composite.getComponents()) {
+ for (ComponentService componentService : component.getServices()) {
+ for (Binding binding : componentService.getBindings()) {
+ if (binding instanceof BindingBuilderExtension) {
+ BindingBuilder builder = ((BindingBuilderExtension)binding).getBuilder();
+ if (builder != null) {
+ builder.build(component, componentService, binding, monitor);
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java
new file mode 100644
index 0000000000..aaebfaf29e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.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.builder.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.CompositeService;
+import org.apache.tuscany.sca.assembly.Endpoint2;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that creates endpoint models for component services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentServiceEndpointBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public ComponentServiceEndpointBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentReferenceEndpointReferenceBuilder";
+ }
+
+ /**
+ * Create endpoint models for all component services.
+ *
+ * @param composite
+ */
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+
+ // process top level composite services
+ // TODO - I don't think OASIS spec doesn't allows composite references in the domain composite
+ //
+ // processCompositeServices(composite);
+
+ // process component services
+ processComponentServices(composite);
+
+ }
+
+ private void processCompositeServices(Composite composite) {
+ // top level services are treated slightly differently
+ // as no component will use these top level services
+ // as part of its component type. In this case we push down
+ // the service configuration to create a new endpoint on the
+ // component from which the service is promoted
+ for (Service service : composite.getServices()) {
+
+ Component promotedComponent = ((CompositeService)service).getPromotedComponent();
+ ComponentService promotedService = ((CompositeService)service).getPromotedService();
+
+ if (promotedService != null) {
+ for (Binding binding : service.getBindings()){
+ Endpoint2 endpoint = assemblyFactory.createEndpoint();
+ endpoint.setComponent(promotedComponent);
+ endpoint.setService(promotedService);
+ endpoint.setBinding(binding);
+ endpoint.setUnresolved(false);
+ promotedService.getEndpoints().add(endpoint);
+ }
+ }
+ }
+ }
+
+ private void processComponentServices(Composite composite) {
+
+ for (Component component : composite.getComponents()) {
+
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ processComponentServices((Composite)implementation);
+ }
+
+ // create an endpoint for each component service binding
+ for (ComponentService service : component.getServices()) {
+
+ Component endpointComponent = component;
+ ComponentService endpointService = service;
+
+ // TODO - EPR - We maintain all endpoints at the right level now
+ // but endpoints for promoting services must point down
+ // to the services they promote.
+ if (service.getService() instanceof CompositeService) {
+ CompositeService compositeService = (CompositeService)service.getService();
+ endpointService = ServiceConfigurationUtil.getPromotedComponentService(compositeService);
+ endpointComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService);
+ }
+
+
+ for (Binding binding : service.getBindings()){
+ Endpoint2 endpoint = assemblyFactory.createEndpoint();
+ endpoint.setComponent(endpointComponent);
+ endpoint.setService(endpointService);
+ endpoint.setBinding(binding);
+ endpoint.setUnresolved(false);
+ service.getEndpoints().add(endpoint);
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java
new file mode 100644
index 0000000000..d5a94e0ee9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.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.builder.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.CompositeService;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that handles the creation of promoted services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentServicePromotionBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public ComponentServicePromotionBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentServicePromotionBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+
+ // Process nested composites recursively
+ configureNestedCompositeServices(composite);
+ }
+
+ private void configureNestedCompositeServices(Composite composite) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // First process nested composites
+ configureNestedCompositeServices((Composite)implementation);
+
+ // Process the component services declared on components in this composite
+ for (ComponentService componentService : component.getServices()) {
+ Service implService = componentService.getService();
+ if (implService != null && implService instanceof CompositeService) {
+ CompositeService compositeService = (CompositeService)implService;
+
+ // Get the innermost promoted service
+ ComponentService promotedService =
+ ServiceConfigurationUtil.getPromotedComponentService(compositeService);
+ if (promotedService != null) {
+ Component promotedComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService);
+
+ // Create a new component service to represent this
+ // component service on the promoted component
+ ComponentService newComponentService = assemblyFactory.createComponentService();
+ newComponentService.setName("$promoted$" + component.getName() + "$slash$" + componentService.getName());
+ promotedComponent.getServices().add(newComponentService);
+ newComponentService.setService(promotedService.getService());
+ newComponentService.getBindings().addAll(componentService.getBindings());
+ newComponentService.setInterfaceContract(componentService.getInterfaceContract());
+
+ if (componentService.getInterfaceContract() != null &&
+ componentService.getInterfaceContract().getCallbackInterface() != null) {
+ newComponentService.setCallback(assemblyFactory.createCallback());
+ newComponentService.getCallback().getBindings()
+ .addAll(componentService.getCallback().getBindings());
+ }
+
+ // Change the composite service to now promote the
+ // newly created component service directly
+ compositeService.setPromotedComponent(promotedComponent);
+ compositeService.setPromotedService(newComponentService);
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java
new file mode 100644
index 0000000000..d31a38c70b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java
@@ -0,0 +1,76 @@
+/*
+ * 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.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that performs any additional building steps that
+ * composite service bindings may need. Used for WSDL generation.
+ *
+ * TODO - What is this actually used for? I can't find any references in the
+ * code base
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeBindingConfigurationBuilderImpl extends CompositeBindingURIBuilderImpl implements CompositeBuilder {
+
+ public CompositeBindingConfigurationBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) {
+ super(factories.getFactory(AssemblyFactory.class),
+ factories.getFactory(SCABindingFactory.class),
+ null, null,
+ mapper);
+ }
+
+ public CompositeBindingConfigurationBuilderImpl(AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ InterfaceContractMapper interfaceContractMapper) {
+ super(assemblyFactory,
+ scaBindingFactory,
+ null, null,
+ interfaceContractMapper);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeServiceBindingBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ List<Binding> defaultBindings = null;
+ for (Object x: composite.getExtensions()) {
+ if (x instanceof List) {
+ defaultBindings = (List<Binding>)x;
+ }
+ }
+ configureBindingURIs(composite, definitions, defaultBindings, monitor);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
new file mode 100644
index 0000000000..6b9d5d9c46
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
@@ -0,0 +1,536 @@
+/*
+ * 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.impl;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactory;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+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.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.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that handles the configuration of binding URIs.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements CompositeBuilder {
+
+ @Deprecated
+ public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ InterfaceContractMapper interfaceContractMapper) {
+ super(assemblyFactory, scaBindingFactory,
+ null, null,
+ interfaceContractMapper);
+ }
+
+ public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ TransformerFactory transformerFactory,
+ InterfaceContractMapper interfaceContractMapper) {
+ super(assemblyFactory, scaBindingFactory,
+ documentBuilderFactory, transformerFactory, interfaceContractMapper);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeBindingURIBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ configureBindingURIsAndNames(composite, definitions, monitor);
+ }
+
+ /**
+ * Called by CompositeBindingURIBuilderImpl
+ *
+ * @param composite the composite to be configured
+ */
+ protected void configureBindingURIsAndNames(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ configureBindingURIs(composite, null, definitions, null, monitor);
+ configureBindingNames(composite, monitor);
+ }
+
+ /**
+ * Fully resolve the binding URIs based on available information. This includes information
+ * from the ".composite" files, from resources associated with the binding, e.g. WSDL files,
+ * from any associated policies and from the default information for each binding type.
+ *
+ * @param composite the composite to be configured
+ * @param defaultBindings list of default binding configurations
+ */
+ protected void configureBindingURIs(Composite composite,
+ Definitions definitions, List<Binding> defaultBindings,
+ Monitor monitor) throws CompositeBuilderException {
+ configureBindingURIs(composite, null, definitions, defaultBindings, monitor);
+ }
+
+ /**
+ * Fully resolve the binding URIs based on available information. This includes information
+ * from the ".composite" files, from resources associated with the binding, e.g. WSDL files,
+ * from any associated policies and from the default information for each binding type.
+ *
+ * NOTE: This method repeats some of the processing performed by the configureComponents()
+ * method above. The duplication is needed because NodeConfigurationServiceImpl
+ * calls this method without previously calling configureComponents(). In the
+ * normal builder sequence used by CompositeBuilderImpl, both of these methods
+ * are called.
+ *
+ * TODO: Share the URL calculation algorithm with the configureComponents() method above
+ * although keeping the configureComponents() methods signature as is because when
+ * a composite is actually build in a node the node default information is currently
+ * available
+ *
+ * @param composite the composite to be configured
+ * @param uri the path to the composite provided through any nested composite component implementations
+ * @param defaultBindings list of default binding configurations
+ */
+ private void configureBindingURIs(Composite composite, String uri,
+ Definitions definitions, List<Binding> defaultBindings,
+ Monitor monitor) throws CompositeBuilderException {
+
+ String parentComponentURI = uri;
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+
+ // Initialize component URI
+ String componentURI;
+ if (parentComponentURI == null) {
+ componentURI = component.getName();
+ } else {
+ componentURI = URI.create(parentComponentURI + '/').resolve(component.getName()).toString();
+ }
+ component.setURI(componentURI);
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // Process nested composite
+ configureBindingURIs((Composite)implementation, componentURI, definitions, defaultBindings, monitor);
+ }
+ }
+
+ // Initialize composite service binding URIs
+ List<Service> compositeServices = composite.getServices();
+ for (Service service : compositeServices) {
+ // Set default binding names
+
+ // Create default SCA binding
+ if (service.getBindings().isEmpty()) {
+ SCABinding scaBinding = createSCABinding(definitions);
+ service.getBindings().add(scaBinding);
+ }
+
+ // Initialize binding names and URIs
+ for (Binding binding : service.getBindings()) {
+ constructBindingName(service, binding, monitor);
+ constructBindingURI(parentComponentURI, composite, service, binding, defaultBindings, monitor);
+ }
+ }
+
+ // Initialize component service binding URIs
+ for (Component component : composite.getComponents()) {
+
+ // Index properties, services and references
+ Map<String, Service> services = new HashMap<String, Service>();
+ Map<String, Reference> references = new HashMap<String, Reference>();
+ Map<String, Property> properties = new HashMap<String, Property>();
+ indexImplementationPropertiesServicesAndReferences(component,
+ services,
+ references,
+ properties,
+ monitor);
+
+ // Index component services, references and properties
+ // Also check for duplicates
+ Map<String, ComponentService> componentServices =
+ new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences =
+ new HashMap<String, ComponentReference>();
+ Map<String, ComponentProperty> componentProperties =
+ new HashMap<String, ComponentProperty>();
+ indexComponentPropertiesServicesAndReferences(component,
+ componentServices,
+ componentReferences,
+ componentProperties,
+ monitor);
+
+ // Reconcile component services/references/properties and
+ // implementation services/references and create component
+ // services/references/properties for the services/references
+ // declared by the implementation
+ reconcileServices(component, services, componentServices, monitor);
+ reconcileReferences(component, references, componentReferences, monitor);
+ reconcileProperties(component, properties, componentProperties, monitor);
+
+ for (ComponentService service : component.getServices()) {
+
+ // Create default SCA binding
+ if (service.getBindings().isEmpty()) {
+ SCABinding scaBinding = createSCABinding(definitions);
+ service.getBindings().add(scaBinding);
+ }
+
+ // Initialize binding names and URIs
+ for (Binding binding : service.getBindings()) {
+
+ constructBindingName(service, binding, monitor);
+ constructBindingURI(component, service, binding, defaultBindings, monitor);
+ }
+ }
+ }
+ }
+
+ /**
+ * Add default names for callback bindings and reference bindings. Needs to be
+ * separate from configureBindingURIs() because configureBindingURIs() is called
+ * by NodeConfigurationServiceImpl as well as by CompositeBuilderImpl.
+ */
+ private void configureBindingNames(Composite composite, Monitor monitor) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // Process nested composite
+ configureBindingNames((Composite)implementation, monitor);
+ }
+ }
+
+ // Initialize composite service callback binding names
+ for (Service service : composite.getServices()) {
+
+ if (service.getCallback() != null) {
+ for (Binding binding : service.getCallback().getBindings()) {
+ constructBindingName(service, binding, monitor);
+ }
+ }
+ }
+
+ // Initialize composite reference binding names
+ for (Reference reference : composite.getReferences()) {
+
+ for (Binding binding : reference.getBindings()) {
+ constructBindingName(reference, binding, monitor);
+ }
+
+ if (reference.getCallback() != null) {
+ for (Binding binding : reference.getCallback().getBindings()) {
+ constructBindingName(reference, binding, monitor);
+ }
+ }
+ }
+
+ // Initialize component service and reference binding names
+ for (Component component : composite.getComponents()) {
+
+ // Initialize component service callback binding names
+ for (ComponentService service : component.getServices()) {
+
+ if (service.getCallback() != null) {
+ for (Binding binding : service.getCallback().getBindings()) {
+ constructBindingName(service, binding, monitor);
+ }
+ }
+ }
+
+ // Initialize component reference binding names
+ for (ComponentReference reference : component.getReferences()) {
+
+ // Initialize binding names
+ for (Binding binding : reference.getBindings()) {
+ constructBindingName(reference, binding, monitor);
+ }
+
+ if (reference.getCallback() != null) {
+ for (Binding binding : reference.getCallback().getBindings()) {
+ constructBindingName(reference, binding, monitor);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * If a binding name is not provided by the user, construct it based on the service
+ * or reference name
+ *
+ * @param contract the service or reference
+ * @param binding
+ */
+ private void constructBindingName(Contract contract, Binding binding, Monitor monitor) {
+
+ // set the default binding name if one is required
+ // if there is no name on the binding then set it to the service or reference name
+ if (binding.getName() == null){
+ binding.setName(contract.getName());
+ }
+
+ // Check that multiple bindings do not have the same name
+ for (Binding otherBinding : contract.getBindings()) {
+ if (otherBinding == binding) {
+ // Skip the current binding
+ continue;
+ }
+ if (binding.getClass() != otherBinding.getClass()) {
+ // Look for a binding of the same type
+ continue;
+ }
+ if (binding.getName().equals(otherBinding.getName())) {
+ warning(monitor, contract instanceof Service ? "MultipleBindingsForService" : "MultipleBindingsForReference",
+ binding, contract.getName(), binding.getName());
+ }
+ }
+ }
+
+ /**
+ * URI construction for composite bindings based on Assembly Specification section 1.7.2, This method
+ * assumes that the component URI part of the binding URI is formed from the part to the
+ * composite in question and just calls the generic constructBindingURI method with this
+ * information
+ *
+ * @param parentComponentURI
+ * @param composite
+ * @param service
+ * @param binding
+ * @param defaultBindings
+ */
+ private void constructBindingURI(String parentComponentURI, Composite composite, Service service,
+ Binding binding, List<Binding> defaultBindings, Monitor monitor)
+ throws CompositeBuilderException{
+ // This is a composite service so there is no component to provide a component URI
+ // The path to this composite (through nested composites) is used.
+ boolean includeBindingName = composite.getServices().size() != 1;
+ constructBindingURI(parentComponentURI, service, binding, includeBindingName, defaultBindings, monitor);
+ }
+
+ /**
+ * URI construction for component bindings based on Assembly Specification section 1.7.2. This method
+ * calculates the component URI part based on component information before calling the generic
+ * constructBindingURI method
+ *
+ * @param component the component that holds the service
+ * @param service the service that holds the binding
+ * @param binding the binding for which the URI is being constructed
+ * @param defaultBindings the list of default binding configurations
+ */
+ private void constructBindingURI(Component component, Service service,
+ Binding binding, List<Binding> defaultBindings, Monitor monitor)
+ throws CompositeBuilderException{
+ boolean includeBindingName = component.getServices().size() != 1;
+ constructBindingURI(component.getURI(), service, binding, includeBindingName, defaultBindings, monitor);
+ }
+
+ /**
+ * Generic URI construction for bindings based on Assembly Specification section 1.7.2
+ *
+ * @param componentURIString the string version of the URI part that comes from the component name
+ * @param service the service in question
+ * @param binding the binding for which the URI is being constructed
+ * @param includeBindingName when set true the serviceBindingURI part should be used
+ * @param defaultBindings the list of default binding configurations
+ * @throws CompositeBuilderException
+ */
+ private void constructBindingURI(String componentURIString, Service service, Binding binding,
+ boolean includeBindingName, List<Binding> defaultBindings, Monitor monitor)
+ throws CompositeBuilderException{
+
+ try {
+ // calculate the service binding URI
+ URI bindingURI;
+ if (binding.getURI() != null){
+ bindingURI = new URI(binding.getURI());
+
+ // if the user has provided an absolute binding URI then use it
+ if (bindingURI.isAbsolute()){
+ binding.setURI(bindingURI.toString());
+ return;
+ }
+ } else {
+ bindingURI = null;
+ }
+
+ // Get the service binding name
+ URI bindingName;
+ if (binding.getName() != null) {
+ bindingName = new URI(binding.getName());
+ } else {
+ bindingName = new URI("");
+ }
+
+ // calculate the component URI
+ URI componentURI;
+ if (componentURIString != null) {
+ componentURI = new URI(addSlashToPath(componentURIString));
+ } else {
+ componentURI = null;
+ }
+
+ // if the user has provided an absolute component URI then use it
+ if (componentURI != null && componentURI.isAbsolute()){
+ binding.setURI(constructBindingURI(null, componentURI, bindingURI, includeBindingName, bindingName));
+ return;
+ }
+
+ // calculate the base URI
+ URI baseURI = null;
+ if (defaultBindings != null) {
+ for (Binding defaultBinding : defaultBindings){
+ if (binding.getClass() == defaultBinding.getClass()){
+ baseURI = new URI(addSlashToPath(defaultBinding.getURI()));
+ break;
+ }
+ }
+ }
+
+ binding.setURI(constructBindingURI(baseURI, componentURI, bindingURI, includeBindingName, bindingName));
+ } catch (URISyntaxException ex) {
+ error(monitor, "URLSyntaxException", binding, componentURIString, service.getName(), binding.getName());
+ }
+ }
+
+ /**
+ * Use to ensure that URI paths end in "/" as here we want to maintain the
+ * last path element of an base URI when other URI are resolved against it. This is
+ * not the default behaviour of URI resolution as defined in RFC 2369
+ *
+ * @param path the path string to which the "/" is to be added
+ * @return the resulting path with a "/" added if it not already there
+ */
+ private static String addSlashToPath(String path){
+ if (path.endsWith("/") || path.endsWith("#")){
+ return path;
+ } else {
+ return path + "/";
+ }
+ }
+
+ /**
+ * Concatenate binding URI parts together based on Assembly Specification section 1.7.2
+ *
+ * @param baseURI the base of the binding URI
+ * @param componentURI the middle part of the binding URI derived from the component name
+ * @param bindingURI the end part of the binding URI
+ * @param includeBindingName when set true the binding name part should be used
+ * @param bindingName the binding name
+ * @return the resulting URI as a string
+ */
+ private static String constructBindingURI(URI baseURI, URI componentURI, URI bindingURI, boolean includeBindingName, URI bindingName){
+ String uriString;
+
+ if (baseURI == null) {
+ if (componentURI == null){
+ if (bindingURI != null ) {
+ uriString = bindingURI.toString();
+ } else {
+ uriString = bindingName.toString();
+ }
+ } else {
+ if (bindingURI != null ) {
+ uriString = componentURI.resolve(bindingURI).toString();
+ } else {
+ if (includeBindingName) {
+ uriString = componentURI.resolve(bindingName).toString();
+ } else {
+ uriString = componentURI.toString();
+ }
+ }
+ }
+ } else {
+ if (componentURI == null) {
+ if (bindingURI != null ) {
+ uriString = basedURI(baseURI, bindingURI).toString();
+ } else {
+ if (includeBindingName) {
+ uriString = basedURI(baseURI, bindingName).toString();
+ } else {
+ uriString = baseURI.toString();
+ }
+ }
+ } else {
+ if (bindingURI != null ) {
+ uriString = basedURI(baseURI, componentURI.resolve(bindingURI)).toString();
+ } else {
+ if (includeBindingName) {
+ uriString = basedURI(baseURI, componentURI.resolve(bindingName)).toString();
+ } else {
+ uriString = basedURI(baseURI, componentURI).toString();
+ }
+ }
+ }
+ }
+
+ // tidy up by removing any trailing "/"
+ if (uriString.endsWith("/")){
+ uriString = uriString.substring(0, uriString.length()-1);
+ }
+
+ URI uri = URI.create(uriString);
+ if (!uri.isAbsolute()) {
+ uri = URI.create("/").resolve(uri);
+ }
+ return uri.toString();
+ }
+
+ /**
+ * Combine a URI with a base URI.
+ *
+ * @param baseURI
+ * @param uri
+ * @return
+ */
+ private static URI basedURI(URI baseURI, URI uri) {
+ if (uri.getScheme() != null) {
+ return uri;
+ }
+ String str = uri.toString();
+ if (str.startsWith("/")) {
+ str = str.substring(1);
+ }
+ return URI.create(baseURI.toString() + str).normalize();
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
new file mode 100644
index 0000000000..bd904ede10
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
@@ -0,0 +1,212 @@
+/*
+ * 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.impl;
+
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactory;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * 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 class CompositeBuilderImpl implements CompositeBuilder {
+ private static final Logger logger = Logger.getLogger(CompositeBuilderImpl.class.getName());
+ private CompositeBuilder compositeIncludeBuilder;
+ private CompositeBuilder componentReferenceWireBuilder;
+ //private CompositeBuilder componentReferencePromotionWireBuilder;
+ private CompositeBuilder componentReferencePromotionBuilder;
+ //private CompositeBuilder compositeReferenceWireBuilder;
+ private CompositeBuilder compositeCloneBuilder;
+ private CompositeBuilder componentConfigurationBuilder;
+ private CompositeBuilder compositeServiceConfigurationBuilder;
+ private CompositeBuilder compositeReferenceConfigurationBuilder;
+ private CompositeBuilder compositeBindingURIBuilder;
+ //private CompositeBuilder componentServicePromotionBuilder;
+ //private CompositeBuilder compositeServicePromotionBuilder;
+ private CompositeBuilder compositePromotionBuilder;
+ private CompositeBuilder compositePolicyBuilder;
+ private CompositeBuilder componentServiceBindingBuilder;
+ private CompositeBuilder componentReferenceBindingBuilder;
+
+ private CompositeBuilder componentReferenceEndpointReferenceBuilder;
+ private CompositeBuilder componentServiceEndpointBuilder;
+ //private CompositeBuilder endpointReferenceBuilder;
+
+ public CompositeBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) {
+ this(factories.getFactory(AssemblyFactory.class),
+ factories.getFactory(SCABindingFactory.class),
+ factories.getFactory(PolicyFactory.class),
+ factories.getFactory(DocumentBuilderFactory.class),
+ factories.getFactory(TransformerFactory.class),
+ mapper);
+ }
+
+
+ /**
+ * Constructs a new composite builder.
+ *
+ * @param assemblyFactory
+ * @param scaBindingFactory
+ * @param endpointFactory
+ * @param intentAttachPointTypeFactory
+ * @param interfaceContractMapper
+ * @param policyDefinitions
+ * @param monitor
+ */
+ @Deprecated
+ public CompositeBuilderImpl(AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ PolicyFactory intentAttachPointTypeFactory,
+ InterfaceContractMapper interfaceContractMapper) {
+ this(assemblyFactory, scaBindingFactory, intentAttachPointTypeFactory,
+ null, null, interfaceContractMapper);
+ }
+
+ /**
+ * Constructs a new composite builder.
+ *
+ * @param assemblyFactory
+ * @param scaBindingFactory
+ * @param endpointFactory
+ * @param intentAttachPointTypeFactory
+ * @param interfaceContractMapper
+ * @param policyDefinitions
+ * @param monitor
+ */
+ public CompositeBuilderImpl(AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ PolicyFactory intentAttachPointTypeFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ TransformerFactory transformerFactory,
+ InterfaceContractMapper interfaceContractMapper) {
+
+
+ compositeIncludeBuilder = new CompositeIncludeBuilderImpl();
+ componentReferenceWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, interfaceContractMapper);
+ //componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory);
+ componentReferencePromotionBuilder = new ComponentReferencePromotionBuilderImpl(assemblyFactory);
+ //compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory);
+ compositeCloneBuilder = new CompositeCloneBuilderImpl();
+ componentConfigurationBuilder = new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper);
+ compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory);
+ compositeReferenceConfigurationBuilder = new CompositeReferenceConfigurationBuilderImpl(assemblyFactory);
+ compositeBindingURIBuilder = new CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper);
+ //componentServicePromotionBuilder = new ComponentServicePromotionBuilderImpl(assemblyFactory);
+ //compositeServicePromotionBuilder = new CompositeServicePromotionBuilderImpl(assemblyFactory);
+ compositePromotionBuilder = new CompositePromotionBuilderImpl(assemblyFactory, interfaceContractMapper);
+ compositePolicyBuilder = new CompositePolicyBuilderImpl(assemblyFactory, interfaceContractMapper);
+ componentServiceBindingBuilder = new ComponentServiceBindingBuilderImpl();
+ componentReferenceBindingBuilder = new ComponentReferenceBindingBuilderImpl();
+
+ componentReferenceEndpointReferenceBuilder = new ComponentReferenceEndpointReferenceBuilderImpl(assemblyFactory, interfaceContractMapper);
+ componentServiceEndpointBuilder = new ComponentServiceEndpointBuilderImpl(assemblyFactory);
+ //endpointReferenceBuilder = new EndpointReference2BuilderImpl(assemblyFactory, interfaceContractMapper);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+
+ // Collect and fuse includes
+ compositeIncludeBuilder.build(composite, definitions, monitor);
+
+ // Expand nested composites
+ compositeCloneBuilder.build(composite, definitions, monitor);
+
+ // Configure all components
+ componentConfigurationBuilder.build(composite, definitions, monitor);
+
+ // Connect composite services/references to promoted services/references
+ compositePromotionBuilder.build(composite, definitions, monitor);
+
+ // Compute the policies across the model hierarchy
+ compositePolicyBuilder.build(composite, definitions, monitor);
+
+ // Configure composite services by copying bindings up the promotion
+ // hierarchy overwriting automatic bindings with those added manually
+ compositeServiceConfigurationBuilder.build(composite, definitions, monitor);
+
+ // Configure composite references by copying bindings down promotion
+ // hierarchy overwriting automatic bindings with those added manually
+ compositeReferenceConfigurationBuilder.build(composite, definitions, monitor);
+
+ // Configure service binding URIs and names. Creates an SCA defined URI based
+ // on the scheme base URI, the component name and the binding name
+ compositeBindingURIBuilder.build(composite, definitions, monitor);
+
+ // Create $promoted$ component services on bottom level components
+ // to represent promoted services
+ // TODO - EPR replaced by endpoints on the promoted services
+ //componentServicePromotionBuilder.build(composite, definitions, monitor);
+
+ // Create $promoted$ component services on bottom level components
+ // to represent promoted composite services
+ // TODO - EPR OASIS doesn't deploy top level composite services
+ // if it did it would be replaced by endpoints
+ //compositeServicePromotionBuilder.build(composite, definitions, monitor);
+
+ // Perform and service binding related build activities. The binding
+ // will provide the builder.
+ componentServiceBindingBuilder.build(composite, definitions, monitor);
+
+ // create endpoints on component services.
+ componentServiceEndpointBuilder.build(composite, definitions, monitor);
+
+ // Apply any wires in the composite to create new component reference targets
+ componentReferenceWireBuilder.build(composite, definitions, monitor);
+
+ // create reference endpoint reference models
+ componentReferenceEndpointReferenceBuilder.build(composite, definitions, monitor);
+
+ // Push down configuration from promoted references to the
+ // references they promote
+ componentReferencePromotionBuilder.build(composite, definitions, monitor);
+
+ // Push down configuration from promoted references to the
+ // references they promote
+ // TODO - EPR Seems to be a repeat of compositeReferenceConfigurationBuilder
+ // componentReferencePromotionWireBuilder.build(composite, definitions, monitor);
+
+ // Wire the composite references
+ // TODO - EPR OASIS doesn't deploy top level composite references
+ // compositeReferenceWireBuilder.build(composite, definitions, monitor);
+
+ // Perform and reference binding related build activities. The binding
+ // will provide the builder.
+ componentReferenceBindingBuilder.build(composite, definitions, monitor);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java
new file mode 100644
index 0000000000..21e5192ae8
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java
@@ -0,0 +1,123 @@
+/*
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that clones nested composites.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeCloneBuilderImpl implements CompositeBuilder {
+
+ public CompositeCloneBuilderImpl() {
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ expandCompositeImplementations(composite);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeCloneBuilder";
+ }
+
+ /**
+ * Expand composite component implementations.
+ *
+ * @param composite
+ * @param problems
+ */
+ private void expandCompositeImplementations(Composite composite) {
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ Composite compositeImplementation = (Composite)implementation;
+ Composite clone;
+ try {
+ clone = (Composite)compositeImplementation.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeException(e);
+ }
+ component.setImplementation(clone);
+ expandCompositeImplementations(clone);
+ }
+ }
+ }
+
+ /**
+ * Collect all nested composite implementations in a graph of composites.
+ *
+ * @param composite
+ * @param nested
+ */
+ private void collectNestedComposites(Composite composite, List<Composite> nested) {
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ Composite nestedComposite = (Composite)implementation;
+ nested.add(nestedComposite);
+ collectNestedComposites(nestedComposite, nested);
+ }
+ }
+ }
+
+ /**
+ * Fuse nested composites into a top level composite.
+ *
+ * @param composite
+ */
+ private void fuseCompositeImplementations(Composite composite) {
+
+ // First collect all nested composites
+ List<Composite> nested = new ArrayList<Composite>();
+ collectNestedComposites(composite, nested);
+
+ // Then add all the non-composite components they contain
+ for (Composite nestedComposite : nested) {
+ for (Component component: nestedComposite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (!(implementation instanceof Composite)) {
+ composite.getComponents().add(component);
+ }
+ }
+ }
+
+ // Clear the initial list of composite components
+ for (Iterator<Component> i = composite.getComponents().iterator(); i.hasNext();) {
+ Component component = i.next();
+ if (component.getImplementation() instanceof Composite) {
+ i.remove();
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java
new file mode 100644
index 0000000000..730c002468
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.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.builder.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Implementation of a CompositeBuilder.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeIncludeBuilderImpl implements CompositeBuilder {
+
+ public CompositeIncludeBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) {
+ }
+
+ public CompositeIncludeBuilderImpl() {
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeIncludeBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ fuseIncludes(composite, monitor);
+ }
+
+ private void warning(Monitor monitor, String message, Object model, String... messageParameters) {
+ if (monitor != null){
+ Problem problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Collect all includes in a graph of includes.
+ *
+ * @param composite
+ * @param includes
+ */
+ private void collectIncludes(Composite composite, List<Composite> includes,
+ Set<Composite> visited, Monitor monitor) {
+ for (Composite include : composite.getIncludes()) {
+ if (visited.contains(include)) {
+ warning(monitor, "CompositeAlreadyIncluded", composite, include.getName().toString());
+ continue;
+ }
+
+ includes.add(include);
+ visited.add(include);
+ collectIncludes(include, includes, visited, monitor);
+ }
+ }
+
+ /**
+ * Copy a list of includes into a composite.
+ *
+ * @param composite
+ */
+ private void fuseIncludes(Composite composite, Monitor monitor) {
+
+ // First collect all includes
+ List<Composite> includes = new ArrayList<Composite>();
+ Set<Composite> visited = new HashSet<Composite>();
+ visited.add(composite);
+ collectIncludes(composite, includes, visited, monitor);
+
+ // Then clone them
+ for (Composite include : includes) {
+ Composite clone;
+ try {
+ clone = (Composite)include.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeException(e);
+ }
+ composite.getComponents().addAll(clone.getComponents());
+ composite.getServices().addAll(clone.getServices());
+ composite.getReferences().addAll(clone.getReferences());
+ composite.getProperties().addAll(clone.getProperties());
+ composite.getWires().addAll(clone.getWires());
+ composite.getPolicySets().addAll(clone.getPolicySets());
+ composite.getRequiredIntents().addAll(clone.getRequiredIntents());
+ }
+
+ // Clear the list of includes
+ composite.getIncludes().clear();
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java
new file mode 100644
index 0000000000..1fc00705e7
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java
@@ -0,0 +1,309 @@
+/*
+ * 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.impl;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Endpoint2;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * A composite builder that computes policy sets based on attached intents and policy sets.
+ * Useful if you want to build the model without making any runtime decisions such as
+ * reference/services matching
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements CompositeBuilder {
+
+ public CompositePolicyBuilderImpl(AssemblyFactory assemblyFactory,
+ InterfaceContractMapper interfaceContractMapper) {
+ super(assemblyFactory, null, null, null, interfaceContractMapper);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositePolicyBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ computePolicies(composite, monitor);
+ }
+
+ /**
+ * Inherit the intents and policySets from the list of models
+ * @param intents
+ * @param policySets
+ * @param models
+ */
+ private void inherit(PolicySubject policySubject, Object... models) {
+ for (Object model : models) {
+ if (model instanceof PolicySubject) {
+ PolicySubject subject = (PolicySubject)model;
+ policySubject.getRequiredIntents().addAll(subject.getRequiredIntents());
+ policySubject.getPolicySets().addAll(subject.getPolicySets());
+ }
+ }
+ }
+
+ /**
+ * Check if two policy subjects requires multually exclusive intents
+ * @param subject1
+ * @param subject2
+ * @return
+ */
+ private boolean isMutualExclusive(PolicySubject subject1, PolicySubject subject2) {
+ if (subject1 == subject2 || subject1 == null || subject2 == null) {
+ return false;
+ }
+ for (Intent i1 : subject1.getRequiredIntents()) {
+ for (Intent i2 : subject1.getRequiredIntents()) {
+ if (i1.getExcludedIntents().contains(i2) || i2.getExcludedIntents().contains(i1)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private void inheritFromService(PolicySubject subject, Service service) {
+ if (service instanceof ComponentService) {
+ inheritFromService(subject, ((ComponentService)service).getService());
+ } else if (service instanceof CompositeService) {
+ CompositeService compositeService = (CompositeService)service;
+ inherit(subject, compositeService.getPromotedComponent());
+ inheritFromService(subject, compositeService.getPromotedService());
+ }
+ inherit(subject, service);
+ }
+
+ private void inheritFromReference(PolicySubject subject, Reference reference) {
+ if (reference instanceof ComponentReference) {
+ inheritFromReference(subject, ((ComponentReference)reference).getReference());
+ } else if (reference instanceof CompositeReference) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ for (ComponentReference componentReference : compositeReference.getPromotedReferences()) {
+ inheritFromReference(subject, componentReference);
+ }
+ }
+ inherit(subject, reference);
+ }
+
+ /**
+ * Check if two names are equal
+ * @param name1
+ * @param name2
+ * @return
+ */
+ private boolean isEqual(String name1, String name2) {
+ if (name1 == name2) {
+ return true;
+ }
+ if (name1 != null) {
+ return name1.equals(name2);
+ } else {
+ return name2.equals(name1);
+ }
+ }
+
+ private void validate(PolicySubject subject) {
+ Set<Intent> intents = new HashSet<Intent>(subject.getRequiredIntents());
+
+ // Replace profile intents with their required intents
+ boolean profileIntentsFound = false;
+ while (true) {
+ Set<Intent> copy = new HashSet<Intent>(intents);
+ for (Intent i : copy) {
+ if (!i.getRequiredIntents().isEmpty()) {
+ intents.remove(i);
+ intents.addAll(i.getRequiredIntents());
+ profileIntentsFound = true;
+ }
+ }
+ if (!profileIntentsFound) {
+ // No more profileIntents
+ break;
+ }
+ }
+
+ // Remove the intents whose @contraints do not include the current element
+ // Replace unqualified intents if there is a qualified intent in the list
+ Set<Intent> copy = new HashSet<Intent>(intents);
+ for (Intent i : copy) {
+ if (i.getQualifiableIntent() != null) {
+ intents.remove(i.getQualifiableIntent());
+ }
+ }
+
+ // Replace qualifiable intents with the default qualified intent
+ copy = new HashSet<Intent>(intents);
+ for (Intent i : copy) {
+ if (i.getDefaultQualifiedIntent() != null) {
+ intents.remove(i);
+ intents.add(i.getDefaultQualifiedIntent());
+ }
+ }
+
+ }
+
+ protected void computePolicies(Composite composite, Monitor monitor) {
+
+ // compute policies recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ computePolicies((Composite)implementation, monitor);
+ }
+ }
+
+ for (Component component : composite.getComponents()) {
+ isMutualExclusive(component, component.getImplementation());
+
+ for (ComponentService componentService : component.getServices()) {
+ isMutualExclusive(componentService, componentService.getService());
+
+ if (componentService.getInterfaceContract() != null) {
+ isMutualExclusive(componentService.getInterfaceContract().getInterface(), componentService
+ .getService().getInterfaceContract().getInterface());
+ isMutualExclusive(componentService.getInterfaceContract().getCallbackInterface(), componentService
+ .getService().getInterfaceContract().getCallbackInterface());
+ }
+
+ for (Endpoint2 ep : componentService.getEndpoints()) {
+ // Inherit from the componentType.service.interface
+ inherit(ep, componentService.getService().getInterfaceContract().getInterface());
+ // Inherit from the component.service.interface
+ inherit(ep, componentService.getInterfaceContract().getInterface());
+ // Inherit from the componentType/service
+ inherit(ep, component.getImplementation(), componentService.getService());
+ // Find the corresponding binding in the componentType and inherit the intents/policySets
+ for (Binding binding : componentService.getService().getBindings()) {
+ if (isEqual(ep.getBinding().getName(), binding.getName()) && (binding instanceof PolicySubject)) {
+ isMutualExclusive((PolicySubject)ep.getBinding(), (PolicySubject)binding);
+ // Inherit from componentType.service.binding
+ inherit(ep, binding);
+ break;
+ }
+ }
+ // Inherit from composite/component/service/binding
+ inherit(ep, composite, ep.getComponent(), ep.getService(), ep.getBinding());
+
+ // Replace profile intents with their required intents
+ // Remove the intents whose @contraints do not include the current element
+ // Replace unqualified intents if there is a qualified intent in the list
+ // Replace qualifiable intents with the default qualied intent
+ }
+ }
+
+ for (ComponentReference componentReference : component.getReferences()) {
+ isMutualExclusive(componentReference, componentReference.getReference());
+
+ if (componentReference.getInterfaceContract() != null) {
+ isMutualExclusive(componentReference.getInterfaceContract().getInterface(), componentReference
+ .getReference().getInterfaceContract().getInterface());
+ isMutualExclusive(componentReference.getInterfaceContract().getCallbackInterface(),
+ componentReference.getReference().getInterfaceContract().getCallbackInterface());
+ }
+
+ for (EndpointReference2 epr : componentReference.getEndpointReferences()) {
+ // Inherit from the componentType.reference.interface
+ inherit(epr, componentReference.getReference().getInterfaceContract().getInterface());
+ // Inherit from the component.reference.interface
+ inherit(epr, componentReference.getInterfaceContract().getInterface());
+ // Inherit from the componentType/reference
+ inherit(epr, component.getImplementation(), componentReference.getReference());
+ // Find the corresponding binding in the componentType and inherit the intents/policySets
+ for (Binding binding : componentReference.getReference().getBindings()) {
+ if (isEqual(epr.getBinding().getName(), binding.getName()) && (binding instanceof PolicySubject)) {
+ isMutualExclusive((PolicySubject)epr.getBinding(), (PolicySubject)binding);
+ // Inherit from componentType.reference.binding
+ inherit(epr, binding);
+ break;
+ }
+ }
+ // Inherit from composite/component/reference/binding
+ inherit(epr, composite, epr.getComponent(), epr.getReference(), epr.getBinding());
+
+ // Replace profile intents with their required intents
+ // Remove the intents whose @contraints do not include the current element
+ // Replace unqualified intents if there is a qualified intent in the list
+ // Replace qualifiable intents with the default qualied intent
+ }
+ }
+
+ Implementation implemenation = component.getImplementation();
+ try {
+ PolicyConfigurationUtil.computeImplementationIntentsAndPolicySets(implemenation, component);
+ } catch (Exception e) {
+ error(monitor, "PolicyRelatedException", implemenation, e);
+ //throw new RuntimeException(e);
+ }
+ }
+
+ //compute policies for composite service bindings
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+
+ // Composite service inherits the policySets and intents from the promoted component service
+ Component promotedComponent = compositeService.getPromotedComponent();
+ // Promoted component service inherits from the component type service
+ // as well as the structural hierarchy, i.e., composite/promotedComponent
+ ComponentService promotedService = compositeService.getPromotedService();
+ // We need to calculate the inherited intents/policySets for the promoted
+ // service first
+ isMutualExclusive(compositeService, promotedService);
+ }
+
+ //compute policies for composite reference bindings
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+
+ // Composite reference inherits the policySets and intents from the promoted component references
+ for (ComponentReference promotedReference : compositeReference.getPromotedReferences()) {
+
+ // Promoted component reference inherits from the component type reference
+ // as well as the structural hierarchy, i.e., composite/promotedComponent
+ // We need to calculate the inherited intents/policySets for the promoted
+ // reference first
+ isMutualExclusive(compositeReference, promotedReference);
+
+ }
+ }
+
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java
new file mode 100644
index 0000000000..30c4e78367
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java
@@ -0,0 +1,232 @@
+/*
+ * 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.impl;
+
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that makes the connections between composite services and references
+ * and the services and references that they promote
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements CompositeBuilder {
+
+ public CompositePromotionBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) {
+ super(assemblyFactory, null, null, null, interfaceContractMapper);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositePromotionBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ connectCompositeReferencesAndServices(composite, monitor);
+ }
+
+ /**
+ * Connect composite references and services to the reference and services that they promote.
+ *
+ * @param composite
+ * @param componentServices
+ * @param problems
+ */
+ protected void connectCompositeReferencesAndServices(Composite composite, Monitor monitor){
+ // Wire nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ connectCompositeReferencesAndServices((Composite)implementation, monitor);
+ }
+ }
+
+ // Index components, services and references
+ Map<String, Component> components = new HashMap<String, Component>();
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences);
+
+ // Connect composite services and references to the component
+ // services and references that they promote
+ connectCompositeServices(composite, components, componentServices, monitor);
+ connectCompositeReferences(composite, components, componentReferences, monitor);
+ }
+
+ /**
+ * Connect composite services to the component services that they promote.
+ *
+ * @param composite
+ * @param componentServices
+ * @param problems
+ */
+ private void connectCompositeServices(Composite composite,
+ Map<String, Component> components,
+ Map<String, ComponentService> componentServices,
+ Monitor monitor) {
+
+ // Propagate interfaces from inner composite components' services to
+ // their component services
+ for (Component component : composite.getComponents()) {
+ if (component.getImplementation() instanceof Composite) {
+ for (ComponentService componentService : component.getServices()) {
+ Service service = componentService.getService();
+ if (service != null) {
+ if (componentService.getInterfaceContract() == null) {
+ componentService.setInterfaceContract(service.getInterfaceContract());
+ }
+ }
+ }
+ }
+ }
+
+ // Connect composite services to the component services that they
+ // promote
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null && componentService.isUnresolved()) {
+
+ String promotedComponentName = compositeService.getPromotedComponent().getName();
+ String promotedServiceName;
+ if (componentService.getName() != null) {
+ promotedServiceName = promotedComponentName + '/' + componentService.getName();
+ } else {
+ promotedServiceName = promotedComponentName;
+ }
+ ComponentService promotedService = componentServices.get(promotedServiceName);
+ if (promotedService != null) {
+
+ // Point to the resolved component
+ Component promotedComponent = components.get(promotedComponentName);
+ compositeService.setPromotedComponent(promotedComponent);
+
+ // Point to the resolved component service
+ compositeService.setPromotedService(promotedService);
+
+ // Use the interface contract from the component service if
+ // none is specified on the composite service
+ InterfaceContract compositeServiceInterfaceContract = compositeService.getInterfaceContract();
+ InterfaceContract promotedServiceInterfaceContract = promotedService.getInterfaceContract();
+ if (compositeServiceInterfaceContract == null) {
+ compositeService.setInterfaceContract(promotedServiceInterfaceContract);
+ } else if (promotedServiceInterfaceContract != null) {
+ // Check the compositeServiceInterfaceContract and promotedServiceInterfaceContract
+ boolean isCompatible = interfaceContractMapper.isCompatible(compositeServiceInterfaceContract, promotedServiceInterfaceContract);
+ if(!isCompatible){
+ warning(monitor, "ServiceInterfaceNotSubSet", compositeService, promotedServiceName);
+ }
+ }
+
+ } else {
+ warning(monitor, "PromotedServiceNotFound", composite, composite.getName().toString(), promotedServiceName);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Resolves promoted references.
+ *
+ * @param composite
+ * @param componentReferences
+ * @param problems
+ */
+ private void connectCompositeReferences(Composite composite,
+ Map<String, Component> components,
+ Map<String, ComponentReference> componentReferences, Monitor monitor) {
+
+ // Propagate interfaces from inner composite components' references to
+ // their component references
+ for (Component component : composite.getComponents()) {
+ if (component.getImplementation() instanceof Composite) {
+ for (ComponentReference componentReference : component.getReferences()) {
+ Reference reference = componentReference.getReference();
+ if (reference != null) {
+ if (componentReference.getInterfaceContract() == null) {
+ componentReference.setInterfaceContract(reference.getInterfaceContract());
+ }
+ }
+ }
+ }
+ }
+
+ // Connect composite references to the component references
+ // that they promote
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ List<ComponentReference> promotedReferences = compositeReference.getPromotedReferences();
+ for (int i = 0, n = promotedReferences.size(); i < n; i++) {
+ ComponentReference componentReference = promotedReferences.get(i);
+ if (componentReference.isUnresolved()) {
+ String componentReferenceName = componentReference.getName();
+ componentReference = componentReferences.get(componentReferenceName);
+ if (componentReference != null) {
+ // Set the promoted component
+ Component promotedComponent = compositeReference.getPromotedComponents().get(i);
+ promotedComponent = components.get(promotedComponent.getName());
+ compositeReference.getPromotedComponents().set(i, promotedComponent);
+
+ // Point to the resolved component reference
+ promotedReferences.set(i, componentReference);
+
+ // Use the interface contract from the component
+ // reference if none
+ // is specified on the composite reference
+
+ InterfaceContract compositeReferenceInterfaceContract = compositeReference.getInterfaceContract();
+ InterfaceContract componentReferenceInterfaceContract = componentReference.getInterfaceContract();
+ if (compositeReferenceInterfaceContract == null) {
+ compositeReference.setInterfaceContract(componentReferenceInterfaceContract);
+ } else if (componentReferenceInterfaceContract != null) {
+ // Check the compositeInterfaceContract and componentInterfaceContract
+ boolean isCompatible = interfaceContractMapper.isCompatible(compositeReferenceInterfaceContract, componentReferenceInterfaceContract);
+ if (!isCompatible) {
+ warning(monitor, "ReferenceInterfaceNotSubSet", compositeReference, componentReferenceName);
+ }
+ }
+ } else {
+ warning(monitor, "PromotedReferenceNotFound", composite, composite.getName().toString(), componentReferenceName);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java
new file mode 100644
index 0000000000..07422ef9f2
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java
@@ -0,0 +1,232 @@
+/*
+ * 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.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.builder.AutomaticBinding;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that handles the configuration of composite references.
+ *
+ * @version $Rev: 651179 $ $Date: 2008-04-24 08:21:13 +0100 (Thu, 24 Apr 2008) $
+ */
+public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public CompositeReferenceConfigurationBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeReferenceConfigurationBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+
+ // Process nested composites recursively
+ configureNestedCompositeReferences(composite);
+
+ // Process top level composite references
+ // TODO - In OASIS the treament of top level composite references is different so need to review
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+
+ // Get the next lower level promoted reference
+ List<ComponentReference> promotedRefs = compositeReference.getPromotedReferences();
+ if (!promotedRefs.isEmpty()) {
+ if (promotedRefs.size() == 1) {
+ ComponentReference promotedReference = promotedRefs.get(0);
+
+ // Set the bindings using the top level bindings to override the lower level bindings
+ if (bindingsSpecifiedManually(compositeReference.getBindings())) {
+ compositeReference.setPromotionOverride(true);
+ } else if (bindingsSpecifiedManually(promotedReference.getBindings()) ) {
+ compositeReference.getBindings().clear();
+ for (Binding binding : promotedReference.getBindings()) {
+ try {
+ compositeReference.getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted reference
+ }
+ }
+ }
+ if (compositeReference.getInterfaceContract() != null &&
+ compositeReference.getInterfaceContract().getCallbackInterface() != null) {
+ if (compositeReference.getCallback() != null &&
+ bindingsSpecifiedManually(compositeReference.getCallback().getBindings())) {
+ compositeReference.setPromotionOverride(true);
+ } else if (promotedReference.getCallback() != null &&
+ bindingsSpecifiedManually(promotedReference.getCallback().getBindings())) {
+ if (compositeReference.getCallback() != null) {
+ compositeReference.getCallback().getBindings().clear();
+ } else {
+ compositeReference.setCallback(assemblyFactory.createCallback());
+ }
+ for (Binding binding : promotedReference.getCallback().getBindings()) {
+ try {
+ compositeReference.getCallback().getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted reference
+ }
+ }
+ }
+ }
+ } else {
+ // This composite reference promotes multiple component references.
+ // Because the component reference bindings can all be different, we don't
+ // copy any of them up to this composite reference, which will therefore always
+ // have its own binding, even if it's only the default SCA binding.
+ if (bindingsSpecifiedManually(compositeReference.getBindings()) ||
+ (compositeReference.getCallback() != null &&
+ bindingsSpecifiedManually(compositeReference.getCallback().getBindings()))) {
+ compositeReference.setPromotionOverride(true);
+ }
+ }
+ }
+ }
+ }
+
+ private void configureNestedCompositeReferences(Composite composite) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // First process nested composites
+ configureNestedCompositeReferences((Composite)implementation);
+
+ // Process the component references declared on components in this composite
+ for (ComponentReference componentReference : component.getReferences()) {
+ Reference implReference = componentReference.getReference();
+ if (implReference != null && implReference instanceof CompositeReference) {
+ CompositeReference compositeReference = (CompositeReference)implReference;
+
+ // Get the next lower level promoted reference
+ List<ComponentReference> promotedRefs = compositeReference.getPromotedReferences();
+ if (!promotedRefs.isEmpty()) {
+ if (promotedRefs.size() == 1) {
+ ComponentReference promotedReference = promotedRefs.get(0);
+
+ // Set the bindings using the top level bindings to override the lower level bindings
+ if (!bindingsSpecifiedManually(compositeReference.getBindings()) &&
+ bindingsSpecifiedManually(promotedReference.getBindings()) ) {
+ compositeReference.getBindings().clear();
+ for (Binding binding : promotedReference.getBindings()) {
+ try {
+ compositeReference.getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted reference
+ }
+ }
+ }
+ if (bindingsSpecifiedManually(componentReference.getBindings())) {
+ componentReference.setPromotionOverride(true);
+ } else if (bindingsSpecifiedManually(compositeReference.getBindings()) ) {
+ componentReference.getBindings().clear();
+ componentReference.getBindings().addAll(compositeReference.getBindings());
+ }
+ if (componentReference.getInterfaceContract() != null &&
+ componentReference.getInterfaceContract().getCallbackInterface() != null) {
+ if (!(compositeReference.getCallback() != null &&
+ bindingsSpecifiedManually(compositeReference.getCallback().getBindings())) &&
+ promotedReference.getCallback() != null &&
+ bindingsSpecifiedManually(promotedReference.getCallback().getBindings())) {
+ if (compositeReference.getCallback() != null) {
+ compositeReference.getCallback().getBindings().clear();
+ } else {
+ compositeReference.setCallback(assemblyFactory.createCallback());
+ }
+ compositeReference.getCallback().getBindings().addAll(
+ promotedReference.getCallback().getBindings());
+ }
+ if (componentReference.getCallback() != null &&
+ bindingsSpecifiedManually(componentReference.getCallback().getBindings())) {
+ componentReference.setPromotionOverride(true);
+ } else if (compositeReference.getCallback() != null &&
+ bindingsSpecifiedManually(compositeReference.getCallback().getBindings())) {
+ if (componentReference.getCallback() != null) {
+ componentReference.getCallback().getBindings().clear();
+ } else {
+ componentReference.setCallback(assemblyFactory.createCallback());
+ }
+ for (Binding binding : compositeReference.getCallback().getBindings()) {
+ try {
+ componentReference.getCallback().getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted reference
+ }
+ }
+ }
+ }
+ } else {
+ // This component reference promotes multiple lower-level component references.
+ // Because the lower-level component reference bindings can all be different,
+ // we don't copy any of them up to this component reference, which will therefore
+ // always have its own binding, even if it's only the default SCA binding.
+ if (bindingsSpecifiedManually(componentReference.getBindings()) ||
+ (componentReference.getCallback() != null &&
+ bindingsSpecifiedManually(componentReference.getCallback().getBindings()))) {
+ componentReference.setPromotionOverride(true);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * If the bindings are specified in the composite file return true as they should
+ * otherwise return false
+ *
+ * @param bindings
+ * @return true if the bindings were specified manually
+ */
+ private boolean bindingsSpecifiedManually(List<Binding> bindings) {
+
+ if (bindings.size() > 1) {
+ return true;
+ } else if (bindings.size() == 1 &&
+ bindings.get(0) instanceof AutomaticBinding &&
+ ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) {
+ return false;
+ } else if (bindings.size() == 1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java
new file mode 100644
index 0000000000..451b378941
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java
@@ -0,0 +1,94 @@
+/*
+ * 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.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that wires composite references.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeReferenceWireBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public CompositeReferenceWireBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentReferenceWireBuilder";
+ }
+
+ /**
+ * Wire composite references in a deployment composite.
+ *
+ * @param composite
+ */
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+
+ // Process composite references declared in this composite
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+
+ // If the composite reference is a promotion override, override the
+ // configuration of the promoted reference.
+ //FIXME: Policy configuration or wiring of domain-level composite references
+ // doesn't cause a promotion override, unless the composite reference has
+ // additional bindings. Do we need to detect this and force an override?
+ if (compositeReference.isPromotionOverride()) {
+ List<ComponentReference> promotedReferences =
+ ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference);
+ for (ComponentReference promotedReference : promotedReferences) {
+ ReferenceConfigurationUtil.reconcileReferenceBindings(
+ compositeReference, promotedReference, assemblyFactory, monitor);
+ if (compositeReference.getInterfaceContract() != null && // can be null in unit tests
+ compositeReference.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
+ if (promotedReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().clear();
+ } else {
+ promotedReference.setCallback(assemblyFactory.createCallback());
+ }
+ if (scaCallbackBinding != null) {
+ promotedReference.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ if (compositeReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().addAll(compositeReference.getCallback()
+ .getBindings());
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java
new file mode 100644
index 0000000000..6a8da7241a
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.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.assembly.builder.impl;
+
+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.CompositeService;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that performs any additional building steps that
+ * composite service bindings may need. Used for WSDL generation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeServiceBindingBuilderImpl implements CompositeBuilder {
+
+ public CompositeServiceBindingBuilderImpl() {
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeServiceBindingBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ buildServiceBindings(composite, monitor);
+ }
+
+ private void buildServiceBindings(Composite composite, Monitor monitor) {
+
+ // build bindings recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ buildServiceBindings((Composite)implementation, monitor);
+ }
+ }
+
+ // find all the composite service bindings
+ for (Service service : composite.getServices()) {
+ for (Binding binding : service.getBindings()) {
+ if (binding instanceof BindingBuilderExtension) {
+ Component component = ServiceConfigurationUtil.getPromotedComponent((CompositeService)service);
+ ((BindingBuilderExtension)binding).getBuilder().build(component, service, binding, monitor);
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java
new file mode 100644
index 0000000000..099996d244
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java
@@ -0,0 +1,202 @@
+/*
+ * 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.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.CompositeService;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.AutomaticBinding;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that handles the configuration of composite services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public CompositeServiceConfigurationBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeServiceConfigurationBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+
+ // Process nested composites recursively
+ configureNestedCompositeServices(composite);
+
+ // TODO - In OASIS the treatment of top level composite services it different
+ // Process top level composite services
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+
+ // Get the next lower level promoted service
+ ComponentService promotedService = compositeService.getPromotedService();
+ if (promotedService != null) {
+
+ // Set the bindings using the top level bindings to override the lower level bindings
+ if (!bindingsSpecifiedManually(compositeService.getBindings()) &&
+ bindingsSpecifiedManually(promotedService.getBindings())) {
+ compositeService.getBindings().clear();
+ for (Binding binding : promotedService.getBindings()) {
+ try {
+ compositeService.getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted service
+ }
+ }
+ }
+ if (compositeService.getInterfaceContract() != null &&
+ compositeService.getInterfaceContract().getCallbackInterface() != null) {
+ if (!(compositeService.getCallback() != null &&
+ bindingsSpecifiedManually(compositeService.getCallback().getBindings())) &&
+ promotedService.getCallback() != null &&
+ bindingsSpecifiedManually(promotedService.getCallback().getBindings())) {
+ if (compositeService.getCallback() != null) {
+ compositeService.getCallback().getBindings().clear();
+ } else {
+ compositeService.setCallback(assemblyFactory.createCallback());
+ }
+ for (Binding binding : promotedService.getCallback().getBindings()) {
+ try {
+ compositeService.getCallback().getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted service
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void configureNestedCompositeServices(Composite composite) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // First process nested composites
+ configureNestedCompositeServices((Composite)implementation);
+
+ // Process the component services declared on components in this composite
+ for (ComponentService componentService : component.getServices()) {
+ Service implService = componentService.getService();
+ if (implService != null && implService instanceof CompositeService) {
+ CompositeService compositeService = (CompositeService)implService;
+
+ // Get the next lower level promoted service
+ ComponentService promotedService = compositeService.getPromotedService();
+ if (promotedService != null) {
+
+ // Set the bindings using the top level bindings to override the lower level bindings
+ if (!bindingsSpecifiedManually(compositeService.getBindings()) &&
+ bindingsSpecifiedManually(promotedService.getBindings()) ) {
+ compositeService.getBindings().clear();
+ for (Binding binding : promotedService.getBindings()) {
+ try {
+ compositeService.getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted service
+ }
+ }
+ }
+ if (!bindingsSpecifiedManually(componentService.getBindings()) &&
+ bindingsSpecifiedManually(compositeService.getBindings()) ) {
+ componentService.getBindings().clear();
+ componentService.getBindings().addAll(compositeService.getBindings());
+ }
+ if (componentService.getInterfaceContract() != null &&
+ componentService.getInterfaceContract().getCallbackInterface() != null) {
+ if (!(compositeService.getCallback() != null &&
+ bindingsSpecifiedManually(compositeService.getCallback().getBindings())) &&
+ promotedService.getCallback() != null &&
+ bindingsSpecifiedManually(promotedService.getCallback().getBindings())) {
+ if (compositeService.getCallback() != null) {
+ compositeService.getCallback().getBindings().clear();
+ } else {
+ compositeService.setCallback(assemblyFactory.createCallback());
+ }
+ for (Binding binding : promotedService.getCallback().getBindings()) {
+ try {
+ compositeService.getCallback().getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted service
+ }
+ }
+ }
+ if (!(componentService.getCallback() != null &&
+ bindingsSpecifiedManually(componentService.getCallback().getBindings())) &&
+ compositeService.getCallback() != null &&
+ bindingsSpecifiedManually(compositeService.getCallback().getBindings())) {
+ if (componentService.getCallback() != null) {
+ componentService.getCallback().getBindings().clear();
+ } else {
+ componentService.setCallback(assemblyFactory.createCallback());
+ }
+ componentService.getCallback().getBindings().addAll(
+ compositeService.getCallback().getBindings());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * If the bindings are specified in the composite file return true as they should
+ * otherwise return false
+ *
+ * @param bindings
+ * @return true if the bindings were specified manually
+ */
+ private boolean bindingsSpecifiedManually(List<Binding> bindings) {
+
+ if (bindings.size() > 1) {
+ return true;
+ } else if (bindings.size() == 1 &&
+ bindings.get(0) instanceof AutomaticBinding &&
+ ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) {
+ return false;
+ } else if (bindings.size() == 1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java
new file mode 100644
index 0000000000..3004a9f590
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.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.builder.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.CompositeService;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that handles the creation of promoted composite services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeServicePromotionBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public CompositeServicePromotionBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeServicePromotionBuilder";
+ }
+
+ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+
+ // Process top level composite services
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+
+ // Get the innermost promoted service
+ ComponentService promotedService = ServiceConfigurationUtil.getPromotedComponentService(compositeService);
+ if (promotedService != null) {
+ Component promotedComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService);
+
+ // Create a new component service to represent this composite
+ // service on the promoted component
+ ComponentService newComponentService = assemblyFactory.createComponentService();
+ newComponentService.setName("$promoted$" + compositeService.getName());
+ promotedComponent.getServices().add(newComponentService);
+ newComponentService.setService(promotedService.getService());
+ newComponentService.getBindings().addAll(compositeService.getBindings());
+ newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
+ if (compositeService.getInterfaceContract() != null &&
+ compositeService.getInterfaceContract().getCallbackInterface() != null) {
+ newComponentService.setCallback(assemblyFactory.createCallback());
+ newComponentService.getCallback().getBindings()
+ .addAll(compositeService.getCallback().getBindings());
+ }
+
+ // Change the composite service to now promote the newly
+ // created component service directly
+ compositeService.setPromotedComponent(promotedComponent);
+ compositeService.setPromotedService(newComponentService);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationException.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationException.java
new file mode 100644
index 0000000000..944cf2cf36
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationException.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.assembly.builder.impl;
+
+/**
+ * Exception to be throw for invalid policy intents / policysets
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyConfigurationException extends Exception {
+ private static final long serialVersionUID = 506979037642587755L;
+
+ public PolicyConfigurationException(String message) {
+ super(message);
+ }
+
+ public PolicyConfigurationException(Throwable e) {
+ super(e);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java
new file mode 100644
index 0000000000..a7a40e62e6
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java
@@ -0,0 +1,428 @@
+/*
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+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.Contract;
+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.IntentMap;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.policy.util.PolicyComputationUtils;
+import org.apache.tuscany.sca.policy.util.PolicyValidationException;
+import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
+
+/**
+ * This class contains policy computation methods common to computing implementation and binding policies
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class PolicyConfigurationUtil {
+
+ private static List<Intent> computeInheritableIntents(ExtensionType attachPointType,
+ List<Intent> inheritableIntents) throws PolicyValidationException {
+ List<Intent> validInheritableIntents = new ArrayList<Intent>();
+
+ //expand profile intents in inherited intents
+ PolicyComputationUtils.expandProfileIntents(inheritableIntents);
+
+ //validate if inherited intent applies to the attachpoint (binding / implementation) and
+ //only add such intents to the attachpoint (binding / implementation)
+ for (Intent intent : inheritableIntents) {
+ if ( !intent.isUnresolved() ) {
+ for (ExtensionType constrained : intent.getConstrainedTypes()) {
+ if ( PolicyValidationUtils.isConstrained(constrained, attachPointType)) {
+ validInheritableIntents.add(intent);
+ break;
+ }
+ }
+ } else {
+ throw new PolicyValidationException("Policy Intent '" + intent.getName() + "' is not defined in this domain");
+ }
+ }
+
+ return validInheritableIntents;
+ }
+
+ private static void normalizeIntents(PolicySubject intentAttachPoint) {
+ //expand profile intents specified in the attachpoint (binding / implementation)
+ PolicyComputationUtils.expandProfileIntents(intentAttachPoint.getRequiredIntents());
+
+ //remove duplicates and ...
+ //where qualified form of intent exists retain it and remove the qualifiable intent
+ filterDuplicatesAndQualifiableIntents(intentAttachPoint);
+ }
+
+ private static void trimInherentlyProvidedIntents(ExtensionType attachPointType, List<Intent>intents) {
+ //exclude intents that are inherently supported by the
+ //attachpoint-type (binding-type / implementation-type)
+ List<Intent> requiredIntents = new ArrayList<Intent>(intents);
+ for ( Intent intent : requiredIntents ) {
+ if ( isProvidedInherently(attachPointType, intent) ) {
+ intents.remove(intent);
+ }
+ }
+ }
+
+
+ private static List<PolicySet> computeInheritablePolicySets(List<PolicySet> inheritablePolicySets)
+ throws PolicyValidationException {
+ // FIXME:
+ return inheritablePolicySets;
+ }
+
+ private static void normalizePolicySets(PolicySubject subject ) {
+ //get rid of duplicate entries
+ Set<PolicySet> policySetTable = new HashSet<PolicySet>(subject.getPolicySets());
+
+ subject.getPolicySets().clear();
+ subject.getPolicySets().addAll(policySetTable);
+
+ //expand profile intents
+ for ( PolicySet policySet : subject.getPolicySets() ) {
+ PolicyComputationUtils.expandProfileIntents(policySet.getProvidedIntents());
+ }
+ }
+
+ private static void trimProvidedIntents(List<Intent> requiredIntents, List<PolicySet> policySets) {
+ for ( PolicySet policySet : policySets ) {
+ trimProvidedIntents(requiredIntents, policySet);
+ }
+ }
+
+ private static void determineApplicableDomainPolicySets(List<PolicySet> applicablePolicySets,
+ PolicySubject policySetAttachPoint,
+ ExtensionType intentAttachPointType) {
+
+ if (policySetAttachPoint.getRequiredIntents().size() > 0) {
+
+ // form a list of all intents required by the attach point
+ List<Intent> combinedTargetIntents = new ArrayList<Intent>();
+ combinedTargetIntents.addAll(policySetAttachPoint.getRequiredIntents());
+ for (PolicySet targetPolicySet : policySetAttachPoint.getPolicySets()) {
+ combinedTargetIntents.addAll(PolicyComputationUtils.findAndExpandProfileIntents(targetPolicySet.getProvidedIntents()));
+ }
+
+ //since the set of applicable policysets for this attachpoint is known
+ //we only need to check in that list if there is a policyset that matches
+ for (PolicySet policySet : applicablePolicySets) {
+ // do not use the policy set if it provides intents that conflict with required intents
+ boolean conflict = false;
+ List<Intent> providedIntents = PolicyComputationUtils.findAndExpandProfileIntents(policySet.getProvidedIntents());
+ checkConflict: for (Intent intent : providedIntents) {
+ for (Intent excluded : intent.getExcludedIntents()) {
+ if (combinedTargetIntents.contains(excluded)) {
+ conflict = true;
+ break checkConflict;
+ }
+ }
+ }
+ if (conflict)
+ continue;
+ int prevSize = policySetAttachPoint.getRequiredIntents().size();
+ trimProvidedIntents(policySetAttachPoint.getRequiredIntents(), policySet);
+ // if any intent was trimmed off, then this policyset must
+ // be attached to the intent attachpoint's policyset
+ if (prevSize != policySetAttachPoint.getRequiredIntents().size()) {
+ policySetAttachPoint.getPolicySets().add(policySet);
+ }
+ }
+ }
+ }
+
+ private static boolean isProvidedInherently(ExtensionType attachPointType, Intent intent) {
+ return ( attachPointType != null &&
+ (( attachPointType.getAlwaysProvidedIntents() != null &&
+ attachPointType.getAlwaysProvidedIntents().contains(intent) ) ||
+ ( attachPointType.getMayProvidedIntents() != null &&
+ attachPointType.getMayProvidedIntents().contains(intent) )
+ ) );
+ }
+
+ private static void trimProvidedIntents(List<Intent> requiredIntents, PolicySet policySet) {
+ for ( Intent providedIntent : policySet.getProvidedIntents() ) {
+ if ( requiredIntents.contains(providedIntent) ) {
+ requiredIntents.remove(providedIntent);
+ }
+ }
+
+ for ( IntentMap intentMap : policySet.getIntentMaps() ) {
+ if ( requiredIntents.contains(intentMap.getProvidedIntent()) ) {
+ requiredIntents.remove(intentMap.getProvidedIntent());
+ }
+ }
+ }
+
+ private static void filterDuplicatesAndQualifiableIntents(PolicySubject intentAttachPoint) {
+ //remove duplicates
+ Map<QName, Intent> intentsTable = new HashMap<QName, Intent>();
+ for ( Intent intent : intentAttachPoint.getRequiredIntents() ) {
+ intentsTable.put(intent.getName(), intent);
+ }
+
+ //where qualified form of intent exists retain it and remove the qualifiable intent
+ Map<QName, Intent> intentsTableCopy = new HashMap<QName, Intent>(intentsTable);
+ //if qualified form of intent exists remove the unqualified form
+ for ( Intent intent : intentsTableCopy.values() ) {
+ if ( intent.getQualifiableIntent()!=null ) {
+ if ( intentsTable.get(intent.getQualifiableIntent().getName()) != null ) {
+ intentsTable.remove(intent.getQualifiableIntent().getName());
+ }
+ }
+ }
+ intentAttachPoint.getRequiredIntents().clear();
+ intentAttachPoint.getRequiredIntents().addAll(intentsTable.values());
+ }
+
+ static void computeBindingIntentsAndPolicySets(Contract contract) throws PolicyValidationException {
+ for (Binding binding : contract.getBindings()) {
+ if (binding instanceof PolicySubject) {
+ PolicySubject policiedBinding = (PolicySubject)binding;
+ computeIntents((PolicySubject)binding, contract.getRequiredIntents());
+
+ computePolicySets(policiedBinding, contract.getPolicySets());
+
+ PolicyComputationUtils.checkForMutuallyExclusiveIntents(
+ policiedBinding.getRequiredIntents(),
+ policiedBinding.getPolicySets(),
+ policiedBinding.getType(),
+ contract.getName());
+ }
+ }
+
+ if ( contract.getCallback() != null ) {
+ for (Binding binding : contract.getCallback().getBindings()) {
+ if (binding instanceof PolicySubject) {
+ PolicySubject policiedBinding = (PolicySubject)binding;
+ computeIntents((PolicySubject)binding, contract.getCallback().getRequiredIntents());
+
+ computePolicySets(policiedBinding, contract.getCallback().getPolicySets());
+
+ PolicyComputationUtils.checkForMutuallyExclusiveIntents(
+ policiedBinding.getRequiredIntents(),
+ policiedBinding.getPolicySets(),
+ policiedBinding.getType(),
+ contract.getName() + " callback");
+
+ }
+ }
+ }
+ }
+
+ private static void computeIntents(PolicySubject policiedBinding, List<Intent> inheritedIntents)
+ throws PolicyValidationException {
+ //since the parent component could also contain intents that apply to implementation
+ //and binding elements within, we filter out only those that apply to this binding type
+ List<Intent> prunedIntents = computeInheritableIntents(policiedBinding.getType(),
+ inheritedIntents);
+ policiedBinding.getRequiredIntents().addAll(prunedIntents);
+
+ normalizeIntents(policiedBinding);
+ }
+
+ private static void computePolicySets(PolicySubject policiedBinding,
+ List<PolicySet> inheritedPolicySets) throws PolicyValidationException {
+
+ List<PolicySet> prunedPolicySets = computeInheritablePolicySets(inheritedPolicySets);
+ policiedBinding.getPolicySets().addAll(prunedPolicySets);
+ normalizePolicySets(policiedBinding);
+ }
+
+ static void determineApplicableBindingPolicySets(Contract source, Contract target) throws PolicyConfigurationException {
+ List<Intent> intentsCopy = null;
+ for (Binding aBinding : source.getBindings()) {
+ if (aBinding instanceof PolicySubject) {
+ PolicySubject policiedBinding = (PolicySubject)aBinding;
+ ExtensionType bindingType = policiedBinding.getType();
+
+
+ intentsCopy = new ArrayList<Intent>(policiedBinding.getRequiredIntents());
+ // add the target component's intents to the reference binding
+ if (target != null) {
+ for (Intent intent : target.getRequiredIntents()) {
+ if (!policiedBinding.getRequiredIntents().contains(intent)) {
+ for (ExtensionType constrained : intent.getConstrainedTypes()) {
+ if (bindingType != null && bindingType.getType().getNamespaceURI()
+ .equals(constrained.getType().getNamespaceURI())
+ && bindingType.getType().getLocalPart().startsWith(constrained
+ .getType().getLocalPart())) {
+ policiedBinding.getRequiredIntents().add(intent);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ trimInherentlyProvidedIntents(policiedBinding.getType(),
+ policiedBinding.getRequiredIntents());
+ trimProvidedIntents(policiedBinding.getRequiredIntents(), policiedBinding
+ .getPolicySets());
+
+ // determine additional policysets that match remaining intents
+ // TODO: resolved to domain policy registry and attach suitable
+ // policy sets to the binding
+ // for now using the SCA Definitions instead of registry
+ // if there are intents that are not provided by any policy set
+ // throw a warning
+ determineApplicableDomainPolicySets(source, policiedBinding);
+
+ //the intents list could have been trimmed when matching for policysets
+ //since the bindings may need the original set of intents we copy that back
+ policiedBinding.getRequiredIntents().clear();
+ policiedBinding.getRequiredIntents().addAll(intentsCopy);
+
+ }
+ }
+ }
+
+ private static void determineApplicableDomainPolicySets(Contract contract,
+ PolicySubject policiedBinding)
+ throws PolicyConfigurationException {
+ // FIXME:
+ /*
+ //if ( domainPolicySets != null) {
+ determineApplicableDomainPolicySets(policiedBinding.getApplicablePolicySets(),
+ policiedBinding,
+ policiedBinding.getType());
+
+ if ( policiedBinding.getRequiredIntents().size() > 0 ) {
+ if ( contract instanceof Service ) {
+ throw new PolicyConfigurationException("The following are unfulfilled intents for " +
+ "binding in service - " + contract.getName() + "\nUnfulfilled Intents = " +
+ policiedBinding.getRequiredIntents());
+ } else {
+ throw new PolicyConfigurationException("The are unfulfilled intents for " +
+ "binding in reference - " + contract.getName() + "\nUnfulfilled Intents = " +
+ policiedBinding.getRequiredIntents());
+ }
+ }
+ //}
+ */
+ }
+
+ private static void aggregateAndPruneApplicablePolicySets(List<PolicySet> source, List<PolicySet> target) {
+ target.addAll(source);
+ //strip duplicates
+ Hashtable<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
+ for ( PolicySet policySet : target ) {
+ policySetTable.put(policySet.getName(), policySet);
+ }
+
+ target.clear();
+ target.addAll(policySetTable.values());
+ }
+
+ static <C extends Contract> void inheritDefaultPolicies(Base parent, List<C> contracts) {
+
+ for (Contract contract : contracts) {
+
+ // The contract inherits default policies from the parent composite/component.
+ if ( parent instanceof PolicySubject ) {
+ PolicyComputationUtils.addDefaultPolicies(
+ ((PolicySubject)parent).getRequiredIntents(),
+ ((PolicySubject)parent).getPolicySets(),
+ contract.getRequiredIntents(),
+ contract.getPolicySets());
+ }
+
+ // The contract's callback inherits default policies from the contract.
+ if (contract.getCallback() != null) {
+ PolicyComputationUtils.addDefaultPolicies(
+ contract.getRequiredIntents(),
+ contract.getPolicySets(),
+ contract.getCallback().getRequiredIntents(),
+ contract.getCallback().getPolicySets());
+ }
+
+ }
+ }
+
+ static void computeImplementationIntentsAndPolicySets(Implementation implementation, Component parent)
+ throws PolicyValidationException, PolicyConfigurationException {
+ if ( implementation instanceof PolicySubject ) {
+ PolicySubject policiedImplementation = (PolicySubject)implementation;
+ //since for an implementation the component has its policy intents and policysets its possible
+ //that there are some intents there that does not constrain the implementation.. so prune
+ List<Intent> prunedIntents = computeInheritableIntents(policiedImplementation.getType(),
+ parent.getRequiredIntents());
+ parent.getRequiredIntents().clear();
+ parent.getRequiredIntents().addAll(prunedIntents);
+ normalizeIntents(parent);
+
+ List<PolicySet> prunedPolicySets = computeInheritablePolicySets(parent.getPolicySets());
+ parent.getPolicySets().clear();
+ parent.getPolicySets().addAll(prunedPolicySets);
+ normalizePolicySets(parent);
+
+ PolicyComputationUtils.checkForMutuallyExclusiveIntents(
+ parent.getRequiredIntents(),
+ parent.getPolicySets(),
+ policiedImplementation.getType(),
+ parent.getName());
+
+ determineApplicableImplementationPolicySets(parent);
+
+ }
+ }
+
+ private static void determineApplicableImplementationPolicySets(Component component) throws PolicyConfigurationException {
+ List<Intent> intentsCopy = null;
+ if ( component.getImplementation() instanceof PolicySubject ) {
+ PolicySubject policiedImplementation = (PolicySubject)component.getImplementation();
+
+ intentsCopy = new ArrayList<Intent>(component.getRequiredIntents());
+ trimInherentlyProvidedIntents(policiedImplementation.getType(),
+ component.getRequiredIntents());
+ trimProvidedIntents(component.getRequiredIntents(), component.getPolicySets());
+
+ //determine additional policysets that match remaining intents
+ //if there are intents that are not provided by any policy set throw a warning
+ //TODO: resolved to domain policy registry and attach suitable policy sets to the implementation
+ //...for now using the SCA Definitions instead of registry
+ //if ( domainPolicySets != null) {
+
+ if (component.getRequiredIntents().size() > 0) {
+ throw new PolicyConfigurationException("The following are unfulfilled intents for component implementation - " + component
+ .getName() + "\nUnfulfilled Intents = " + component.getRequiredIntents());
+ }
+ //}
+
+ //the intents list could have been trimmed when matching for policysets
+ //since the bindings may need the original set of intents we copy that back
+ component.getRequiredIntents().clear();
+ component.getRequiredIntents().addAll(intentsCopy);
+ }
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtil.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtil.java
new file mode 100644
index 0000000000..3762cc6e77
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtil.java
@@ -0,0 +1,273 @@
+/*
+ * 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.impl;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.w3c.dom.Node;
+
+/**
+ * A simple print utility class to help print model instances.
+ *
+ * @version $Rev$ $Date$
+ */
+class PrintUtil {
+ private boolean useGetters = false;
+ private PrintWriter out;
+ private int indent;
+
+ public PrintUtil(PrintWriter out, boolean useGetters) {
+ this.out = out;
+ this.useGetters = useGetters;
+ }
+
+ public PrintUtil(OutputStream out) {
+ this.out = new PrintWriter(new OutputStreamWriter(out), true);
+ }
+
+ void indent() {
+ for (int i = 0; i < indent; i++) {
+ out.print(" ");
+ }
+ }
+
+ /**
+ * Print an object.
+ *
+ * @param object
+ */
+ public void print(Object object) {
+ Set<Integer> objects = new HashSet<Integer>();
+ print(object, objects);
+ }
+
+ /**
+ * Print an object.
+ *
+ * @param object
+ */
+ private void print(Object object, Set<Integer> printed) {
+ if (object == null) {
+ return;
+ }
+ int id = System.identityHashCode(object);
+ if (printed.contains(id)) {
+
+ // If we've already printed an object, print just it's HashCode
+ indent();
+ out.println(object.getClass().getName() + "@" + id);
+ } else {
+ printed.add(id);
+ try {
+
+ // Print the object class name
+ indent();
+ out.println(object.getClass().getSimpleName() + " {");
+
+ // Get the object's properties
+ ValueAccessor accessor = useGetters ? new PropertyAccessor(object) : new FieldAccessor(object);
+ for (int i = 0; i < accessor.size(); i++) {
+ try {
+
+ // Get the value of each property
+ Object value = accessor.getValue(i);
+ if (value != null) {
+
+ // Convert array value into a list
+ if (value.getClass().isArray()) {
+ value = Arrays.asList((Object[])value);
+ }
+
+ // Print elements in a list
+ if (value instanceof List) {
+ if (!((List<?>)value).isEmpty()) {
+ indent++;
+ indent();
+ out.println(accessor.getName(i) + "= [");
+
+ // Print each element, recursively
+ for (Object element : (List<?>)value) {
+ indent++;
+ print(element, printed);
+ indent--;
+ }
+ indent();
+ out.println(" ]");
+ indent--;
+ }
+ } else {
+ Class<?> valueClass = value.getClass();
+
+ // Print a primitive, java built in type or
+ // enum, using toString()
+ if (valueClass.isPrimitive() || valueClass.getName().startsWith("java.")
+ || valueClass.getName().startsWith("javax.")
+ || valueClass.isEnum()) {
+ if (!accessor.getName(i).equals("class")) {
+ if (!(Boolean.FALSE.equals(value))) {
+ indent++;
+ indent();
+ out.println(accessor.getName(i) + "=" + value.toString());
+ indent--;
+ }
+ }
+ } else if (value instanceof Node) {
+ indent++;
+ indent();
+ out.println(accessor.getName(i) + "=" + value.toString());
+ indent--;
+ } else {
+
+ // Print an object, recursively
+ indent++;
+ indent();
+ out.println(accessor.getName(i) + "= {");
+ indent++;
+ print(value, printed);
+ indent--;
+ indent();
+ out.println("}");
+ indent--;
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ indent();
+ out.println("}");
+ } catch (Exception e) {
+ indent();
+ out.println(e);
+ }
+ }
+ }
+
+ public static interface ValueAccessor {
+ int size();
+
+ String getName(int i);
+
+ Object getValue(int i) throws Exception;
+ }
+
+ /**
+ * Java field reflection based value accessor
+ */
+ private static class FieldAccessor implements ValueAccessor {
+
+ private Object object;
+ private List<Field> fields;
+
+ public FieldAccessor(Object object) {
+ this.fields = getAllFields(object.getClass());
+ this.object = object;
+ }
+
+ public String getName(int i) {
+ return fields.get(i).getName();
+ }
+
+ public Object getValue(int i) throws Exception {
+ return fields.get(i).get(object);
+ }
+
+ public int size() {
+ return fields.size();
+ }
+
+ }
+
+ /**
+ * JavaBean-based value accessor
+ */
+ private static class PropertyAccessor implements ValueAccessor {
+
+ private Object object;
+ private PropertyDescriptor[] fields;
+
+ public PropertyAccessor(Object object) throws IntrospectionException {
+ BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());
+ this.fields = beanInfo.getPropertyDescriptors();
+ this.object = object;
+ }
+
+ public String getName(int i) {
+ return fields[i].getName();
+ }
+
+ public Object getValue(int i) throws Exception {
+ Method getter = fields[i].getReadMethod();
+ if (getter != null) {
+ return getter.invoke(object);
+ }
+ return null;
+ }
+
+ public int size() {
+ return fields.length;
+ }
+
+ }
+
+ /**
+ * Returns a collection of fields declared by a class
+ * or one of its supertypes
+ */
+ private static List<Field> getAllFields(Class<?> clazz) {
+ return getAllFields(clazz, new ArrayList<Field>());
+ }
+
+ /**
+ * Recursively evaluates the type hierarchy to return all fields
+ */
+ private static List<Field> getAllFields(Class<?> clazz, List<Field> fields) {
+ if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) {
+ return fields;
+ }
+ fields = getAllFields(clazz.getSuperclass(), fields);
+ Field[] declaredFields = clazz.getDeclaredFields();
+ for (final Field field : declaredFields) {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ field.setAccessible(true); // ignore Java accessibility
+ return null;
+ }
+ });
+ fields.add(field);
+ }
+ return fields;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java
new file mode 100644
index 0000000000..0105d4af50
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java
@@ -0,0 +1,213 @@
+/*
+ * 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.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+/**
+ * Utility class to deal with processing of component properties that are taking values from the parent
+ * composite's properties or an external file.
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class PropertyConfigurationUtil {
+
+ private static Document evaluate(Document node, XPathExpression expression, DocumentBuilderFactory documentBuilderFactory)
+ throws XPathExpressionException, ParserConfigurationException {
+
+ Node value = node.getDocumentElement();
+ Node result = (Node)expression.evaluate(value, XPathConstants.NODE);
+ if (result == null) {
+ return null;
+ }
+
+ // TODO: How to wrap the result into a Document?
+ Document document = documentBuilderFactory.newDocumentBuilder().newDocument();
+ if (result instanceof Document) {
+ return (Document)result;
+ } else {
+ //Element root = document.createElementNS(null, "value");
+ //document.appendChild(root);
+ document.appendChild(document.importNode(result, true));
+ return document;
+ }
+ }
+
+ private static Document loadFromFile(String file, TransformerFactory transformerFactory) throws MalformedURLException, IOException,
+ TransformerException, ParserConfigurationException {
+ URI uri = URI.create(file);
+ // URI resolution for relative URIs is done when the composite is resolved.
+ URL url = uri.toURL();
+ URLConnection connection = url.openConnection();
+ connection.setUseCaches(false);
+ InputStream is = null;
+ try {
+ is = connection.getInputStream();
+
+ Source streamSource = new SAXSource(new InputSource(is));
+ DOMResult result = new DOMResult();
+ javax.xml.transform.Transformer transformer = transformerFactory.newTransformer();
+ transformer.transform(streamSource, result);
+
+ Document document = (Document)result.getNode();
+
+ // TUSCANY-2377, Add a fake value element so it's consistent with
+ // the DOM tree loaded from inside SCDL
+ Element root = document.createElementNS(null, "value");
+ root.appendChild(document.getDocumentElement());
+ document.appendChild(root);
+ return document;
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ }
+ }
+
+ static void sourceComponentProperties(Map<String, Property> compositeProperties,
+ Component componentDefinition,
+ DocumentBuilderFactory documentBuilderFactory,
+ TransformerFactory transformerFactory) throws CompositeBuilderException,
+ ParserConfigurationException,
+ XPathExpressionException,
+ TransformerException,
+ IOException {
+
+ List<ComponentProperty> componentProperties = componentDefinition.getProperties();
+ for (ComponentProperty aProperty : componentProperties) {
+ String source = aProperty.getSource();
+ String file = aProperty.getFile();
+ if (source != null) {
+ // $<name>/...
+ int index = source.indexOf('/');
+ if (index == -1) {
+ // Tolerating $prop
+ source = source + "/";
+ index = source.length() - 1;
+ }
+ if (source.charAt(0) == '$') {
+ String name = source.substring(1, index);
+ Property compositeProp = compositeProperties.get(name);
+ if (compositeProp == null) {
+ throw new CompositeBuilderException("The 'source' cannot be resolved to a composite property: " + source);
+ }
+
+ Document compositePropDefValues = (Document)compositeProp.getValue();
+
+ // FIXME: How to deal with namespaces?
+ Document node = evaluate(compositePropDefValues, aProperty.getSourceXPathExpression(), documentBuilderFactory);
+
+ if (node != null) {
+ aProperty.setValue(node);
+ }
+ } else {
+ throw new CompositeBuilderException("The 'source' has an invalid value: " + source);
+ }
+ } else if (file != null) {
+ aProperty.setValue(loadFromFile(aProperty.getFile(), transformerFactory));
+
+ }
+ }
+ }
+
+ private static class DOMNamespaceContext implements NamespaceContext {
+ private Node node;
+
+ /**
+ * @param node
+ */
+ public DOMNamespaceContext(Node node) {
+ super();
+ this.node = node;
+ }
+
+ public String getNamespaceURI(String prefix) {
+ if (prefix == null) {
+ throw new IllegalArgumentException("Prefix is null");
+ } else if (XMLConstants.XML_NS_PREFIX.equals(prefix)) {
+ return XMLConstants.XML_NS_URI;
+ } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) {
+ return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+ }
+ String ns = node.lookupNamespaceURI(prefix);
+ return ns == null ? XMLConstants.NULL_NS_URI : ns;
+ }
+
+ public String getPrefix(String namespaceURI) {
+ if (namespaceURI == null) {
+ throw new IllegalArgumentException("Namespace URI is null");
+ } else if (XMLConstants.XML_NS_URI.equals(namespaceURI)) {
+ return XMLConstants.XML_NS_PREFIX;
+ } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) {
+ return XMLConstants.XMLNS_ATTRIBUTE;
+ }
+ return node.lookupPrefix(namespaceURI);
+ }
+
+ public Iterator<?> getPrefixes(String namespaceURI) {
+ // Not implemented
+ if (namespaceURI == null) {
+ throw new IllegalArgumentException("Namespace URI is null");
+ } else if (XMLConstants.XML_NS_URI.equals(namespaceURI)) {
+ return Arrays.asList(XMLConstants.XML_NS_PREFIX).iterator();
+ } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) {
+ return Arrays.asList(XMLConstants.XMLNS_ATTRIBUTE).iterator();
+ }
+ String prefix = getPrefix(namespaceURI);
+ if (prefix == null) {
+ return Collections.emptyList().iterator();
+ }
+ return Arrays.asList(prefix).iterator();
+ }
+
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java
new file mode 100644
index 0000000000..c1862e0380
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java
@@ -0,0 +1,207 @@
+/*
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.OptimizableBinding;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * This class encapsulates utility methods to deal with reference definitions
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class ReferenceConfigurationUtil {
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private static void warning(Monitor monitor, String message, Object model, String... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(ReferenceConfigurationUtil.class.getName(), "assembly-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ static boolean isValidMultiplicityOverride(Multiplicity definedMul, Multiplicity overridenMul) {
+ if (definedMul != overridenMul) {
+ switch (definedMul) {
+ case ZERO_N:
+ return overridenMul == Multiplicity.ZERO_ONE;
+ case ONE_N:
+ return overridenMul == Multiplicity.ONE_ONE;
+ default:
+ return false;
+ }
+ } else {
+ return true;
+ }
+ }
+
+ static boolean validateMultiplicityAndTargets(Multiplicity multiplicity,
+ List<?> targets, List<Binding> bindings) {
+
+ // Count targets
+ int count = targets.size();
+
+ //FIXME workaround, this validation is sometimes invoked too early
+ // before we get a chance to init the multiplicity attribute
+ if (multiplicity == null) {
+ return true;
+ }
+
+ switch (multiplicity) {
+ case ZERO_N:
+ break;
+ case ZERO_ONE:
+ if (count > 1) {
+ return false;
+ }
+ break;
+ case ONE_ONE:
+ if (count != 1) {
+ if (count == 0) {
+ for (Binding binding: bindings) {
+ if (!(binding instanceof OptimizableBinding) || binding.getURI()!=null) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ break;
+ case ONE_N:
+ if (count < 1) {
+ if (count == 0) {
+ for (Binding binding: bindings) {
+ if (!(binding instanceof OptimizableBinding) || binding.getURI()!=null) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ break;
+ }
+ return true;
+ }
+
+ /**
+ * Follow a reference promotion chain down to the innermost (non composite)
+ * component references.
+ *
+ * @param compositeReference
+ * @return
+ */
+ static List<ComponentReference> getPromotedComponentReferences(CompositeReference compositeReference) {
+ List<ComponentReference> componentReferences = new ArrayList<ComponentReference>();
+ collectPromotedComponentReferences(compositeReference, componentReferences);
+ return componentReferences;
+ }
+
+ /**
+ * Follow a reference promotion chain down to the innermost (non composite)
+ * component references.
+ *
+ * @param compositeReference
+ * @param componentReferences
+ * @return
+ */
+ private static void collectPromotedComponentReferences(CompositeReference compositeReference,
+ List<ComponentReference> componentReferences) {
+ for (ComponentReference componentReference : compositeReference.getPromotedReferences()) {
+ Reference reference = componentReference.getReference();
+ if (reference instanceof CompositeReference) {
+
+ // Continue to follow the reference promotion chain
+ collectPromotedComponentReferences((CompositeReference)reference, componentReferences);
+
+ } else if (reference != null) {
+
+ // Found a non-composite reference
+ componentReferences.add(componentReference);
+ }
+ }
+ }
+
+ /**
+ * Override the bindings for a promoted reference from an outer component
+ * reference
+ *
+ * @param reference
+ * @param promotedReference
+ */
+ static void reconcileReferenceBindings(Reference reference,
+ ComponentReference promotedReference,
+ AssemblyFactory assemblyFactory,
+ Monitor monitor) {
+
+ if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE ||
+ promotedReference.getMultiplicity() == Multiplicity.ZERO_ONE) {
+
+ // override the promoted endpoint references (and bindings)
+ // with configuration from the top level
+
+ if (reference.getEndpointReferences().size() > 0){
+ promotedReference.getEndpointReferences().clear();
+ promotedReference.getEndpointReferences().addAll(reference.getEndpointReferences());
+ }
+
+ if (promotedReference.getEndpointReferences().size() > 1) {
+ warning(monitor, "ComponentReferenceMoreWire", promotedReference, promotedReference.getName());
+ }
+ } else {
+ // merge the promoted endpoint reference with the those from the top level
+ if (reference.getEndpointReferences().size() > 0){
+ promotedReference.getEndpointReferences().addAll(reference.getEndpointReferences());
+ }
+ }
+
+ Set<Binding> callbackBindings = new HashSet<Binding>();
+ if (promotedReference.getCallback() != null) {
+ callbackBindings.addAll(promotedReference.getCallback().getBindings());
+ }
+ if (reference.getCallback() != null) {
+ callbackBindings.addAll(reference.getCallback().getBindings());
+ }
+ promotedReference.setCallback(assemblyFactory.createCallback());
+ for (Binding binding : callbackBindings) {
+ if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
+ promotedReference.getCallback().getBindings().add(binding);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java
new file mode 100644
index 0000000000..41a8b3f8ba
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.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.builder.impl;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Service;
+
+/**
+ * This class encapsulates utility methods to deal with service definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class ServiceConfigurationUtil {
+
+ /**
+ * Follow a service promotion chain down to the inner most (non composite)
+ * component service.
+ *
+ * @param topCompositeService
+ * @return
+ */
+ static ComponentService getPromotedComponentService(CompositeService compositeService) {
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ Service service = componentService.getService();
+ if (componentService.getName() != null && service instanceof CompositeService) {
+
+ // Continue to follow the service promotion chain
+ return getPromotedComponentService((CompositeService)service);
+
+ } else {
+
+ // Found a non-composite service
+ return componentService;
+ }
+ } else {
+
+ // No promoted service
+ return null;
+ }
+ }
+
+ /**
+ * Follow a service promotion chain down to the innermost (non-composite) component.
+ *
+ * @param compositeService
+ * @return
+ */
+ static Component getPromotedComponent(CompositeService compositeService) {
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ Service service = componentService.getService();
+ if (componentService.getName() != null && service instanceof CompositeService) {
+
+ // Continue to follow the service promotion chain
+ return getPromotedComponent((CompositeService)service);
+
+ } else {
+
+ // Found a non-composite service
+ return compositeService.getPromotedComponent();
+ }
+ } else {
+
+ // No promoted service
+ return null;
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
new file mode 100644
index 0000000000..db4bcb0060
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
@@ -0,0 +1,93 @@
+/*
+ * 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;
+
+/**
+ * Represents an abstract property.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractPropertyImpl extends ExtensibleImpl implements AbstractProperty {
+ private Object value;
+ private String name;
+ private QName xsdType;
+ private QName xsdElement;
+ private boolean many;
+ private boolean mustSupply;
+
+ /**
+ * 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;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java
new file mode 100644
index 0000000000..d0ee3832c5
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java
new file mode 100644
index 0000000000..346764b1b4
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
new file mode 100644
index 0000000000..e9939a2d2c
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.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.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.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Endpoint2;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
+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;
+
+/**
+ * A factory for the assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AssemblyFactoryImpl implements AssemblyFactory {
+
+ 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 ConstrainingType createConstrainingType() {
+ return new ConstrainingTypeImpl();
+ }
+
+ 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 Endpoint2 createEndpoint() {
+ return new Endpoint2Impl();
+ }
+
+ public EndpointReference2 createEndpointReference() {
+ return new EndpointReference2Impl();
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java
new file mode 100644
index 0000000000..553e600bc9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java
new file mode 100644
index 0000000000..1e69dfcc87
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.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.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ *
+ */
+public abstract class BindingImpl extends ExtensibleImpl implements Binding {
+ private String name;
+ private ExtensionType type;
+ private String uri;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ 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 getType() {
+ return type;
+ }
+
+ public void setType(ExtensionType type) {
+ this.type = type;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
new file mode 100644
index 0000000000..f8f856f1b4
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.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.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.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>();
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ protected CallbackImpl() {
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ public ExtensionType getType() {
+ return null;
+ }
+
+ public void setType(ExtensionType type) {
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
new file mode 100644
index 0000000000..d751d59f83
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.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 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.ConstrainingType;
+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 ConstrainingType constrainingType;
+ 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());
+ }
+ return clone;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public ConstrainingType getConstrainingType() {
+ return constrainingType;
+ }
+
+ public Implementation getImplementation() {
+ return implementation;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List<ComponentProperty> getProperties() {
+ return properties;
+ }
+
+ public List<ComponentReference> getReferences() {
+ return references;
+ }
+
+ public List<ComponentService> getServices() {
+ return services;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ this.constrainingType = constrainingType;
+ }
+
+ 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 getType() {
+ return type;
+ }
+
+ public void setType(ExtensionType type) {
+ this.type = type;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java
new file mode 100644
index 0000000000..e2e7b59896
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java
@@ -0,0 +1,93 @@
+/*
+ * 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;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
new file mode 100644
index 0000000000..2380bbf088
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.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.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;
+
+ /**
+ * 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;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java
new file mode 100644
index 0000000000..0c78a2505f
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
new file mode 100644
index 0000000000..c79aaf6b2e
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.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.ComponentType;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+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 ConstrainingType constrainingType;
+ 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());
+ }
+ return clone;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public ConstrainingType getConstrainingType() {
+ return constrainingType;
+ }
+
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ public List<Service> getServices() {
+ return services;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ this.constrainingType = constrainingType;
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(getURI()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else {
+ if (obj instanceof ComponentType) {
+ if (getURI() != null) {
+ return getURI().equals(((ComponentType)obj).getURI());
+ } else {
+ return ((ComponentType)obj).getURI() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public ExtensionType getType() {
+ return null;
+ }
+
+ public void setType(ExtensionType type) {
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java
new file mode 100644
index 0000000000..4e14cf0e53
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.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.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() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ CompositeImpl clone = (CompositeImpl)super.clone();
+
+ clone.components = new ArrayList<Component>();
+ for (Component component : getComponents()) {
+ Component clonedComponent = (Component)component.clone();
+ 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.components.add(clonedComponent);
+ }
+ clone.wires = new ArrayList<Wire>();
+ for (Wire wire : getWires()) {
+ clone.wires.add((Wire)wire.clone());
+ }
+ return clone;
+ }
+
+ public String getSpecVersion() {
+ return specVersion;
+ }
+
+ public void setSpecVersion(String specVersion) {
+ this.specVersion = specVersion;
+ }
+
+ public List<Component> getComponents() {
+ return components;
+ }
+
+ 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 ( this.name != null ) ? getName().toString() : "null";
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java
new file mode 100644
index 0000000000..db88798cb5
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.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.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 {
+ return super.clone();
+ }
+
+ public List<ComponentReference> getPromotedReferences() {
+ return promotedReferences;
+ }
+
+ public List<Component> getPromotedComponents() {
+ return promotedComponents;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java
new file mode 100644
index 0000000000..6777a96982
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java
new file mode 100644
index 0000000000..641e0f17df
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.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.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+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.ConstrainingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a constraining type.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeImpl extends ExtensibleImpl implements ConstrainingType {
+ private QName name;
+ private List<AbstractProperty> properties = new ArrayList<AbstractProperty>();
+ private List<AbstractReference> references = new ArrayList<AbstractReference>();
+ private List<AbstractService> services = new ArrayList<AbstractService>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ /**
+ * Constructs a new ConstrainingType
+ */
+ protected ConstrainingTypeImpl() {
+ }
+
+ public QName getName() {
+ return name;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ public List<AbstractProperty> getProperties() {
+ return properties;
+ }
+
+ public List<AbstractReference> getReferences() {
+ return references;
+ }
+
+ public List<AbstractService> getServices() {
+ return services;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(getName()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof ConstrainingType) {
+ if (getName() != null) {
+ return getName().equals(((ConstrainingType)obj).getName());
+ } else {
+ return ((ConstrainingType)obj).getName() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public ExtensionType getType() {
+ return null;
+ }
+
+ public void setType(ExtensionType type) {
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java
new file mode 100644
index 0000000000..a121635323
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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 isCallback() {
+ return isCallback;
+ }
+
+ public void setIsCallback(boolean isCallback) {
+ this.isCallback = isCallback;
+ }
+
+ public ExtensionType getType() {
+ return null;
+ }
+
+ public void setType(ExtensionType type) {
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.java
new file mode 100644
index 0000000000..eb3b87dec0
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.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 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.Endpoint2;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
+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 Endpoint2Impl implements Endpoint2 {
+
+ private Boolean unresolved;
+ private Component component;
+ private ComponentService service;
+ private Binding binding;
+ private InterfaceContract interfaceContract;
+ private List<EndpointReference2> callbackEndpointReferences = new ArrayList<EndpointReference2>();
+ //private String uri;
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+
+ protected Endpoint2Impl() {
+ }
+
+ @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() {
+ return component;
+ }
+
+ public void setComponent(Component component) {
+ this.component = component;
+ }
+
+ public ComponentService getService() {
+ return service;
+ }
+
+ public void setService(ComponentService service) {
+ this.service = service;
+ }
+
+ public Binding getBinding() {
+ return binding;
+ }
+
+ public void setBinding(Binding binding) {
+ this.binding = binding;
+ }
+
+ public InterfaceContract 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<EndpointReference2> getCallbackEndpointReferences(){
+ return callbackEndpointReferences;
+ }
+
+/*
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+*/
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getType() {
+ if (binding instanceof PolicySubject) {
+ return ((PolicySubject)binding).getType();
+ }
+ return null;
+ }
+
+ public void setType(ExtensionType type) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java
new file mode 100644
index 0000000000..58b80d74ec
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java
@@ -0,0 +1,157 @@
+/*
+ * 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.Endpoint2;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
+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 EndpointReference2Impl implements EndpointReference2 {
+
+ // this endpoint reference
+ private Boolean unresolved = true;
+ private Component component;
+ private ComponentReference reference;
+ private Binding binding;
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private InterfaceContract interfaceContract;
+
+ // the target of the endpoint reference
+ private Endpoint2 targetEndpoint;
+// private String uri;
+
+ // callback endpoint that messages across this reference
+ // will be directed toward
+ private Endpoint2 callbackEndpoint;
+
+ protected EndpointReference2Impl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ EndpointReference2 cloned = (EndpointReference2)super.clone();
+
+ if (targetEndpoint != null){
+ cloned.setTargetEndpoint((Endpoint2)targetEndpoint.clone());
+ }
+
+ return cloned;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public Component getComponent() {
+ return component;
+ }
+
+ public void setComponent(Component component) {
+ this.component = component;
+ }
+
+ public ComponentReference getReference() {
+ return reference;
+ }
+
+ public void setReference(ComponentReference reference) {
+ this.reference = reference;
+ }
+
+ public Binding getBinding() {
+ return binding;
+ }
+
+ public void setBinding(Binding binding) {
+ this.binding = binding;
+ }
+
+ public Endpoint2 getTargetEndpoint() {
+ return targetEndpoint;
+ }
+
+ public void setTargetEndpoint(Endpoint2 targetEndpoint) {
+ this.targetEndpoint = targetEndpoint;
+ }
+
+ public InterfaceContract getInterfaceContract() {
+ return interfaceContract;
+ }
+
+ public void setInterfaceContract(InterfaceContract interfaceContract) {
+ this.interfaceContract = interfaceContract;
+ }
+
+ /*
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+ */
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getType() {
+ if (binding instanceof PolicySubject) {
+ return ((PolicySubject)binding).getType();
+ }
+ return null;
+ }
+
+ public void setType(ExtensionType type) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Endpoint2 getCallbackEndpoint() {
+ return callbackEndpoint;
+ }
+
+ public void setCallbackEndpoint(Endpoint2 callbackEndpoint) {
+ this.callbackEndpoint = callbackEndpoint;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java
new file mode 100644
index 0000000000..761799a4d5
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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;
+ }
+} \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java
new file mode 100644
index 0000000000..9befad9f2b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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;
+ 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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
new file mode 100644
index 0000000000..1c28192b3a
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
@@ -0,0 +1,60 @@
+/*
+ * 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.Implementation;
+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;
+
+/**
+ * Base implementation class of Implementation model interface
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ImplementationImpl extends ComponentTypeImpl implements Implementation, PolicySubject {
+ private ExtensionType type;
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+
+ protected ImplementationImpl() {
+ super();
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getType() {
+ return type;
+ }
+
+ public void setType(ExtensionType type) {
+ this.type = type;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java
new file mode 100644
index 0000000000..0c1051199f
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
new file mode 100644
index 0000000000..41d090c9d4
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
@@ -0,0 +1,126 @@
+/*
+ * 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.ComponentService;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
+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 promotionOverride;
+ private List<EndpointReference2> endpointReferences = new ArrayList<EndpointReference2>();
+
+ /**
+ * Constructs a new reference.
+ */
+ protected ReferenceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ReferenceImpl clone = (ReferenceImpl)super.clone();
+ clone.bindings = new ArrayList<Binding>();
+ clone.bindings.addAll(getBindings());
+ clone.targets = new ArrayList<ComponentService>();
+ clone.targets.addAll(getTargets());
+ clone.endpointReferences = new ArrayList<EndpointReference2>();
+ clone.endpointReferences.addAll(getEndpointReferences());
+ 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 boolean isPromotionOverride() {
+ return promotionOverride;
+ }
+
+ public void setPromotionOverride(boolean promotionOverride) {
+ this.promotionOverride = promotionOverride;
+ }
+
+ 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<EndpointReference2> getEndpointReferences() {
+ return endpointReferences;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
new file mode 100644
index 0000000000..a4010400e2
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
@@ -0,0 +1,98 @@
+/*
+ * 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.Endpoint2;
+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 Callback callback;
+ private List<Endpoint2> endpoints = new ArrayList<Endpoint2>();
+
+
+ /**
+ * 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<Endpoint2> getEndpoints() {
+ return endpoints;
+ }
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java
new file mode 100644
index 0000000000..9f8af0907d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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 getType() {
+ return null;
+ }
+
+ public void setType(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/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory b/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
new file mode 100644
index 0000000000..859c4bde4b
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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 \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointFactory b/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointFactory
new file mode 100644
index 0000000000..8dbff76ad9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointFactory
@@ -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.DefaultEndpointFactory \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder b/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder
new file mode 100644
index 0000000000..b7ba756879
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder
@@ -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.
+
+org.apache.tuscany.sca.assembly.builder.impl.ComponentConfigurationBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.ComponentConfigurationBuilder
+org.apache.tuscany.sca.assembly.builder.impl.ComponentReferenceBindingBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.ComponentReferenceBindingBuilder
+org.apache.tuscany.sca.assembly.builder.impl.ComponentReferencePromotionWireBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.ComponentReferencePromotionWireBuilder
+org.apache.tuscany.sca.assembly.builder.impl.ComponentReferenceWireBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.ComponentReferenceWireBuilder
+org.apache.tuscany.sca.assembly.builder.impl.ComponentServiceBindingBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.ComponentServiceBindingBuilder
+org.apache.tuscany.sca.assembly.builder.impl.ComponentServicePromotionBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.ComponentServicePromotionBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositeBindingURIBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeBindingURIBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositeCloneBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeCloneBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositeIncludeBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeIncludeBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositePolicyBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositePolicyBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositePromotionBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositePromotionBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositeReferenceConfigurationBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeReferenceConfigurationBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositeReferenceWireBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeReferenceWireBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositeServiceBindingBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeServiceBindingBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositeServiceConfigurationBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeServiceConfigurationBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositeServicePromotionBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeServicePromotionBuilder
+org.apache.tuscany.sca.assembly.builder.impl.CompositeBindingConfigurationBuilderImpl;id=org.apache.tuscany.assembly.builder.CompositeBindingConfigurationBuilder
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint b/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint
new file mode 100644
index 0000000000..693834e23d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint
@@ -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.DefaultCompositeBuilderExtensionPoint \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/assembly-validation-messages.properties b/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/assembly-validation-messages.properties
new file mode 100644
index 0000000000..6aeda18aab
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/assembly-validation-messages.properties
@@ -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.
+#
+#
+DuplicateComponentName = 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 = Service not found for component service: Component = {0} Service = {1}
+UnresolvedComponentImplementation = Component implementation not found: Component = {0} Uri = {1}
+DuplicateImplementationPropertyName = Duplicate property name: Component = {0} Property = {1}
+DuplicateImplementationServiceName = Duplicate service name: Component = {0} Service = {1}
+DuplicateImplementationReferenceName = Duplicate reference name: Component = {0} Reference = {1}
+PropertyNotFound = Property not found for component property: Component = {0} Property = {1}
+PropertyMustSupplyIncompatible = Component property mustSupply attribute incompatible with property: Component = {0} Property = {1}
+PropertyMustSupplyNull = No value configured on a mustSupply property: Component = {0} Property = {1}
+PropertyOverrideManyAttribute = Component property many attribute incompatible with property: Component = {0} Property = {1}
+ReferenceNotFound = Reference not found for component reference: Component = {0} Reference = {1}
+ReferenceIncompatibleMultiplicity = 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}
+ReferenceIncompatibleComponentInterface = Component reference interface incompatible with reference interface: Component = {0} Reference = {1}
+ServiceIncompatibleComponentInterface = Component service interface incompatible with service interface: Component = {0} Service = {1}
+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 = No targets for reference: Composite = {0} Reference = {1}
+PromotedReferenceNotFound = Promoted component reference not found: Composite = {0} Reference = {1}
+PromotedServiceNotFound = Promoted component service not found: Composite = {0} Service = {1}
+ComponentReferenceTargetNotFound = Component reference target not found, it might be a remote service running elsewhere in the SCA Domain: 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 = Reference {0} must not specify endpoints using both target attribute and with binding uri attribute
+PolicyRelatedException = Policy Related Exception occured due to : {0}
+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 = Too many targets on reference: {0}
+ReferenceInterfaceNotSubSet = Interface of composite reference {0} must be compatible with the interface declared by promoted component reference.
+ServiceInterfaceNotSubSet = Interface of composite service {0} must be subset of the interface declared by promoted component service.
+NoComponentReferenceTarget = 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} \ No newline at end of file
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/assembly-validation-messages_it.properties b/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/assembly-validation-messages_it.properties
new file mode 100644
index 0000000000..b94d37ba2d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/resources/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/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java
new file mode 100644
index 0000000000..e73119204d
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java
@@ -0,0 +1,214 @@
+/*
+ * 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();
+ }
+
+ @Test
+ public void testCreateConstrainingType() {
+ createConstrainingType();
+ }
+
+ /**
+ * 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);
+
+ ConstrainingType constraint = createConstrainingType();
+ c.setConstrainingType(constraint);
+
+ 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;
+ }
+
+ /**
+ * Create a new constraining type
+ *
+ * @return
+ */
+ ConstrainingType createConstrainingType() {
+ ConstrainingType ctype = assemblyFactory.createConstrainingType();
+
+ AbstractProperty p = assemblyFactory.createAbstractProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ ctype.getProperties().add(p);
+
+ AbstractReference ref1 = assemblyFactory.createAbstractReference();
+ ref1.setName("accountDataService");
+ ref1.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref1);
+
+ AbstractReference ref2 = assemblyFactory.createAbstractReference();
+ ref2.setName("stockQuoteService");
+ ref2.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref2);
+
+ AbstractService s = assemblyFactory.createAbstractService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ctype.getServices().add(s);
+
+ return ctype;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java
new file mode 100644
index 0000000000..3a75bbcc36
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.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 org.apache.tuscany.sca.assembly.impl.BindingImpl;
+
+
+/**
+ * A test interface model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestBinding extends BindingImpl implements Binding {
+ public TestBinding(AssemblyFactory factory) {
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public String getURI() {
+ return "http://test";
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java
new file mode 100644
index 0000000000..19702954c9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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) {
+
+ 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/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java
new file mode 100644
index 0000000000..dbe0cb8225
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java
new file mode 100644
index 0000000000..ee6b95edc9
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java
new file mode 100644
index 0000000000..d94a7e93a3
--- /dev/null
+++ b/sandbox/ant/sca/trunk/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/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java
new file mode 100644
index 0000000000..2992aeb263
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.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.builder.impl;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+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.DefaultAssemblyFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test the CompositeBuilder.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeBuilderTestCase {
+
+ private static AssemblyFactory assemblyFactory;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ assemblyFactory = new DefaultAssemblyFactory();
+ }
+
+ @Test
+ public void testFuseIncludes() throws Exception {
+ Composite c1 = assemblyFactory.createComposite();
+ c1.setName(new QName("http://foo", "C1"));
+ Component a = assemblyFactory.createComponent();
+ a.setName("a");
+ c1.getComponents().add(a);
+ CompositeService s = assemblyFactory.createCompositeService();
+ s.setName("s");
+ c1.getServices().add(s);
+ CompositeReference r = assemblyFactory.createCompositeReference();
+ r.setName("r");
+ c1.getReferences().add(r);
+
+ Composite c2 = assemblyFactory.createComposite();
+ c2.setName(new QName("http://foo", "C2"));
+ c1.getIncludes().add(c2);
+ Component b = assemblyFactory.createComponent();
+ b.setName("b");
+ c2.getComponents().add(b);
+
+ Composite c = assemblyFactory.createComposite();
+ c.setName(new QName("http://foo", "C"));
+ c.getIncludes().add(c1);
+
+ new CompositeIncludeBuilderImpl().build(c, null, null);
+
+ assertTrue(c.getComponents().get(0).getName().equals("a"));
+ assertTrue(c.getComponents().get(1).getName().equals("b"));
+ assertTrue(c.getServices().get(0).getName().equals("s"));
+ assertTrue(c.getReferences().get(0).getName().equals("r"));
+ }
+
+ @Test
+ public void testExpandComposites() throws Exception {
+ Composite c1 = assemblyFactory.createComposite();
+ c1.setName(new QName("http://foo", "C1"));
+ Component a = assemblyFactory.createComponent();
+ a.setName("a");
+ c1.getComponents().add(a);
+ CompositeService s = assemblyFactory.createCompositeService();
+ s.setName("s");
+ c1.getServices().add(s);
+ CompositeReference r = assemblyFactory.createCompositeReference();
+ r.setName("r");
+ c1.getReferences().add(r);
+
+ Composite c2 = assemblyFactory.createComposite();
+ c2.setName(new QName("http://foo", "C2"));
+ Component b = assemblyFactory.createComponent();
+ b.setName("b");
+ c2.getComponents().add(b);
+
+ Composite c = assemblyFactory.createComposite();
+ c.setName(new QName("http://foo", "C"));
+ Component x = assemblyFactory.createComponent();
+ x.setName("x");
+ x.setImplementation(c1);
+ c.getComponents().add(x);
+ Component y = assemblyFactory.createComponent();
+ y.setName("y");
+ y.setImplementation(c2);
+ c.getComponents().add(y);
+ Component z = assemblyFactory.createComponent();
+ z.setName("z");
+ z.setImplementation(c1);
+ c.getComponents().add(z);
+
+ new CompositeCloneBuilderImpl().build(c, null, null);
+
+ assertTrue(c.getComponents().get(0).getImplementation() != c1);
+ assertTrue(c.getComponents().get(1).getImplementation() != c2);
+ assertTrue(c.getComponents().get(2).getImplementation() != c1);
+
+ Composite i = (Composite)c.getComponents().get(0).getImplementation();
+ assertTrue(i.getComponents().get(0) != a);
+ assertTrue(i.getComponents().get(0).getName().equals("a"));
+ assertTrue(i.getServices().get(0).getName().equals("s"));
+ assertTrue(i.getServices().get(0) != s);
+ assertTrue(i.getReferences().get(0).getName().equals("r"));
+ assertTrue(i.getReferences().get(0) != r);
+ }
+
+}
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtilTestCase.java b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtilTestCase.java
new file mode 100644
index 0000000000..82b1fd8665
--- /dev/null
+++ b/sandbox/ant/sca/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtilTestCase.java
@@ -0,0 +1,229 @@
+/*
+ * 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.impl;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.xml.namespace.QName;
+
+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.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.ConstrainingType;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+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.TestBinding;
+import org.apache.tuscany.sca.assembly.TestImplementation;
+import org.apache.tuscany.sca.assembly.TestInterfaceContract;
+import org.apache.tuscany.sca.assembly.Wire;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PrintUtilTestCase {
+
+ private AssemblyFactory factory = new DefaultAssemblyFactory();
+
+ /**
+ * Create a composite
+ */
+ Composite createComposite() {
+ Composite c = factory.createComposite();
+
+ Component c1 = createComponent("AccountServiceComponent1");
+ c.getComponents().add(c1);
+ Component c2 = createComponent("AccountServiceComponent2");
+ c.getComponents().add(c2);
+
+ Wire w = factory.createWire();
+ w.setSource(c1.getReferences().get(0));
+ w.setTarget(c2.getServices().get(0));
+ c.getWires().add(w);
+
+ CompositeService cs = factory.createCompositeService();
+ cs.setName("AccountService");
+ cs.setPromotedService(c1.getServices().get(0));
+ cs.setInterfaceContract(new TestInterfaceContract(factory));
+ c.getServices().add(cs);
+ cs.getBindings().add(new TestBinding(factory));
+
+ CompositeReference cr = factory.createCompositeReference();
+ cr.setName("StockQuoteService");
+ cr.getPromotedReferences().add(c2.getReferences().get(1));
+ cr.setInterfaceContract(new TestInterfaceContract(factory));
+ c.getReferences().add(cr);
+ cr.getBindings().add(new TestBinding(factory));
+
+ return c;
+ }
+
+ /**
+ * Create a new component
+ */
+ Component createComponent(String name) {
+ Component c = factory.createComponent();
+ c.setName(name);
+
+ ConstrainingType constraint = createConstrainingType();
+ c.setConstrainingType(constraint);
+
+ Implementation i = new TestImplementation(factory);
+ c.setImplementation(i);
+
+ ComponentProperty p = factory.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 = factory.createComponentReference();
+ ref1.setName("accountDataService");
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ ref1.setInterfaceContract(new TestInterfaceContract(factory));
+ ref1.setReference(i.getReferences().get(0));
+ c.getReferences().add(ref1);
+ ref1.getBindings().add(new TestBinding(factory));
+
+ ComponentReference ref2 = factory.createComponentReference();
+ ref2.setName("stockQuoteService");
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ref2.setInterfaceContract(new TestInterfaceContract(factory));
+ ref2.setReference(i.getReferences().get(1));
+ c.getReferences().add(ref2);
+ ref2.getBindings().add(new TestBinding(factory));
+
+ ComponentService s = factory.createComponentService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(factory));
+ s.setService(i.getServices().get(0));
+ c.getServices().add(s);
+ s.getBindings().add(new TestBinding(factory));
+
+ return c;
+ }
+
+ /**
+ * Create a new component type
+ *
+ * @return
+ */
+ ComponentType createComponentType() {
+ ComponentType ctype = factory.createComponentType();
+
+ Property p = factory.createProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ ctype.getProperties().add(p);
+
+ Reference ref1 = factory.createReference();
+ ref1.setName("accountDataService");
+ ref1.setInterfaceContract(new TestInterfaceContract(factory));
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref1);
+ ref1.getBindings().add(new TestBinding(factory));
+
+ Reference ref2 = factory.createReference();
+ ref2.setName("stockQuoteService");
+ ref2.setInterfaceContract(new TestInterfaceContract(factory));
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref2);
+ ref2.getBindings().add(new TestBinding(factory));
+
+ Service s = factory.createService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(factory));
+ ctype.getServices().add(s);
+ s.getBindings().add(new TestBinding(factory));
+
+ return ctype;
+ }
+
+ /**
+ * Create a new constraining type
+ *
+ * @return
+ */
+ ConstrainingType createConstrainingType() {
+ ConstrainingType ctype = factory.createConstrainingType();
+
+ AbstractProperty p = factory.createAbstractProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ ctype.getProperties().add(p);
+
+ AbstractReference ref1 = factory.createAbstractReference();
+ ref1.setName("accountDataService");
+ ref1.setInterfaceContract(new TestInterfaceContract(factory));
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref1);
+
+ AbstractReference ref2 = factory.createAbstractReference();
+ ref2.setName("stockQuoteService");
+ ref2.setInterfaceContract(new TestInterfaceContract(factory));
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref2);
+
+ AbstractService s = factory.createAbstractService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(factory));
+ ctype.getServices().add(s);
+
+ return ctype;
+ }
+
+ @Test
+ public void testPrint1() {
+ Composite composite = createComposite();
+ StringWriter sw = new StringWriter();
+ PrintUtil p = new PrintUtil(new PrintWriter(sw), true);
+ p.print(composite);
+ // System.out.println(sw.toString());
+ }
+
+ @Test
+ public void testPrint2() {
+ Composite composite = createComposite();
+ StringWriter sw = new StringWriter();
+ PrintUtil p = new PrintUtil(new PrintWriter(sw), false);
+ p.print(composite);
+ // System.out.println(sw.toString());
+ }
+}