diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-08 15:55:13 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-08 15:55:13 +0000 |
commit | 70b64f446536e4860e0726b23da0ef24f21d9637 (patch) | |
tree | 82d99e74923158f6c44c8e7d4307d1e0b761dcf2 /java/sca/modules/core/src | |
parent | 651e0baa84ad6de6ba6628966660ce7cd6db4de9 (diff) |
Remove the non-OASIS code from the endpoint builder and set up build-time and runt-time operations so that I can reorganize the endpoint reference build process and get all of the endpoint building code in on place.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@802401 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/core/src')
2 files changed, 71 insertions, 3 deletions
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java index d165f7fba2..5fa3e679a0 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java @@ -34,6 +34,7 @@ import org.apache.tuscany.sca.assembly.CompositeService; import org.apache.tuscany.sca.assembly.Contract; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.assembly.builder.EndpointReferenceBuilder; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; @@ -328,7 +329,7 @@ public class RuntimeWireImpl implements RuntimeWire { * is first used */ private void resolveEndpointReference(){ - endpointReferenceBuilder.build(endpointReference, null); + endpointReferenceBuilder.runtimeBuild(endpointReference); // set the endpoint based on the resolved endpoint endpoint = endpointReference.getTargetEndpoint(); @@ -631,12 +632,24 @@ public class RuntimeWireImpl implements RuntimeWire { ComponentService service, InvocationChain chain, Operation operation) { + + + + if (service.getService() instanceof CompositeService){ + CompositeService compositeService = (CompositeService)service.getService(); + component = getPromotedComponent(compositeService); + service = getPromotedComponentService(compositeService); + } + ImplementationProvider provider = ((RuntimeComponent)component).getImplementationProvider(); - if (provider != null) { + + if (provider != null) { Invoker invoker = null; invoker = provider.createInvoker((RuntimeComponentService)service, operation); chain.addInvoker(invoker); } + // TODO - EPR - don't we need to get the policy from the right level in the + // model rather than the leafmost level List<PolicyProvider> pps = ((RuntimeComponent)component).getPolicyProviders(); if (pps != null) { for (PolicyProvider p : pps) { @@ -696,4 +709,59 @@ public class RuntimeWireImpl implements RuntimeWire { public ExtensionPointRegistry getExtensionPoints() { return extensionPoints; } + + /** + * Follow a service promotion chain down to the inner most (non composite) + * component service. + * + * @param topCompositeService + * @return + */ + private ComponentService getPromotedComponentService(CompositeService compositeService) { + ComponentService componentService = compositeService.getPromotedService(); + if (componentService != null) { + Service service = componentService.getService(); + if (componentService.getName() != null && service instanceof CompositeService) { + + // Continue to follow the service promotion chain + return getPromotedComponentService((CompositeService)service); + + } else { + + // Found a non-composite service + return componentService; + } + } else { + + // No promoted service + return null; + } + } + + /** + * Follow a service promotion chain down to the innermost (non-composite) component. + * + * @param compositeService + * @return + */ + private Component getPromotedComponent(CompositeService compositeService) { + ComponentService componentService = compositeService.getPromotedService(); + if (componentService != null) { + Service service = componentService.getService(); + if (componentService.getName() != null && service instanceof CompositeService) { + + // Continue to follow the service promotion chain + return getPromotedComponent((CompositeService)service); + + } else { + + // Found a non-composite service + return compositeService.getPromotedComponent(); + } + } else { + + // No promoted service + return null; + } + } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java index 02bab99cb1..7ad4db79dc 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java @@ -361,7 +361,7 @@ public class ComponentContextImpl implements ComponentContextExt { componentReference.getEndpointReferences().add(endpointReference); // do binding matching - endpointReferenceBuilder.build(endpointReference, monitor); + endpointReferenceBuilder.runtimeBuild(endpointReference); return componentReference; } |