You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by na...@apache.org on 2008/07/25 14:09:37 UTC
svn commit: r679774 [3/5] - in /tuscany/java/sca: itest/
itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/
itest/builder/src/main/resources/scenario1/
itest/builder/src/main/resources/scenario10/
itest/builder/src/main/resources/scenari...
Modified: tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java (original)
+++ tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java Fri Jul 25 05:09:35 2008
@@ -34,23 +34,34 @@
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 @@
}
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 @@
// 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);
Modified: tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java (original)
+++ tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java Fri Jul 25 05:09:35 2008
@@ -76,7 +76,12 @@
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 @@
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 {
Added: tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java?rev=679774&view=auto
==============================================================================
--- tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java (added)
+++ tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java Fri Jul 25 05:09:35 2008
@@ -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
+ }
+ }
+ }
+
+}
Modified: tuscany/java/sca/itest/policy/src/main/resources/definitions.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/policy/src/main/resources/definitions.xml?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/itest/policy/src/main/resources/definitions.xml (original)
+++ tuscany/java/sca/itest/policy/src/main/resources/definitions.xml Fri Jul 25 05:09:35 2008
@@ -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">
Modified: tuscany/java/sca/itest/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/pom.xml?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/itest/pom.xml (original)
+++ tuscany/java/sca/itest/pom.xml Fri Jul 25 05:09:35 2008
@@ -59,6 +59,7 @@
</activation>
<modules>
<module>bpel</module>
+ <module>builder</module>
<module>callablereferences</module>
<module>callablereferences-ws</module>
<module>callback-api</module>
Modified: tuscany/java/sca/itest/validation/src/main/resources/policy/xml/UnableToMapPolicies/definitions.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/validation/src/main/resources/policy/xml/UnableToMapPolicies/definitions.xml?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/itest/validation/src/main/resources/policy/xml/UnableToMapPolicies/definitions.xml (original)
+++ tuscany/java/sca/itest/validation/src/main/resources/policy/xml/UnableToMapPolicies/definitions.xml Fri Jul 25 05:09:35 2008
@@ -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">
Modified: tuscany/java/sca/itest/validation/src/test/java/policy/xml/UnableToMapPoliciesTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/validation/src/test/java/policy/xml/UnableToMapPoliciesTestCase.java?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/itest/validation/src/test/java/policy/xml/UnableToMapPoliciesTestCase.java (original)
+++ tuscany/java/sca/itest/validation/src/test/java/policy/xml/UnableToMapPoliciesTestCase.java Fri Jul 25 05:09:35 2008
@@ -51,7 +51,7 @@
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());*/
Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java Fri Jul 25 05:09:35 2008
@@ -20,6 +20,7 @@
import java.util.List;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
@@ -78,4 +79,17 @@
*/
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);
+
}
Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java Fri Jul 25 05:09:35 2008
@@ -20,6 +20,8 @@
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 @@
*
* @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);
}
Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java Fri Jul 25 05:09:35 2008
@@ -47,6 +47,24 @@
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.
Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java Fri Jul 25 05:09:35 2008
@@ -35,6 +35,7 @@
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 @@
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 @@
SCABinding scaBinding = createSCABinding();
service.getBindings().add(scaBinding);
}
-
+/*
// Initialize binding names and URIs
for (Binding binding : service.getBindings()) {
@@ -150,6 +151,7 @@
}
}
}
+*/
}
// Initialize reference bindings
@@ -159,7 +161,7 @@
SCABinding scaBinding = createSCABinding();
reference.getBindings().add(scaBinding);
}
-
+/*
// Set binding names
for (Binding binding : reference.getBindings()) {
if (binding.getName() == null) {
@@ -174,6 +176,7 @@
}
}
}
+*/
}
// Initialize all component services and references
@@ -247,7 +250,7 @@
SCABinding scaBinding = createSCABinding();
componentService.getBindings().add(scaBinding);
}
-
+/*
// Set binding names
for (Binding binding : componentService.getBindings()) {
@@ -263,6 +266,7 @@
}
}
}
+*/
}
// Initialize reference bindings
@@ -273,7 +277,7 @@
SCABinding scaBinding = createSCABinding();
componentReference.getBindings().add(scaBinding);
}
-
+/*
// Set binding names
for (Binding binding : componentReference.getBindings()) {
if (binding.getName() == null) {
@@ -287,6 +291,7 @@
}
}
}
+*/
}
}
}
@@ -796,208 +801,6 @@
}
/**
- * 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 @@
}
}
- /**
- * 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 @@
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 @@
}
/**
+ * 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 @@
* 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 @@
}
}
}
+
+ /**
+ * 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 @@
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());
}
}
}
Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java Fri Jul 25 05:09:35 2008
@@ -424,6 +424,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
} 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 @@
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 @@
// 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
Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java?rev=679774&r1=679773&r2=679774&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java Fri Jul 25 05:09:35 2008
@@ -47,16 +47,8 @@
}
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 @@
}
}
}
+
+ // build bindings recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ buildReferenceBindings((Composite)implementation);
+ }
+ }
}
}
Added: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java?rev=679774&view=auto
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java (added)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java Fri Jul 25 05:09:35 2008
@@ -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);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
Added: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java?rev=679774&view=auto
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java (added)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java Fri Jul 25 05:09:35 2008
@@ -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);
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
Added: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java?rev=679774&view=auto
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java (added)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java Fri Jul 25 05:09:35 2008
@@ -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);
+ }
+
+}