diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-20 15:07:53 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-20 15:07:53 +0000 |
commit | b272cfd554a84b0537fe0de5dbfde41f8da3f688 (patch) | |
tree | fa6351e48c704693e605fcfc9e57bed57a9f5099 /java/sca/modules/assembly | |
parent | fce6ad4c30b15b4284a94e7a00e084bf18748cf2 (diff) |
Remove the old Endpoint support. It has been replaced by Endpoint2/EndpointReference2. The old EndpointReference is still waiting to be removed.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@756512 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/assembly')
19 files changed, 17 insertions, 1605 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java index 67c1ec1409..fa31657d0f 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java @@ -105,12 +105,5 @@ public interface ComponentReference extends Reference { * @param nonOverridable */ void setNonOverridable(boolean nonOverridable); - - /** - * Returns the endpoints implied by this reference. - * - * @return the endpoints implied by this reference - */ - List<Endpoint> getEndpoints(); - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultEndpointFactory.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultEndpointFactory.java deleted file mode 100644 index 6b0c076ee5..0000000000 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultEndpointFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly; - - -import org.apache.tuscany.sca.assembly.impl.EndpointFactoryImpl; - -/** - * A default factory for the Endpoint model. - * - * @version $Rev$ $Date$ - */ -public class DefaultEndpointFactory extends EndpointFactoryImpl { - -} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java deleted file mode 100644 index ee63497fbe..0000000000 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.util.List; - -import org.apache.tuscany.sca.interfacedef.InterfaceContract; - -/** - * Represents an endpoint (primarily a combination of a target service name and a set of - * candidate bindings) - * - * @version $Rev$ $Date$ - */ -public interface Endpoint extends Base, Cloneable { - - /** - * Get the name of the target service that this endpoint refers to - * - * @return target service name - */ - String getTargetName(); - - /** - * Set the name of the target service that this endpoint refers to - * - * @param targetName - */ - void setTargetName(String targetName); - - /** - * Get the source component model object - * - * @return source component - */ - Component getSourceComponent(); - - /** - * Set the source component model object - * - * @param component the source component for the endpoint - */ - void setSourceComponent(Component component); - - /** - * Get the source component reference model object - * - * @return reference the source component reference for the endpoint - */ - ComponentReference getSourceComponentReference(); - - /** - * Set the source component reference model object - * - * @param reference - */ - void setSourceComponentReference(ComponentReference reference); - - /** - * Get the resolved source binding - * - * @return binding the resolved source binding - */ - Binding getSourceBinding(); - - /** - * Set the resolved source binding - * - * @param binding the resolved source binding - */ - void setSourceBinding(Binding binding); - - /** - * Get the resolved source callback binding - * - * @return binding the resolved source callback binding - */ - Binding getSourceCallbackBinding(); - - /** - * Set the resolved source callback binding - * - * @param binding the resolved source callback binding - */ - void setSourceCallbackBinding(Binding binding); - - /** - * Get the list of candidate bindings that could be used to - * communication with the target service - * - * @return list of candidate bindings - */ - List<Binding> getCandidateBindings(); - - - /** - * Get the target component model object - * - * @return target component - */ - Component getTargetComponent(); - - /** - * Set the target component model object - * - * @param component target component - */ - void setTargetComponent(Component component); - - /** - * Get the target component service model object - * - * @return target component service - */ - ComponentService getTargetComponentService(); - - /** - * Set the target component service model object - * - * @param service - */ - void setTargetComponentService(ComponentService service); - - /** - * Get the resolved target binding - * - * @return target binding - */ - Binding getTargetBinding(); - - /** - * Set the resolved target binding - * - * @param binding target binding - */ - void setTargetBinding(Binding binding); - - /** - * Returns the interface contract defining the interface - * - * @return the interface contract - */ - InterfaceContract getInterfaceContract(); - - /** - * Sets the interface contract defining the interface - * - * @param interfaceContract the interface contract - */ - void setInterfaceContract(InterfaceContract interfaceContract); -} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointFactory.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointFactory.java deleted file mode 100644 index 93e6c4d630..0000000000 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - - - -/** - * A factory for the endpoint model - * - * @version $Rev$ $Date$ - */ -public interface EndpointFactory { - - /** - * Create a new endpoint model object - * - * @return a new endpoint - */ - Endpoint createEndpoint(); - -} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultEndpointBuilder.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultEndpointBuilder.java deleted file mode 100644 index 30b929c43c..0000000000 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultEndpointBuilder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder; - -import org.apache.tuscany.sca.assembly.builder.impl.EndpointBuilderImpl; - -/** - * A default builder. - * - * @version $Rev$ $Date$ - */ -public class DefaultEndpointBuilder extends EndpointBuilderImpl { - public DefaultEndpointBuilder (){ - super(); - } -} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointBuilder.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointBuilder.java deleted file mode 100644 index e98be49551..0000000000 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointBuilder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder; - -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A builder that handles the configuration of reference endpoints - * It collects together the logic so that it can be used at build time - * or later on during late binding scenarios - * - * @version $Rev$ $Date$ - */ -public interface EndpointBuilder { - - /** - * Build an endpoint. - * - * @param endpoint - * @param monitor - */ - void build(Endpoint endpoint, Monitor monitor); - -} 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 index 9a34c44eeb..eb06f67f8e 100644 --- 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 @@ -26,7 +26,6 @@ import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.EndpointFactory; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.SCABinding; @@ -42,11 +41,9 @@ import org.apache.tuscany.sca.monitor.Monitor; */ public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder { private AssemblyFactory assemblyFactory; - private EndpointFactory endpointFactory; - public ComponentReferencePromotionBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory) { + public ComponentReferencePromotionBuilderImpl(AssemblyFactory assemblyFactory) { this.assemblyFactory = assemblyFactory; - this.endpointFactory = endpointFactory; } public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { @@ -94,7 +91,7 @@ public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); for (ComponentReference promotedReference : promotedReferences) { ReferenceConfigurationUtil.reconcileReferenceBindings( - componentReference, promotedReference, assemblyFactory, endpointFactory, monitor); + componentReference, promotedReference, assemblyFactory, monitor); if (componentReference.getInterfaceContract() != null && // can be null in unit tests componentReference.getInterfaceContract().getCallbackInterface() != null) { SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class); 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 4698fa14e7..5552fda286 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 @@ -26,7 +26,6 @@ import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.EndpointFactory; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.SCABinding; @@ -42,11 +41,9 @@ import org.apache.tuscany.sca.monitor.Monitor; */ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuilder { private AssemblyFactory assemblyFactory; - private EndpointFactory endpointFactory; - public ComponentReferencePromotionWireBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory) { + public ComponentReferencePromotionWireBuilderImpl(AssemblyFactory assemblyFactory) { this.assemblyFactory = assemblyFactory; - this.endpointFactory = endpointFactory; } public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { @@ -94,7 +91,7 @@ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuil ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); for (ComponentReference promotedReference : promotedReferences) { ReferenceConfigurationUtil.reconcileReferenceBindings( - componentReference, promotedReference, assemblyFactory, endpointFactory, monitor); + componentReference, promotedReference, assemblyFactory, monitor); if (componentReference.getInterfaceContract() != null && // can be null in unit tests componentReference.getInterfaceContract().getCallbackInterface() != null) { SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class); 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 99d4defb21..fb2b34ac98 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 @@ -19,29 +19,21 @@ package org.apache.tuscany.sca.assembly.builder.impl; -import java.net.URI; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.Endpoint; -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.Wire; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.assembly.builder.DefaultEndpointBuilder; -import org.apache.tuscany.sca.assembly.builder.EndpointBuilder; import org.apache.tuscany.sca.definitions.Definitions; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; import org.apache.tuscany.sca.monitor.Monitor; @@ -52,14 +44,9 @@ import org.apache.tuscany.sca.monitor.Monitor; * @version $Rev$ $Date$ */ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - - protected EndpointFactory endpointFactory; - private EndpointBuilder endpointBuilder; - - public ComponentReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory, InterfaceContractMapper interfaceContractMapper) { + + public ComponentReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { super(assemblyFactory, null, null, null, interfaceContractMapper); - this.endpointFactory = endpointFactory; - this.endpointBuilder = new DefaultEndpointBuilder(); } public String getID() { @@ -92,19 +79,9 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>(); indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences); - // Connect composite services and references to the component - // services and references that they promote - //connectCompositeServices(composite, components, componentServices); - //connectCompositeReferences(composite, componentReferences); - - // Compute the policies before connecting component references - //computePolicies(composite); - // Connect component references as described in wires connectWires(composite, componentServices, componentReferences, monitor); - // Connect component references to their targets -// connectComponentReferences(composite, components, componentServices, componentReferences, monitor); // Validate that references are wired or promoted, according // to their multiplicity @@ -207,466 +184,4 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement composite.getWires().clear(); } - private List<Endpoint> createComponentReferenceTargets(Composite composite, - Map<String, Component> components, - Map<String, ComponentService> componentServices, - ComponentReference componentReference, Monitor monitor) { - - List<Endpoint> endpoints = new ArrayList<Endpoint>(); - - if (componentReference.getAutowire() == Boolean.TRUE - && componentReference.getTargets().isEmpty()) { - - // Find suitable targets in the current composite for an - // autowired reference - Multiplicity multiplicity = componentReference.getMultiplicity(); - for (Component targetComponent : composite.getComponents()) { - // prevent autowire connecting to self - boolean skipSelf = false; - for (ComponentReference targetComponentReference : targetComponent - .getReferences()) { - if (componentReference == targetComponentReference) { - skipSelf = true; - } - } - - if (!skipSelf) { - for (ComponentService targetComponentService : targetComponent - .getServices()) { - if (componentReference.getInterfaceContract() == null - || interfaceContractMapper.isCompatible( - componentReference - .getInterfaceContract(), - targetComponentService - .getInterfaceContract())) { - - Endpoint endpoint = endpointFactory - .createEndpoint(); - 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()); - endpoints.add(endpoint); - - if (multiplicity == Multiplicity.ZERO_ONE - || multiplicity == Multiplicity.ONE_ONE) { - break; - } - } - } - } - } - - if (multiplicity == Multiplicity.ONE_N - || multiplicity == Multiplicity.ONE_ONE) { - if (endpoints.size() == 0) { - warning(monitor, "NoComponentReferenceTarget", - componentReference, componentReference.getName()); - } - } - - } else if (!componentReference.getTargets().isEmpty()) { - - // Check if the component reference does not mix the use of - // endpoints specified via - // binding elements with target endpoints specified via the target - // attribute - for (Binding binding : componentReference.getBindings()) { - if (binding.getURI() != null) { - warning(monitor, "ReferenceEndPointMixWithTarget", - composite, componentReference.getName()); - } - } - - // Resolve targets specified on the component reference - for (ComponentService componentService : componentReference - .getTargets()) { - - // Resolve the target component and service - String name = componentService.getName(); - ComponentService targetComponentService = componentServices - .get(name); - Component targetComponent; - int s = name.indexOf('/'); - if (s == -1) { - targetComponent = components.get(name); - } else { - targetComponent = components.get(name.substring(0, s)); - } - - if (targetComponentService != null) { - - // Check that the target component service provides - // a superset of the component reference interface - if (componentReference.getInterfaceContract() == null - || interfaceContractMapper.isCompatible( - componentReference.getInterfaceContract(), - targetComponentService - .getInterfaceContract())) { - - Endpoint endpoint = endpointFactory.createEndpoint(); - 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()); - endpoints.add(endpoint); - - // mark the reference target as resolved. Used later - // when we are looking to - // see if an sca binding is associated with a resolved - // target or not - componentService.setUnresolved(false); - } else { - warning(monitor, "ReferenceIncompatibleInterface", - composite, composite.getName().toString(), - componentReference.getName(), componentService - .getName()); - } - } else { - // add all the reference bindings into the target so that - // they - // can be used for comparison when the target is resolved at - // runtime - componentService.getBindings().addAll( - componentReference.getBindings()); - - Endpoint endpoint = endpointFactory.createEndpoint(); - endpoint.setTargetName(name); - endpoint.setSourceComponent(null); // TODO - fixed up at - // start - endpoint.setSourceComponentReference(componentReference); - endpoint.setInterfaceContract(componentReference - .getInterfaceContract()); - endpoint.getCandidateBindings().addAll( - componentReference.getBindings()); - endpoints.add(endpoint); - - // The bindings will be cloned back into the reference when - // the - // target is finally resolved. - warning(monitor, "ComponentReferenceTargetNotFound", - composite, composite.getName().toString(), - componentService.getName()); - } - } - } else if ((componentReference.getReference() != null) - && (!componentReference.getReference().getTargets().isEmpty())) { - - // Resolve targets from the corresponding reference in the - // componentType - for (ComponentService componentService : componentReference - .getReference().getTargets()) { - - // Resolve the target component and service - String name = componentService.getName(); - ComponentService targetComponentService = componentServices - .get(name); - Component targetComponent; - int s = name.indexOf('/'); - if (s == -1) { - targetComponent = components.get(name); - } else { - targetComponent = components.get(name.substring(0, s)); - } - - if (targetComponentService != null) { - - // Check that the target component service provides - // a superset of - // the component reference interface - if (componentReference.getInterfaceContract() == null - || interfaceContractMapper.isCompatible( - componentReference.getInterfaceContract(), - targetComponentService - .getInterfaceContract())) { - - Endpoint endpoint = endpointFactory.createEndpoint(); - 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()); - endpoints.add(endpoint); - - // mark the reference target as resolved. Used later - // when we are looking to - // see if an sca binding is associated with a resolved - // target or not - componentService.setUnresolved(false); - } else { - warning(monitor, "ComponentIncompatibleInterface", - composite, componentReference.getName(), - componentService.getName()); - } - } else { - // add all the reference bindings into the target so that - // they - // can be used for comparison when the target is resolved at - // runtime - componentService.getBindings().addAll( - componentReference.getBindings()); - - // The bindings will be cloned back into the reference when - // the - // target is finally resolved. - - Endpoint endpoint = endpointFactory.createEndpoint(); - endpoint.setTargetName(name); - endpoint.setSourceComponent(null); // TODO - fixed up at - // start - endpoint.setSourceComponentReference(componentReference); - endpoint.setInterfaceContract(componentReference - .getInterfaceContract()); - endpoint.getCandidateBindings().addAll( - componentReference.getBindings()); - endpoints.add(endpoint); - - warning(monitor, "ComponentReferenceTargetNotFound", - composite, composite.getName().toString(), - componentService.getName()); - } - } - } else if (componentReference.getAutowire() == Boolean.TRUE) { - - // Find suitable targets in the current composite for an - // autowired reference - Multiplicity multiplicity = componentReference.getMultiplicity(); - for (Component targetComponent : composite.getComponents()) { - // prevent autowire connecting to self - boolean skipSelf = false; - for (ComponentReference targetComponentReference : targetComponent - .getReferences()) { - if (componentReference == targetComponentReference) { - skipSelf = true; - } - } - - if (!skipSelf) { - for (ComponentService targetComponentService : targetComponent - .getServices()) { - if (componentReference.getInterfaceContract() == null - || interfaceContractMapper.isCompatible( - componentReference - .getInterfaceContract(), - targetComponentService - .getInterfaceContract())) { - - Endpoint endpoint = endpointFactory - .createEndpoint(); - 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()); - endpoints.add(endpoint); - - if (multiplicity == Multiplicity.ZERO_ONE - || multiplicity == Multiplicity.ONE_ONE) { - break; - } - } - } - } - } - - if (multiplicity == Multiplicity.ONE_N - || multiplicity == Multiplicity.ONE_ONE) { - if (endpoints.size() == 0) { - warning(monitor, "NoComponentReferenceTarget", - componentReference, componentReference.getName()); - } - } - } - - // if no endpoints have found so far retrieve any target names that are - // in binding URIs - if (endpoints.isEmpty()) { - for (Binding binding : componentReference.getBindings()) { - - String uri = binding.getURI(); - - // user hasn't put a uri on the binding so it's not a target - // name - if (uri == null) { - continue; - } - - // user might have put a local target name in the uri so get - // the path part and see if it refers to a target we know about - // - if it does the reference binding will be matched with a - // service binding - // - if it doesn't it is assumed to be an external reference - Component targetComponent = null; - ComponentService targetComponentService = null; - String path = null; - - try { - path = URI.create(uri).getPath(); - } catch (Exception ex) { - // just assume that no target is identified if - // a URI related exception is thrown - } - - if (path != null) { - if (path.startsWith("/")) { - path = path.substring(1); - } - - // Resolve the target component and service - targetComponentService = componentServices.get(path); - int s = path.indexOf('/'); - if (s == -1) { - targetComponent = components.get(path); - } else { - targetComponent = components.get(path.substring(0, s)); - } - } - - // if the path of the binding URI matches a component in the - // composite then configure an endpoint with this component as - // the target - // if not then the binding URI will be assumed to reference an - // external service - if (targetComponentService != null) { - - // Check that the target component service provides - // a superset of the component reference interface - if (componentReference.getInterfaceContract() == null - || interfaceContractMapper.isCompatible( - componentReference.getInterfaceContract(), - targetComponentService - .getInterfaceContract())) { - - Endpoint endpoint = endpointFactory.createEndpoint(); - 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().add(binding); - endpoints.add(endpoint); - } else { - warning(monitor, "ReferenceIncompatibleInterface", - composite, composite.getName().toString(), - componentReference.getName(), uri); - } - } else { - - // 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.setInterfaceContract(componentReference - .getInterfaceContract()); - endpoint.setSourceBinding(binding); - endpoints.add(endpoint); - } - } - } - - return endpoints; - } - - /** - * Connect references to their targets. - * - * @param composite - * @param componentServices - * @param componentReferences - * @param problems - */ - private void connectComponentReferences(Composite composite, - Map<String, Component> components, - Map<String, ComponentService> componentServices, - Map<String, ComponentReference> componentReferences, - Monitor monitor){ - - for (ComponentReference componentReference : componentReferences.values()) { - - List<Endpoint> endpoints = createComponentReferenceTargets(composite, - components, - componentServices, - componentReference, - monitor); - - 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 (endpointsRequireAutomaticResolution) { - - for(Endpoint endpoint : endpoints){ - endpointBuilder.build(endpoint, monitor); - } - - // TODO - The following step ensures that the reference binding list remains - // as the record of resolved targets for now. This needs fixing so - // that the endpoint takes on this responsibility. - componentReference.getBindings().clear(); - - if (componentReference.getCallback() != null){ - componentReference.getCallback().getBindings().clear(); - } - - for(Endpoint endpoint : endpoints){ - if (endpoint.isUnresolved() == false){ - componentReference.getBindings().add(endpoint.getSourceBinding()); - - if (componentReference.getCallback() != null){ - componentReference.getCallback().getBindings().add(endpoint.getSourceCallbackBinding()); - } - } - } - - } else { - // do nothing as no targets have been specified so the bindings - // in the reference binding list are assumed to be manually configured - } - } - } - } 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 6c8228d58a..bd904ede10 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 @@ -25,8 +25,6 @@ import javax.xml.transform.TransformerFactory; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.DefaultEndpointFactory; -import org.apache.tuscany.sca.assembly.EndpointFactory; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; @@ -67,7 +65,6 @@ public class CompositeBuilderImpl implements CompositeBuilder { public CompositeBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) { this(factories.getFactory(AssemblyFactory.class), - factories.getFactory(EndpointFactory.class), factories.getFactory(SCABindingFactory.class), factories.getFactory(PolicyFactory.class), factories.getFactory(DocumentBuilderFactory.class), @@ -75,26 +72,6 @@ public class CompositeBuilderImpl implements CompositeBuilder { mapper); } - /** - * Constructs a new composite builder. - * - * @param assemblyFactory - * @param scaBindingFactory - * @param endpointFactory - * @param intentAttachPointTypeFactory - * @param interfaceContractMapper - * @param policyDefinitions - * @param monitor - */ - @Deprecated - public CompositeBuilderImpl(AssemblyFactory assemblyFactory, - EndpointFactory endpointFactory, - SCABindingFactory scaBindingFactory, - PolicyFactory intentAttachPointTypeFactory, - InterfaceContractMapper interfaceContractMapper) { - this(assemblyFactory, endpointFactory, scaBindingFactory, intentAttachPointTypeFactory, - null, null, interfaceContractMapper); - } /** * Constructs a new composite builder. @@ -112,31 +89,10 @@ public class CompositeBuilderImpl implements CompositeBuilder { SCABindingFactory scaBindingFactory, PolicyFactory intentAttachPointTypeFactory, InterfaceContractMapper interfaceContractMapper) { - this(assemblyFactory, null, scaBindingFactory, intentAttachPointTypeFactory, + this(assemblyFactory, scaBindingFactory, intentAttachPointTypeFactory, null, null, interfaceContractMapper); } - - /** - * Constructs a new composite builder. - * - * @param assemblyFactory - * @param scaBindingFactory - * @param intentAttachPointTypeFactory - * @param documentBuilderFactory - * @param transformerFactory - * @param interfaceContractMapper - * @param monitor - */ - public CompositeBuilderImpl(AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - PolicyFactory intentAttachPointTypeFactory, - DocumentBuilderFactory documentBuilderFactory, - TransformerFactory transformerFactory, - InterfaceContractMapper interfaceContractMapper) { - this(assemblyFactory, null, scaBindingFactory, intentAttachPointTypeFactory, - documentBuilderFactory, transformerFactory, interfaceContractMapper); - } - + /** * Constructs a new composite builder. * @@ -149,21 +105,17 @@ public class CompositeBuilderImpl implements CompositeBuilder { * @param monitor */ public CompositeBuilderImpl(AssemblyFactory assemblyFactory, - EndpointFactory endpointFactory, SCABindingFactory scaBindingFactory, PolicyFactory intentAttachPointTypeFactory, DocumentBuilderFactory documentBuilderFactory, TransformerFactory transformerFactory, InterfaceContractMapper interfaceContractMapper) { - - if (endpointFactory == null){ - endpointFactory = new DefaultEndpointFactory(); - } + compositeIncludeBuilder = new CompositeIncludeBuilderImpl(); - componentReferenceWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper); + componentReferenceWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, interfaceContractMapper); //componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory); - componentReferencePromotionBuilder = new ComponentReferencePromotionBuilderImpl(assemblyFactory, endpointFactory); + componentReferencePromotionBuilder = new ComponentReferencePromotionBuilderImpl(assemblyFactory); //compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory); compositeCloneBuilder = new CompositeCloneBuilderImpl(); componentConfigurationBuilder = new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper); @@ -172,8 +124,8 @@ public class CompositeBuilderImpl implements CompositeBuilder { compositeBindingURIBuilder = new CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper); //componentServicePromotionBuilder = new ComponentServicePromotionBuilderImpl(assemblyFactory); //compositeServicePromotionBuilder = new CompositeServicePromotionBuilderImpl(assemblyFactory); - compositePromotionBuilder = new CompositePromotionBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper); - compositePolicyBuilder = new CompositePolicyBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper); + compositePromotionBuilder = new CompositePromotionBuilderImpl(assemblyFactory, interfaceContractMapper); + compositePolicyBuilder = new CompositePolicyBuilderImpl(assemblyFactory, interfaceContractMapper); componentServiceBindingBuilder = new ComponentServiceBindingBuilderImpl(); componentReferenceBindingBuilder = new ComponentReferenceBindingBuilderImpl(); diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java index 28ca856c0f..1fc00705e7 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java @@ -31,7 +31,6 @@ import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.CompositeReference; import org.apache.tuscany.sca.assembly.CompositeService; import org.apache.tuscany.sca.assembly.Endpoint2; -import org.apache.tuscany.sca.assembly.EndpointFactory; import org.apache.tuscany.sca.assembly.EndpointReference2; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Reference; @@ -54,7 +53,6 @@ import org.apache.tuscany.sca.policy.PolicySubject; public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { public CompositePolicyBuilderImpl(AssemblyFactory assemblyFactory, - EndpointFactory endpointFactory, InterfaceContractMapper interfaceContractMapper) { super(assemblyFactory, null, null, null, interfaceContractMapper); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java index abacc06067..eb858b4e3d 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java @@ -31,7 +31,6 @@ 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.Reference; import org.apache.tuscany.sca.assembly.Service; @@ -50,7 +49,7 @@ import org.apache.tuscany.sca.monitor.Monitor; */ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - public CompositePromotionBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory, InterfaceContractMapper interfaceContractMapper) { + public CompositePromotionBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { super(assemblyFactory, null, null, null, interfaceContractMapper); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java index 3786cdfa38..451b378941 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java @@ -25,7 +25,6 @@ import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.EndpointFactory; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; @@ -40,11 +39,9 @@ import org.apache.tuscany.sca.monitor.Monitor; */ public class CompositeReferenceWireBuilderImpl implements CompositeBuilder { private AssemblyFactory assemblyFactory; - private EndpointFactory endpointFactory; - public CompositeReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory) { + public CompositeReferenceWireBuilderImpl(AssemblyFactory assemblyFactory) { this.assemblyFactory = assemblyFactory; - this.endpointFactory = endpointFactory; } public String getID() { @@ -72,7 +69,7 @@ public class CompositeReferenceWireBuilderImpl implements CompositeBuilder { ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); for (ComponentReference promotedReference : promotedReferences) { ReferenceConfigurationUtil.reconcileReferenceBindings( - compositeReference, promotedReference, assemblyFactory, endpointFactory, monitor); + compositeReference, promotedReference, assemblyFactory, monitor); if (compositeReference.getInterfaceContract() != null && // can be null in unit tests compositeReference.getInterfaceContract().getCallbackInterface() != null) { SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class); diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/EndpointBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/EndpointBuilderImpl.java deleted file mode 100644 index aaface154b..0000000000 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/EndpointBuilderImpl.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.OptimizableBinding; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.builder.EndpointBuilder; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * A factory for the Endpoint model. - * - * @version $Rev$ $Date$ - */ -public abstract class EndpointBuilderImpl implements EndpointBuilder { - - public EndpointBuilderImpl (){ - } - - private void warning(Monitor monitor, String message, Object model, String... messageParameters) { - if (monitor != null){ - Problem problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - private void error(Monitor monitor, String message, Object model, Exception ex) { - if (monitor != null){ - Problem problem = null; - problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.ERROR, model, message, ex); - monitor.problem(problem); - } - } - - /** - * Resolve an endpoint against the provided target information and the - * set of candidate bindings. - */ - public void build(Endpoint endpoint, Monitor monitor) { - - // If this endpoint is not fully configured then don't try and resolve it - if (endpoint.getTargetComponentService() == null){ - return; - } - - // Does the reference expect callbacks - boolean bidirectional = false; - - if (endpoint.getSourceComponentReference().getInterfaceContract() != null && - endpoint.getSourceComponentReference().getInterfaceContract().getCallbackInterface() != null) { - bidirectional = true; - } - - // if the target service is a promoted service then find the - // service it promotes - if (endpoint.getTargetComponentService().getService() instanceof CompositeService) { - CompositeService compositeService = (CompositeService) endpoint.getTargetComponentService().getService(); - // Find the promoted component service - ComponentService promotedComponentService = ServiceConfigurationUtil.getPromotedComponentService(compositeService); - if (promotedComponentService != null && !promotedComponentService.isUnresolved()) { - endpoint.setTargetComponentService(promotedComponentService); - } - } - - try { - PolicyConfigurationUtil.determineApplicableBindingPolicySets(endpoint.getSourceComponentReference(), - endpoint.getTargetComponentService()); - } catch ( Exception e ) { - error(monitor, "PolicyRelatedException", endpoint, e); - } - - - // Match the binding against the bindings of the target service - Binding resolvedBinding = matchBinding(endpoint.getTargetComponent(), - endpoint.getTargetComponentService(), - endpoint.getCandidateBindings(), - endpoint.getTargetComponentService().getBindings()); - if (resolvedBinding == null) { - warning(monitor, "NoMatchingBinding", - endpoint.getSourceComponentReference(), - endpoint.getSourceComponentReference().getName(), - endpoint.getTargetComponentService().getName()); - } else { - endpoint.setSourceBinding(resolvedBinding); - } - - if (bidirectional) { - Binding resolvedCallbackBinding = matchBinding(endpoint.getTargetComponent(), - endpoint.getTargetComponentService(), - endpoint.getSourceComponentReference().getCallback().getBindings(), - endpoint.getTargetComponentService().getCallback().getBindings()); - if (resolvedBinding == null) { - warning(monitor, "NoMatchingCallbackBinding", - endpoint.getSourceComponentReference(), - endpoint.getSourceComponentReference().getName(), - endpoint.getTargetComponentService().getName()); - } else { - endpoint.setSourceCallbackBinding(resolvedCallbackBinding); - } - } - } - - private boolean hasCompatiblePolicySets(Binding refBinding, Binding svcBinding) { - boolean isCompatible = true; - if ( refBinding instanceof PolicySubject && svcBinding instanceof PolicySubject ) { - //TODO : need to add more compatibility checks at the policy attachment levels - for ( PolicySet svcPolicySet : ((PolicySubject)svcBinding).getPolicySets() ) { - isCompatible = false; - for ( PolicySet refPolicySet : ((PolicySubject)refBinding).getPolicySets() ) { - if ( svcPolicySet.equals(refPolicySet) ) { - isCompatible = true; - break; - } - } - //if there exists no matching policy set in the reference binding - if ( !isCompatible ) { - return isCompatible; - } - } - } - return isCompatible; - } - - - private Binding matchBinding(Component targetComponent, ComponentService targetComponentService, List<Binding> source, List<Binding> target) { - List<Binding> matched = new ArrayList<Binding>(); - // Find the corresponding bindings from the service side - for (Binding binding : source) { - for (Binding serviceBinding : target) { - if (binding.getClass() == serviceBinding.getClass() && - hasCompatiblePolicySets(binding, serviceBinding)) { - - try { - Binding cloned = (Binding)binding.clone(); - - //Customise the binding name to make it unique - // regardless of how many bindings or targets there are - if ( targetComponent != null){ - cloned.setName(binding.getName()); - } else { - cloned.setName(binding.getName()); - } - - // Set the binding URI to the URI of the target service - // that has been matched - if (binding.getURI() == null) { - cloned.setURI(serviceBinding.getURI()); - } - - if (binding instanceof OptimizableBinding) { - OptimizableBinding endpoint = ((OptimizableBinding)cloned); - endpoint.setTargetComponent(targetComponent); - endpoint.setTargetComponentService(targetComponentService); - endpoint.setTargetBinding(serviceBinding); - } - - matched.add(cloned); - break; - } catch (Exception ex) { - // do nothing - } - } - } - } - if (matched.isEmpty()) { - // No matching binding - return null; - } else { - for (Binding binding : matched) { - // If binding.sca is present, use it - if (SCABinding.class.isInstance(binding)) { - return binding; - } - } - // Use the first one - return matched.get(0); - } - } - -} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/EndpointReference2BuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/EndpointReference2BuilderImpl.java deleted file mode 100644 index 3120f16334..0000000000 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/EndpointReference2BuilderImpl.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Endpoint2; -import org.apache.tuscany.sca.assembly.EndpointReference2; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.OptimizableBinding; -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.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * An builder that takes endpoint references and resolves them. It either finds local - * service endpoints if they are available or asks the domain. The main function here - * is to perform binding and policy matching. - * This is a separate builder in case it is required by undresolved endpoints - * once the runtime has started. - * - * @version $Rev$ $Date$ - */ -public class EndpointReference2BuilderImpl extends BaseBuilderImpl implements CompositeBuilder/*, EndpointReference2Builder*/ { - - - public EndpointReference2BuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, null, null, null, interfaceContractMapper); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.EndpointReference2Builder"; - } - - /** - * Build all the endpoint references - * - * @param composite - */ - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException - { - // process top level composite references - // TODO - I don't think OASIS allows for these - // - //processCompositeReferences(composite); - - // process component services - processComponentReferences(composite, monitor); - } - - private void processCompositeReferences(Composite composite) { - // TODO do we need this for OASIS? - } - - private void processComponentReferences(Composite composite, Monitor monitor) { - - // index all of the components in the composite - Map<String, Component> components = new HashMap<String, Component>(); - indexComponents(composite, components); - - // index all of the services in the composite - Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>(); - indexServices(composite, componentServices); - - // create endpoint references for each component's references - for (Component component : composite.getComponents()) { - // recurse for composite implementations - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - processComponentReferences((Composite)implementation, monitor); - } - - // build endpoint references - for (ComponentReference reference : component.getReferences()) { - for (EndpointReference2 endpointReference : reference.getEndpointReferences()){ - build(endpointReference, monitor); - } - } - } - } - - /** - * Build a single endpoint reference - * - * @param endpoint - * @param monitor - */ - public void build(EndpointReference2 endpointReference, Monitor monitor) { - Endpoint2 endpoint = endpointReference.getTargetEndpoint(); - - if (endpoint == null){ - // an error? - } else { - if (endpoint.isUnresolved() == false){ - // everything is resolved - return; - } - - if (endpointReference.isUnresolved() == false ){ - // TODO - bring resolution and binding matching together - // just do binding matching - matchForwardBinding(endpointReference, - endpointReference.getTargetEndpoint().getService(), - monitor); - - matchCallbackBinding(endpointReference, - endpointReference.getTargetEndpoint().getService(), - monitor); - } else { - // resolve the endpoint reference in the domain and then - // match bindings - } - } - } - - // TODO - In OASIS case there are no bindings to match with on the - // reference side. This code will be factored out into a pluggable - // piece - private void matchForwardBinding(EndpointReference2 endpointReference, - ComponentService service, - Monitor monitor) { - - List<Binding> matchedReferenceBinding = new ArrayList<Binding>(); - List<Endpoint2> matchedServiceEndpoint = new ArrayList<Endpoint2>(); - - // Find the corresponding bindings from the service side - for (Binding referenceBinding : endpointReference.getReference().getBindings()) { - for (Endpoint2 serviceEndpoint : service.getEndpoints()) { - - if (referenceBinding.getClass() == serviceEndpoint.getBinding().getClass() && - hasCompatiblePolicySets(referenceBinding, serviceEndpoint.getBinding())) { - - matchedReferenceBinding.add(referenceBinding); - matchedServiceEndpoint.add(serviceEndpoint); - } - } - } - - if (matchedReferenceBinding.isEmpty()) { - // No matching binding - endpointReference.setBinding(null); - endpointReference.setTargetEndpoint(null); - warning(monitor, - "NoMatchingBinding", - endpointReference.getReference(), - endpointReference.getReference().getName(), - service.getName()); - return; - } else { - // default to using the first matched binding - int selectedBinding = 0; - - for (int i = 0; i < matchedReferenceBinding.size(); i++) { - // If binding.sca is present, use it - if (SCABinding.class.isInstance(matchedReferenceBinding.get(i))) { - selectedBinding = i; - } - } - - Binding referenceBinding = matchedReferenceBinding.get(selectedBinding); - Endpoint2 serviceEndpoint = matchedServiceEndpoint.get(selectedBinding); - - // populate the endpoint reference - try { - - Binding cloned = (Binding) referenceBinding.clone(); - - // Set the binding URI to the URI of the target service - // that has been matched - if (referenceBinding.getURI() == null) { - cloned.setURI(serviceEndpoint.getBinding().getURI()); - } - - // TODO - can we remove this? - if (cloned instanceof OptimizableBinding) { - OptimizableBinding optimizableBinding = (OptimizableBinding)cloned; - optimizableBinding.setTargetComponent(serviceEndpoint.getComponent()); - optimizableBinding.setTargetComponentService(serviceEndpoint.getService()); - optimizableBinding.setTargetBinding(serviceEndpoint.getBinding()); - } - - endpointReference.setBinding(referenceBinding); - endpointReference.setTargetEndpoint(serviceEndpoint); - - } catch (Exception ex) { - // do nothing - } - } - } - - // TODO - // Pretty much a duplicate of matchForwardBinding to handle callback bindings - // will rationalize when I understand what we need to do with callbacks - private void matchCallbackBinding(EndpointReference2 endpointReference, - ComponentService service, - Monitor monitor) { - - // if no callback on the interface do nothing - if (endpointReference.getReference().getInterfaceContract() == null || - endpointReference.getReference().getInterfaceContract().getCallbackInterface() == null){ - return; - } - - List<Binding> matchedReferenceBinding = new ArrayList<Binding>(); - List<Binding> matchedServiceBinding = new ArrayList<Binding>(); - - // Find the corresponding bindings from the service side - for (Binding referenceBinding : endpointReference.getReference().getCallback().getBindings()) { - for (Binding serviceBinding : service.getCallback().getBindings()) { - - if (referenceBinding.getClass() == serviceBinding.getClass() && - hasCompatiblePolicySets(referenceBinding, serviceBinding)) { - - matchedReferenceBinding.add(referenceBinding); - matchedServiceBinding.add(serviceBinding); - } - } - } - - if (matchedReferenceBinding.isEmpty()) { - // No matching binding - endpointReference.setCallbackEndpoint(null); - warning(monitor, - "NoMatchingCallbackBinding", - endpointReference.getReference(), - endpointReference.getReference().getName(), - service.getName()); - return; - } else { - // default to using the first matched binding - int selectedBinding = 0; - - for (int i = 0; i < matchedReferenceBinding.size(); i++){ - // If binding.sca is present, use it - if (SCABinding.class.isInstance(matchedReferenceBinding.get(i))) { - selectedBinding = i; - } - } - - Binding selectedCallbackBinding = matchedReferenceBinding.get(selectedBinding); - - ComponentService callbackService = endpointReference.getReference().getCallbackService(); - - if (callbackService != null) { - // find the callback endpoint that has the selected binding - for (Endpoint2 endpoint : callbackService.getEndpoints()){ - if (endpoint.getBinding().getName().startsWith(selectedCallbackBinding.getName())){ - endpointReference.setCallbackEndpoint(endpoint); - break; - } - } - } - } - } - - private boolean hasCompatiblePolicySets(Binding refBinding, Binding svcBinding) { - boolean isCompatible = true; - if ( refBinding instanceof PolicySubject && svcBinding instanceof PolicySubject ) { - //TODO : need to add more compatibility checks at the policy attachment levels - for ( PolicySet svcPolicySet : ((PolicySubject)svcBinding).getPolicySets() ) { - isCompatible = false; - for ( PolicySet refPolicySet : ((PolicySubject)refBinding).getPolicySets() ) { - if ( svcPolicySet.equals(refPolicySet) ) { - isCompatible = true; - break; - } - } - //if there exists no matching policy set in the reference binding - if ( !isCompatible ) { - return isCompatible; - } - } - } - return isCompatible; - } - -} 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 33611fb8c0..c1862e0380 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 @@ -27,7 +27,6 @@ import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.EndpointFactory; import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.assembly.OptimizableBinding; import org.apache.tuscany.sca.assembly.Reference; @@ -167,7 +166,6 @@ abstract class ReferenceConfigurationUtil { static void reconcileReferenceBindings(Reference reference, ComponentReference promotedReference, AssemblyFactory assemblyFactory, - EndpointFactory endpointFactory, Monitor monitor) { if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE || diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java index 9a90d7aaea..2380bbf088 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java @@ -26,7 +26,6 @@ import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.interfacedef.InterfaceContract; @@ -41,7 +40,6 @@ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentRe private boolean nonOverridable; private List<CompositeReference> promotedAs = new ArrayList<CompositeReference>(); private ComponentService callbackService; - private List<Endpoint> endpoints = new ArrayList<Endpoint>(); /** * Constructs a new component reference. @@ -88,9 +86,6 @@ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentRe this.callbackService = callbackService; } - public List<Endpoint> getEndpoints(){ - return endpoints; - } /** * Use endpoint information to work out what the interface contract for the @@ -100,12 +95,6 @@ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentRe public InterfaceContract getInterfaceContract(Binding binding){ InterfaceContract interfaceContract = null; - for (Endpoint theEndpoint : endpoints){ - if (theEndpoint.getSourceBinding() == binding){ - interfaceContract = theEndpoint.getInterfaceContract(); - } - } - if (interfaceContract == null){ interfaceContract = getInterfaceContract(); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointFactoryImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointFactoryImpl.java deleted file mode 100644 index ece51cbe9b..0000000000 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointFactoryImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - - -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointFactory; - -/** - * A factory for the Endpoint model. - * - * @version $Rev$ $Date$ - */ -public abstract class EndpointFactoryImpl implements EndpointFactory { - - public EndpointFactoryImpl (){ - - } - - public Endpoint createEndpoint() { - return new EndpointImpl(); - } - -} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java deleted file mode 100644 index 5748abb07d..0000000000 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; - -/** - * The assembly model object for an endpoint. - * - * @version $Rev$ $Date$ - */ -public class EndpointImpl implements Endpoint { - - private String targetName; - - private Component sourceComponent; - private ComponentReference sourceComponentReference; - private Binding resolvedBinding; - private Binding resolvedCallbackBinding; - - private List<Binding> candidateBindings = new ArrayList<Binding>(); - - private Component targetComponent; - private ComponentService targetComponentService; - private Binding targetBinding; - private Binding targetCallbackBinding; - - private InterfaceContract interfaceContract; - - protected EndpointImpl() { - } - - public boolean isUnresolved() { - return resolvedBinding == null; - } - - public void setUnresolved(boolean unresolved) { - // do nothing as the status is determined by having - // a resolved source binding - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - public String getTargetName(){ - return targetName; - } - - public void setTargetName(String targetName){ - this.targetName = targetName; - } - - public Component getSourceComponent() { - return sourceComponent; - } - - public void setSourceComponent(Component sourceComponent) { - this.sourceComponent = sourceComponent; - } - - public ComponentReference getSourceComponentReference() { - return sourceComponentReference; - } - - public void setSourceComponentReference(ComponentReference sourceComponentReference) { - this.sourceComponentReference = sourceComponentReference; - } - - public Binding getSourceBinding() { - return resolvedBinding; - } - - public void setSourceBinding(Binding resolvedBinding) { - this.resolvedBinding = resolvedBinding; - } - - public Binding getSourceCallbackBinding(){ - return resolvedCallbackBinding; - } - - public void setSourceCallbackBinding(Binding resolvedCallbackBinding){ - this.resolvedCallbackBinding = resolvedCallbackBinding; - } - - public List<Binding> getCandidateBindings() { - return candidateBindings; - } - - public Component getTargetComponent() { - return targetComponent; - } - - public void setTargetComponent(Component targetComponent) { - this.targetComponent = targetComponent; - } - - public ComponentService getTargetComponentService() { - return targetComponentService; - } - - public void setTargetComponentService(ComponentService targetComponentService) { - this.targetComponentService = targetComponentService; - } - - public Binding getTargetBinding() { - return targetBinding; - } - - public void setTargetBinding(Binding targetBinding) { - this.targetBinding = targetBinding; - } - - public Binding getTargetCallbackBinding(){ - return targetCallbackBinding; - } - - public void setTargetCallbackBinding(Binding targetCallbackBinding){ - this.targetCallbackBinding = targetCallbackBinding; - } - - public InterfaceContract getInterfaceContract() { - return interfaceContract; - } - - public void setInterfaceContract(InterfaceContract interfaceContract) { - this.interfaceContract = interfaceContract; - } -} |