summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java6
-rw-r--r--java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java48
-rw-r--r--java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java36
-rw-r--r--java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java36
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario1/scenario1.composite27
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario1/scenario1a.composite27
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml24
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario10/scenario10.composite62
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario10/scenario10a.composite61
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario10/service3.wsdl63
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml24
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario11/scenario11.composite59
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario11/scenario11a.composite64
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario11/service3.wsdl63
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml24
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario12/scenario12.composite58
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario12/scenario12a.composite64
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml24
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario13/scenario13.composite58
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario13/scenario13a.composite64
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario2/scenario2.composite28
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario2/scenario2a.composite28
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario3/scenario3.composite28
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario3/scenario3a.composite28
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario4/scenario4.composite27
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario4/scenario4a.composite27
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml24
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario5/scenario5.composite46
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario5/scenario5a.composite47
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario5/scenarios.wsdl63
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml24
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario6/scenario6.composite47
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario6/scenario6a.composite47
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario6/scenarios.wsdl63
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml24
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario7/scenario7.composite45
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario7/scenario7a.composite49
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario7/scenarios.wsdl63
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml24
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario8/scenario8.composite44
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario8/scenario8a.composite50
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario8/scenarios.wsdl63
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml24
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario9/scenario9.composite60
-rw-r--r--java/sca/itest/builder/src/main/resources/scenario9/scenario9a.composite61
-rw-r--r--java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java797
-rw-r--r--java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java61
-rw-r--r--java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java14
-rw-r--r--java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java203
-rw-r--r--java/sca/itest/policy/src/main/resources/definitions.xml1
-rw-r--r--java/sca/itest/pom.xml1
-rw-r--r--java/sca/itest/validation/src/main/resources/policy/xml/UnableToMapPolicies/definitions.xml6
-rw-r--r--java/sca/itest/validation/src/test/java/policy/xml/UnableToMapPoliciesTestCase.java2
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java14
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java18
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java18
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java355
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java248
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java18
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java165
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java99
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java50
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java50
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java224
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java62
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java2
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java170
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java77
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java169
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java29
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java21
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java11
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java17
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java8
-rw-r--r--java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties1
-rw-r--r--java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java4
-rw-r--r--java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestNode.java464
-rw-r--r--java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java5
-rw-r--r--java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java6
-rw-r--r--java/sca/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties1
-rw-r--r--java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java2
-rw-r--r--java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java2
-rw-r--r--java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java2
-rw-r--r--java/sca/samples/databinding-echo/src/main/resources/EchoDataBinding.composite108
-rw-r--r--java/sca/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite2
85 files changed, 4513 insertions, 920 deletions
diff --git a/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java b/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java
index 538309f619..932ae3987a 100644
--- a/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java
+++ b/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java
@@ -18,6 +18,9 @@
*/
package org.apache.tuscany.sca.itest.builder;
+import java.util.List;
+
+import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
/**
@@ -28,6 +31,9 @@ import org.osoa.sca.annotations.Service;
@Service(interfaces={Service3.class, Service3a.class})
public class ComponentDImpl implements Service3, Service3a {
+ @Reference
+ protected Service3a reference3;
+
public String getGreetings(String name) {
return "Hello, " + name + "!";
}
diff --git a/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java b/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java
new file mode 100644
index 0000000000..f9ef0a1b4f
--- /dev/null
+++ b/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.builder;
+
+import java.util.List;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation class for ComponentD.
+ *
+ * @version $Rev: 678875 $ $Date: 2008-07-22 21:01:07 +0100 (Tue, 22 Jul 2008) $
+ */
+@Service(interfaces={Service3.class, Service3a.class})
+public class ComponentDReferenceMultiplicityImpl implements Service3, Service3a {
+
+ @Reference
+ protected Service3a reference3;
+
+ @Reference
+ protected List<Service3> reference3a;
+
+ public String getGreetings(String name) {
+ return "Hello, " + name + "!";
+ }
+
+ public String getGreetings2(String name) {
+ return "Goodbye, " + name + "!";
+ }
+
+}
diff --git a/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java b/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java
new file mode 100644
index 0000000000..c041a76b47
--- /dev/null
+++ b/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.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.itest.builder;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation class for ComponentD.
+ *
+ * @version $Rev: 678875 $ $Date: 2008-07-22 21:01:07 +0100 (Tue, 22 Jul 2008) $
+ */
+@Service(interfaces={Service3.class})
+public class ComponentEImpl implements Service3 {
+
+
+ public String getGreetings(String name) {
+ return "Hello, " + name + " from ComponentE";
+ }
+}
diff --git a/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java b/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java
new file mode 100644
index 0000000000..ccfeff0997
--- /dev/null
+++ b/java/sca/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.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.itest.builder;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation class for ComponentD.
+ *
+ * @version $Rev: 678875 $ $Date: 2008-07-22 21:01:07 +0100 (Tue, 22 Jul 2008) $
+ */
+@Service(interfaces={Service3.class})
+public class ComponentFImpl implements Service3 {
+
+
+ public String getGreetings(String name) {
+ return "Hello, " + name + " from ComponentF";
+ }
+}
diff --git a/java/sca/itest/builder/src/main/resources/scenario1/scenario1.composite b/java/sca/itest/builder/src/main/resources/scenario1/scenario1.composite
index 4339681fa4..5c2a98ab40 100644
--- a/java/sca/itest/builder/src/main/resources/scenario1/scenario1.composite
+++ b/java/sca/itest/builder/src/main/resources/scenario1/scenario1.composite
@@ -1,3 +1,22 @@
+<?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"
targetNamespace="http://scenario1"
xmlns:tns="http://scenario1"
@@ -7,6 +26,9 @@
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
<binding.ws />
</service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
<component name="ComponentB">
<implementation.composite name="tns:CompositeC" />
@@ -16,7 +38,8 @@
<service name="Service2a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
</component>
-
</composite>
-
diff --git a/java/sca/itest/builder/src/main/resources/scenario1/scenario1a.composite b/java/sca/itest/builder/src/main/resources/scenario1/scenario1a.composite
index 2379a1ffa8..21b5897aa1 100644
--- a/java/sca/itest/builder/src/main/resources/scenario1/scenario1a.composite
+++ b/java/sca/itest/builder/src/main/resources/scenario1/scenario1a.composite
@@ -1,3 +1,22 @@
+<?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"
targetNamespace="http://scenario1"
xmlns:tns="http://scenario1"
@@ -9,6 +28,9 @@
<service name="Service2a" promote="ComponentD/Service3a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference2" promote="ComponentD/reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
<component name="ComponentD">
<implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
@@ -18,7 +40,8 @@
<service name="Service3a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
</component>
</composite>
-
-
diff --git a/java/sca/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml b/java/sca/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..083079ba42
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario10"
+ xmlns:ns10="http://scenario10">
+ <deployable composite="ns10:CompositeA" />
+</contribution>
diff --git a/java/sca/itest/builder/src/main/resources/scenario10/scenario10.composite b/java/sca/itest/builder/src/main/resources/scenario10/scenario10.composite
new file mode 100644
index 0000000000..c24b7f0046
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario10/scenario10.composite
@@ -0,0 +1,62 @@
+<?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"
+ targetNamespace="http://scenario10"
+ xmlns:tns="http://scenario10"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference1a" promote="ComponentB/reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference2" target="ComponentB/Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </reference>
+ <reference name="reference2a" target="ComponentF">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3)" />
+ <binding.ws />
+ </reference>
+ </component>
+
+ <component name="ComponentF">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario10/scenario10a.composite b/java/sca/itest/builder/src/main/resources/scenario10/scenario10a.composite
new file mode 100644
index 0000000000..27a73d5c41
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario10/scenario10a.composite
@@ -0,0 +1,61 @@
+<?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"
+ targetNamespace="http://scenario10"
+ xmlns:tns="http://scenario10"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDReferenceMultiplicityImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference3a" target="ComponentE">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentE">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario10/service3.wsdl b/java/sca/itest/builder/src/main/resources/scenario10/service3.wsdl
new file mode 100644
index 0000000000..14edcc00e6
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario10/service3.wsdl
@@ -0,0 +1,63 @@
+<?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.
+-->
+<wsdl:definitions name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings">
+ <wsdl:part name="getGreetings" element="tns:getGreetings" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part name="getGreetingsResponse" element="tns:getGreetingsResponse" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetings" />
+ <wsdl:output message="tns:getGreetingsResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/java/sca/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml b/java/sca/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..a6e4b65970
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario11"
+ xmlns:ns11="http://scenario11">
+ <deployable composite="ns11:CompositeA" />
+</contribution>
diff --git a/java/sca/itest/builder/src/main/resources/scenario11/scenario11.composite b/java/sca/itest/builder/src/main/resources/scenario11/scenario11.composite
new file mode 100644
index 0000000000..3a94152e6a
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario11/scenario11.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"
+ targetNamespace="http://scenario11"
+ xmlns:tns="http://scenario11"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference1a" promote="ComponentB/reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" target="ComponentF">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentF">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario11/scenario11a.composite b/java/sca/itest/builder/src/main/resources/scenario11/scenario11a.composite
new file mode 100644
index 0000000000..6130c68651
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario11/scenario11a.composite
@@ -0,0 +1,64 @@
+<?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"
+ targetNamespace="http://scenario11"
+ xmlns:tns="http://scenario11"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" target="ComponentB/Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3)" />
+ <binding.ws />
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDReferenceMultiplicityImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference3a" target="ComponentE">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentE">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario11/service3.wsdl b/java/sca/itest/builder/src/main/resources/scenario11/service3.wsdl
new file mode 100644
index 0000000000..14edcc00e6
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario11/service3.wsdl
@@ -0,0 +1,63 @@
+<?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.
+-->
+<wsdl:definitions name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings">
+ <wsdl:part name="getGreetings" element="tns:getGreetings" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part name="getGreetingsResponse" element="tns:getGreetingsResponse" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetings" />
+ <wsdl:output message="tns:getGreetingsResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/java/sca/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml b/java/sca/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..125bdc5e53
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario12"
+ xmlns:ns12="http://scenario12">
+ <deployable composite="ns12:CompositeA" />
+</contribution>
diff --git a/java/sca/itest/builder/src/main/resources/scenario12/scenario12.composite b/java/sca/itest/builder/src/main/resources/scenario12/scenario12.composite
new file mode 100644
index 0000000000..aabd445e23
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario12/scenario12.composite
@@ -0,0 +1,58 @@
+<?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"
+ targetNamespace="http://scenario12"
+ xmlns:tns="http://scenario12"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference1a" promote="ComponentB/reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" target="ComponentF">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentF">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario12/scenario12a.composite b/java/sca/itest/builder/src/main/resources/scenario12/scenario12a.composite
new file mode 100644
index 0000000000..a2ccc47c28
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario12/scenario12a.composite
@@ -0,0 +1,64 @@
+<?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"
+ targetNamespace="http://scenario12"
+ xmlns:tns="http://scenario12"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDReferenceMultiplicityImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws/>
+ </reference>
+ <reference name="reference3a" target="ComponentE">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </reference>
+ </component>
+
+ <component name="ComponentE">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml b/java/sca/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..c906c6c5b0
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario13"
+ xmlns:ns13="http://scenario13">
+ <deployable composite="ns13:CompositeA" />
+</contribution>
diff --git a/java/sca/itest/builder/src/main/resources/scenario13/scenario13.composite b/java/sca/itest/builder/src/main/resources/scenario13/scenario13.composite
new file mode 100644
index 0000000000..ed59cd2adf
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario13/scenario13.composite
@@ -0,0 +1,58 @@
+<?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"
+ targetNamespace="http://scenario13"
+ xmlns:tns="http://scenario13"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference1a" promote="ComponentB/reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentF">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario13/scenario13a.composite b/java/sca/itest/builder/src/main/resources/scenario13/scenario13a.composite
new file mode 100644
index 0000000000..41150f78fd
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario13/scenario13a.composite
@@ -0,0 +1,64 @@
+<?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"
+ targetNamespace="http://scenario13"
+ xmlns:tns="http://scenario13"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDReferenceMultiplicityImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws/>
+ </reference>
+ <reference name="reference3a" target="ComponentE">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </reference>
+ </component>
+
+ <component name="ComponentE">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario2/scenario2.composite b/java/sca/itest/builder/src/main/resources/scenario2/scenario2.composite
index dc225f3d8f..66f88294ff 100644
--- a/java/sca/itest/builder/src/main/resources/scenario2/scenario2.composite
+++ b/java/sca/itest/builder/src/main/resources/scenario2/scenario2.composite
@@ -1,3 +1,22 @@
+<?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"
targetNamespace="http://scenario2"
xmlns:tns="http://scenario2"
@@ -6,16 +25,21 @@
<service name="Service1" promote="ComponentB/Service2">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
<component name="ComponentB">
<implementation.composite name="tns:CompositeC" />
<service name="Service2">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
</service>
<service name="Service2a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
</component>
-
</composite>
-
diff --git a/java/sca/itest/builder/src/main/resources/scenario2/scenario2a.composite b/java/sca/itest/builder/src/main/resources/scenario2/scenario2a.composite
index 505a3d14bb..db1af4743f 100644
--- a/java/sca/itest/builder/src/main/resources/scenario2/scenario2a.composite
+++ b/java/sca/itest/builder/src/main/resources/scenario2/scenario2a.composite
@@ -1,3 +1,22 @@
+<?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"
targetNamespace="http://scenario2"
xmlns:tns="http://scenario2"
@@ -5,11 +24,13 @@
<service name="Service2" promote="ComponentD/Service3">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
- <binding.ws />
</service>
<service name="Service2a" promote="ComponentD/Service3a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference2" promote="ComponentD/reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
<component name="ComponentD">
<implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
@@ -19,7 +40,8 @@
<service name="Service3a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
</component>
</composite>
-
-
diff --git a/java/sca/itest/builder/src/main/resources/scenario3/scenario3.composite b/java/sca/itest/builder/src/main/resources/scenario3/scenario3.composite
index c537ec7b30..4b37c19e4e 100644
--- a/java/sca/itest/builder/src/main/resources/scenario3/scenario3.composite
+++ b/java/sca/itest/builder/src/main/resources/scenario3/scenario3.composite
@@ -1,3 +1,22 @@
+<?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"
targetNamespace="http://scenario3"
xmlns:tns="http://scenario3"
@@ -6,17 +25,20 @@
<service name="Service1" promote="ComponentB/Service2">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
<component name="ComponentB">
<implementation.composite name="tns:CompositeC" />
<service name="Service2">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
- <binding.ws />
</service>
<service name="Service2a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
</component>
-
</composite>
-
diff --git a/java/sca/itest/builder/src/main/resources/scenario3/scenario3a.composite b/java/sca/itest/builder/src/main/resources/scenario3/scenario3a.composite
index 27a76148b6..fedd79ff3d 100644
--- a/java/sca/itest/builder/src/main/resources/scenario3/scenario3a.composite
+++ b/java/sca/itest/builder/src/main/resources/scenario3/scenario3a.composite
@@ -1,3 +1,22 @@
+<?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"
targetNamespace="http://scenario3"
xmlns:tns="http://scenario3"
@@ -5,10 +24,14 @@
<service name="Service2" promote="ComponentD/Service3">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
</service>
<service name="Service2a" promote="ComponentD/Service3a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference2" promote="ComponentD/reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
<component name="ComponentD">
<implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
@@ -18,7 +41,8 @@
<service name="Service3a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
</component>
</composite>
-
-
diff --git a/java/sca/itest/builder/src/main/resources/scenario4/scenario4.composite b/java/sca/itest/builder/src/main/resources/scenario4/scenario4.composite
index cfd4c537b3..1bb876b33d 100644
--- a/java/sca/itest/builder/src/main/resources/scenario4/scenario4.composite
+++ b/java/sca/itest/builder/src/main/resources/scenario4/scenario4.composite
@@ -1,3 +1,22 @@
+<?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"
targetNamespace="http://scenario4"
xmlns:tns="http://scenario4"
@@ -6,6 +25,9 @@
<service name="Service1" promote="ComponentB/Service2">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
<component name="ComponentB">
<implementation.composite name="tns:CompositeC" />
@@ -15,7 +37,8 @@
<service name="Service2a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
</component>
-
</composite>
-
diff --git a/java/sca/itest/builder/src/main/resources/scenario4/scenario4a.composite b/java/sca/itest/builder/src/main/resources/scenario4/scenario4a.composite
index affa80afb3..55e13700a6 100644
--- a/java/sca/itest/builder/src/main/resources/scenario4/scenario4a.composite
+++ b/java/sca/itest/builder/src/main/resources/scenario4/scenario4a.composite
@@ -1,3 +1,22 @@
+<?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"
targetNamespace="http://scenario4"
xmlns:tns="http://scenario4"
@@ -9,6 +28,9 @@
<service name="Service2a" promote="ComponentD/Service3a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference2" promote="ComponentD/reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
<component name="ComponentD">
<implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
@@ -19,7 +41,8 @@
<service name="Service3a">
<!-- bindings and/or interfaces may or may not be specified explicitly here -->
</service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
</component>
</composite>
-
-
diff --git a/java/sca/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml b/java/sca/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..92da17179f
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario5"
+ xmlns:ns5="http://scenario5">
+ <deployable composite="ns5:CompositeA" />
+</contribution>
diff --git a/java/sca/itest/builder/src/main/resources/scenario5/scenario5.composite b/java/sca/itest/builder/src/main/resources/scenario5/scenario5.composite
new file mode 100644
index 0000000000..403e19b087
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario5/scenario5.composite
@@ -0,0 +1,46 @@
+<?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"
+ targetNamespace="http://scenario5"
+ xmlns:tns="http://scenario5"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3a)" />
+ <binding.ws uri="http://foo.com/bar" />
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario5/scenario5a.composite b/java/sca/itest/builder/src/main/resources/scenario5/scenario5a.composite
new file mode 100644
index 0000000000..0e37ded0e4
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario5/scenario5a.composite
@@ -0,0 +1,47 @@
+<?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"
+ targetNamespace="http://scenario5"
+ xmlns:tns="http://scenario5"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario5/scenarios.wsdl b/java/sca/itest/builder/src/main/resources/scenario5/scenarios.wsdl
new file mode 100644
index 0000000000..7480419231
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario5/scenarios.wsdl
@@ -0,0 +1,63 @@
+<?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.
+-->
+<wsdl:definitions name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetings2Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings2">
+ <wsdl:part name="getGreetings2" element="tns:getGreetings2" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings2Response">
+ <wsdl:part name="getGreetings2Response" element="tns:getGreetings2Response" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3a">
+ <wsdl:operation name="getGreetings2">
+ <wsdl:input message="tns:getGreetings2" />
+ <wsdl:output message="tns:getGreetings2Response" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/java/sca/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml b/java/sca/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..42d45b0b98
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario6"
+ xmlns:ns6="http://scenario6">
+ <deployable composite="ns6:CompositeA" />
+</contribution>
diff --git a/java/sca/itest/builder/src/main/resources/scenario6/scenario6.composite b/java/sca/itest/builder/src/main/resources/scenario6/scenario6.composite
new file mode 100644
index 0000000000..1c89139905
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario6/scenario6.composite
@@ -0,0 +1,47 @@
+<?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"
+ targetNamespace="http://scenario6"
+ xmlns:tns="http://scenario6"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference2" target="ComponentB/Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3a)" />
+ <binding.ws />
+ </reference>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario6/scenario6a.composite b/java/sca/itest/builder/src/main/resources/scenario6/scenario6a.composite
new file mode 100644
index 0000000000..853703a353
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario6/scenario6a.composite
@@ -0,0 +1,47 @@
+<?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"
+ targetNamespace="http://scenario6"
+ xmlns:tns="http://scenario6"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario6/scenarios.wsdl b/java/sca/itest/builder/src/main/resources/scenario6/scenarios.wsdl
new file mode 100644
index 0000000000..7480419231
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario6/scenarios.wsdl
@@ -0,0 +1,63 @@
+<?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.
+-->
+<wsdl:definitions name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetings2Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings2">
+ <wsdl:part name="getGreetings2" element="tns:getGreetings2" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings2Response">
+ <wsdl:part name="getGreetings2Response" element="tns:getGreetings2Response" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3a">
+ <wsdl:operation name="getGreetings2">
+ <wsdl:input message="tns:getGreetings2" />
+ <wsdl:output message="tns:getGreetings2Response" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/java/sca/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml b/java/sca/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..44c471cc65
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario7"
+ xmlns:ns7="http://scenario7">
+ <deployable composite="ns7:CompositeA" />
+</contribution>
diff --git a/java/sca/itest/builder/src/main/resources/scenario7/scenario7.composite b/java/sca/itest/builder/src/main/resources/scenario7/scenario7.composite
new file mode 100644
index 0000000000..6b1ac24cec
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario7/scenario7.composite
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario7"
+ xmlns:tns="http://scenario7"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario7/scenario7a.composite b/java/sca/itest/builder/src/main/resources/scenario7/scenario7a.composite
new file mode 100644
index 0000000000..8e0cebbdd5
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario7/scenario7a.composite
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario7"
+ xmlns:tns="http://scenario7"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" target="ComponentB/Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3a)" />
+ <binding.ws />
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario7/scenarios.wsdl b/java/sca/itest/builder/src/main/resources/scenario7/scenarios.wsdl
new file mode 100644
index 0000000000..7480419231
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario7/scenarios.wsdl
@@ -0,0 +1,63 @@
+<?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.
+-->
+<wsdl:definitions name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetings2Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings2">
+ <wsdl:part name="getGreetings2" element="tns:getGreetings2" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings2Response">
+ <wsdl:part name="getGreetings2Response" element="tns:getGreetings2Response" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3a">
+ <wsdl:operation name="getGreetings2">
+ <wsdl:input message="tns:getGreetings2" />
+ <wsdl:output message="tns:getGreetings2Response" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/java/sca/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml b/java/sca/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7cb09d0a74
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario8"
+ xmlns:ns8="http://scenario8">
+ <deployable composite="ns8:CompositeA" />
+</contribution>
diff --git a/java/sca/itest/builder/src/main/resources/scenario8/scenario8.composite b/java/sca/itest/builder/src/main/resources/scenario8/scenario8.composite
new file mode 100644
index 0000000000..26e5ee33fa
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario8/scenario8.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://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario8"
+ xmlns:tns="http://scenario8"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario8/scenario8a.composite b/java/sca/itest/builder/src/main/resources/scenario8/scenario8a.composite
new file mode 100644
index 0000000000..4fa0712199
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario8/scenario8a.composite
@@ -0,0 +1,50 @@
+<?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"
+ targetNamespace="http://scenario8"
+ xmlns:tns="http://scenario8"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3a)" />
+ <binding.ws />
+ </reference>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario8/scenarios.wsdl b/java/sca/itest/builder/src/main/resources/scenario8/scenarios.wsdl
new file mode 100644
index 0000000000..7480419231
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario8/scenarios.wsdl
@@ -0,0 +1,63 @@
+<?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.
+-->
+<wsdl:definitions name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetings2Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings2">
+ <wsdl:part name="getGreetings2" element="tns:getGreetings2" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings2Response">
+ <wsdl:part name="getGreetings2Response" element="tns:getGreetings2Response" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3a">
+ <wsdl:operation name="getGreetings2">
+ <wsdl:input message="tns:getGreetings2" />
+ <wsdl:output message="tns:getGreetings2Response" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/java/sca/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml b/java/sca/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..6e0908702b
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://scenario9"
+ xmlns:ns9="http://scenario9">
+ <deployable composite="ns9:CompositeA" />
+</contribution>
diff --git a/java/sca/itest/builder/src/main/resources/scenario9/scenario9.composite b/java/sca/itest/builder/src/main/resources/scenario9/scenario9.composite
new file mode 100644
index 0000000000..3fce35470e
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario9/scenario9.composite
@@ -0,0 +1,60 @@
+<?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"
+ targetNamespace="http://scenario9"
+ xmlns:tns="http://scenario9"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar"/>
+ </reference>
+ <reference name="reference1a" promote="ComponentB/reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar"/>
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentF">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/main/resources/scenario9/scenario9a.composite b/java/sca/itest/builder/src/main/resources/scenario9/scenario9a.composite
new file mode 100644
index 0000000000..6e86c547b3
--- /dev/null
+++ b/java/sca/itest/builder/src/main/resources/scenario9/scenario9a.composite
@@ -0,0 +1,61 @@
+<?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"
+ targetNamespace="http://scenario9"
+ xmlns:tns="http://scenario9"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDReferenceMultiplicityImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference3a" target="ComponentE">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentE">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java b/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
index 9e17db4646..5f16bc0bea 100644
--- a/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
+++ b/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
@@ -18,28 +18,21 @@
*/
package org.apache.tuscany.sca.itest.builder;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import javax.wsdl.Definition;
-import javax.wsdl.WSDLException;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLWriter;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.stream.XMLStreamWriter;
+import javax.wsdl.Port;
+import javax.xml.namespace.QName;
import junit.framework.TestCase;
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.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.Problem;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
-import org.w3c.dom.Document;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
/**
* Load and build some composites and inspect the results.
@@ -57,102 +50,756 @@ public class BuilderTestCase extends TestCase {
protected void tearDown() throws Exception {
}
+
+ // Scenario 1: <binding.ws> on outer composite service CompositeA/Service1
public void testScenario1() throws Exception {
System.out.println("====>Running testScenario1");
- customBuilder = new CustomCompositeBuilder();
- customBuilder.loadContribution("src/main/resources/scenario1/scenario1.composite",
- "TestContribution", "src/main/resources/scenario1/");
- printResults();
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario1.composite", "TestContribution", "src/main/resources/scenario1/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario1Results(false);
+ }
+
+ public void testScenario1NonWiring() throws Exception {
+ System.out.println("====>Running testScenario1NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario1.composite", "TestContribution", "src/main/resources/scenario1/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario1Results(true);
+ }
+
+ private void checkScenario1Results(boolean nonWiring) {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ if (!nonWiring) {
+ // Should create component service $promoted$.Service1 on innermost component
+ // ComponentD, with <binding.ws> and uri="/Service1"
+ // No other services on ComponentD should have <binding.ws>
+ WebServiceBinding wsBinding = null;
+ for (ComponentService service : componentD.getServices()) {
+ WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
+ if ("$promoted$.Service1".equals(service.getName())) {
+ wsBinding = wsb;
+ } else {
+ assert wsb == null;
+ }
+ }
+ assert "/Service1".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/$promoted$.Service1 with endpoint uri="/Service1"
+ Definition def = wsBinding.getWSDLDocument();
+ javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ Port port = svc.getPort("Service3Port");
+ assert "/Service1".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not create component service $promoted$.Service1 on innermost component ComponentD
+ // No component services on ComponentD should have <binding.ws>
+ for (ComponentService service : componentD.getServices()) {
+ assert !"$promoted$.Service1".equals(service.getName());
+ assert service.getBinding(WebServiceBinding.class) == null;
+ }
+ }
+
+ // No services on ComponentB should have <binding.ws>
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ for (ComponentService service : componentB.getServices()) {
+ assert service.getBinding(WebServiceBinding.class) == null;
+ }
+
+ // No services on CompositeC should have <binding.ws>
+ Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario1", "CompositeC"));
+ for (Service service : compositeC.getServices()) {
+ assert service.getBinding(WebServiceBinding.class) == null;
+ }
+
+ if (nonWiring) {
+ // Should not add a WSDL document to domain composite service Service1
+ WebServiceBinding wsBinding = null;
+ for (Service service : domainComposite.getServices()) {
+ if ("Service1".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ assert wsBinding.getWSDLDocument() == null;
+ }
}
+ // Scenario 2: <binding.ws> on outer component service ComponentB/Service2
public void testScenario2() throws Exception {
System.out.println("====>Running testScenario2");
- customBuilder = new CustomCompositeBuilder();
- customBuilder.loadContribution("src/main/resources/scenario2/scenario2.composite",
- "TestContribution", "src/main/resources/scenario2/");
- printResults();
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario2.composite", "TestContribution", "src/main/resources/scenario2/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario2and3Results("http://scenario2", false);
+ }
+
+ public void testScenario2NonWiring() throws Exception {
+ System.out.println("====>Running testScenario2NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario2.composite", "TestContribution", "src/main/resources/scenario2/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario2and3Results("http://scenario2", true);
}
+ private void checkScenario2and3Results(String namespace, boolean nonWiring) {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ // Should create WSDL document for ComponentB/Service2 with endpoint uri="/ComponentB/Service2"
+ // No other services on ComponentB should have <binding.ws>
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ WebServiceBinding wsBinding = null;
+ for (ComponentService service : componentB.getServices()) {
+ WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
+ if ("Service2".equals(service.getName())) {
+ wsBinding = wsb;
+ } else {
+ assert wsb == null;
+ }
+ }
+ Definition def = wsBinding.getWSDLDocument();
+ javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ Port port = svc.getPort("Service3Port");
+ assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ if (!nonWiring) {
+ // Should create component service $promoted$.ComponentB.Service2 on innermost component
+ // ComponentD, with <binding.ws> and uri="/ComponentB/Service2"
+ wsBinding = null;
+ for (ComponentService service : componentD.getServices()) {
+ if ("$promoted$.ComponentB.Service2".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ assert "/ComponentB/Service2".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/$promoted$.ComponentB.Service2 with endpoint uri="/ComponentB/Service2"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ port = svc.getPort("Service3Port");
+ assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not create component service $promoted$.ComponentB.Service2 on innermost component ComponentD
+ for (ComponentService service : componentD.getServices()) {
+ assert !"$promoted$.ComponentB.Service2".equals(service.getName());
+ }
+ }
+
+ // Should add <binding.ws> to outer composite service CompositeA/Service1
+ wsBinding = null;
+ for (Service service : domainComposite.getServices()) {
+ if ("Service1".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ assert wsBinding != null;
+ if (nonWiring) {
+ // Should not add a WSDL document to domain composite service Service1
+ assert wsBinding.getWSDLDocument() == null;
+ }
+
+ if (!nonWiring) {
+ // Should create component service $promoted$.Service1 on innermost component
+ // ComponentD, with <binding.ws> and uri="/Service1"
+ wsBinding = null;
+ for (ComponentService service : componentD.getServices()) {
+ if ("$promoted$.Service1".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ assert "/Service1".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/$promoted$.Service1 with endpoint uri="/Service1"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ port = svc.getPort("Service3Port");
+ assert "/Service1".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not create component service $promoted$.Service1 on innermost component ComponentD
+ for (ComponentService service : componentD.getServices()) {
+ assert !"$promoted$.Service1".equals(service.getName());
+ }
+ }
+
+ // No services on ComponentD should have <binding.ws>, except for $promoted$.Service1
+ // and $promoted$.ComponentB.Service2
+ for (ComponentService service : componentD.getServices()) {
+ if (!"$promoted$.Service1".equals(service.getName()) &&
+ !"$promoted$.ComponentB.Service2".equals(service.getName())) {
+ assert service.getBinding(WebServiceBinding.class) == null;
+ }
+ }
+
+ // No services on CompositeC should have <binding.ws>, except for Service2 in Scenario 3
+ Composite compositeC = TestUtils.getComposite(domainComposite, new QName(namespace, "CompositeC"));
+ for (Service service : compositeC.getServices()) {
+ if ("http://scenario3".equals(namespace) && "Service2".equals(service.getName())) {
+ assert service.getBinding(WebServiceBinding.class) != null;
+ } else {
+ assert service.getBinding(WebServiceBinding.class) == null;
+ }
+ }
+ }
+
+ // Scenario 3: <binding.ws> on inner composite service CompositeC/Service2
public void testScenario3() throws Exception {
System.out.println("====>Running testScenario3");
- customBuilder = new CustomCompositeBuilder();
- customBuilder.loadContribution("src/main/resources/scenario3/scenario3.composite",
- "TestContribution", "src/main/resources/scenario3/");
- printResults();
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario3.composite", "TestContribution", "src/main/resources/scenario3/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario2and3Results("http://scenario3", false);
+ }
+
+ public void testScenario3NonWiring() throws Exception {
+ System.out.println("====>Running testScenario3NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario3.composite", "TestContribution", "src/main/resources/scenario3/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario2and3Results("http://scenario3", true);
}
+ // Scenario 4: <binding.ws> on inner component service ComponentD/Service3
public void testScenario4() throws Exception {
System.out.println("====>Running testScenario4");
- customBuilder = new CustomCompositeBuilder();
- customBuilder.loadContribution("src/main/resources/scenario4/scenario4.composite",
- "TestContribution", "src/main/resources/scenario4/");
- printResults();
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario4.composite", "TestContribution", "src/main/resources/scenario4/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario4Results(false);
}
- private void printResults() throws Exception {
- for (Problem problem : customBuilder.getMonitor().getProblems()) {
- if (problem.getCause() != null) {
- problem.getCause().printStackTrace();
+ public void testScenario4NonWiring() throws Exception {
+ System.out.println("====>Running testScenario4NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario4.composite", "TestContribution", "src/main/resources/scenario4/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario4Results(true);
+ }
+
+ private void checkScenario4Results(boolean nonWiring) {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ // Should create WSDL document for ComponentD/Service3 with endpoint uri="/ComponentD/Service3"
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ WebServiceBinding wsBinding = null;
+ for (ComponentService service : componentD.getServices()) {
+ if ("Service3".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
}
}
+ Definition def = wsBinding.getWSDLDocument();
+ javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ Port port = svc.getPort("Service3Port");
+ assert "/ComponentB/ComponentD/Service3".equals(TestUtils.getPortAddress(port));
+
+ // Should add <binding.ws> to inner composite service CompositeC/Service2
+ // No other services on CompositeC should have <binding.ws>
+ Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario4", "CompositeC"));
+ wsBinding = null;
+ for (Service service : compositeC.getServices()) {
+ WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
+ if ("Service2".equals(service.getName())) {
+ wsBinding = wsb;
+ } else {
+ assert wsb == null;
+ }
+ }
+ assert "/ComponentB/Service2".equals(wsBinding.getURI());
+
+ // Should add <binding.ws> to outer component service ComponentB/Service2
+ // Should create WSDL document for ComponentB/Service2 with endpoint uri="/ComponentB/Service2"
+ // No other services on ComponentB should have <binding.ws>
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ wsBinding = null;
+ for (ComponentService service : componentB.getServices()) {
+ WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
+ if ("Service2".equals(service.getName())) {
+ wsBinding = wsb;
+ } else {
+ assert wsb == null;
+ }
+ }
+ assert "/ComponentB/Service2".equals(wsBinding.getURI());
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ port = svc.getPort("Service3Port");
+ assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));
+
+ if (!nonWiring) {
+ // Should create component service $promoted$.ComponentB.Service2 on innermost component
+ // ComponentD, with <binding.ws> and uri="/ComponentB/Service2"
+ wsBinding = null;
+ for (ComponentService service : componentD.getServices()) {
+ if ("$promoted$.ComponentB.Service2".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ assert "/ComponentB/Service2".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/$promoted$.ComponentB.Service2 with endpoint uri="/ComponentB/Service2"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ port = svc.getPort("Service3Port");
+ assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not create component service $promoted$.ComponentB.Service2 on innermost component ComponentD
+ for (ComponentService service : componentD.getServices()) {
+ assert !"$promoted$.ComponentB.Service2".equals(service.getName());
+ }
+ }
+
+ // Should add <binding.ws> to outer composite service CompositeA/Service1
+ wsBinding = null;
+ for (Service service : domainComposite.getServices()) {
+ if ("Service1".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ assert wsBinding != null;
+ if (nonWiring) {
+ // Should not add a WSDL document to domain composite service Service1
+ assert wsBinding.getWSDLDocument() == null;
+ }
+
+ if (!nonWiring) {
+ // Should create component service $promoted$.Service1 on innermost component
+ // ComponentD, with <binding.ws> and uri="/Service1"
+ wsBinding = null;
+ for (ComponentService service : componentD.getServices()) {
+ if ("$promoted$.Service1".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ assert "/Service1".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/$promoted$.Service1 with endpoint uri="/Service1"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ port = svc.getPort("Service3Port");
+ assert "/Service1".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not create component service $promoted$.Service1 on innermost component ComponentD
+ for (ComponentService service : componentD.getServices()) {
+ assert !"$promoted$.Service1".equals(service.getName());
+ }
+ }
+
+ // No services on ComponentD should have <binding.ws>, except for Service3,
+ // $promoted$.Service1 and $promoted$.ComponentB.Service2
+ for (ComponentService service : componentD.getServices()) {
+ if (!"Service3".equals(service.getName()) &&
+ !"$promoted$.Service1".equals(service.getName()) &&
+ !"$promoted$.ComponentB.Service2".equals(service.getName())) {
+ assert service.getBinding(WebServiceBinding.class) == null;
+ }
+ }
+ }
+
+ // Scenario 5: <binding.ws> and <interface.wsdl> on outer composite reference CompositeA/reference1
+ public void testScenario5() throws Exception {
+ System.out.println("====>Running testScenario5");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario5.composite", "TestContribution", "src/main/resources/scenario5/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario5Results(false);
+ }
+
+ public void testScenario5NonWiring() throws Exception {
+ System.out.println("====>Running testScenario5NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario5.composite", "TestContribution", "src/main/resources/scenario5/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario5Results(true);
+ }
+
+ private void checkScenario5Results(boolean nonWiring) {
Composite domainComposite = customBuilder.getDomainComposite();
- printComposite(domainComposite);
+
+ // Should not add <binding.ws> to any outer component references
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ for (ComponentReference reference : componentB.getReferences()) {
+ assert reference.getBinding(WebServiceBinding.class) == null;
+ }
+
+ Definition def;
+ javax.wsdl.Service svc;
+ Port port;
+ WebServiceBinding wsBinding;
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ if (!nonWiring) {
+ // Should add <binding.ws> to inner component reference ComponentD/reference3 with uri="http://foo.com/bar"
+ // Should set <interface.wsdl> on inner component reference ComponentD/reference3
+ wsBinding = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getInterfaceContract(wsBinding) instanceof WSDLInterfaceContract;
+ }
+ }
+ assert "http://foo.com/bar".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://scenarios/ComponentD/reference3", "Service3aService"));
+ port = svc.getPort("Service3aPort");
+ assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not add <binding.ws> to any inner component references
+ for (ComponentReference reference : componentD.getReferences()) {
+ assert reference.getBinding(WebServiceBinding.class) == null;
+ }
+ }
+
+ // Should not add <binding.ws> or <interface.wsdl> to inner composite reference CompositeC/reference2
+ Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario5", "CompositeC"));
+ for (Reference reference : compositeC.getReferences()) {
+ assert reference.getBinding(WebServiceBinding.class) == null;
+ assert reference.getInterfaceContract() instanceof JavaInterfaceContract;
+ }
}
- private void printComposite(Composite composite) throws Exception {
- // process implementation composites recursively
- for (Component component : composite.getComponents()) {
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- printComposite((Composite)implementation);
+ // Scenario 6: <binding.ws> and <interface.wsdl> on outer component reference ComponentB/reference2
+ public void testScenario6() throws Exception {
+ System.out.println("====>Running testScenario6");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario6.composite", "TestContribution", "src/main/resources/scenario6/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario6and7Results("http://scenario6", false);
+ }
+
+ public void testScenario6NonWiring() throws Exception {
+ System.out.println("====>Running testScenario6NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario6.composite", "TestContribution", "src/main/resources/scenario6/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario6and7Results("http://scenario6", true);
+ }
+
+ private void checkScenario6and7Results(String namespace, boolean nonWiring) {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ // Should remove target= on ComponentB/reference2 (for Scenario 6) or
+ // CompositeC/reference2 (for Scenario 7), and add uri="http://foo.com/bar"
+ // to the <binding.ws> element on ComponentB/reference2
+ // For nonWiring, ComponentB/reference2 should have target=
+ // and no uri= should be added
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ WebServiceBinding wsBinding = null;
+ for (ComponentReference reference : componentB.getReferences()) {
+ if ("reference2".equals(reference.getName())) {
+ if (!nonWiring) {
+ assert reference.getTargets().size() == 0;
+ } else {
+ assert reference.getTargets().size() == 1;
+ }
+ wsBinding = reference.getBinding(WebServiceBinding.class);
}
}
+ if (!nonWiring) {
+ assert "http://foo.com/bar".equals(wsBinding.getURI());
+ } else {
+ assert wsBinding.getURI() == null;
+ }
- // write out the SCDL
- writeSCDL(composite);
+ Definition def;
+ javax.wsdl.Service svc;
+ Port port;
+ if (!nonWiring) {
+ // Should create WSDL document for ComponentB/reference2 with endpoint uri="http://foo.com/bar"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://scenarios/ComponentB/reference2", "Service3aService"));
+ port = svc.getPort("Service3aPort");
+ assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
+ }
- // find all the component service bindings
- for (Component component : composite.getComponents()) {
- for (ComponentService componentService : component.getServices()) {
- for (Binding binding : componentService.getBindings()) {
- if (binding instanceof WebServiceBinding) {
- writeWSDL(component, componentService, ((WebServiceBinding)binding).getWSDLDocument());
- }
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ if (!nonWiring) {
+ // Should add <binding.ws> to inner component reference ComponentD/reference3 with uri="http://foo.com/bar"
+ // Should set <interface.wsdl> on inner component reference ComponentD/reference3
+ wsBinding = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getBindings().size() == 1;
+ assert reference.getInterfaceContract(wsBinding) instanceof WSDLInterfaceContract;
}
}
+ assert "http://foo.com/bar".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://scenarios/ComponentB/reference2", "Service3aService"));
+ port = svc.getPort("Service3aPort");
+ assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not add <binding.ws> to any inner component references
+ for (ComponentReference reference : componentD.getReferences()) {
+ assert reference.getBinding(WebServiceBinding.class) == null;
+ }
+ }
+
+ // No references on CompositeC should have <binding.ws> or <interface.wsdl>, except for
+ // reference2 in Scenario 7
+ Composite compositeC = TestUtils.getComposite(domainComposite, new QName(namespace, "CompositeC"));
+ for (Reference reference : compositeC.getReferences()) {
+ if ("http://scenario7".equals(namespace) && "reference2".equals(reference.getName())) {
+ assert reference.getBinding(WebServiceBinding.class)!= null;
+ assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
+ } else {
+ assert reference.getBinding(WebServiceBinding.class) == null;
+ assert reference.getInterfaceContract() instanceof JavaInterfaceContract;
+ }
+ }
+
+ // Should add <binding.ws> and <interface.wsdl> to outer composite reference CompositeA/reference1
+ wsBinding = null;
+ for (Reference reference : domainComposite.getReferences()) {
+ if ("reference1".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
+ }
}
+ assert wsBinding.getURI() == null;
+
+ // Should not add a WSDL document to domain composite reference reference1
+ assert wsBinding.getWSDLDocument() == null;
}
- private void writeSCDL(Composite composite) throws Exception {
- // Print out a composite
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- XMLStreamWriter writer = customBuilder.getOutputFactory().createXMLStreamWriter(bos);
- customBuilder.getModelProcessor().write(composite, writer);
-
- // Parse and write again to pretty format it
- DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document document = documentBuilder.parse(new ByteArrayInputStream(bos.toByteArray()));
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
- format.setIndent(2);
- XMLSerializer serializer = new XMLSerializer(System.out, format);
- System.out.println("-->Runtime SCDL model for composite " + composite.getName());
- serializer.serialize(document);
+ // Scenario 7: <binding.ws> and <interface.wsdl> on inner composite reference CompositeC/reference2
+ public void testScenario7() throws Exception {
+ System.out.println("====>Running testScenario7");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario7.composite", "TestContribution", "src/main/resources/scenario7/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario6and7Results("http://scenario7", false);
}
- private void writeWSDL(Component component, ComponentService service, Definition definition) {
- if (definition == null) {
- System.out.println("-->No generated WSDL for " + component.getName() + "/" + service.getName());
+ public void testScenario7NonWiring() throws Exception {
+ System.out.println("====>Running testScenario7NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario7.composite", "TestContribution", "src/main/resources/scenario7/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario6and7Results("http://scenario7", true);
+ }
+
+ // Scenario 8: <binding.ws> and <interface.wsdl> on inner component reference ComponentD/reference3
+ public void testScenario8() throws Exception {
+ System.out.println("====>Running testScenario8");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario8.composite", "TestContribution", "src/main/resources/scenario8/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario8Results(false);
+ }
+
+ public void testScenario8NonWiring() throws Exception {
+ System.out.println("====>Running testScenario8NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario8.composite", "TestContribution", "src/main/resources/scenario8/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario8Results(true);
+ }
+
+ private void checkScenario8Results(boolean nonWiring) {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ // Should replace target= on ComponentD/reference3 by uri="http://foo.com/bar" on <binding.ws>
+ // For nonWiring, the original target= is preserved and there is no uri=
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ WebServiceBinding wsBinding = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3".equals(reference.getName())) {
+ if (!nonWiring) {
+ assert reference.getTargets().size() == 0;
+ } else {
+ assert reference.getTargets().size() == 1;
+ }
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ }
+ }
+ if (!nonWiring) {
+ assert "http://foo.com/bar".equals(wsBinding.getURI());
} else {
- try {
- System.out.println("-->Generated WSDL for " + component.getName() + "/" + service.getName());
- WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
- writer.writeWSDL(definition, System.out);
- } catch (WSDLException e) {
- // ignore
+ assert wsBinding.getURI() == null;
+ }
+
+ Definition def;
+ javax.wsdl.Service svc;
+ Port port;
+ if (!nonWiring) {
+ // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://scenarios/ComponentD/reference3", "Service3aService"));
+ port = svc.getPort("Service3aPort");
+ assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
+ }
+
+ // Should add <binding.ws> and <interface.wsdl> to inner composite reference CompositeC/reference2
+ Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario8", "CompositeC"));
+ wsBinding = null;
+ for (Reference reference : compositeC.getReferences()) {
+ if ("reference2".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
+ }
+ }
+ assert wsBinding.getURI() == null;
+
+ // Should add <binding.ws> and <interface.wsdl> to outer component reference ComponentB/reference2
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ wsBinding = null;
+ for (ComponentReference reference : componentB.getReferences()) {
+ if ("reference2".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
+ }
+ }
+ assert wsBinding.getURI() == null;
+
+ // Should add <binding.ws> and <interface.wsdl> to outer composite reference CompositeA/reference1
+ wsBinding = null;
+ for (Reference reference : domainComposite.getReferences()) {
+ if ("reference1".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
}
}
+ assert wsBinding.getURI() == null;
+
+ // Should not add a WSDL document to domain composite reference reference1
+ assert wsBinding.getWSDLDocument() == null;
}
+ // Scenario 9: target in reference CDR3A and binding.ws uri= at CAR1A
+ public void testScenario9() throws Exception {
+ System.out.println("====>Running testScenario9");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario9.composite", "TestContribution", "src/main/resources/scenario9/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario9Results();
+ }
+
+ private void checkScenario9Results() {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ ComponentReference componentRef = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3a".equals(reference.getName())) {
+ componentRef = reference;
+ assertTrue(reference.getBindings().size() == 2);
+ assertTrue(reference.getBindings().get(0) instanceof SCABinding);
+ assertTrue(reference.getBindings().get(1) instanceof WebServiceBinding);
+ }
+ }
+ assertTrue(componentRef != null);
+ }
+
+ // Scenario 10: targets in references CBR2A and CDR3A and binding.ws at CBR2A
+ public void testScenario10() throws Exception {
+ System.out.println("====>Running testScenario10");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario10.composite", "TestContribution", "src/main/resources/scenario10/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario10And11Results();
+ }
+
+ // Scenario 11: targets in references CBR2A and CDR3A and binding.ws at CCR2A
+ public void testScenario11() throws Exception {
+ System.out.println("====>Running testScenario11");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario11.composite", "TestContribution", "src/main/resources/scenario11/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario10And11Results();
+ }
+
+ private void checkScenario10And11Results() {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ ComponentReference componentRef = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3a".equals(reference.getName())) {
+ componentRef = reference;
+ assertTrue(reference.getBindings().size() == 2);
+ Binding binding1 = reference.getBindings().get(0);
+ assertTrue(binding1 instanceof SCABinding);
+ assertTrue(reference.getInterfaceContract(binding1) instanceof JavaInterfaceContract);
+ Binding binding2 = reference.getBindings().get(1);
+ assertTrue(binding2 instanceof WebServiceBinding);
+ assertTrue(reference.getInterfaceContract(binding2) instanceof WSDLInterfaceContract);
+ }
+ }
+ assertTrue(componentRef != null);
+ }
+
+ // Scenario 12: targets in references CBR2A and CDR3A and binding.ws at CDR3A
+ public void testScenario12() throws Exception {
+ System.out.println("====>Running testScenario12");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario12.composite", "TestContribution", "src/main/resources/scenario12/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario12Results();
+ }
+
+ private void checkScenario12Results() {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ ComponentReference componentRef = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3a".equals(reference.getName())) {
+ componentRef = reference;
+ assertTrue(reference.getBindings().size() == 2);
+ assertTrue(reference.getBindings().get(0) instanceof WebServiceBinding);
+ assertTrue(reference.getBindings().get(1) instanceof WebServiceBinding);
+ }
+ }
+ assertTrue(componentRef != null);
+ }
+
+ // Scenario 13: target in reference CDR3A
+ public void testScenario13() throws Exception {
+ System.out.println("====>Running testScenario13");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario13.composite", "TestContribution", "src/main/resources/scenario13/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario13Results();
+ }
+
+ private void checkScenario13Results() {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ ComponentReference componentRef = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3a".equals(reference.getName())) {
+ componentRef = reference;
+ assertTrue(reference.getBindings().size() == 1);
+ assertTrue(reference.getBindings().get(0) instanceof WebServiceBinding);
+ }
+ }
+ assertTrue(componentRef != null);
+ }
}
diff --git a/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java b/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java
index d39df250ca..cad09920e8 100644
--- a/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java
+++ b/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java
@@ -34,23 +34,34 @@ import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
/**
- * A builder that handles the configuration of the components inside a composite
- * and the wiring of component references to component services.
+ * Test version of org.apache.tuscany.sca.assembly.builder.impl.builder.CompositeBuilderImpl
+ *
+ * This class should be identical to CompositeBuilderImpl except for omitting the
+ * following builders:
+ * componentWireBuilder
+ * compositeReferenceWireBuilder
+ * compositePromotedServiceBuilder
+ * It omits the component wiring step and the special processing that's performed
+ * for composite service and reference promotion.
*
* @version $Rev$ $Date$
*/
public class CompositeBuilderNonWiringImpl implements CompositeBuilder {
private static final Logger logger = Logger.getLogger(CompositeBuilderNonWiringImpl.class.getName());
private CompositeBuilder compositeIncludeBuilder;
- private CompositeBuilder componentWireBuilder;
- private CompositeBuilder compositeReferenceWireBuilder;
+ //private CompositeBuilder componentReferenceWireBuilder;
+ //private CompositeBuilder componentReferencePromotionWireBuilder;
+ //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 compositeServiceBindingBuilder;
private CompositeBuilder componentReferenceBindingBuilder;
/**
@@ -94,15 +105,19 @@ public class CompositeBuilderNonWiringImpl implements CompositeBuilder {
}
compositeIncludeBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeIncludeBuilderImpl(monitor);
- componentWireBuilder = new org.apache.tuscany.sca.assembly.builder.impl.ComponentReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
- compositeReferenceWireBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
+ //componentReferenceWireBuilder = new org.apache.tuscany.sca.assembly.builder.impl.ComponentReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
+ //componentReferencePromotionWireBuilder = new org.apache.tuscany.sca.assembly.builder.impl.ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory, monitor);
+ //compositeReferenceWireBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory, monitor);
compositeCloneBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeCloneBuilderImpl(monitor);
componentConfigurationBuilder = new org.apache.tuscany.sca.assembly.builder.impl.ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
- compositeServiceConfigurationBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeServiceConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+ compositeServiceConfigurationBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeServiceConfigurationBuilderImpl(assemblyFactory);
+ compositeReferenceConfigurationBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeReferenceConfigurationBuilderImpl(assemblyFactory);
+ compositeBindingURIBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+ //componentServicePromotionBuilder = new org.apache.tuscany.sca.assembly.builder.impl.ComponentServicePromotionBuilderImpl(assemblyFactory);
+ //compositeServicePromotionBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeServicePromotionBuilderImpl(assemblyFactory);
compositePromotionBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositePromotionBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
compositePolicyBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositePolicyBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
componentServiceBindingBuilder = new org.apache.tuscany.sca.assembly.builder.impl.ComponentServiceBindingBuilderImpl(monitor);
- compositeServiceBindingBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeServiceBindingBuilderImpl(monitor);
componentReferenceBindingBuilder = new org.apache.tuscany.sca.assembly.builder.impl.ComponentReferenceBindingBuilderImpl(monitor);
}
@@ -122,21 +137,33 @@ public class CompositeBuilderNonWiringImpl implements CompositeBuilder {
// Compute the policies across the model hierarchy
compositePolicyBuilder.build(composite);
+
+ // Configure composite services
+ compositeServiceConfigurationBuilder.build(composite);
+
+ // Configure composite references
+ compositeReferenceConfigurationBuilder.build(composite);
+
+ // Configure binding URIs
+ compositeBindingURIBuilder.build(composite);
+
+ // Create promoted component services
+// componentServicePromotionBuilder.build(composite);
+
+ // Create promoted composite services
+// compositeServicePromotionBuilder.build(composite);
// Build component service binding-related information
componentServiceBindingBuilder.build(composite);
-
- // Build composite service binding-related information
-// compositeServiceBindingBuilder.build(composite);
-
- // Configure composite services
-// compositeServiceConfigurationBuilder.build(composite);
// Wire the components
-// componentWireBuilder.build(composite);
+// componentReferenceWireBuilder.build(composite);
+
+ // Wire the promoted component references
+// componentReferencePromotionWireBuilder.build(composite);
// Wire the composite references
-// compositeReferenceWireBuilder.build(composite);
+// compositeReferenceWireBuilder.build(composite);
// Build component reference binding-related information
componentReferenceBindingBuilder.build(composite);
diff --git a/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java b/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
index e77cd81d2e..82a8ca6689 100644
--- a/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
+++ b/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
@@ -76,7 +76,12 @@ public class CustomCompositeBuilder {
private List<SCADefinitions> policyDefinitions;
private Monitor monitor;
private Composite domainComposite;
-
+ private boolean nonWiring;
+
+ protected CustomCompositeBuilder(boolean nonWiring) {
+ this.nonWiring = nonWiring;
+ }
+
private void init() {
// Create extension point registry
@@ -120,8 +125,11 @@ public class CustomCompositeBuilder {
SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
InterfaceContractMapper contractMapper = utilities.getUtility(InterfaceContractMapper.class);
- domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, contractMapper, monitor);
- //domainCompositeBuilder = new CompositeBuilderNonWiringImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, contractMapper, monitor);
+ if (nonWiring) {
+ domainCompositeBuilder = new CompositeBuilderNonWiringImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, contractMapper, monitor);
+ } else {
+ domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, contractMapper, monitor);
+ }
}
public void loadContribution(String compositeURL, String sourceURI, String sourceURL) throws Exception {
diff --git a/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java b/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java
new file mode 100644
index 0000000000..9bff4d394e
--- /dev/null
+++ b/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.builder;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLStreamWriter;
+import junit.framework.TestCase;
+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.ComponentReference;
+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.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.Document;
+
+/**
+ * Static utility methods for use by test cases.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestUtils {
+
+ protected static void checkProblems(CustomCompositeBuilder customBuilder) throws Exception {
+ boolean problems = false;
+ for (Problem problem : customBuilder.getMonitor().getProblems()) {
+ if (problem.getCause() != null) {
+ problem.getCause().printStackTrace();
+ }
+ problems = true;
+ }
+ assert !problems;
+ }
+
+ protected static String getPortAddress(Port port) {
+ Object ext = port.getExtensibilityElements().get(0);
+ if (ext instanceof SOAPAddress) {
+ return ((SOAPAddress)ext).getLocationURI();
+ }
+ if (ext instanceof SOAP12Address) {
+ return ((SOAP12Address)ext).getLocationURI();
+ }
+ return null;
+ }
+
+ protected static Component getComponent(Composite composite, String name) {
+ for (Component component : composite.getComponents()) {
+ if (name.equals(component.getName())) {
+ return component;
+ }
+ // process implementation composites recursively
+ Implementation impl = component.getImplementation();
+ if (impl instanceof Composite) {
+ Component comp = getComponent((Composite)impl, name);
+ if (comp != null) {
+ return comp;
+ }
+ }
+ }
+ return null;
+ }
+
+ protected static Composite getComposite(Composite composite, QName name) {
+ if (name.equals(composite.getName())) {
+ return composite;
+ }
+ for (Component component : composite.getComponents()) {
+ // process implementation composites recursively
+ Implementation impl = component.getImplementation();
+ if (impl instanceof Composite) {
+ Composite comp = getComposite((Composite)impl, name);
+ if (comp != null) {
+ return comp;
+ }
+ }
+ }
+ return null;
+ }
+
+ protected static void printResults(CustomCompositeBuilder customBuilder) throws Exception {
+ for (Problem problem : customBuilder.getMonitor().getProblems()) {
+ if (problem.getCause() != null) {
+ problem.getCause().printStackTrace();
+ }
+ }
+ Composite domainComposite = customBuilder.getDomainComposite();
+ printComposite(domainComposite, customBuilder);
+ }
+
+ private static void printComposite(Composite composite, CustomCompositeBuilder customBuilder) throws Exception {
+ // process implementation composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ printComposite((Composite)implementation, customBuilder);
+ }
+ }
+
+ // write out the SCDL
+ writeSCDL(composite, customBuilder);
+
+ // find all the component service and reference bindings
+ for (Component component : composite.getComponents()) {
+ for (ComponentService componentService : component.getServices()) {
+ for (Binding binding : componentService.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ writeWSDL(component, componentService, ((WebServiceBinding)binding).getWSDLDocument());
+ }
+ }
+ }
+ for (ComponentReference componentReference : component.getReferences()) {
+ for (Binding binding : componentReference.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ writeWSDL(component, componentReference, ((WebServiceBinding)binding).getWSDLDocument());
+ }
+ }
+ }
+ }
+
+ // find all the composite service and reference bindings
+ for (Service service : composite.getServices()) {
+ for (Binding binding : service.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ writeWSDL(null, service, ((WebServiceBinding)binding).getWSDLDocument());
+ }
+ }
+ }
+ for (Reference reference : composite.getReferences()) {
+ for (Binding binding : reference.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ writeWSDL(null, reference, ((WebServiceBinding)binding).getWSDLDocument());
+ }
+ }
+ }
+ }
+
+ private static void writeSCDL(Composite composite, CustomCompositeBuilder customBuilder) throws Exception {
+ // Print out a composite
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ XMLStreamWriter writer = customBuilder.getOutputFactory().createXMLStreamWriter(bos);
+ customBuilder.getModelProcessor().write(composite, writer);
+
+ // Parse and write again to pretty format it
+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document document = documentBuilder.parse(new ByteArrayInputStream(bos.toByteArray()));
+ OutputFormat format = new OutputFormat();
+ format.setIndenting(true);
+ format.setIndent(2);
+ XMLSerializer serializer = new XMLSerializer(System.out, format);
+ System.out.println("-->Runtime SCDL model for composite " + composite.getName());
+ serializer.serialize(document);
+ }
+
+ private static void writeWSDL(Component component, Contract contract, Definition definition) {
+ if (definition == null) {
+ System.out.println("-->No generated WSDL for " + (component != null ? component.getName() : "") + "/" + contract.getName());
+ } else {
+ try {
+ System.out.println("-->Generated WSDL for " + (component != null ? component.getName() : "") + "/" + contract.getName());
+ WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+ writer.writeWSDL(definition, System.out);
+ } catch (WSDLException e) {
+ // ignore
+ }
+ }
+ }
+
+}
diff --git a/java/sca/itest/policy/src/main/resources/definitions.xml b/java/sca/itest/policy/src/main/resources/definitions.xml
index a3d68044bb..0009d712f3 100644
--- a/java/sca/itest/policy/src/main/resources/definitions.xml
+++ b/java/sca/itest/policy/src/main/resources/definitions.xml
@@ -72,6 +72,7 @@
<wsp:Policy />
</sca:policySet>
+ <sca:intent name="TestIntent_4.Qualifier_1" />
<sca:policySet name="TestPolicySet_2_implementation" provides="ip:TestIntent_2"
appliesTo="sca:implementation.java" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
diff --git a/java/sca/itest/pom.xml b/java/sca/itest/pom.xml
index 45782bd942..029dc9687e 100644
--- a/java/sca/itest/pom.xml
+++ b/java/sca/itest/pom.xml
@@ -59,6 +59,7 @@
</activation>
<modules>
<module>bpel</module>
+ <module>builder</module>
<module>callablereferences</module>
<module>callablereferences-ws</module>
<module>callback-api</module>
diff --git a/java/sca/itest/validation/src/main/resources/policy/xml/UnableToMapPolicies/definitions.xml b/java/sca/itest/validation/src/main/resources/policy/xml/UnableToMapPolicies/definitions.xml
index 14eefadaba..8346dcc01a 100644
--- a/java/sca/itest/validation/src/main/resources/policy/xml/UnableToMapPolicies/definitions.xml
+++ b/java/sca/itest/validation/src/main/resources/policy/xml/UnableToMapPolicies/definitions.xml
@@ -19,6 +19,7 @@
-->
<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:test="http://tuscany.apache.org/xmlns/sca/1.0"
xmlns:calc="http://calculator">
<!-- Extension Types Metadata -->
@@ -46,7 +47,7 @@
<intent name="TestIntentTwo"
constrains="sca:binding"
- requires="TestIntentOne">
+ requires="test:TestIntentOne">
<description>
Protect messages from unauthorized reading or modification
</description>
@@ -91,6 +92,7 @@
</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">
@@ -137,7 +139,7 @@
<policySet name="ConfidentialityPolicies"
provides="test:confidentiality"
- bindings="binding.ws"
+ 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">
diff --git a/java/sca/itest/validation/src/test/java/policy/xml/UnableToMapPoliciesTestCase.java b/java/sca/itest/validation/src/test/java/policy/xml/UnableToMapPoliciesTestCase.java
index 1b064d4b72..2a767d3550 100644
--- a/java/sca/itest/validation/src/test/java/policy/xml/UnableToMapPoliciesTestCase.java
+++ b/java/sca/itest/validation/src/test/java/policy/xml/UnableToMapPoliciesTestCase.java
@@ -51,7 +51,7 @@ public class UnableToMapPoliciesTestCase extends TestCase {
public void testCalculator() {
Monitor monitor = customDomain.getMonitorInstance();
- assertTrue(((DefaultLoggingMonitorImpl)monitor).isMessageLogged("ReferredPolicySetNotFound"));
+ assertTrue(((DefaultLoggingMonitorImpl)monitor).isMessageLogged("UnableToMapPolicies"));
/*Problem problem = ((DefaultLoggingMonitorImpl)monitor).getLastLoggedProblem();
assertNotNull(problem);
assertEquals("UnableToMapPolicies", problem.getMessageId());*/
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
index 55540452af..f9a62774e6 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
@@ -20,6 +20,7 @@ package org.apache.tuscany.sca.assembly;
import java.util.List;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
@@ -78,4 +79,17 @@ public interface Contract extends AbstractContract, PolicySetAttachPoint, Clonea
*/
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/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
index f1522688fc..ee63497fbe 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
@@ -20,6 +20,8 @@ package org.apache.tuscany.sca.assembly;
import java.util.List;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
/**
* Represents an endpoint (primarily a combination of a target service name and a set of
* candidate bindings)
@@ -147,5 +149,19 @@ public interface Endpoint extends Base, Cloneable {
*
* @param binding target binding
*/
- void setTargetBinding(Binding binding);
+ void setTargetBinding(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);
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
index f38346663a..2eb1bf21b0 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
@@ -47,6 +47,24 @@ public interface Reference extends AbstractReference, Contract {
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.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
index 71523bd713..bbdb89ad3c 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
@@ -35,6 +35,7 @@ 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.CompositeService;
+import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
@@ -90,7 +91,7 @@ public abstract class BaseConfigurationBuilderImpl {
protected void configureComponents(Composite composite) throws CompositeBuilderException {
configureComponents(composite, null);
configureSourcedProperties(composite, null);
- configureBindingURIs(composite, null, null);
+ //configureBindingURIs(composite, null, null);
}
/**
@@ -133,7 +134,7 @@ public abstract class BaseConfigurationBuilderImpl {
SCABinding scaBinding = createSCABinding();
service.getBindings().add(scaBinding);
}
-
+/*
// Initialize binding names and URIs
for (Binding binding : service.getBindings()) {
@@ -150,6 +151,7 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
}
+*/
}
// Initialize reference bindings
@@ -159,7 +161,7 @@ public abstract class BaseConfigurationBuilderImpl {
SCABinding scaBinding = createSCABinding();
reference.getBindings().add(scaBinding);
}
-
+/*
// Set binding names
for (Binding binding : reference.getBindings()) {
if (binding.getName() == null) {
@@ -174,6 +176,7 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
}
+*/
}
// Initialize all component services and references
@@ -247,7 +250,7 @@ public abstract class BaseConfigurationBuilderImpl {
SCABinding scaBinding = createSCABinding();
componentService.getBindings().add(scaBinding);
}
-
+/*
// Set binding names
for (Binding binding : componentService.getBindings()) {
@@ -263,6 +266,7 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
}
+*/
}
// Initialize reference bindings
@@ -273,7 +277,7 @@ public abstract class BaseConfigurationBuilderImpl {
SCABinding scaBinding = createSCABinding();
componentReference.getBindings().add(scaBinding);
}
-
+/*
// Set binding names
for (Binding binding : componentReference.getBindings()) {
if (binding.getName() == null) {
@@ -287,6 +291,7 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
}
+*/
}
}
}
@@ -796,208 +801,6 @@ public abstract class BaseConfigurationBuilderImpl {
}
/**
- * Activate composite services in nested composites.
- *
- * @param composite
- * @param problems
- */
- protected void configureCompositeServices(Composite composite) {
-
- // Process nested composites recursively
- configureNestedCompositeServices(composite);
-
- // Process top level composite services
- for (Service service : composite.getServices()) {
- CompositeService compositeService = (CompositeService)service;
-
- // Get the inner most promoted service
- ComponentService promotedService = ServiceConfigurationUtil.getPromotedComponentService(compositeService);
- if (promotedService != null) {
- Component promotedComponent = getPromotedComponent(compositeService);
-
- // Default to use the interface from the promoted service
- if (compositeService.getInterfaceContract() == null && promotedService.getInterfaceContract() != null) {
- compositeService.setInterfaceContract(promotedService.getInterfaceContract());
- }
-
- // 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());
- // set the bindings using the top level bindings to override the
- // lower level bindings
- if (bindingsSpecifiedManually(compositeService.getBindings())){
- newComponentService.getBindings()
- .addAll(compositeService.getBindings());
- } else {
- for (Binding binding : promotedService.getBindings()){
- try {
- newComponentService.getBindings().add((Binding)binding.clone());
- } catch(CloneNotSupportedException ex){
- // this binding can't be used in the promoted service
- }
- }
- }
- newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
- if (compositeService.getInterfaceContract() != null && compositeService
- .getInterfaceContract().getCallbackInterface() != null) {
- newComponentService.setCallback(assemblyFactory.createCallback());
- if ((compositeService.getCallback() != null) &&
- (bindingsSpecifiedManually(compositeService.getCallback().getBindings()))){
- newComponentService.getCallback().getBindings()
- .addAll(compositeService.getCallback().getBindings());
- } else if ((promotedService.getCallback() != null) &&
- (bindingsSpecifiedManually(promotedService.getCallback().getBindings()))){
- for (Binding binding : promotedService.getCallback().getBindings()){
- try {
- newComponentService.getCallback().getBindings().add((Binding)binding.clone());
- } catch(CloneNotSupportedException ex){
- // this binding can't be used in the promoted service
- }
- }
- }
- }
-
- // Change the composite service to now promote the newly
- // created component service directly
- compositeService.setPromotedComponent(promotedComponent);
- compositeService.setPromotedService(newComponentService);
- }
- }
- }
-
- /**
- * Activate composite services in nested composites.
- *
- * @param composite
- * @param problems
- */
- 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 inner most promoted service
- ComponentService promotedService =
- ServiceConfigurationUtil.getPromotedComponentService(compositeService);
- if (promotedService != null) {
- Component promotedComponent = getPromotedComponent(compositeService);
-
- // Default to use the interface from the promoted
- // service
- if (compositeService.getInterfaceContract() == null) {
- compositeService.setInterfaceContract(promotedService
- .getInterfaceContract());
- }
- if (componentService.getInterfaceContract() == null) {
- componentService.setInterfaceContract(promotedService
- .getInterfaceContract());
- }
-
- // Create a new component service to represent this
- // composite service on the promoted component
- ComponentService newComponentService =
- assemblyFactory.createComponentService();
- newComponentService.setName("$promoted$." + componentService.getName());
- promotedComponent.getServices().add(newComponentService);
- newComponentService.setService(promotedService.getService());
-
- // set the bindings using the top level bindings to override the
- // lower level bindings
- if (bindingsSpecifiedManually(componentService.getBindings())){
- newComponentService.getBindings()
- .addAll(componentService.getBindings());
- } else if (bindingsSpecifiedManually(compositeService.getBindings())){
- newComponentService.getBindings()
- .addAll(compositeService.getBindings());
- } else {
- for (Binding binding : promotedService.getBindings()){
- try {
- newComponentService.getBindings().add((Binding)binding.clone());
- } catch(CloneNotSupportedException ex){
- // this binding can't be used in the promoted service
- }
- }
- }
-
- newComponentService.setInterfaceContract(componentService
- .getInterfaceContract());
-
- if (componentService.getInterfaceContract() != null &&
- componentService.getInterfaceContract().getCallbackInterface() != null) {
-
- newComponentService.setCallback(assemblyFactory.createCallback());
-
- // set the bindings using the top level bindings to override the
- // lower level bindings
- if ((componentService.getCallback() != null) &&
- (bindingsSpecifiedManually(componentService.getCallback().getBindings()))){
- newComponentService.getCallback().getBindings()
- .addAll(componentService.getCallback().getBindings());
- } else if ((compositeService.getCallback() != null) &&
- (bindingsSpecifiedManually(compositeService.getCallback().getBindings()))){
- newComponentService.getCallback().getBindings()
- .addAll(compositeService.getCallback().getBindings());
- } else if ((promotedService.getCallback() != null) &&
- (bindingsSpecifiedManually(promotedService.getCallback().getBindings()))){
- for (Binding binding : promotedService.getCallback().getBindings()){
- try {
- newComponentService.getCallback().getBindings().add((Binding)binding.clone());
- } catch(CloneNotSupportedException ex){
- // this binding can't be used in the promoted service
- }
- }
- }
- }
-
- // Change the composite service to now promote the
- // newly created component service directly
- compositeService.setPromotedComponent(promotedComponent);
- compositeService.setPromotedService(newComponentService);
- }
- }
- }
- }
- }
- }
-
- /**
- * 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() == true )){
- return false;
- } else if (bindings.size() == 1) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
* @param composite
*/
private void configureSourcedProperties(Composite composite, List<ComponentProperty> propertySettings) {
@@ -1027,34 +830,6 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
- /**
- * Follow a service promotion chain down to the inner most (non composite)
- * component.
- *
- * @param compositeService
- * @return
- */
- protected 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;
- }
- }
-
private ComponentProperty getComponentPropertyByName(String propertyName, List<ComponentProperty> properties) {
if (properties != null) {
for (ComponentProperty aProperty : properties) {
@@ -1069,8 +844,8 @@ public abstract class BaseConfigurationBuilderImpl {
private SCABinding createSCABinding() {
SCABinding scaBinding = scaBindingFactory.createSCABinding();
- // mark the bindings that are added automatically so that theu can
- // can be disregarded for overriding purposes
+ // mark the bindings that are added automatically so that they can
+ // be disregarded for overriding purposes
if (scaBinding instanceof AutomaticBinding){
((AutomaticBinding)scaBinding).setIsAutomatic(true);
}
@@ -1087,6 +862,16 @@ public abstract class BaseConfigurationBuilderImpl {
}
/**
+ * Called by CompositeBindingURIBuilderImpl
+ *
+ * @param composite the composite to be configured
+ */
+ protected void configureBindingURIsAndNames(Composite composite) throws CompositeBuilderException {
+ configureBindingURIs(composite, null, null);
+ configureBindingNames(composite);
+ }
+
+ /**
* 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.
@@ -1103,7 +888,13 @@ public abstract class BaseConfigurationBuilderImpl {
* 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.
*
- * TODO: Share the URL calculation algorithm with the configureComponents() method above
+ * 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
@@ -1204,23 +995,96 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
}
+
+ /**
+ * 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) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // Process nested composite
+ configureBindingNames((Composite)implementation);
+ }
+ }
+
+ // Initialize composite service callback binding names
+ for (Service service : composite.getServices()) {
+
+ if (service.getCallback() != null) {
+ for (Binding binding : service.getCallback().getBindings()) {
+ constructBindingName(service, binding);
+ }
+ }
+ }
+
+ // Initialize composite reference binding names
+ for (Reference reference : composite.getReferences()) {
+
+ for (Binding binding : reference.getBindings()) {
+ constructBindingName(reference, binding);
+ }
+
+ if (reference.getCallback() != null) {
+ for (Binding binding : reference.getCallback().getBindings()) {
+ constructBindingName(reference, binding);
+ }
+ }
+ }
+
+ // 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);
+ }
+ }
+ }
+
+ // Initialize component reference binding names
+ for (ComponentReference reference : component.getReferences()) {
+
+ // Initialize binding names
+ for (Binding binding : reference.getBindings()) {
+ constructBindingName(reference, binding);
+ }
+
+ if (reference.getCallback() != null) {
+ for (Binding binding : reference.getCallback().getBindings()) {
+ constructBindingName(reference, binding);
+ }
+ }
+ }
+ }
+ }
/**
- * If a binding name is not provided by the user construct it based on the service name
+ * If a binding name is not provided by the user, construct it based on the service
+ * or reference name
*
- * @param service
+ * @param contract the service or reference
* @param binding
*/
- private void constructBindingName(Service service, Binding binding) throws CompositeBuilderException{
+ private void constructBindingName(Contract contract, Binding binding) {
// set the default binding name if one is required
- // if there is no name on the binding then set it to the service name
+ // if there is no name on the binding then set it to the service or reference name
if (binding.getName() == null){
- binding.setName(service.getName());
+ binding.setName(contract.getName());
}
// Check that multiple bindings do not have the same name
- for (Binding otherBinding : service.getBindings()) {
+ for (Binding otherBinding : contract.getBindings()) {
if (otherBinding == binding) {
// Skip the current binding
continue;
@@ -1230,7 +1094,8 @@ public abstract class BaseConfigurationBuilderImpl {
continue;
}
if (binding.getName().equals(otherBinding.getName())) {
- warning("MultipleBindingsForService", binding, service.getName(), binding.getName());
+ warning(contract instanceof Service ? "MultipleBindingsForService" : "MultipleBindingsForReference",
+ binding, contract.getName(), binding.getName());
}
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
index 544240d07e..0c2d02ab48 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
@@ -424,6 +424,7 @@ class BaseWireBuilderImpl {
endpoint.setTargetName(targetComponent.getName());
endpoint.setSourceComponent(null); // TODO - fixed up at start
endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.setTargetComponent(targetComponent);
endpoint.setTargetComponentService(targetComponentService);
endpoint.getCandidateBindings().addAll(componentReference.getBindings());
@@ -477,7 +478,8 @@ class BaseWireBuilderImpl {
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(targetComponent.getName());
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.setTargetComponent(targetComponent);
endpoint.setTargetComponentService(targetComponentService);
endpoint.getCandidateBindings().addAll(componentReference.getBindings());
@@ -498,7 +500,8 @@ class BaseWireBuilderImpl {
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(name);
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.getCandidateBindings().addAll(componentReference.getBindings());
endpoints.add(endpoint);
@@ -536,7 +539,8 @@ class BaseWireBuilderImpl {
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(targetComponent.getName());
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.setTargetComponent(targetComponent);
endpoint.setTargetComponentService(targetComponentService);
endpoint.getCandidateBindings().addAll(componentReference.getBindings());
@@ -560,7 +564,8 @@ class BaseWireBuilderImpl {
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(name);
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.getCandidateBindings().addAll(componentReference.getBindings());
endpoints.add(endpoint);
@@ -625,7 +630,8 @@ class BaseWireBuilderImpl {
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(targetComponent.getName());
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.setTargetComponent(targetComponent);
endpoint.setTargetComponentService(targetComponentService);
endpoint.getCandidateBindings().add(binding);
@@ -639,16 +645,14 @@ class BaseWireBuilderImpl {
}
} else {
- /* TODO - don't enable this yet as we have tests that
- use relative URIs in bindings that don't refer to
- targets
+ // create endpoints for manually configured bindings
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(uri);
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
- endpoint.getCandidateBindings().add(binding);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
+ endpoint.setSourceBinding(binding);
endpoints.add(endpoint);
- */
}
}
}
@@ -679,8 +683,16 @@ class BaseWireBuilderImpl {
componentReference.getEndpoints().addAll(endpoints);
+ // the result of calculating the endpoints is either that bindings have been
+ // configured manually using a URI or that targets have been provided and the
+ // endpoint remains unresolved. So all endpoints should be either resved or uresolved.
+ boolean endpointsRequireAutomaticResolution = false;
+ for(Endpoint endpoint : endpoints){
+ endpointsRequireAutomaticResolution = endpoint.isUnresolved();
+ }
+
// build each endpoint
- if (!endpoints.isEmpty()) {
+ if (endpointsRequireAutomaticResolution) {
for(Endpoint endpoint : endpoints){
endpointBuilder.build(endpoint);
@@ -939,218 +951,6 @@ class BaseWireBuilderImpl {
// Clear the list of wires
composite.getWires().clear();
}
-
- /**
- * Wire composite references in nested composites.
- *
- * @param composite
- * @param problems
- */
- protected void wireCompositeReferences(Composite composite) {
-
- // Process nested composites recursively
- for (Component component : composite.getComponents()) {
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- wireCompositeReferences((Composite)implementation);
- }
- }
-
- // Process composite references declared in this composite
- for (Reference reference : composite.getReferences()) {
- CompositeReference compositeReference = (CompositeReference)reference;
- List<ComponentReference> promotedReferences = getPromotedComponentReferences(compositeReference);
- for (ComponentReference promotedReference : promotedReferences) {
-
- reconcileReferenceBindings(compositeReference, promotedReference);
- 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());
- }
- }
- }
- }
-
- // Process the 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) {
- CompositeReference compositeReference = (CompositeReference)implReference;
- List<ComponentReference> promotedReferences =
- getPromotedComponentReferences(compositeReference);
- for (ComponentReference promotedReference : promotedReferences) {
-
- // Override the configuration of the promoted reference
- reconcileReferenceBindings(componentReference, promotedReference);
- 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());
- }
- }
-
- // Wire the promoted reference to the actual
- // non-composite component services
- if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE || 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 {
- 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);
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * Follow a reference promotion chain down to the inner most (non composite)
- * component references.
- *
- * @param compositeReference
- * @return
- */
- private List<ComponentReference> getPromotedComponentReferences(CompositeReference compositeReference) {
- List<ComponentReference> componentReferences = new ArrayList<ComponentReference>();
- collectPromotedComponentReferences(compositeReference, componentReferences);
- return componentReferences;
- }
-
- /**
- * Follow a reference promotion chain down to the inner most (non composite)
- * component references.
- *
- * @param compositeReference
- * @param componentReferences
- * @return
- */
- private 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
- */
- private void reconcileReferenceBindings(Reference reference, ComponentReference promotedReference) {
- List<Binding> bindings = new ArrayList<Binding>();
-
- // collect the top level bindings first
- for (Binding binding : reference.getBindings()) {
- if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
- bindings.add(binding);
- }
- }
-
- // if there are not top level bindings to override the promoted bindings
- // then collect the promoted bindings
- if (bindings.size() == 0){
- for (Binding binding : promotedReference.getBindings()) {
- if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
- bindings.add(binding);
- }
- }
- }
-
- promotedReference.getBindings().clear();
- promotedReference.getBindings().addAll(bindings);
-
- if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE || promotedReference.getMultiplicity() == Multiplicity.ZERO_ONE) {
- if (promotedReference.getBindings().size() > 1) {
- warning("ComponentReferenceMoreWire", promotedReference, promotedReference.getName());
- }
- }
- 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);
- }
- }
- }
private void addPoliciesFromPromotedService(CompositeService compositeService) {
//inherit intents and policies from promoted service
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java
index dc0628a54f..4913705e91 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java
@@ -47,16 +47,8 @@ public class ComponentReferenceBindingBuilderImpl implements CompositeBuilder {
}
private void buildReferenceBindings(Composite composite) {
-
- // build bindings recursively
- for (Component component : composite.getComponents()) {
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- buildReferenceBindings((Composite)implementation);
- }
- }
- // find all the component reference bindings
+ // 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()) {
@@ -66,6 +58,14 @@ public class ComponentReferenceBindingBuilderImpl implements CompositeBuilder {
}
}
}
+
+ // build bindings recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ buildReferenceBindings((Composite)implementation);
+ }
+ }
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java
new file mode 100644
index 0000000000..c0702c87b3
--- /dev/null
+++ b/java/sca/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.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.EndpointFactory;
+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.SCABinding;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+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;
+ private EndpointFactory endpointFactory;
+ private Monitor monitor;
+
+ public ComponentReferencePromotionWireBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory, Monitor monitor) {
+ this.assemblyFactory = assemblyFactory;
+ this.endpointFactory = endpointFactory;
+ this.monitor = monitor;
+ }
+
+ public void build(Composite composite) throws CompositeBuilderException {
+ wireCompositeReferences(composite);
+ }
+
+ /**
+ * Wire composite references in nested composites.
+ *
+ * @param composite
+ * @param problems
+ */
+ private void wireCompositeReferences(Composite composite) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ wireCompositeReferences((Composite)implementation);
+ }
+ }
+
+ // 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.getEndpoints().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, endpointFactory, 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());
+ }
+ }
+
+ // 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 {
+ 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/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java
new file mode 100644
index 0000000000..53e6eda1eb
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.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.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.Implementation;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+
+/**
+ * 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 void build(Composite composite) 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() + "." + 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/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
new file mode 100644
index 0000000000..4c2c369f3e
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder.impl;
+
+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.definitions.SCADefinitions;
+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 BaseConfigurationBuilderImpl implements CompositeBuilder {
+
+ public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ InterfaceContractMapper interfaceContractMapper,
+ SCADefinitions policyDefinitions,
+ Monitor monitor) {
+ super(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+ }
+
+ public void build(Composite composite) throws CompositeBuilderException {
+ configureBindingURIsAndNames(composite);
+ }
+
+}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
index dd80312b4b..6fc946b29a 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
@@ -42,15 +42,19 @@ import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
public class CompositeBuilderImpl implements CompositeBuilder {
private static final Logger logger = Logger.getLogger(CompositeBuilderImpl.class.getName());
private CompositeBuilder compositeIncludeBuilder;
- private CompositeBuilder componentWireBuilder;
+ private CompositeBuilder componentReferenceWireBuilder;
+ private CompositeBuilder componentReferencePromotionWireBuilder;
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 compositeServiceBindingBuilder;
private CompositeBuilder componentReferenceBindingBuilder;
/**
@@ -94,15 +98,19 @@ public class CompositeBuilderImpl implements CompositeBuilder {
}
compositeIncludeBuilder = new CompositeIncludeBuilderImpl(monitor);
- componentWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
- compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
+ componentReferenceWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
+ componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory, monitor);
+ compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory, monitor);
compositeCloneBuilder = new CompositeCloneBuilderImpl(monitor);
componentConfigurationBuilder = new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
- compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+ compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory);
+ compositeReferenceConfigurationBuilder = new CompositeReferenceConfigurationBuilderImpl(assemblyFactory);
+ compositeBindingURIBuilder = new CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+ componentServicePromotionBuilder = new ComponentServicePromotionBuilderImpl(assemblyFactory);
+ compositeServicePromotionBuilder = new CompositeServicePromotionBuilderImpl(assemblyFactory);
compositePromotionBuilder = new CompositePromotionBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
compositePolicyBuilder = new CompositePolicyBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
componentServiceBindingBuilder = new ComponentServiceBindingBuilderImpl(monitor);
- compositeServiceBindingBuilder = new CompositeServiceBindingBuilderImpl(monitor);
componentReferenceBindingBuilder = new ComponentReferenceBindingBuilderImpl(monitor);
}
@@ -119,28 +127,40 @@ public class CompositeBuilderImpl implements CompositeBuilder {
// Connect composite services/references to promoted services/references
compositePromotionBuilder.build(composite);
-
+
// Compute the policies across the model hierarchy
compositePolicyBuilder.build(composite);
- // Build component service binding-related information
- componentServiceBindingBuilder.build(composite);
-
- // Build composite service binding-related information
- compositeServiceBindingBuilder.build(composite);
-
// Configure composite services
compositeServiceConfigurationBuilder.build(composite);
+ // Configure composite references
+ compositeReferenceConfigurationBuilder.build(composite);
+
+ // Configure binding URIs
+ compositeBindingURIBuilder.build(composite);
+
+ // Create promoted component services
+ componentServicePromotionBuilder.build(composite);
+
+ // Create promoted composite services
+ compositeServicePromotionBuilder.build(composite);
+
+ // Build component service binding-related information
+ componentServiceBindingBuilder.build(composite);
+
// Wire the components
- componentWireBuilder.build(composite);
+ componentReferenceWireBuilder.build(composite);
+
+ // Wire the promoted component references
+ componentReferencePromotionWireBuilder.build(composite);
// Wire the composite references
compositeReferenceWireBuilder.build(composite);
// Build component reference binding-related information
componentReferenceBindingBuilder.build(composite);
-
+
// Fuse nested composites
//FIXME do this later
//cloneBuilder.fuseCompositeImplementations(composite);
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java
new file mode 100644
index 0000000000..41462b151d
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.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.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.Reference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.AutomaticBinding;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+
+/**
+ * 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 void build(Composite composite) throws CompositeBuilderException {
+
+ // Process nested composites recursively
+ configureNestedCompositeReferences(composite);
+
+ // Process top level composite references
+ 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/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java
index 56b3fc79dd..8aa1897311 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java
@@ -19,12 +19,19 @@
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.EndpointFactory;
+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.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
/**
@@ -32,13 +39,58 @@ import org.apache.tuscany.sca.monitor.Monitor;
*
* @version $Rev$ $Date$
*/
-public class CompositeReferenceWireBuilderImpl extends BaseWireBuilderImpl implements CompositeBuilder {
+public class CompositeReferenceWireBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+ private EndpointFactory endpointFactory;
+ private Monitor monitor;
- public CompositeReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory, InterfaceContractMapper interfaceContractMapper, Monitor monitor) {
- super(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
+ public CompositeReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory, Monitor monitor) {
+ this.assemblyFactory = assemblyFactory;
+ this.endpointFactory = endpointFactory;
+ this.monitor = monitor;
}
+ /**
+ * Wire composite references in a deployment composite.
+ *
+ * @param composite
+ */
public void build(Composite composite) throws CompositeBuilderException {
- wireCompositeReferences(composite);
+
+ // 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, endpointFactory, 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/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java
index 3842fee909..3aa9f3bf85 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java
@@ -61,7 +61,7 @@ public class CompositeServiceBindingBuilderImpl implements CompositeBuilder {
for (Service service : composite.getServices()) {
for (Binding binding : service.getBindings()) {
if (binding instanceof BindingBuilderExtension) {
- Component component = BaseConfigurationBuilderImpl.getPromotedComponent((CompositeService)service);
+ Component component = ServiceConfigurationUtil.getPromotedComponent((CompositeService)service);
((BindingBuilderExtension)binding).getBuilder().build(component, service, binding, monitor);
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java
index 7303570ac8..a3f31ea2fa 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java
@@ -19,32 +19,176 @@
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.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Implementation;
+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.SCADefinitions;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
-import org.apache.tuscany.sca.monitor.Monitor;
/**
* A composite builder that handles the configuration of composite services.
*
* @version $Rev$ $Date$
*/
-public class CompositeServiceConfigurationBuilderImpl extends BaseConfigurationBuilderImpl implements CompositeBuilder {
-
- public CompositeServiceConfigurationBuilderImpl(AssemblyFactory assemblyFactory,
- SCABindingFactory scaBindingFactory,
- InterfaceContractMapper interfaceContractMapper,
- SCADefinitions policyDefinitions,
- Monitor monitor) {
- super(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public CompositeServiceConfigurationBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
}
public void build(Composite composite) throws CompositeBuilderException {
- configureCompositeServices(composite);
+
+ // Process nested composites recursively
+ configureNestedCompositeServices(composite);
+
+ // 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/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java
new file mode 100644
index 0000000000..39d2cec396
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.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.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;
+
+/**
+ * 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 void build(Composite composite) 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/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java
index 5d3d8a3a04..23d547efaf 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java
@@ -18,11 +18,23 @@
*/
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.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointFactory;
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
@@ -30,6 +42,21 @@ import org.apache.tuscany.sca.assembly.OptimizableBinding;
* @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 = new ProblemImpl(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) {
@@ -92,4 +119,146 @@ abstract class ReferenceConfigurationUtil {
}
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,
+ EndpointFactory endpointFactory,
+ Monitor monitor) {
+
+ if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE ||
+ promotedReference.getMultiplicity() == Multiplicity.ZERO_ONE) {
+
+ // if necessary override the promoted endpoints (and bindings) with the top level bindings
+ if (reference.getBindings().size() > 0 ){
+
+ List<Binding> bindingsToCopyDown = new ArrayList<Binding>();
+ List<Endpoint> endpointsToCopyDown = new ArrayList<Endpoint>();
+
+ for (Binding binding : reference.getBindings()) {
+ if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
+ bindingsToCopyDown.add(binding);
+
+ if (reference instanceof ComponentReference){
+ for (Endpoint endpoint : ((ComponentReference)reference).getEndpoints()){
+ if ( endpoint.getSourceBinding() == binding){
+ endpointsToCopyDown.add(endpoint);
+ break;
+ }
+ }
+ } else {
+ // create a new endpoint to represent this promoted binding
+ Endpoint endpoint = endpointFactory.createEndpoint();
+ endpoint.setTargetName(binding.getURI());
+ endpoint.setSourceComponent(null); // TODO - fixed up at start
+ endpoint.setSourceComponentReference(promotedReference);
+ endpoint.setInterfaceContract(reference.getInterfaceContract());
+ endpoint.setSourceBinding(binding);
+ endpointsToCopyDown.add(endpoint);
+ }
+ }
+ }
+
+ if (bindingsToCopyDown.size() > 0) {
+ promotedReference.getBindings().clear();
+ promotedReference.getBindings().addAll(bindingsToCopyDown);
+
+ promotedReference.getEndpoints().clear();
+ promotedReference.getEndpoints().addAll(endpointsToCopyDown);
+ }
+ }
+
+ if (promotedReference.getBindings().size() > 1) {
+ warning(monitor, "ComponentReferenceMoreWire", promotedReference, promotedReference.getName());
+ }
+ } else {
+ // if necessary merge the promoted endpoints (and bindings) with the top level bindings
+ if (reference.getBindings().size() > 0 ){
+
+ for (Binding binding : reference.getBindings()) {
+ if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
+ promotedReference.getBindings().add(binding);
+
+ if (reference instanceof ComponentReference){
+ for (Endpoint endpoint : ((ComponentReference)reference).getEndpoints()){
+ if ( endpoint.getSourceBinding() == binding){
+ promotedReference.getEndpoints().add(endpoint);
+ break;
+ }
+ }
+ } else {
+ // create a new endpoint to represent this promoted binding
+ Endpoint endpoint = endpointFactory.createEndpoint();
+ endpoint.setTargetName(binding.getURI());
+ endpoint.setSourceComponent(null); // TODO - fixed up at start
+ endpoint.setSourceComponentReference(promotedReference);
+ endpoint.setInterfaceContract(reference.getInterfaceContract());
+ endpoint.setSourceBinding(binding);
+ promotedReference.getEndpoints().add(endpoint);
+ }
+ }
+ }
+ }
+ }
+
+ 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/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java
index 5a8d373eb2..41a8b3f8ba 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java
@@ -18,6 +18,7 @@
*/
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;
@@ -56,4 +57,32 @@ abstract class ServiceConfigurationUtil {
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/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
index b3fdd32aee..ea9f768f4e 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
@@ -22,11 +22,13 @@ 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.Endpoint;
import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
/**
* Represents a component reference
@@ -88,4 +90,23 @@ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentRe
public List<Endpoint> getEndpoints(){
return endpoints;
}
+
+ /**
+ * Use endpoint information to work out what the interface contract for the
+ * binding is.
+ */
+ public InterfaceContract getInterfaceContract(Binding binding){
+ InterfaceContract interfaceContract = null;
+
+ for (Endpoint theEndpoint : endpoints){
+ if (theEndpoint.getSourceBinding() == binding){
+ interfaceContract = theEndpoint.getInterfaceContract();
+ }
+ }
+
+ if (interfaceContract == null){
+ interfaceContract = getInterfaceContract();
+ }
+ return interfaceContract;
+ }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
index 4396967137..5748abb07d 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
@@ -26,6 +26,7 @@ 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.Endpoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
/**
* The assembly model object for an endpoint.
@@ -48,6 +49,8 @@ public class EndpointImpl implements Endpoint {
private Binding targetBinding;
private Binding targetCallbackBinding;
+ private InterfaceContract interfaceContract;
+
protected EndpointImpl() {
}
@@ -140,4 +143,12 @@ public class EndpointImpl implements Endpoint {
public void setTargetCallbackBinding(Binding targetCallbackBinding){
this.targetCallbackBinding = targetCallbackBinding;
}
+
+ public InterfaceContract getInterfaceContract() {
+ return interfaceContract;
+ }
+
+ public void setInterfaceContract(InterfaceContract interfaceContract) {
+ this.interfaceContract = interfaceContract;
+ }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
index 297a7c3a99..1800222bfb 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
@@ -26,6 +26,7 @@ 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.Reference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -40,6 +41,7 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C
private List<ComponentService> targets = new ArrayList<ComponentService>();
private Callback callback;
private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+ private boolean promotionOverride;
public List<PolicySet> getApplicablePolicySets() {
return applicablePolicySets;
@@ -93,6 +95,14 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C
this.wiredByImpl = wiredByImpl;
}
+ public boolean isPromotionOverride() {
+ return promotionOverride;
+ }
+
+ public void setPromotionOverride(boolean promotionOverride) {
+ this.promotionOverride = promotionOverride;
+ }
+
public List<PolicySet> getPolicySets() {
return policySets;
}
@@ -112,5 +122,12 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C
public void setPolicySets(List<PolicySet> policySets) {
this.policySets = policySets;
}
+
+ /**
+ * By default return the interface contract for the reference
+ */
+ public InterfaceContract getInterfaceContract(Binding binding){
+ return getInterfaceContract();
+ }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
index bee7cbec2d..8d745cb7e1 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Callback;
import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -95,5 +96,12 @@ public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneab
public void setPolicySets(List<PolicySet> policySets) {
this.policySets = policySets;
}
+
+ /**
+ * By default return the interface contract for the service
+ */
+ public InterfaceContract getInterfaceContract(Binding binding){
+ return getInterfaceContract();
+ }
}
diff --git a/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties b/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties
index eaf01e0e62..f9760aa3cb 100644
--- a/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties
+++ b/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties
@@ -38,6 +38,7 @@ ReferenceIncompatibleInterface = Incompatible interfaces on component reference
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: Binding = {0} Service = {1} Binding = {2}
+MultipleBindingsForReference = Multiple bindings with the same name for a reference: Binding = {0} Reference = {1} Binding = {2}
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}
diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java
index e105c5f3de..6889b4c06c 100644
--- a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java
+++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java
@@ -146,6 +146,10 @@ public class TestRuntimeComponentService implements RuntimeComponentService {
return interfaceContract;
}
+ public InterfaceContract getInterfaceContract(Binding binding) {
+ return getInterfaceContract();
+ }
+
public String getName() {
return null;
}
diff --git a/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestNode.java b/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestNode.java
index 1c1a6ecd67..f28174c81d 100644
--- a/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestNode.java
+++ b/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestNode.java
@@ -1,232 +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.binding.sca.axis2;
-
-import java.net.URL;
-import java.util.logging.Logger;
-
-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.ComponentService;
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.CompositeService;
-import org.apache.tuscany.sca.assembly.SCABinding;
-import org.apache.tuscany.sca.assembly.SCABindingFactory;
-import org.apache.tuscany.sca.assembly.xml.Constants;
-import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.contribution.service.ContributionService;
-import org.apache.tuscany.sca.core.context.ServiceReferenceImpl;
-import org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.osoa.sca.ServiceReference;
-import org.osoa.sca.ServiceRuntimeException;
-
-/**
- * The very minimum node implementation to get these tests going without creating a dependency on
- * any runtime/hosting implementation
- *
- * @version $Rev: 552343 $ $Date: 2007-09-20 14:53:40 +0100 (Thu, 20 Sep 2007) $
- */
-public class TestNode {
-
- private static final Logger logger = Logger.getLogger(TestNode.class.getName());
-
- private String nodeName;
- private ReallySmallRuntime nodeRuntime;
-
- private ClassLoader cl = TestNode.class.getClassLoader();
-
- private Composite nodeComposite = null;
- private Composite appComposite = null;
-
- public TestNode(String nodeName)
- throws Exception {
- this.nodeName = nodeName;
-
- try {
-
- // create and start domainA
- nodeRuntime = new ReallySmallRuntime(cl);
- nodeRuntime.start();
-
- // Create an in-memory domain level composite
- AssemblyFactory assemblyFactory = nodeRuntime.getAssemblyFactory();
- nodeComposite = assemblyFactory.createComposite();
- nodeComposite.setName(new QName(Constants.SCA10_NS, "domain"));
- nodeComposite.setURI("http://localhost");
-
- // add the top level composite into the composite activator
- nodeRuntime.getCompositeActivator().setDomainComposite(nodeComposite);
-
- // add a contribution to the domain
- ContributionService contributionService = nodeRuntime.getContributionService();
-
- // find the current directory as a URL. This is where our contribution
- // will come from
- URL contributionURL = Thread.currentThread().getContextClassLoader().getResource(nodeName + "/");
-
- // Contribute the SCA application
- Contribution contribution = contributionService.contribute("http://calculator", contributionURL, null, false);
- appComposite = contribution.getDeployables().get(0);
-
- // Add the deployable composite to the domain
- nodeComposite.getIncludes().add(appComposite);
- nodeRuntime.buildComposite(appComposite);
- nodeRuntime.getCompositeActivator().activate(appComposite);
-
-
- } catch (Exception ex) {
- System.err.println("Exception when creating node " + ex.getMessage());
- ex.printStackTrace(System.err);
- throw ex;
- }
- }
-
- public void start() {
-
- try {
- nodeRuntime.getCompositeActivator().start(appComposite);
- } catch (Exception ex) {
- System.err.println("Exception when creating domain " + ex.getMessage());
- ex.printStackTrace(System.err);
- }
-
- }
-
- public void stop() {
- try {
- nodeRuntime.stop();
- } catch (Exception ex) {
- System.err.println("Exception when creating domain " + ex.getMessage());
- ex.printStackTrace(System.err);
- }
- }
-
- public <B> B getService(Class<B> businessInterface, String serviceName) {
- ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName);
- if (serviceReference == null) {
- throw new ServiceRuntimeException("Service not found: " + serviceName);
- }
- return serviceReference.getService();
- }
-
- private <B> ServiceReference<B> createServiceReference(Class<B> businessInterface, String targetURI) {
- try {
- AssemblyFactory assemblyFactory = nodeRuntime.getAssemblyFactory();
- Composite composite = assemblyFactory.createComposite();
- composite.setName(new QName(Constants.SCA10_TUSCANY_NS, "default"));
- RuntimeComponent component = (RuntimeComponent)assemblyFactory.createComponent();
- component.setName("default");
- component.setURI("default");
- nodeRuntime.getCompositeActivator().configureComponentContext(component);
- composite.getComponents().add(component);
- RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference();
- reference.setName("default");
- ModelFactoryExtensionPoint factories =
- nodeRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
- JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
- InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
- interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface));
- reference.setInterfaceContract(interfaceContract);
- component.getReferences().add(reference);
- reference.setComponent(component);
- SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class);
- SCABinding binding = scaBindingFactory.createSCABinding();
- binding.setURI(targetURI);
- reference.getBindings().add(binding);
- return new ServiceReferenceImpl<B>(businessInterface, component, reference, binding, nodeRuntime
- .getProxyFactory(), nodeRuntime.getCompositeActivator());
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) {
-
- // Extract the component name
- String componentName;
- String serviceName;
- int i = name.indexOf('/');
- if (i != -1) {
- componentName = name.substring(0, i);
- serviceName = name.substring(i + 1);
-
- } else {
- componentName = name;
- serviceName = null;
- }
-
- // Lookup the component in the domain
-
- Component component = null;
-
- for (Composite composite: nodeComposite.getIncludes()) {
- for (Component componentLoop: composite.getComponents()) {
- if (componentLoop.getName().equals(componentName)) {
- component = componentLoop;
- break;
- }
- }
- }
- if (component == null) {
- // The component is not local in the partition, try to create a remote service ref
- return createServiceReference(businessInterface, name);
- }
- RuntimeComponentContext componentContext = null;
-
- // If the component is a composite, then we need to find the
- // non-composite component that provides the requested service
- if (component.getImplementation() instanceof Composite) {
- for (ComponentService componentService : component.getServices()) {
- if (serviceName == null || serviceName.equals(componentService.getName())) {
- CompositeService compositeService = (CompositeService)componentService.getService();
- if (compositeService != null) {
- if (serviceName != null) {
- serviceName = "$promoted$." + serviceName;
- }
- componentContext =
- ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
- return componentContext.createSelfReference(businessInterface, compositeService
- .getPromotedService());
- }
- break;
- }
- }
- // No matching service is found
- throw new ServiceRuntimeException("Composite service not found: " + name);
- } else {
- componentContext = ((RuntimeComponent)component).getComponentContext();
- if (serviceName != null) {
- return componentContext.createSelfReference(businessInterface, serviceName);
- } else {
- return componentContext.createSelfReference(businessInterface);
- }
- }
- }
-
-}
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.axis2;
+
+import java.net.URL;
+import java.util.logging.Logger;
+
+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.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.core.context.ServiceReferenceImpl;
+import org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * The very minimum node implementation to get these tests going without creating a dependency on
+ * any runtime/hosting implementation
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-20 14:53:40 +0100 (Thu, 20 Sep 2007) $
+ */
+public class TestNode {
+
+ private static final Logger logger = Logger.getLogger(TestNode.class.getName());
+
+ private String nodeName;
+ private ReallySmallRuntime nodeRuntime;
+
+ private ClassLoader cl = TestNode.class.getClassLoader();
+
+ private Composite nodeComposite = null;
+ private Composite appComposite = null;
+
+ public TestNode(String nodeName)
+ throws Exception {
+ this.nodeName = nodeName;
+
+ try {
+
+ // create and start domainA
+ nodeRuntime = new ReallySmallRuntime(cl);
+ nodeRuntime.start();
+
+ // Create an in-memory domain level composite
+ AssemblyFactory assemblyFactory = nodeRuntime.getAssemblyFactory();
+ nodeComposite = assemblyFactory.createComposite();
+ nodeComposite.setName(new QName(Constants.SCA10_NS, "domain"));
+ nodeComposite.setURI("http://localhost");
+
+ // add the top level composite into the composite activator
+ nodeRuntime.getCompositeActivator().setDomainComposite(nodeComposite);
+
+ // add a contribution to the domain
+ ContributionService contributionService = nodeRuntime.getContributionService();
+
+ // find the current directory as a URL. This is where our contribution
+ // will come from
+ URL contributionURL = Thread.currentThread().getContextClassLoader().getResource(nodeName + "/");
+
+ // Contribute the SCA application
+ Contribution contribution = contributionService.contribute("http://calculator", contributionURL, null, false);
+ appComposite = contribution.getDeployables().get(0);
+
+ // Add the deployable composite to the domain
+ nodeComposite.getIncludes().add(appComposite);
+ nodeRuntime.buildComposite(appComposite);
+ nodeRuntime.getCompositeActivator().activate(appComposite);
+
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating node " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ public void start() {
+
+ try {
+ nodeRuntime.getCompositeActivator().start(appComposite);
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ }
+
+ }
+
+ public void stop() {
+ try {
+ nodeRuntime.stop();
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ }
+ }
+
+ public <B> B getService(Class<B> businessInterface, String serviceName) {
+ ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName);
+ if (serviceReference == null) {
+ throw new ServiceRuntimeException("Service not found: " + serviceName);
+ }
+ return serviceReference.getService();
+ }
+
+ private <B> ServiceReference<B> createServiceReference(Class<B> businessInterface, String targetURI) {
+ try {
+ AssemblyFactory assemblyFactory = nodeRuntime.getAssemblyFactory();
+ Composite composite = assemblyFactory.createComposite();
+ composite.setName(new QName(Constants.SCA10_TUSCANY_NS, "default"));
+ RuntimeComponent component = (RuntimeComponent)assemblyFactory.createComponent();
+ component.setName("default");
+ component.setURI("default");
+ nodeRuntime.getCompositeActivator().configureComponentContext(component);
+ composite.getComponents().add(component);
+ RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference();
+ reference.setName("default");
+ ModelFactoryExtensionPoint factories =
+ nodeRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
+ JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface));
+ reference.setInterfaceContract(interfaceContract);
+ component.getReferences().add(reference);
+ reference.setComponent(component);
+ SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class);
+ SCABinding binding = scaBindingFactory.createSCABinding();
+ binding.setURI(targetURI);
+ reference.getBindings().add(binding);
+ return new ServiceReferenceImpl<B>(businessInterface, component, reference, binding, nodeRuntime
+ .getProxyFactory(), nodeRuntime.getCompositeActivator());
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) {
+
+ // Extract the component name
+ String componentName;
+ String serviceName;
+ int i = name.indexOf('/');
+ if (i != -1) {
+ componentName = name.substring(0, i);
+ serviceName = name.substring(i + 1);
+
+ } else {
+ componentName = name;
+ serviceName = null;
+ }
+
+ // Lookup the component in the domain
+
+ Component component = null;
+
+ for (Composite composite: nodeComposite.getIncludes()) {
+ for (Component componentLoop: composite.getComponents()) {
+ if (componentLoop.getName().equals(componentName)) {
+ component = componentLoop;
+ break;
+ }
+ }
+ }
+ if (component == null) {
+ // The component is not local in the partition, try to create a remote service ref
+ return createServiceReference(businessInterface, name);
+ }
+ RuntimeComponentContext componentContext = null;
+
+ // If the component is a composite, then we need to find the
+ // non-composite component that provides the requested service
+ if (component.getImplementation() instanceof Composite) {
+ for (ComponentService componentService : component.getServices()) {
+ if (serviceName == null || serviceName.equals(componentService.getName())) {
+ CompositeService compositeService = (CompositeService)componentService.getService();
+ if (compositeService != null) {
+ if (serviceName != null) {
+ serviceName = "$promoted$." + component.getName() + "." + serviceName;
+ }
+ componentContext =
+ ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
+ return componentContext.createSelfReference(businessInterface, compositeService
+ .getPromotedService());
+ }
+ break;
+ }
+ }
+ // No matching service is found
+ throw new ServiceRuntimeException("Composite service not found: " + name);
+ } else {
+ componentContext = ((RuntimeComponent)component).getComponentContext();
+ if (serviceName != null) {
+ return componentContext.createSelfReference(businessInterface, serviceName);
+ } else {
+ return componentContext.createSelfReference(businessInterface);
+ }
+ }
+ }
+
+}
+
diff --git a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
index b8ddb9f51a..d94ed30c34 100644
--- a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
+++ b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
@@ -30,6 +30,7 @@ import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.AbstractContract;
import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension;
import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
@@ -190,14 +191,14 @@ public class BindingWSDLGenerator {
WSDLFactory wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
XSDFactory xsdFactory = modelFactories.getFactory(XSDFactory.class);
- if (contract.getInterfaceContract() == null) {
+ if (((Contract)contract).getInterfaceContract(wsBinding) == null) {
// can happen if incorrect component service name
fatal(monitor, "MissingInterfaceContract", wsBinding, component.getName(), contract.getName());
}
InterfaceContract icontract = wsBinding.getBindingInterfaceContract();
if (icontract == null) {
- icontract = contract.getInterfaceContract().makeUnidirectional(false);
+ icontract = ((Contract)contract).getInterfaceContract(wsBinding).makeUnidirectional(false);
if (icontract instanceof JavaInterfaceContract) {
ModelResolver resolver = component instanceof ResolverExtension ?
((ResolverExtension)component).getModelResolver() : null;
diff --git a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
index 407877c36d..d2e2e9eb34 100644
--- a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
+++ b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
@@ -151,13 +151,19 @@ public class WSDLServiceGenerator {
AbstractContract contract,
Monitor monitor) {
+ //[nash] changes to the builder sequence avoid calling this for a CompositeService
+ assert !(contract instanceof CompositeService);
+ /*
// For every promoted composite service, the underlying component
// gets a copy of the service with the name prefixed by "$promoted$."
String contractName = (contract instanceof CompositeService ? "$promoted$." : "") + contract.getName();
+ */
+ String contractName = contract.getName();
List<Port> ports = new ArrayList<Port>();
WSDLDefinition wsdlDefinition = wsBinding.getWSDLDefinition();
if (wsdlDefinition == null) {
+ error(monitor, "NoWsdlInterface", wsBinding, component.getName(), contract.getName());
return null;
}
Definition def = wsdlDefinition.getDefinition();
diff --git a/java/sca/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties b/java/sca/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties
index 91e99f1891..4bfbdd2901 100644
--- a/java/sca/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties
+++ b/java/sca/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties
@@ -28,3 +28,4 @@ PortTypeNotFound = PortType {0} in {1}/{2} was not found
BindingNotFound = Binding {0} in {1}/{2} was not found
InvalidPort = Port {0}/{1} in {2}/{3} is not supported
NoValidPorts = No valid ports for service {0} in {1}/{2}
+NoWsdlInterface = No WSDL interface definition for {1}/{2}
diff --git a/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java b/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java
index 6edfa94139..875a139ca2 100644
--- a/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java
+++ b/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java
@@ -561,7 +561,7 @@ public class DefaultSCADomain extends SCADomain {
CompositeService compositeService = (CompositeService)componentService.getService();
if (compositeService != null) {
if (serviceName != null) {
- serviceName = "$promoted$." + serviceName;
+ serviceName = "$promoted$." + component.getName() + "." + serviceName;
}
componentContext =
((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
diff --git a/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java b/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java
index 3b578fe1b1..45daf57399 100644
--- a/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java
+++ b/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java
@@ -203,7 +203,7 @@ public class EmbeddedSCADomain extends SCADomain {
CompositeService compositeService = (CompositeService)componentService.getService();
if (compositeService != null) {
if (serviceName != null) {
- serviceName = "$promoted$." + serviceName;
+ serviceName = "$promoted$." + component.getName() + "." + serviceName;
}
componentContext =
((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
diff --git a/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
index af4d531e01..eb39b379b6 100644
--- a/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
+++ b/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -683,7 +683,7 @@ public class NodeImpl implements SCANode2, SCAClient {
CompositeService compositeService = (CompositeService)componentService.getService();
if (compositeService != null) {
if (serviceName != null) {
- serviceName = "$promoted$." + serviceName;
+ serviceName = "$promoted$." + component.getName() + "." + serviceName;
}
componentContext =
((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
diff --git a/java/sca/samples/databinding-echo/src/main/resources/EchoDataBinding.composite b/java/sca/samples/databinding-echo/src/main/resources/EchoDataBinding.composite
index 2f042b8e34..30b77a6152 100644
--- a/java/sca/samples/databinding-echo/src/main/resources/EchoDataBinding.composite
+++ b/java/sca/samples/databinding-echo/src/main/resources/EchoDataBinding.composite
@@ -1,58 +1,58 @@
-<?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.
--->
+<?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:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:local="http://tuscany.apache.org/xmlns/sca/binding/1.0"
- xmlns:f="http://foo"
+ xmlns:f="http://foo"
xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
xmlns:e="http://echo"
- name="EchoDataBinding">
-
- <component name="ComponentA">
- <implementation.java class="dbecho.ComponentAImpl" />
- <reference name="componentBReference" target="ComponentB" />
- <property name="prefix">ABC</property>
- <property name="prefix1" source="$messagePrefix"></property>
- <property name="bar" source="$complexProperty/*[local-name()='foo']/*[local-name()='bar']"></property>
- </component>
-
- <component name="ComponentB">
- <implementation.java class="dbecho.ComponentBImpl" />
- </component>
-
- <reference name="EchoReference" promote="ComponentB/echoReference">
- <!--
- <interface.java interface="dbecho.Echo"/>
- -->
- <interface.wsdl interface="http://example.com/echo.wsdl#wsdl.interface(EchoPortType)"
- wsdli:wsdlLocation="http://example.com/echo.wsdl wsdl/echo.wsdl">
- <db:databinding xmlns:db="http://tuscany.apache.org/xmlns/sca/databinding/1.0" name="org.apache.axiom.om.OMElement" />
- </interface.wsdl>
- <e:binding.echo/>
- </reference>
-
- <property name="messagePrefix" type="xsd:string">ABC</property>
- <property name="complexProperty" type="f:FooType">
- <foo>
- <bar attr="barAttr">BAR</bar>
- </foo>
- </property>
-
-</composite>
+ name="EchoDataBinding">
+
+ <component name="ComponentA">
+ <implementation.java class="dbecho.ComponentAImpl" />
+ <reference name="componentBReference" target="ComponentB" />
+ <property name="prefix">ABC</property>
+ <property name="prefix1" source="$messagePrefix"></property>
+ <property name="bar" source="$complexProperty/*[local-name()='foo']/*[local-name()='bar']"></property>
+ </component>
+
+ <component name="ComponentB">
+ <implementation.java class="dbecho.ComponentBImpl" />
+ </component>
+
+ <reference name="EchoReference" promote="ComponentB/echoReference">
+ <interface.java interface="dbecho.Echo"/>
+ <!-- Replaced interface.wsdl by interface.java because TUSCANY-2324 fix uses the interface specified here
+ <interface.wsdl interface="http://example.com/echo.wsdl#wsdl.interface(EchoPortType)"
+ wsdli:wsdlLocation="http://example.com/echo.wsdl wsdl/echo.wsdl">
+ <db:databinding xmlns:db="http://tuscany.apache.org/xmlns/sca/databinding/1.0" name="org.apache.axiom.om.OMElement" />
+ </interface.wsdl>
+ -->
+ <e:binding.echo/>
+ </reference>
+
+ <property name="messagePrefix" type="xsd:string">ABC</property>
+ <property name="complexProperty" type="f:FooType">
+ <foo>
+ <bar attr="barAttr">BAR</bar>
+ </foo>
+ </property>
+
+</composite> \ No newline at end of file
diff --git a/java/sca/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite b/java/sca/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite
index f078b9ee9f..35306b9f89 100644
--- a/java/sca/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite
+++ b/java/sca/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite
@@ -101,7 +101,9 @@
</component>
<reference name="availQuoteProvider" promote="QuoteJoinExternalReferencesComponent/availQuoteProvider">
+ <!-- removed because it doesn't work with TUSCANY-2324 fix
<interface.java interface="xquery.quote.AvailQuoteProviderService" />
+ -->
<binding.ws wsdlElement="http://quote.xquery#wsdl.port(AvailQuoteProviderService/AvailQuoteProviderSoapPort)" />
</reference>
<reference name="quoteJoinWs" promote="QuoteJoinLocalComponent/quoteJoinWs">