From f74dc2ca6226375eb23f8322531e2a4a66d3c8f2 Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 17 Jun 2010 10:43:48 +0000 Subject: TUSCANY-3593 - Create an endpoint on the fly at the point a reference target is resolved in order to handle callbacks. This investigation has raised some questions that OASIS needs to answer, e.g. how to handle policy in this late bound scenario. Also this code change turns off generated WSDL caching and also relies on the SCA binding being attached to the callback service to carry the binding URI but this causes problems if you explicitly specify binding.sca. So more work to do but the basic test passes now. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@955544 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/builder/impl/ComponentBuilderImpl.java | 31 +++++++++++++--------- .../sca/builder/impl/EndpointBuilderImpl.java | 2 ++ 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany') diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java index 497d7ab989..32ebc71348 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java @@ -1095,14 +1095,14 @@ public class ComponentBuilderImpl { private void createCallbackService(Component component, ComponentReference reference) { if (reference.getInterfaceContract() != null && // can be null in unit tests reference.getInterfaceContract().getCallbackInterface() != null) { - ComponentService componentService = assemblyFactory.createComponentService(); - componentService.setForCallback(true); - componentService.setName(reference.getName()); + ComponentService callbackService = assemblyFactory.createComponentService(); + callbackService.setForCallback(true); + callbackService.setName(reference.getName()); try { InterfaceContract contract = (InterfaceContract)reference.getInterfaceContract().clone(); contract.setInterface(contract.getCallbackInterface()); contract.setCallbackInterface(null); - componentService.setInterfaceContract(contract); + callbackService.setInterfaceContract(contract); } catch (CloneNotSupportedException e) { // will not happen } @@ -1151,16 +1151,16 @@ public class ComponentBuilderImpl { } catch (CloneNotSupportedException e) { // will not happen } - componentService.setService(implService); + callbackService.setService(implService); } - component.getServices().add(componentService); + component.getServices().add(callbackService); // configure bindings for the callback service - if (componentService.getBindings().isEmpty()) { + if (callbackService.getBindings().isEmpty()) { if (reference.getCallback() != null && reference.getCallback().getBindings().size() > 0) { // set bindings of the callback service based on the information provided in // SCDL reference callback element - componentService.getBindings().addAll(reference.getCallback().getBindings()); + callbackService.getBindings().addAll(reference.getCallback().getBindings()); } else if (reference.getBindings().size() > 0) { // use any bindings explicitly declared on the forward reference for (Binding binding : reference.getBindings()) { @@ -1168,19 +1168,24 @@ public class ComponentBuilderImpl { Binding clonedBinding = (Binding)binding.clone(); // binding uri will be calculated during runtime build clonedBinding.setURI(null); - componentService.getBindings().add(clonedBinding); + callbackService.getBindings().add(clonedBinding); } catch (CloneNotSupportedException ex) { } } } else { - // create a default binding - // TODO - need to mark the binding as needing resolution - createSCABinding(componentService, null); + // create a default binding which will have the correct policy + // and URI added. We check later to see if a new binding is required + // based on the forward binding but can then copy policy and URI + // details from here. + // TODO - there is a hole here. If the user explicitly specified an + // SCA callback binding that is different from the forward + // binding type then we're in trouble + createSCABinding(callbackService, null); } } - reference.setCallbackService(componentService); + reference.setCallbackService(callbackService); } } diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java index 6c44d2e9e0..c1ba47661a 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java @@ -111,6 +111,8 @@ public class EndpointBuilderImpl implements CompositeBuilder { // to the services they promote. This is not actually done // until the wire is created though in order that the // uri is calculated correctly + // Callback endpoints may not be added here in the case that the + // forward reference is not yet resolved. for (Binding binding : service.getBindings()) { Endpoint endpoint = assemblyFactory.createEndpoint(); endpoint.setComponent(component); -- cgit v1.2.3