diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-19 16:12:22 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-19 16:12:22 +0000 |
commit | dcbff0df93448ef786c2e5cb0320f3895759171b (patch) | |
tree | 444d508a0e30ac3c8b00ff394cf46fc64b9f4aab /java/sca/modules/assembly/src | |
parent | 40f139f0e78679d6e9ce837de910f603f819b917 (diff) |
Switch over to new endpoint reference/endpoint model. These are the changes required to exploit the model in the runtime up to the point were the old EndpointReference is retrieved from a wire. The next step is to convert this over too and exploit the new endpoint references fully. There is still tidying to do (search for TODO - EPR) in particular I haven't removed any of the old files yet. So beware don't put changes into CompositeActivator or RuntimeWire as the runtime isn't using them
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@756070 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/assembly/src')
16 files changed, 346 insertions, 138 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.java index 2fe3595292..254432434c 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.java @@ -18,6 +18,8 @@ */ package org.apache.tuscany.sca.assembly; +import java.util.List; + import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.policy.PolicySubject; @@ -95,6 +97,21 @@ public interface Endpoint2 extends Base, PolicySubject, Cloneable { */ void setInterfaceContract(InterfaceContract interfaceContract); + /** + * Get the services callbacl enpoint references that + * represent endpoint references from which callbacks + * originate + * + * @return callbackEndpoint the reference callback endpoint + */ + List<EndpointReference2> getCallbackEndpointReferences(); + + /** + * Set the reference callback endpoint refefences + * + * @param callbackEndpoint the reference callback endpoint + */ + void setCallbackEndpointReferences(List<EndpointReference2> callbackEndpointReferences); // not sure these are required diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java index f84648c203..d8e9888aef 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java @@ -39,23 +39,6 @@ import org.apache.tuscany.sca.monitor.Monitor; public interface EndpointReferenceBuilder { /** - * Create endpoint references for a component reference - * - * @param composite - * @param component - * @param reference - * @param components - * @param componentServices - * @param monitor - */ - public void createEndpointReferences(Composite composite, - Component component, - ComponentReference reference, - Map<String, Component> components, - Map<String, ComponentService> componentServices, - Monitor monitor); - - /** * Build an endpoint reference matching reference bindings * with service bindings. * diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java index 3e8022863d..6720aecb50 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java @@ -199,6 +199,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { String uri = component.getName() + '/' + componentService.getName(); componentServices.put(uri, componentService); + // TODO - EPR - $promoted$ no longer used but it doesn't do any harm here boolean promotedService = false; if (componentService.getName() != null && componentService.getName().indexOf("$promoted$") > -1) { promotedService = true; diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java index 64747978a5..812e06942a 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java @@ -233,7 +233,7 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement for (ComponentReference reference : component.getReferences()) { if (reference.getInterfaceContract() != null && // can be null in // unit tests - reference.getInterfaceContract().getCallbackInterface() != null) { + reference.getInterfaceContract().getCallbackInterface() != null) { ComponentService service = componentServices.get(reference.getName()); if (service == null) { diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceEndpointReferenceBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java index 5de60c114d..1c60428afa 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceEndpointReferenceBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java @@ -55,10 +55,10 @@ import org.apache.tuscany.sca.policy.PolicySubject; * * @version $Rev$ $Date$ */ -public class CompositeReferenceEndpointReferenceBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { +public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - public CompositeReferenceEndpointReferenceBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { + public ComponentReferenceEndpointReferenceBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { super(assemblyFactory, null, null, null, interfaceContractMapper); } @@ -333,6 +333,23 @@ public class CompositeReferenceEndpointReferenceBuilderImpl extends BaseBuilderI // user hasn't put a uri on the binding so it's not a target // name if (uri == null) { + // create endpoint reference for manually configured bindings + EndpointReference2 endpointRef = assemblyFactory.createEndpointReference(); + endpointRef.setComponent(component); + endpointRef.setReference(reference); + endpointRef.setBinding(binding); + endpointRef.setTargetName(null); + endpointRef.setTargetEndpoint(null); + endpointRef.setUnresolved(false); + + // create a resolved endpoint to signify that this + // reference is pointing at some unwired endpoint + Endpoint2 endpoint = assemblyFactory.createEndpoint(); + endpoint.setUnresolved(false); + endpointRef.setTargetEndpoint(endpoint); + + reference.getEndpointReferences().add(endpointRef); + continue; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java new file mode 100644 index 0000000000..2d3c89ca7b --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java @@ -0,0 +1,171 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.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.definitions.Definitions; +import org.apache.tuscany.sca.monitor.Monitor; + +/** + * A composite builder that handles the creation of promoted composite services. + * + * @version $Rev$ $Date$ + */ +public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder { + private AssemblyFactory assemblyFactory; + private EndpointFactory endpointFactory; + + public ComponentReferencePromotionBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory) { + this.assemblyFactory = assemblyFactory; + this.endpointFactory = endpointFactory; + } + + public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { + configureNestedCompositeReferences(composite, monitor); + } + + public String getID() { + return "org.apache.tuscany.sca.assembly.builder.ComponentReferencePromotionBuilder"; + } + + /** + * Push down reference configuration into nested composites. + * + * @param composite + * @param problems + */ + private void configureNestedCompositeReferences(Composite composite, Monitor monitor) { + + // Process nested composites recursively + for (Component component : composite.getComponents()) { + Implementation implementation = component.getImplementation(); + if (implementation instanceof Composite) { + configureNestedCompositeReferences((Composite)implementation, monitor); + } + } + + // Process component references declared on components in this composite + for (Component component : composite.getComponents()) { + Implementation implementation = component.getImplementation(); + if (implementation instanceof Composite) { + for (ComponentReference componentReference : component.getReferences()) { + Reference implReference = componentReference.getReference(); + if (implReference != null && implReference instanceof CompositeReference) { + + // If the component reference is wired, it is a promotion override + if (!componentReference.getEndpointReferences().isEmpty()) { + componentReference.setPromotionOverride(true); + } + + // If the component reference is a promotion override, override the + // configuration of the promoted reference + if (componentReference.isPromotionOverride()) { + CompositeReference compositeReference = (CompositeReference)implReference; + List<ComponentReference> promotedReferences = + ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); + for (ComponentReference promotedReference : promotedReferences) { + ReferenceConfigurationUtil.reconcileReferenceBindings( + componentReference, promotedReference, assemblyFactory, 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()); + } + } + /* TODO - let endpoint references worry about target service + // Wire the promoted reference to the actual non-composite component services + if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE) { + // promotedReference.getTargets().clear(); + } + for (ComponentService target : componentReference.getTargets()) { + if (target.getService() instanceof CompositeService) { + + // Wire to the actual component service + // promoted by a composite service + CompositeService compositeService = (CompositeService)target.getService(); + // Find the promoted component service + ComponentService componentService = + ServiceConfigurationUtil.getPromotedComponentService(compositeService); + if (componentService != null) { + promotedReference.getTargets().add(componentService); + } + } else { + + // Wire to a non-composite target service + promotedReference.getTargets().add(target); + } + } +*/ + } + } + } + } + } else { +/* TODO - let endpoint references worry about target servicep + for (ComponentReference componentReference : component.getReferences()) { + + // Wire the component reference to the actual + // non-composite component services + List<ComponentService> targets = componentReference.getTargets(); + for (int i = 0, n = targets.size(); i < n; i++) { + ComponentService target = targets.get(i); + if (target.getService() instanceof CompositeService) { + + // Wire to the actual component service + // promoted by a composite service + CompositeService compositeService = (CompositeService)target.getService(); + ComponentService componentService = compositeService.getPromotedService(); + if (componentService != null) { + targets.set(i, componentService); + } + } + } + } +*/ + } + } + } + +} diff --git a/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 index 4ceb4bb079..c6b6b38851 100644 --- 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 @@ -85,7 +85,7 @@ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuil if (implReference != null && implReference instanceof CompositeReference) { // If the component reference is wired, it is a promotion override - if (!componentReference.getEndpoints().isEmpty()) { + if (!componentReference.getEndpointReferences().isEmpty()) { componentReference.setPromotionOverride(true); } @@ -114,7 +114,7 @@ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuil .getCallback().getBindings()); } } - + /* TODO - let endpoint references worry about target service // Wire the promoted reference to the actual non-composite component services if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE) { // promotedReference.getTargets().clear(); @@ -137,11 +137,13 @@ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuil promotedReference.getTargets().add(target); } } +*/ } } } } } else { +/* TODO - let endpoint references worry about target servicep for (ComponentReference componentReference : component.getReferences()) { // Wire the component reference to the actual @@ -161,6 +163,7 @@ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuil } } } +*/ } } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java index dc99d1dc3d..99d4defb21 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java @@ -104,7 +104,7 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement connectWires(composite, componentServices, componentReferences, monitor); // Connect component references to their targets - connectComponentReferences(composite, components, componentServices, componentReferences, monitor); +// connectComponentReferences(composite, components, componentServices, componentReferences, monitor); // Validate that references are wired or promoted, according // to their multiplicity @@ -133,9 +133,9 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement // Finally clear the original reference target lists as we now have // bindings to represent the targets - for (ComponentReference componentReference : componentReferences.values()) { - componentReference.getTargets().clear(); - } + // for (ComponentReference componentReference : componentReferences.values()) { + // componentReference.getTargets().clear(); + // } } /** diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceEndpointBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java index a933fd6991..1205bfeef4 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceEndpointBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java @@ -31,6 +31,7 @@ import org.apache.tuscany.sca.assembly.CompositeReference; import org.apache.tuscany.sca.assembly.CompositeService; import org.apache.tuscany.sca.assembly.Endpoint2; import org.apache.tuscany.sca.assembly.EndpointFactory; +import org.apache.tuscany.sca.assembly.EndpointReference2; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.SCABinding; @@ -45,10 +46,10 @@ import org.apache.tuscany.sca.monitor.Monitor; * * @version $Rev$ $Date$ */ -public class CompositeServiceEndpointBuilderImpl implements CompositeBuilder { +public class ComponentServiceEndpointBuilderImpl implements CompositeBuilder { private AssemblyFactory assemblyFactory; - public CompositeServiceEndpointBuilderImpl(AssemblyFactory assemblyFactory) { + public ComponentServiceEndpointBuilderImpl(AssemblyFactory assemblyFactory) { this.assemblyFactory = assemblyFactory; } @@ -109,11 +110,39 @@ public class CompositeServiceEndpointBuilderImpl implements CompositeBuilder { // create an endpoint for each component service binding for (ComponentService service : component.getServices()) { + + Component endpointComponent = component; + ComponentService endpointService = service; + + // TODO - EPR - We maintain all endpoints at the right level now + // but endpoints for promoting services must point down + // to the services they promote. + if (service.getService() instanceof CompositeService) { + CompositeService compositeService = (CompositeService)service.getService(); + endpointService = ServiceConfigurationUtil.getPromotedComponentService(compositeService); + endpointComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService); + } + + // if this service has a callback get the callback endpoint references + List<EndpointReference2> callbackEndpointReferences = null; + + if ((service.getInterfaceContract() != null) && + (service.getInterfaceContract().getCallbackInterface() != null)){ + // find the callback reference + for ( Reference reference : component.getReferences()){ + if ( reference.getName().equals(service.getName())){ + callbackEndpointReferences = reference.getEndpointReferences(); + break; + } + } + } + for (Binding binding : service.getBindings()){ Endpoint2 endpoint = assemblyFactory.createEndpoint(); - endpoint.setComponent(component); - endpoint.setService(service); + endpoint.setComponent(endpointComponent); + endpoint.setService(endpointService); endpoint.setBinding(binding); + endpoint.setCallbackEndpointReferences(callbackEndpointReferences); endpoint.setUnresolved(false); service.getEndpoints().add(endpoint); } 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 7157d8a217..6c8228d58a 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 @@ -46,22 +46,23 @@ public class CompositeBuilderImpl implements CompositeBuilder { private static final Logger logger = Logger.getLogger(CompositeBuilderImpl.class.getName()); private CompositeBuilder compositeIncludeBuilder; private CompositeBuilder componentReferenceWireBuilder; - private CompositeBuilder componentReferencePromotionWireBuilder; - private CompositeBuilder compositeReferenceWireBuilder; + //private CompositeBuilder componentReferencePromotionWireBuilder; + private CompositeBuilder componentReferencePromotionBuilder; + //private CompositeBuilder compositeReferenceWireBuilder; private CompositeBuilder compositeCloneBuilder; private CompositeBuilder componentConfigurationBuilder; private CompositeBuilder compositeServiceConfigurationBuilder; private CompositeBuilder compositeReferenceConfigurationBuilder; private CompositeBuilder compositeBindingURIBuilder; - private CompositeBuilder componentServicePromotionBuilder; - private CompositeBuilder compositeServicePromotionBuilder; + //private CompositeBuilder componentServicePromotionBuilder; + //private CompositeBuilder compositeServicePromotionBuilder; private CompositeBuilder compositePromotionBuilder; private CompositeBuilder compositePolicyBuilder; private CompositeBuilder componentServiceBindingBuilder; private CompositeBuilder componentReferenceBindingBuilder; - private CompositeBuilder compositeReferenceEndpointReferenceBuilder; - private CompositeBuilder compositeServiceEndpointBuilder; + private CompositeBuilder componentReferenceEndpointReferenceBuilder; + private CompositeBuilder componentServiceEndpointBuilder; //private CompositeBuilder endpointReferenceBuilder; public CompositeBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) { @@ -161,22 +162,23 @@ public class CompositeBuilderImpl implements CompositeBuilder { compositeIncludeBuilder = new CompositeIncludeBuilderImpl(); componentReferenceWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper); - componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory); - compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory); + //componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory); + componentReferencePromotionBuilder = new ComponentReferencePromotionBuilderImpl(assemblyFactory, endpointFactory); + //compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory); compositeCloneBuilder = new CompositeCloneBuilderImpl(); componentConfigurationBuilder = new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper); compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory); compositeReferenceConfigurationBuilder = new CompositeReferenceConfigurationBuilderImpl(assemblyFactory); compositeBindingURIBuilder = new CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper); - componentServicePromotionBuilder = new ComponentServicePromotionBuilderImpl(assemblyFactory); - compositeServicePromotionBuilder = new CompositeServicePromotionBuilderImpl(assemblyFactory); + //componentServicePromotionBuilder = new ComponentServicePromotionBuilderImpl(assemblyFactory); + //compositeServicePromotionBuilder = new CompositeServicePromotionBuilderImpl(assemblyFactory); compositePromotionBuilder = new CompositePromotionBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper); compositePolicyBuilder = new CompositePolicyBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper); componentServiceBindingBuilder = new ComponentServiceBindingBuilderImpl(); componentReferenceBindingBuilder = new ComponentReferenceBindingBuilderImpl(); - compositeReferenceEndpointReferenceBuilder = new CompositeReferenceEndpointReferenceBuilderImpl(assemblyFactory, interfaceContractMapper); - compositeServiceEndpointBuilder = new CompositeServiceEndpointBuilderImpl(assemblyFactory); + componentReferenceEndpointReferenceBuilder = new ComponentReferenceEndpointReferenceBuilderImpl(assemblyFactory, interfaceContractMapper); + componentServiceEndpointBuilder = new ComponentServiceEndpointBuilderImpl(assemblyFactory); //endpointReferenceBuilder = new EndpointReference2BuilderImpl(assemblyFactory, interfaceContractMapper); } @@ -201,51 +203,58 @@ public class CompositeBuilderImpl implements CompositeBuilder { // Compute the policies across the model hierarchy compositePolicyBuilder.build(composite, definitions, monitor); - // Configure composite services + // Configure composite services by copying bindings up the promotion + // hierarchy overwriting automatic bindings with those added manually compositeServiceConfigurationBuilder.build(composite, definitions, monitor); - // Configure composite references + // Configure composite references by copying bindings down promotion + // hierarchy overwriting automatic bindings with those added manually compositeReferenceConfigurationBuilder.build(composite, definitions, monitor); - // Configure binding URIs + // Configure service binding URIs and names. Creates an SCA defined URI based + // on the scheme base URI, the component name and the binding name compositeBindingURIBuilder.build(composite, definitions, monitor); - // Create promoted component services - componentServicePromotionBuilder.build(composite, definitions, monitor); + // Create $promoted$ component services on bottom level components + // to represent promoted services + // TODO - EPR replaced by endpoints on the promoted services + //componentServicePromotionBuilder.build(composite, definitions, monitor); - // Create promoted composite services - compositeServicePromotionBuilder.build(composite, definitions, monitor); + // Create $promoted$ component services on bottom level components + // to represent promoted composite services + // TODO - EPR OASIS doesn't deploy top level composite services + // if it did it would be replaced by endpoints + //compositeServicePromotionBuilder.build(composite, definitions, monitor); - // Build component service binding-related information + // Perform and service binding related build activities. The binding + // will provide the builder. componentServiceBindingBuilder.build(composite, definitions, monitor); - // =============================================== - // TODO - temporarily add OASIS endpoint builders - // create service endpoint models - compositeServiceEndpointBuilder.build(composite, definitions, monitor); - // create reference enpointreference models - compositeReferenceEndpointReferenceBuilder.build(composite, definitions, monitor); - // =============================================== - + // create endpoints on component services. + componentServiceEndpointBuilder.build(composite, definitions, monitor); - // Wire the components + // Apply any wires in the composite to create new component reference targets componentReferenceWireBuilder.build(composite, definitions, monitor); + + // create reference endpoint reference models + componentReferenceEndpointReferenceBuilder.build(composite, definitions, monitor); + + // Push down configuration from promoted references to the + // references they promote + componentReferencePromotionBuilder.build(composite, definitions, monitor); - // Wire the promoted component references - componentReferencePromotionWireBuilder.build(composite, definitions, monitor); + // Push down configuration from promoted references to the + // references they promote + // TODO - EPR Seems to be a repeat of compositeReferenceConfigurationBuilder + // componentReferencePromotionWireBuilder.build(composite, definitions, monitor); // Wire the composite references - compositeReferenceWireBuilder.build(composite, definitions, monitor); - - // Build component reference binding-related information - componentReferenceBindingBuilder.build(composite, definitions, monitor); + // TODO - EPR OASIS doesn't deploy top level composite references + // compositeReferenceWireBuilder.build(composite, definitions, monitor); - // =============================================== - // TODO this needs to be offloaded to a plugpoint - // could be called upon when rebuilding wires - // wire endpoint references to endpoints - //endpointReferenceBuilder.build(composite, definitions, monitor); - // =============================================== + // Perform and reference binding related build activities. The binding + // will provide the builder. + componentReferenceBindingBuilder.build(composite, definitions, monitor); } } diff --git a/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 index a89f0d402f..1623591a9f 100644 --- 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 @@ -56,6 +56,7 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil configureNestedCompositeReferences(composite); // Process top level composite references + // TODO - In OASIS the treament of top level composite references is different so need to review for (Reference reference : composite.getReferences()) { CompositeReference compositeReference = (CompositeReference)reference; 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 2fc5e571b2..2bdcf7b19d 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 @@ -55,6 +55,7 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde // Process nested composites recursively configureNestedCompositeServices(composite); + // TODO - In OASIS the treatment of top level composite services it different // Process top level composite services for (Service service : composite.getServices()) { CompositeService compositeService = (CompositeService)service; 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 0612f9ae0e..adf03a1b32 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 @@ -174,76 +174,22 @@ abstract class ReferenceConfigurationUtil { 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); - } + // override the promoted endpoint references (and bindings) + // with configuration from the top level + + if (reference.getEndpointReferences().size() > 0){ + promotedReference.getEndpointReferences().clear(); + promotedReference.getEndpointReferences().addAll(reference.getEndpointReferences()); } - if (promotedReference.getBindings().size() > 1) { + if (promotedReference.getEndpointReferences().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); - } - } - } - } + // merge the promoted endpoint reference with the those from the top level + if (reference.getEndpointReferences().size() > 0){ + promotedReference.getEndpointReferences().addAll(reference.getEndpointReferences()); + } } Set<Binding> callbackBindings = new HashSet<Binding>(); diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.java index 67041fc66a..d1fc0123eb 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.java @@ -25,6 +25,7 @@ import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Endpoint2; +import org.apache.tuscany.sca.assembly.EndpointReference2; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.policy.ExtensionType; import org.apache.tuscany.sca.policy.Intent; @@ -42,8 +43,8 @@ public class Endpoint2Impl implements Endpoint2 { private Component component; private ComponentService service; private Binding binding; - private Binding callbackBinding; private InterfaceContract interfaceContract; + private List<EndpointReference2> callbackEndpointReferences; //private String uri; private List<PolicySet> policySets = new ArrayList<PolicySet>(); private List<Intent> requiredIntents = new ArrayList<Intent>(); @@ -95,6 +96,27 @@ public class Endpoint2Impl implements Endpoint2 { public void setInterfaceContract(InterfaceContract interfaceContract) { this.interfaceContract = interfaceContract; } + + /** + * Get the services callbacl enpoint references that + * represent endpoint references from which callbacks + * originate + * + * @return callbackEndpoint the reference callback endpoint + */ + public List<EndpointReference2> getCallbackEndpointReferences(){ + return callbackEndpointReferences; + } + + /** + * Set the reference callback endpoint refefences + * + * @param callbackEndpoint the reference callback endpoint + */ + public void setCallbackEndpointReferences(List<EndpointReference2> callbackEndpointReferences) + { + this.callbackEndpointReferences = callbackEndpointReferences; + } /* public String getURI() { return uri; diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java index 699d2e89f4..e47eb1c6fe 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java @@ -62,7 +62,13 @@ public class EndpointReference2Impl implements EndpointReference2 { @Override public Object clone() throws CloneNotSupportedException { - return super.clone(); + EndpointReference2 cloned = (EndpointReference2)super.clone(); + + if (targetEndpoint != null){ + cloned.setTargetEndpoint((Endpoint2)targetEndpoint.clone()); + } + + return cloned; } public boolean isUnresolved() { 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 82026b40db..41d090c9d4 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 @@ -55,6 +55,8 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C clone.bindings.addAll(getBindings()); clone.targets = new ArrayList<ComponentService>(); clone.targets.addAll(getTargets()); + clone.endpointReferences = new ArrayList<EndpointReference2>(); + clone.endpointReferences.addAll(getEndpointReferences()); return clone; } |