summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-06-17 10:43:48 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-06-17 10:43:48 +0000
commitf74dc2ca6226375eb23f8322531e2a4a66d3c8f2 (patch)
tree81619d93f6cb19246a1dcae070087fc03aa11575
parentf189bbedd0df8d5d37be4cc13054ab24d23ce4ee (diff)
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
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/itest/callback-basic-ws/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java2
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java1
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java31
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java2
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java4
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java101
6 files changed, 109 insertions, 32 deletions
diff --git a/sca-java-2.x/trunk/itest/callback-basic-ws/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java b/sca-java-2.x/trunk/itest/callback-basic-ws/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java
index 991c1b337f..3161c2ccaa 100644
--- a/sca-java-2.x/trunk/itest/callback-basic-ws/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java
+++ b/sca-java-2.x/trunk/itest/callback-basic-ws/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java
@@ -40,7 +40,7 @@ public class CallBackBasicTestCase {
}
@Test
- @Ignore("TUSCANY-3593")
+ //@Ignore("TUSCANY-3593")
public void testCallBackBasic1() {
CallBackBasicClient aCallBackClient = node.getService(CallBackBasicClient.class, "CallBackBasicClient1");
aCallBackClient.run();
diff --git a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java
index e30298db33..5b9043e226 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java
@@ -45,6 +45,7 @@ public class WebServiceBindingBuilder implements BindingBuilder<WebServiceBindin
* Create a calculated WSDL document and save it in the Web Service binding.
*/
public void build(Component component, Contract contract, WebServiceBinding binding, BuilderContext context) {
+ binding.setWSDLDocument(null);
BindingWSDLGenerator.generateWSDL(component, contract, binding, extensionPoints, context.getMonitor());
}
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);
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java
index 43ca56839e..e852a47cf8 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java
@@ -41,6 +41,7 @@ public interface RuntimeEndpointReference extends EndpointReference, Invocable,
* @return The binding provider
*/
ReferenceBindingProvider getBindingProvider();
+
/**
* Get the interface contract for the binding. This represents the data types that the binding
* protocol stack can process.
@@ -54,7 +55,8 @@ public interface RuntimeEndpointReference extends EndpointReference, Invocable,
* implementation code uses to make the outbound call.
* @return The source component type reference interface contract
*/
- InterfaceContract getComponentTypeReferenceInterfaceContract();
+ InterfaceContract getComponentTypeReferenceInterfaceContract();
+
boolean isOutOfDate();
void rebuild();
boolean isStarted();
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
index 7b0f50ebd0..177221586b 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
@@ -30,9 +30,11 @@ import javax.xml.namespace.QName;
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.ComponentService;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
import org.apache.tuscany.sca.assembly.builder.BuilderContext;
import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
@@ -40,6 +42,7 @@ import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -49,6 +52,7 @@ import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentMap;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.Qualifier;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
@@ -71,7 +75,8 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
protected AssemblyFactory assemblyFactory;
protected InterfaceContractMapper interfaceContractMapper;
protected BuilderExtensionPoint builders;
- private Monitor monitor;
+ protected CompositeActivator compositeActivator;
+ protected Monitor monitor;
public EndpointReferenceBinderImpl(ExtensionPointRegistry extensionPoints) {
@@ -87,6 +92,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
monitor = monitorFactory.createMonitor();
this.builders = extensionPoints.getExtensionPoint(BuilderExtensionPoint.class);
+ this.compositeActivator = extensionPoints.getExtensionPoint(CompositeActivator.class);
}
/**
@@ -97,7 +103,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
* @param endpointReference
*/
public void bindBuildTime(EndpointRegistry endpointRegistry,
- EndpointReference endpointReference) {
+ EndpointReference endpointReference) {
bind(endpointRegistry, endpointReference, false);
}
@@ -109,7 +115,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
* @param endpointReference
*/
public void bindRunTime(EndpointRegistry endpointRegistry,
- EndpointReference endpointReference) {
+ EndpointReference endpointReference) {
bind(endpointRegistry, endpointReference, true);
}
@@ -121,8 +127,8 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
* @param runtime set true if called from the runtime
*/
public void bind(EndpointRegistry endpointRegistry,
- EndpointReference endpointReference,
- boolean runtime){
+ EndpointReference endpointReference,
+ boolean runtime){
logger.fine("Binding " + endpointReference.toString());
@@ -205,7 +211,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
(endpointReference.getCallbackEndpoint() == null
|| endpointReference.getCallbackEndpoint().isUnresolved())) {
selectCallbackEndpoint(endpointReference,
- endpointReference.getReference().getCallbackService().getEndpoints(),
+ endpointReference.getReference().getCallbackService(),
matchAudit);
}
} else if (endpointReference.getStatus() == EndpointReference.Status.WIRED_TARGET_FOUND_READY_FOR_MATCHING ){
@@ -220,7 +226,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
if (hasCallback(endpointReference)){
selectCallbackEndpoint(endpointReference,
- endpointReference.getReference().getCallbackService().getEndpoints(),
+ endpointReference.getReference().getCallbackService(),
matchAudit);
}
} else if (endpointReference.getStatus() == EndpointReference.Status.WIRED_TARGET_IN_BINDING_URI ||
@@ -258,7 +264,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
if (hasCallback(endpointReference)){
selectCallbackEndpoint(endpointReference,
- endpointReference.getReference().getCallbackService().getEndpoints(),
+ endpointReference.getReference().getCallbackService(),
matchAudit);
}
}
@@ -353,28 +359,89 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
* @param endpointReference
* @param endpoints
*/
- private void selectCallbackEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints, StringBuffer matchAudit) {
+ private void selectCallbackEndpoint(EndpointReference endpointReference, ComponentService callbackService, StringBuffer matchAudit) {
// find the first callback endpoint that matches a callback endpoint reference
// at the service
- Endpoint matchedEndpoint = null;
+ RuntimeEndpoint matchedEndpoint = null;
match:
for ( EndpointReference callbackEndpointReference : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
- for (Endpoint endpoint : endpoints){
+ for (Endpoint endpoint : callbackService.getEndpoints()){
if (haveMatchingPolicy(callbackEndpointReference, endpoint, matchAudit) &&
haveMatchingInterfaceContracts(callbackEndpointReference, endpoint, matchAudit)){
- matchedEndpoint = endpoint;
+ matchedEndpoint = (RuntimeEndpoint)endpoint;
break match;
}
}
}
- if (matchedEndpoint == null){
- return;
- } else {
- endpointReference.setCallbackEndpoint(matchedEndpoint);
- }
+ // if no callback endpoint was found or if the binding is the SCA binding and it doesn't match
+ // the forward binding then create a new callback endpoint
+ // TODO - there is a hole here in that the user may explicitly specify an SCA binding for the
+ // callback that is different from the forward binding. Waiting for feedback form OASIS
+ // before doing more drastic surgery to fix this corner case as there are other things
+ // wrong with the default case, such as what to do about policy
+ if (matchedEndpoint == null ||
+ (matchedEndpoint.getBinding().getType().equals(SCABinding.TYPE) &&
+ !endpointReference.getBinding().getType().equals(SCABinding.TYPE))){
+ // no endpoint in place so we need to create one
+ matchedEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
+ matchedEndpoint.setComponent(endpointReference.getComponent());
+ matchedEndpoint.setService(callbackService);
+
+ Binding forwardBinding = endpointReference.getBinding();
+ Binding callbackBinding = null;
+ for (EndpointReference callbackEPR : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
+ if (callbackEPR.getBinding().getType().equals(forwardBinding.getType())){
+ try {
+ callbackBinding = (Binding)callbackEPR.getBinding().clone();
+ } catch (CloneNotSupportedException ex){
+
+ }
+ break;
+ }
+ }
+
+ // get the callback binding URI by looking at the SCA binding
+ // that will have been added at build time
+ callbackBinding.setURI(null);
+ for (Endpoint endpoint : callbackService.getEndpoints()){
+ if (endpoint.getBinding().getType().equals(SCABinding.TYPE)){
+ callbackBinding.setURI(endpoint.getBinding().getURI());
+ }
+ }
+
+ matchedEndpoint.setBinding(callbackBinding);
+ callbackService.getBindings().add(callbackBinding);
+
+ matchedEndpoint.setUnresolved(false);
+ callbackService.getEndpoints().add(matchedEndpoint);
+
+ // build it
+ build(matchedEndpoint);
+
+ // activate it
+ compositeActivator.activate(((RuntimeEndpointReferenceImpl)endpointReference).getCompositeContext(),
+ matchedEndpoint);
+
+ // start it
+ compositeActivator.start(((RuntimeEndpointReferenceImpl)endpointReference).getCompositeContext(),
+ matchedEndpoint);
+ }
+
+ endpointReference.setCallbackEndpoint(matchedEndpoint);
}
+
+ private void build(Endpoint endpoint) {
+
+ BindingBuilder builder = builders.getBindingBuilder(endpoint.getBinding().getType());
+ if (builder != null) {
+ builder.build(endpoint.getComponent(),
+ endpoint.getService(),
+ endpoint.getBinding(),
+ new BuilderContext(extensionPoints));
+ }
+ }
/**
* Determine if endpoint reference and endpoint policies match. We know by this stage