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/10/05 17:21:01 UTC

svn commit: r821835 - in /tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl: ComponentBuilderImpl.java CompositeComponentTypeBuilderImpl.java

Author: slaws
Date: Mon Oct  5 15:21:01 2009
New Revision: 821835

URL: http://svn.apache.org/viewvc?rev=821835&view=rev
Log:
Push/po context in the new component type and component builders

Modified:
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java?rev=821835&r1=821834&r2=821835&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java (original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java Mon Oct  5 15:21:01 2009
@@ -113,35 +113,41 @@
      */
     public void configureComponentFromComponentType(Component outerComponent, Composite parentComposite, Component component) {
 
-        // do any work we need to do before we calculate the component type
-        // for this component. Anything that needs to be pushed down the promotion
-        // hierarchy must be done before we calculate the component type
-
-        // first carry out any implementation specific builder processing
-        Implementation impl = component.getImplementation();
-        if (impl != null) {
-            ImplementationBuilder builder = builders.getImplementationBuilder(impl.getClass());
-            if (builder != null) {
-                builder.build(component, impl, monitor);
-            }
-        }
-
-        // Properties on the composite component type are not affected by the components 
-        // that the composite contains. Instead the child components might source  
-        // composite level property values. Hence we have to calculate whether the component 
-        // type property value should be overridden by this component's property value 
-        // before we go ahead and calculate the component type
-        configureProperties(outerComponent, parentComposite, component);
-
-        // create the component type for this component 
-        // taking any nested composites into account
-        createComponentType(component);
-
-        // configure services based on the calculated component type
-        configureServices(component);
-
-        // configure services based on the calculated component type
-        configureReferences(component);
+        monitor.pushContext("Component: " + component.getName().toString());
+        
+        try {
+            // do any work we need to do before we calculate the component type
+            // for this component. Anything that needs to be pushed down the promotion
+            // hierarchy must be done before we calculate the component type
+    
+            // first carry out any implementation specific builder processing
+            Implementation impl = component.getImplementation();
+            if (impl != null) {
+                ImplementationBuilder builder = builders.getImplementationBuilder(impl.getClass());
+                if (builder != null) {
+                    builder.build(component, impl, monitor);
+                }
+            }
+    
+            // Properties on the composite component type are not affected by the components 
+            // that the composite contains. Instead the child components might source  
+            // composite level property values. Hence we have to calculate whether the component 
+            // type property value should be overridden by this component's property value 
+            // before we go ahead and calculate the component type
+            configureProperties(outerComponent, parentComposite, component);
+    
+            // create the component type for this component 
+            // taking any nested composites into account
+            createComponentType(component);
+    
+            // configure services based on the calculated component type
+            configureServices(component);
+    
+            // configure services based on the calculated component type
+            configureReferences(component);
+        } finally {
+            monitor.popContext();
+        }         
     }
 
     /**
@@ -290,7 +296,7 @@
 
             // configure the property value based on the @source attribute
             // At the moment this is done in the parent composite component
-            // type calculation a
+            // type calculation 
             processPropertySourceAttribute(outerComponent, parentComposite, component, componentProperty);
 
             // configure the property value based on the @file attribute
@@ -298,8 +304,12 @@
             
             // Check that a value is supplied
             if (componentProperty.isMustSupply() && !isPropertyValueSet(componentProperty)) {
-                Monitor.error(monitor, this, "assembly-validation-messages", "PropertyMustSupplyNull", component
-                    .getName(), componentProperty.getName());
+                Monitor.error(monitor, 
+                              this, 
+                              "assembly-validation-messages", 
+                              "PropertyMustSupplyNull", 
+                              component.getName(), 
+                              componentProperty.getName());
             }
         }
     }
@@ -553,8 +563,12 @@
             // Check that a component property does not override the
             // many attribute
             if (!componentTypeProperty.isMany() && componentProperty.isMany()) {
-                Monitor.error(monitor, this, "assembly-validation-messages", "PropertyOverrideManyAttribute", component
-                    .getName(), componentProperty.getName());
+                Monitor.error(monitor, 
+                              this, 
+                              "assembly-validation-messages", 
+                              "PropertyOverrideManyAttribute", 
+                              component.getName(), 
+                              componentProperty.getName());
             }
 
             // Default to the many attribute defined on the property
@@ -570,8 +584,12 @@
 
             // Check that a type or element are specified
             if (componentProperty.getXSDElement() == null && componentProperty.getXSDType() == null) {
-                Monitor.error(monitor, this, "assembly-validation-messages", "NoTypeForComponentProperty", component
-                    .getName(), componentProperty.getName());
+                Monitor.error(monitor, 
+                              this, 
+                              "assembly-validation-messages", 
+                              "NoTypeForComponentProperty", 
+                              component.getName(), 
+                              componentProperty.getName());
             }
         }
     }

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java?rev=821835&r1=821834&r2=821835&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java (original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java Mon Oct  5 15:21:01 2009
@@ -96,51 +96,61 @@
      */
     public void createComponentType(Component outerComponent, Composite composite) {
 
-        // first make sure that each child component has been properly configured based
-        // on its own component type
-        for (Component component : composite.getComponents()) {
-
-            // Check for duplicate component names
-            if (composite.getComponent(component.getName()) == null) {
-                Monitor.error(monitor, this, "assembly-validation-messages", "DuplicateComponentName", composite
-                    .getName().toString(), component.getName());
-            }
-
-            // do any work we need to do before we configure the component
-            // Anything that needs to be pushed down the promotion
-            // hierarchy must be done before we configure the component
-
-            // Push down the autowire flag from the composite to components
-            if (component.getAutowire() == null) {
-                component.setAutowire(composite.getAutowire());
-            }
-
-            // configure the component from its component type
-            componentBuilder.configureComponentFromComponentType(outerComponent, composite, component);
-        }
-
-        // create the composite component type based on the promoted artifacts
-        // from the components that it contains
-
-        // index all the components, services and references in the
-        // component type so that they are easy to find
-        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);
-
-        // services
-        calculateServices(composite, components, componentServices);
-
-        // references
-        calculateReferences(composite, components, componentReferences);
-
-        // properties
-        // Properties on the composite component are unaffected by properties 
-        // on child components. Instead child component properties might take their
-        // values from composite properties. Hence there is nothing to do here.
-        //calculateProperties(composite, components);
-
+        monitor.pushContext("Composite: " + composite.getName().toString());
+        
+        try {
+            // first make sure that each child component has been properly configured based
+            // on its own component type
+            for (Component component : composite.getComponents()) {
+    
+                // Check for duplicate component names
+                if (composite.getComponent(component.getName()) == null) {
+                    Monitor.error(monitor, 
+                                  this, 
+                                  "assembly-validation-messages", 
+                                  "DuplicateComponentName", 
+                                  composite.getName().toString(), 
+                                  component.getName());
+                }
+    
+                // do any work we need to do before we configure the component
+                // Anything that needs to be pushed down the promotion
+                // hierarchy must be done before we configure the component
+    
+                // Push down the autowire flag from the composite to components
+                if (component.getAutowire() == null) {
+                    component.setAutowire(composite.getAutowire());
+                }
+    
+                // configure the component from its component type
+                componentBuilder.configureComponentFromComponentType(outerComponent, composite, component);
+            }
+    
+            // create the composite component type based on the promoted artifacts
+            // from the components that it contains
+    
+            // index all the components, services and references in the
+            // component type so that they are easy to find
+            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);
+    
+            // services
+            calculateServices(composite, components, componentServices);
+    
+            // references
+            calculateReferences(composite, components, componentReferences);
+    
+            // properties
+            // Properties on the composite component are unaffected by properties 
+            // on child components. Instead child component properties might take their
+            // values from composite properties. Hence there is nothing to do here.
+            //calculateProperties(composite, components);
+        
+        } finally {
+            monitor.popContext();
+        } 
     }
 
     /**