From 61b23a56a9e6233baedd5bb534a8c1d8d1369f03 Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 3 Sep 2008 16:28:08 +0000 Subject: Interim fixes to get binding-sca-jms working, see TUSCANY-2580. These need to be improved by fixing the underlying cause which is what TUSCANY-2580 is for git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@691663 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/core/assembly/CompositeActivatorImpl.java | 6 ++++++ .../tuscany/sca/core/assembly/EndpointWireImpl.java | 5 +++++ .../core/assembly/RuntimeComponentReferenceImpl.java | 12 ++++++++++++ .../tuscany/sca/core/context/CallableReferenceImpl.java | 17 ++++++++++++++--- 4 files changed, 37 insertions(+), 3 deletions(-) (limited to 'java/sca/modules/core') diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java index 6eb5f0d1e5..f51931c53b 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java @@ -307,6 +307,12 @@ public class CompositeActivatorImpl implements CompositeActivator { // wire return; } + + // TODO: TUSCANY-2580: avoid NPE if the InterfaceCOntract is null + Reference ctref = endpoint.getSourceComponentReference().getReference(); + if (ctref != null && ctref.getInterfaceContract() == null) { + ctref.setInterfaceContract(reference.getInterfaceContract()); + } RuntimeWire wire = new EndpointWireImpl(endpoint, this); diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java index 87dbf0eeac..c25c580fe6 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java @@ -151,6 +151,11 @@ public class EndpointWireImpl implements RuntimeWire { public void rebuild() { } + // TODO: TUSCANY-2580: give RuntimeComponentReferenceImpl a way to get at the endpoint + public Endpoint getEndpoint() { + return endpoint; + } + /** * @see java.lang.Object#clone() */ diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java index eced10e235..b386495a08 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java @@ -69,6 +69,18 @@ public class RuntimeComponentReferenceImpl extends ComponentReferenceImpl implem return wire; } } + + // TODO: TUSCANY-2580: before returning null see if a candidate binding matches + for (RuntimeWire wire : getRuntimeWires()) { + if (wire instanceof EndpointWireImpl) { + Endpoint endpoint = ((EndpointWireImpl)wire).getEndpoint(); + for (Binding b : endpoint.getCandidateBindings()) { + if (b == binding) { + return wire; + } + } + } + } return null; } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java index f4e8a221b3..fc6d7abf6a 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java @@ -121,7 +121,16 @@ public class CallableReferenceImpl implements CallableReference, Externali if (this.binding == null) { this.binding = this.reference.getBinding(SCABinding.class); if (this.binding == null) { - this.binding = this.reference.getBindings().get(0); + + // TODO: TUSCANY-2580: if the refernece doesn't have a binding yet then instead of NPE use a candidate one if its avaialable + if (reference.getBindings() != null && reference.getBindings().size() > 0) { + this.binding = this.reference.getBindings().get(0); + } else { + this.binding = this.reference.getEndpoints().get(0).getCandidateBindings().get(0); + if (this.reference.getEndpoints().get(0).getInterfaceContract() == null) { + this.reference.getEndpoints().get(0).setInterfaceContract(reference.getInterfaceContract()); + } + } } } @@ -169,8 +178,10 @@ public class CallableReferenceImpl implements CallableReference, Externali } protected void initCallbackID() { - if (reference.getInterfaceContract().getCallbackInterface() != null) { - this.callbackID = createCallbackID(); + if (reference.getInterfaceContract() != null) { + if (reference.getInterfaceContract().getCallbackInterface() != null) { + this.callbackID = createCallbackID(); + } } } -- cgit v1.2.3