Author: rfeng
Date: Thu May 14 17:56:43 2009
New Revision: 774853

URL: http://svn.apache.org/viewvc?rev=774853&view=rev
Log:
Add component name to the error message

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

Modified: 
tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java?rev=774853&r1=774852&r2=774853&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java
 (original)
+++ 
tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java
 Thu May 14 17:56:43 2009
@@ -6,15 +6,15 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 
 package org.apache.tuscany.sca.assembly.builder.impl;
@@ -33,7 +33,6 @@
 import org.apache.tuscany.sca.assembly.EndpointReference2;
 import org.apache.tuscany.sca.assembly.Implementation;
 import org.apache.tuscany.sca.assembly.Multiplicity;
-import org.apache.tuscany.sca.assembly.Reference;
 import org.apache.tuscany.sca.assembly.SCABinding;
 import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
 import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
@@ -59,34 +58,34 @@
 
     /**
      * Create endpoint references for all component references.
-     * 
+     *
      * @param composite
      */
-    public void build(Composite composite, Definitions definitions, Monitor 
monitor) throws CompositeBuilderException 
+    public void build(Composite composite, Definitions definitions, Monitor 
monitor) throws CompositeBuilderException
     {
         // process top level composite references
         // TODO - I don't think OASIS allows for these
         //
         //processCompositeReferences(composite);
-        
+
         // process component services
-        processComponentReferences(composite, monitor);  
+        processComponentReferences(composite, monitor);
     }
-    
+
     private void processCompositeReferences(Composite composite) {
         // TODO do we need this for OASIS?
     }
-    
+
     private void processComponentReferences(Composite composite, Monitor 
monitor) {
-        
+
         // index all of the components in the composite
         Map<String, Component> components = new HashMap<String, Component>();
         indexComponents(composite, components);
-        
+
         // index all of the services in the composite
         Map<String, ComponentService> componentServices = new HashMap<String, 
ComponentService>();
         indexServices(composite, componentServices);
-        
+
         // create endpoint references for each component's references
         for (Component component : composite.getComponents()) {
             // recurse for composite implementations
@@ -94,12 +93,12 @@
             if (implementation instanceof Composite) {
                 processComponentReferences((Composite)implementation, monitor);
             }
-            
+
             // create endpoint references to represent the component reference
             for (ComponentReference reference : component.getReferences()) {
-                
+
                 createReferenceEndpointReferences(composite, component, 
reference, components, componentServices, monitor);
-                
+
                 // fix up links between endpoints and endpoint references that 
represent callbacks
                 for (ComponentService service : component.getServices()){
                     if ((service.getInterfaceContract() != null) &&
@@ -115,29 +114,29 @@
             } // end for
         } // end for
     } // end method processCompoenntReferences
-    
-    private void createReferenceEndpointReferences(Composite composite, 
-                                                   Component component, 
-                                                   ComponentReference 
reference, 
+
+    private void createReferenceEndpointReferences(Composite composite,
+                                                   Component component,
+                                                   ComponentReference 
reference,
                                                    Map<String, Component> 
components,
-                                                   Map<String, 
ComponentService> componentServices, 
+                                                   Map<String, 
ComponentService> componentServices,
                                                    Monitor monitor)
     {
-        // Get reference targets 
+        // Get reference targets
        List<ComponentService> refTargets = getReferenceTargets( reference );
-       if (reference.getAutowire() == Boolean.TRUE && 
+       if (reference.getAutowire() == Boolean.TRUE &&
             reference.getTargets().isEmpty()) {
 
             // Find suitable targets in the current composite for an
             // autowired reference
             Multiplicity multiplicity = reference.getMultiplicity();
             for (Component targetComponent : composite.getComponents()) {
-                
+
                 // Prevent autowire connecting to self
                if( targetComponent == component ) continue;
-                
+
                 for (ComponentService targetComponentService : 
targetComponent.getServices()) {
-                    if (reference.getInterfaceContract() == null || 
+                    if (reference.getInterfaceContract() == null ||
                         
interfaceContractMapper.isCompatible(reference.getInterfaceContract(),
                                                              
targetComponentService.getInterfaceContract())) {
                         // create endpoint reference - with a dummy endpoint 
which will be replaced when policies
@@ -147,7 +146,7 @@
                         reference.getEndpointReferences().add(endpointRef);
 
                         // Stop with the first match for 0..1 and 1..1 
references
-                        if (multiplicity == Multiplicity.ZERO_ONE || 
+                        if (multiplicity == Multiplicity.ZERO_ONE ||
                             multiplicity == Multiplicity.ONE_ONE) {
                             break;
                         } // end if
@@ -155,34 +154,34 @@
                 } // end for
             } // end for
 
-            if (multiplicity == Multiplicity.ONE_N || 
+            if (multiplicity == Multiplicity.ONE_N ||
                 multiplicity == Multiplicity.ONE_ONE) {
                 if (reference.getEndpointReferences().size() == 0) {
                     warning(monitor, "NoComponentReferenceTarget",
-                            reference, 
+                            reference,
                             reference.getName());
                 }
             }
 
         } else if (!refTargets.isEmpty()) {
-            // Check that the component reference does not mix the use of 
endpoint references 
-               // specified via the target attribute with the presence of 
binding elements 
+            // Check that the component reference does not mix the use of 
endpoint references
+               // specified via the target attribute with the presence of 
binding elements
             if( bindingsIdentifyTargets( reference ) ) {
                 warning(monitor, "ReferenceEndPointMixWithTarget",
                         composite, composite.getName().toString(), 
component.getName(), reference.getName());
             }
 
             // Resolve targets specified on the component reference
-            for (ComponentService target : refTargets) {               
-                
+            for (ComponentService target : refTargets) {
+
                 String targetName = target.getName();
                 ComponentService targetComponentService = 
componentServices.get(targetName);
-                
+
                 Component targetComponent = getComponentFromTargetName( 
components, targetName );
 
                 if (targetComponentService != null) {
                     // Check that target component service provides a superset 
of the component reference interface
-                    if (reference.getInterfaceContract() == null || 
+                    if (reference.getInterfaceContract() == null ||
                         
interfaceContractMapper.isCompatible(reference.getInterfaceContract(),
                                                              
targetComponentService.getInterfaceContract())) {
 
@@ -193,9 +192,9 @@
                         reference.getEndpointReferences().add(endpointRef);
                     } else {
                         warning(monitor, "ReferenceIncompatibleInterface",
-                                composite, 
+                                composite,
                                 composite.getName().toString(),
-                                reference.getName(), 
+                                component.getName() + "." + 
reference.getName(),
                                 targetName);
                     }
                 } else {
@@ -204,14 +203,14 @@
                     endpointRef.setTargetEndpoint(createEndpoint(true));
                     reference.getEndpointReferences().add(endpointRef);
                     warning(monitor, "ComponentReferenceTargetNotFound",
-                            composite, 
+                            composite,
                             composite.getName().toString(),
                             targetName);
                 } // end if
             } // end for
         } // end if
 
-        // if no endpoints have found so far the bindings hold the targets. 
+        // if no endpoints have found so far the bindings hold the targets.
         if (reference.getEndpointReferences().isEmpty()) {
             for (Binding binding : reference.getBindings()) {
 
@@ -223,10 +222,10 @@
                        // Regular forward references are UNWIRED with no 
endpoint if they have an SCABinding with NO targets
                        // and NO URI set - but Callbacks with an SCABinding 
are wired and need an endpoint
                        if( !reference.isCallback() && (binding instanceof 
SCABinding) ) continue;
-                       
+
                     // create endpoint reference for manually configured 
bindings with a resolved endpoint to
                        // signify that this reference is pointing at some 
unwired endpoint
-                    EndpointReference2 endpointRef = createEndpointRef( 
component, reference, 
+                    EndpointReference2 endpointRef = createEndpointRef( 
component, reference,
                                binding, null, false  );
                     endpointRef.setTargetEndpoint(createEndpoint(false));
                     reference.getEndpointReferences().add(endpointRef);
@@ -244,14 +243,14 @@
                 ComponentService targetComponentService = 
componentServices.get(uri);
                 Component targetComponent = getComponentFromTargetName( 
components, uri );
 
-                // If the binding URI matches a component in the composite, 
configure an endpoint reference with 
-                // this component as the target. 
+                // If the binding URI matches a component in the composite, 
configure an endpoint reference with
+                // this component as the target.
                 // If not, the binding URI is assumed to reference an external 
service
                 if (targetComponentService != null) {
 
                     // Check that the target component service provides
                     // a superset of the component reference interface
-                    if (reference.getInterfaceContract() == null || 
+                    if (reference.getInterfaceContract() == null ||
                         
interfaceContractMapper.isCompatible(reference.getInterfaceContract(),
                                                              
targetComponentService.getInterfaceContract())) {
                         // create endpoint reference with dummy endpoint which 
will be replaced when policies
@@ -261,22 +260,22 @@
                         reference.getEndpointReferences().add(endpointRef);
                     } else {
                         warning(monitor, "ReferenceIncompatibleInterface",
-                                composite, 
+                                composite,
                                 composite.getName().toString(),
-                                reference.getName(), 
+                                reference.getName(),
                                 uri);
                     }
                 } else {
-                    // create endpoint reference for manually configured 
bindings with resolved endpoint 
+                    // create endpoint reference for manually configured 
bindings with resolved endpoint
                        // to signify that this reference is pointing at some 
unwired endpoint
                     EndpointReference2 endpointRef = createEndpointRef( 
component, reference, binding, null, false  );
                     endpointRef.setTargetEndpoint(createEndpoint( false ));
                     reference.getEndpointReferences().add(endpointRef);
-                } // end if 
+                } // end if
             }
         }
     } // end method
-    
+
     /**
      * Evaluates whether the bindings attached to a reference indentify one or 
more target services.
      * @param reference - the reference
@@ -286,12 +285,12 @@
        for( Binding binding : reference.getBindings() ) {
                // <binding.sca without a URI does not identify a target
                if( (binding instanceof SCABinding) && (binding.getURI() == 
null) ) continue;
-               // any other binding implies a target 
+               // any other binding implies a target
                return true;
        } // end for
        return false;
     } // end bindingsIdentifyTargets
-    
+
     /**
      * Helper method which obtains a list of targets for a reference
      * @param reference - Component reference
@@ -307,7 +306,7 @@
        } // end if
        return theTargets;
     } // end method getReferenceTargets
-    
+
     /**
      * Helper method that finds the Component given a target name
      * @param components
@@ -324,7 +323,7 @@
         }
        return theComponent;
     } // end method getComponentFromTargetName
-    
+
     /**
      * Helper method to create an Endpoint Reference
      * @param component
@@ -334,14 +333,14 @@
      * @param unresolved
      * @return the endpoint reference
      */
-    private EndpointReference2 createEndpointRef( Component component, 
ComponentReference reference, 
+    private EndpointReference2 createEndpointRef( Component component, 
ComponentReference reference,
                Binding binding, Endpoint2 endpoint, boolean unresolved  ) {
        EndpointReference2 endpointRef = createEndpointRef( component, 
reference, unresolved  );
         endpointRef.setBinding(binding);
         endpointRef.setTargetEndpoint(endpoint);
         return endpointRef;
-    } // end method    
-    
+    } // end method
+
     /**
      * Helper method to create an Endpoint Reference
      * @param component
@@ -356,8 +355,8 @@
            endpointRef.setUnresolved(unresolved);
            return endpointRef;
     } // end method createEndpointRef
-    
-    
+
+
     /**
      * Helper method to create an endpoint
      * @param component
@@ -372,7 +371,7 @@
            endpoint.setUnresolved(unresolved);
            return endpoint;
     } // end method createEndpoint
-    
+
     /**
      * Helper method to create an Endpoint
      * @param unresolved
@@ -383,5 +382,5 @@
            endpoint.setUnresolved(unresolved);
            return endpoint;
     } // end method createEndpoint
-    
+
 } // end class


Reply via email to