Author: slaws
Date: Mon Dec 10 09:48:15 2007
New Revision: 602978

URL: http://svn.apache.org/viewvc?rev=602978&view=rev
Log:
Tidy the Reference binding list in the case that unresolved targets are detected

Modified:
    
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java

Modified: 
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java?rev=602978&r1=602977&r2=602978&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java
 Mon Dec 10 09:48:15 2007
@@ -402,10 +402,13 @@
                                 composite);
                     }
                 } else {
-                    // clone all the reference bindings into the target so 
that they
+                    // add all the reference bindings into the target so that 
they
                     // can be used for comparison when the target is resolved 
at runtime
                     
componentService.getBindings().addAll(componentReference.getBindings());
                     
+                    // The bindings will be cloned back into the reference 
when the 
+                    // target is finally resolved. 
+                    
                     warning("Component reference target not found, it might be 
a remote service: " + componentService.getName(), composite);
                 }
             }
@@ -448,7 +451,14 @@
                                 composite);
                     }
                 } else {
-                    warning("Reference target not found: " + 
componentService.getName(), composite);
+                    // add all the reference bindings into the target so that 
they
+                    // can be used for comparison when the target is resolved 
at runtime
+                    
componentService.getBindings().addAll(componentReference.getBindings());
+                    
+                    // The bindings will be cloned back into the reference 
when the 
+                    // target is finally resolved. 
+                    
+                    warning("Component reference target from component type 
not found, it might be a remote service: " + componentService.getName(), 
composite);
                 }
             }
         }
@@ -516,7 +526,7 @@
                     }
                 }
             }
-            
+                       
             if (!targets.isEmpty()) {
 
                 // Add all the effective bindings
@@ -526,6 +536,27 @@
                     componentReference.getCallback().getBindings().clear();
                     
componentReference.getCallback().getBindings().addAll(selectedCallbackBindings);
                 }
+            }
+            
+            // Need to tidy up the reference binding list. The situation so 
far...
+            //    Wired reference (1 or more targets are specified)
+            //       Binding.uri = null  - remove as its left over from target 
resolution
+            //                             the binding will have been moved to 
the target from where 
+            //                             it will be resolved later
+            //       Binding.uri != null - the reference was resolved
+            //    Unwired reference (0 targets)
+            //       Binding.uri = null  - Either a callback reference or the 
reference is yet to be wired
+            //                             either manually or via autowire so 
leave the binding where it is
+            //       Binding.uri != null - from the composite file so leave it 
+            if (componentReference.getTargets().size() > 0){
+                List<Binding> bindingsToRemove = new ArrayList<Binding>();
+                for(Binding binding : componentReference.getBindings()){
+                    if(binding.getURI() == null){
+                        bindingsToRemove.add(binding);
+                    }
+                }
+                
+                componentReference.getBindings().removeAll(bindingsToRemove);
             }
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to