Author: antelder
Date: Wed Sep  3 09:28:08 2008
New Revision: 691663

URL: http://svn.apache.org/viewvc?rev=691663&view=rev
Log:
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

Modified:
    
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java
    
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java
    
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java
    
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java

Modified: 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java?rev=691663&r1=691662&r2=691663&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java
 (original)
+++ 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java
 Wed Sep  3 09:28:08 2008
@@ -307,6 +307,12 @@
             // 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);
         

Modified: 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java?rev=691663&r1=691662&r2=691663&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java
 (original)
+++ 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java
 Wed Sep  3 09:28:08 2008
@@ -151,6 +151,11 @@
     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()
      */

Modified: 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java?rev=691663&r1=691662&r2=691663&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java
 (original)
+++ 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java
 Wed Sep  3 09:28:08 2008
@@ -69,6 +69,18 @@
                 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;
     }
 

Modified: 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java?rev=691663&r1=691662&r2=691663&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java
 (original)
+++ 
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java
 Wed Sep  3 09:28:08 2008
@@ -121,7 +121,16 @@
         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 @@
     }
 
     protected void initCallbackID() {
-        if (reference.getInterfaceContract().getCallbackInterface() != null) {
-            this.callbackID = createCallbackID();
+        if (reference.getInterfaceContract() != null) {
+            if (reference.getInterfaceContract().getCallbackInterface() != 
null) {
+                this.callbackID = createCallbackID();
+            }
         }
     }
 


Reply via email to