You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2009/08/20 13:12:29 UTC

svn commit: r806123 - /tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/

Author: slaws
Date: Thu Aug 20 11:12:28 2009
New Revision: 806123

URL: http://svn.apache.org/viewvc?rev=806123&view=rev
Log:
Move top level monitor.pushContext calls to each build so we are doing this consistently

Modified:
    tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java
    tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java
    tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
    tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java

Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java?rev=806123&r1=806122&r2=806123&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java Thu Aug 20 11:12:28 2009
@@ -98,123 +98,124 @@
      * @param problems
      */
     private void configureComponents(Composite composite, String uri, Definitions definitions, Monitor monitor) {
-        String parentURI = uri;		
-
-        // Process nested composites recursively
-        for (Component component : composite.getComponents()) {
-
-            // Initialize component URI
-            String componentURI;
-            if (parentURI == null) {
-                componentURI = component.getName();
-            } else {
-                componentURI = URI.create(parentURI + '/').resolve(component.getName()).toString();
-            }
-            component.setURI(componentURI);
-
-            Implementation implementation = component.getImplementation();
-            if (implementation instanceof Composite) {
-            	try {
-            		monitor.pushContext("Composite: " + ((Composite)implementation).getURI());
-
+        String parentURI = uri;	
+        
+        monitor.pushContext("Composite: " + composite.getName().toString());
+        
+        try {
+    
+            // Process nested composites recursively
+            for (Component component : composite.getComponents()) {
+    
+                // Initialize component URI
+                String componentURI;
+                if (parentURI == null) {
+                    componentURI = component.getName();
+                } else {
+                    componentURI = URI.create(parentURI + '/').resolve(component.getName()).toString();
+                }
+                component.setURI(componentURI);
+    
+                Implementation implementation = component.getImplementation();
+                if (implementation instanceof Composite) {
 	                // Process nested composite
 	                configureComponents((Composite)implementation, componentURI, definitions, monitor);
-            	
-            	} finally {
-            		monitor.popContext();
-            	} // end try
+                }
+            } // end for
+    
+            // Initialize service bindings
+            List<Service> compositeServices = composite.getServices();
+            for (Service service : compositeServices) {
+                // Set default binding names 
+    
+                // Create default SCA binding
+                attachSCABinding(service, definitions);
             }
-        } // end for
-
-        // Initialize service bindings
-        List<Service> compositeServices = composite.getServices();
-        for (Service service : compositeServices) {
-            // Set default binding names 
-
-            // Create default SCA binding
-            attachSCABinding(service, definitions);
-        }
-
-        // Initialize reference bindings
-        for (Reference reference : composite.getReferences()) {
-            // Create default SCA binding
-            attachSCABinding(reference, definitions);
-        }
-
-        // Initialize all component services and references
-        Map<String, Component> components = new HashMap<String, Component>();
-        for (Component component : composite.getComponents()) {
-            
-            
-            monitor.pushContext("Component: " + component.getName());
-            
-            try {
-	            // Index all components and check for duplicates
-	            if (components.containsKey(component.getName())) {
-	                error(monitor, "DuplicateComponentName", component, composite.getName().toString(), component.getName());
-	            } else {
-	                components.put(component.getName(), component);
-	            }
-	
-	            // Propagate the autowire flag from the composite to components
-	            if (component.getAutowire() == null) {
-	                component.setAutowire(composite.getAutowire());
-	            }
-	
-	            if (component.getImplementation() instanceof ComponentPreProcessor) {
-	                ((ComponentPreProcessor)component.getImplementation()).preProcess(component);
-	            }
-	
-	            // Index implementation properties, services and references
-	            Map<String, Service> services = new HashMap<String, Service>();
-	            Map<String, Reference> references = new HashMap<String, Reference>();
-	            Map<String, Property> properties = new HashMap<String, Property>();
-	            indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor);
-	
-	            // Index component services, references and properties
-	            // Also check for duplicates
-	            Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
-	            Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
-	            Map<String, ComponentProperty> componentProperties = new HashMap<String, ComponentProperty>();
-	            indexComponentPropertiesServicesAndReferences(component,
-	                                                          componentServices,
-	                                                          componentReferences,
-	                                                          componentProperties,
-	                                                          monitor);
-	
-	            // Reconcile component services/references/properties and
-	            // implementation services/references and create component
-	            // services/references/properties for the services/references
-	            // declared by the implementation
-	            reconcileServices(component, services, componentServices, monitor);
-	            reconcileReferences(component, references, componentReferences, monitor);
-	            reconcileProperties(component, properties, componentProperties, monitor);
-	
-	            // Configure or create callback services for component's references
-	            // with callbacks
-	            configureCallbackServices(component, componentServices);
-	
-	            // Configure or create callback references for component's services
-	            // with callbacks
-	            configureCallbackReferences(component, componentReferences);
-	
-	            // Initialize service bindings
-	            for (ComponentService componentService : component.getServices()) {
-	
-	                // Create default SCA binding
-	                attachSCABinding(componentService, definitions);
-	            }
-	
-	            // Initialize reference bindings
-	            for (ComponentReference componentReference : component.getReferences()) {
-	
-	                // Create default SCA binding
-	                attachSCABinding(componentReference, definitions);
-	            }
-            } finally {
-                monitor.popContext();
+    
+            // Initialize reference bindings
+            for (Reference reference : composite.getReferences()) {
+                // Create default SCA binding
+                attachSCABinding(reference, definitions);
             }
-        }
+    
+            // Initialize all component services and references
+            Map<String, Component> components = new HashMap<String, Component>();
+            for (Component component : composite.getComponents()) {
+                
+                
+                monitor.pushContext("Component: " + component.getName());
+                
+                try {
+    	            // Index all components and check for duplicates
+    	            if (components.containsKey(component.getName())) {
+    	                error(monitor, "DuplicateComponentName", component, composite.getName().toString(), component.getName());
+    	            } else {
+    	                components.put(component.getName(), component);
+    	            }
+    	
+    	            // Propagate the autowire flag from the composite to components
+    	            if (component.getAutowire() == null) {
+    	                component.setAutowire(composite.getAutowire());
+    	            }
+    	
+    	            if (component.getImplementation() instanceof ComponentPreProcessor) {
+    	                ((ComponentPreProcessor)component.getImplementation()).preProcess(component);
+    	            }
+    	
+    	            // Index implementation properties, services and references
+    	            Map<String, Service> services = new HashMap<String, Service>();
+    	            Map<String, Reference> references = new HashMap<String, Reference>();
+    	            Map<String, Property> properties = new HashMap<String, Property>();
+    	            indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor);
+    	
+    	            // Index component services, references and properties
+    	            // Also check for duplicates
+    	            Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+    	            Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+    	            Map<String, ComponentProperty> componentProperties = new HashMap<String, ComponentProperty>();
+    	            indexComponentPropertiesServicesAndReferences(component,
+    	                                                          componentServices,
+    	                                                          componentReferences,
+    	                                                          componentProperties,
+    	                                                          monitor);
+    	
+    	            // Reconcile component services/references/properties and
+    	            // implementation services/references and create component
+    	            // services/references/properties for the services/references
+    	            // declared by the implementation
+    	            reconcileServices(component, services, componentServices, monitor);
+    	            reconcileReferences(component, references, componentReferences, monitor);
+    	            reconcileProperties(component, properties, componentProperties, monitor);
+    	
+    	            // Configure or create callback services for component's references
+    	            // with callbacks
+    	            configureCallbackServices(component, componentServices);
+    	
+    	            // Configure or create callback references for component's services
+    	            // with callbacks
+    	            configureCallbackReferences(component, componentReferences);
+    	
+    	            // Initialize service bindings
+    	            for (ComponentService componentService : component.getServices()) {
+    	
+    	                // Create default SCA binding
+    	                attachSCABinding(componentService, definitions);
+    	            }
+    	
+    	            // Initialize reference bindings
+    	            for (ComponentReference componentReference : component.getReferences()) {
+    	
+    	                // Create default SCA binding
+    	                attachSCABinding(componentReference, definitions);
+    	            }
+                } finally {
+                    monitor.popContext();
+                }
+            }
+        
+        } finally {
+            monitor.popContext();
+        } // end try        
     } // end method 
 
     /**

Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java?rev=806123&r1=806122&r2=806123&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java Thu Aug 20 11:12:28 2009
@@ -68,73 +68,37 @@
 
         monitor.pushContext(composite.getName().toString());
         
-        // Wire nested composites recursively
-        for (Component component : composite.getComponents()) {
-            Implementation implementation = component.getImplementation();
-            if (implementation instanceof Composite) {
-                wireComponentReferences((Composite)implementation, monitor);
-            }
-        }
-
-        // Index components, services and references
-        Map<String, Component> components = new HashMap<String, Component>();
-        Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
-        Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
-        indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences);
-
-        // Connect component references as described in wires
-        connectWires(composite, componentServices, componentReferences, monitor);
-
-        // Validate that references are wired or promoted, according
-        // to their multiplicity
-        for (Component component: components.values()){
-            monitor.pushContext(component.getName());
-            for (ComponentReference componentReference : component.getReferences()) {
-                monitor.pushContext(componentReference.getName());
-                if (!ReferenceConfigurationUtil.validateMultiplicityAndTargets(componentReference.getMultiplicity(),
-                                                                               componentReference.getTargets(),
-                                                                               componentReference.getBindings())) {
-                    if (componentReference.getTargets().isEmpty()) {
+        try {
+            // Wire nested composites recursively
+            for (Component component : composite.getComponents()) {
+                Implementation implementation = component.getImplementation();
+                if (implementation instanceof Composite) {
     
-                        // No warning if the reference is promoted out of the current composite
-                        boolean promoted = false;
-                        for (Reference reference : composite.getReferences()) {
-                            CompositeReference compositeReference = (CompositeReference)reference;
-                            if (compositeReference.getPromotedReferences().contains(componentReference)) {
-                                promoted = true;
-                                break;
-                            }
-                        }
-                        if (!promoted && !componentReference.isForCallback()) {
-                            warning(monitor,
-                                    "ReferenceWithoutTargets",
-                                    composite,
-                                    composite.getName().toString(),
-                                    componentReference.getName());
-                        }
-                    } else {
-// ---------------------------                    
-// TUSCANY-3132  first example of updated error handling                  
-                        Monitor.error(monitor,
-                                      this,
-                                      "assembly-validation-messages",
-                                      "TooManyReferenceTargets", 
-                                      componentReference.getName());
-// ---------------------------                    
-                    }
+                        wireComponentReferences((Composite)implementation, monitor);
+                           
                 }
-                monitor.popContext();
             }
+    
+            // Index components, services and references
+            Map<String, Component> components = new HashMap<String, Component>();
+            Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+            Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+            indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences);
+    
+            // Connect component references as described in wires
+            connectWires(composite, componentServices, componentReferences, monitor);
+    
+    
+            // Finally clear the original reference target lists as we now have
+            // bindings to represent the targets
+            //  for (ComponentReference componentReference : componentReferences.values()) {
+            //      componentReference.getTargets().clear();
+            //  }
+        
+        } finally {
             monitor.popContext();
-        }
+        }         
 
-        // Finally clear the original reference target lists as we now have
-        // bindings to represent the targets
-        //  for (ComponentReference componentReference : componentReferences.values()) {
-        //      componentReference.getTargets().clear();
-        //  }
-        
-        monitor.popContext();
     }
 
     /**

Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java?rev=806123&r1=806122&r2=806123&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java Thu Aug 20 11:12:28 2009
@@ -138,86 +138,96 @@
                                       Definitions definitions,
                                       Map<QName, List<String>> defaultBindings,
                                       Monitor monitor) throws CompositeBuilderException {
-
+        
         String parentComponentURI = uri;
-
-        // Process nested composites recursively
-        for (Component component : composite.getComponents()) {
-
-            // Initialize component URI
-            String componentURI;
-            if (parentComponentURI == null) {
-                componentURI = component.getName();
-            } else {
-                componentURI = URI.create(parentComponentURI + '/').resolve(component.getName()).toString();
-            }
-            component.setURI(componentURI);
-
-            Implementation implementation = component.getImplementation();
-            if (implementation instanceof Composite) {
-
-                // Process nested composite
-                configureBindingURIs((Composite)implementation, componentURI, definitions, defaultBindings, monitor);
-            }
-        }
-
-        // Initialize composite service binding URIs
-        List<Service> compositeServices = composite.getServices();
-        for (Service service : compositeServices) {
-            // Set default binding names
-
-            // Create default SCA binding
-            attachSCABinding(service, definitions);
-
-            constructBindingNames(service, monitor);
-            
-            // Initialize binding names and URIs
-            for (Binding binding : service.getBindings()) {
-                constructBindingURI(parentComponentURI, composite, service, binding, defaultBindings, monitor);
+        
+        monitor.pushContext("Composite: " + composite.getName().toString());
+        try {        
+            // Process nested composites recursively
+            for (Component component : composite.getComponents()) {
+    
+                // Initialize component URI
+                String componentURI;
+                if (parentComponentURI == null) {
+                    componentURI = component.getName();
+                } else {
+                    componentURI = URI.create(parentComponentURI + '/').resolve(component.getName()).toString();
+                }
+                component.setURI(componentURI);
+    
+                Implementation implementation = component.getImplementation();
+                if (implementation instanceof Composite) {
+                    // Process nested composite
+                    configureBindingURIs((Composite)implementation, componentURI, definitions, defaultBindings, monitor);  
+                }
             }
-        }
-
-        // Initialize component service binding URIs
-        for (Component component : composite.getComponents()) {
-
-            // Index properties, services and references
-            Map<String, Service> services = new HashMap<String, Service>();
-            Map<String, Reference> references = new HashMap<String, Reference>();
-            Map<String, Property> properties = new HashMap<String, Property>();
-            indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor);
-
-            // Index component services, references and properties
-            // Also check for duplicates
-            Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
-            Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
-            Map<String, ComponentProperty> componentProperties = new HashMap<String, ComponentProperty>();
-            indexComponentPropertiesServicesAndReferences(component,
-                                                          componentServices,
-                                                          componentReferences,
-                                                          componentProperties,
-                                                          monitor);
-
-            // Reconcile component services/references/properties and
-            // implementation services/references and create component
-            // services/references/properties for the services/references
-            // declared by the implementation
-            reconcileServices(component, services, componentServices, monitor);
-            reconcileReferences(component, references, componentReferences, monitor);
-            reconcileProperties(component, properties, componentProperties, monitor);
-
-            for (ComponentService service : component.getServices()) {
-
+    
+            // Initialize composite service binding URIs
+            List<Service> compositeServices = composite.getServices();
+            for (Service service : compositeServices) {
+                // Set default binding names
+    
                 // Create default SCA binding
                 attachSCABinding(service, definitions);
-
+    
                 constructBindingNames(service, monitor);
                 
                 // Initialize binding names and URIs
                 for (Binding binding : service.getBindings()) {
-                    constructBindingURI(component, service, binding, defaultBindings, monitor);
+                    constructBindingURI(parentComponentURI, composite, service, binding, defaultBindings, monitor);
                 }
             }
-        }
+    
+            // Initialize component service binding URIs
+            for (Component component : composite.getComponents()) {
+                
+                monitor.pushContext("Component: " + component.getName());
+                
+                try {
+                    // Index properties, services and references
+                    Map<String, Service> services = new HashMap<String, Service>();
+                    Map<String, Reference> references = new HashMap<String, Reference>();
+                    Map<String, Property> properties = new HashMap<String, Property>();
+                    indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor);
+        
+                    // Index component services, references and properties
+                    // Also check for duplicates
+                    Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+                    Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+                    Map<String, ComponentProperty> componentProperties = new HashMap<String, ComponentProperty>();
+                    indexComponentPropertiesServicesAndReferences(component,
+                                                                  componentServices,
+                                                                  componentReferences,
+                                                                  componentProperties,
+                                                                  monitor);
+        
+                    // Reconcile component services/references/properties and
+                    // implementation services/references and create component
+                    // services/references/properties for the services/references
+                    // declared by the implementation
+                    reconcileServices(component, services, componentServices, monitor);
+                    reconcileReferences(component, references, componentReferences, monitor);
+                    reconcileProperties(component, properties, componentProperties, monitor);
+        
+                    for (ComponentService service : component.getServices()) {
+        
+                        // Create default SCA binding
+                        attachSCABinding(service, definitions);
+        
+                        constructBindingNames(service, monitor);
+                        
+                        // Initialize binding names and URIs
+                        for (Binding binding : service.getBindings()) {
+                            constructBindingURI(component, service, binding, defaultBindings, monitor);
+                        }
+                    }
+                } finally {
+                    monitor.popContext();
+                }
+            }
+        } finally {
+            monitor.popContext();
+        }         
     }
 
     /**

Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java?rev=806123&r1=806122&r2=806123&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java Thu Aug 20 11:12:28 2009
@@ -152,7 +152,6 @@
                       Monitor monitor) throws CompositeBuilderException {
 
         try {
-    		monitor.pushContext("Composite: " + composite.getName().toString());   		
     		
             // Collect and fuse includes
             compositeIncludeBuilder.build(composite, definitions, monitor);
@@ -223,8 +222,6 @@
             compositePolicyBuilder.build(composite, definitions, monitor);
         } catch (Exception e) {
             throw new CompositeBuilderException("Exception while building composite " + composite.getName(), e);
-    	} finally {
-    		monitor.popContext();
     	} // end try
 
     } // end method build