tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r820460 - in /tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl: ComponentBuilderImpl.java CompositeComponentTypeBuilderImpl.java ModelBuilderImpl.java
Date Wed, 30 Sep 2009 21:30:04 GMT
Author: rfeng
Date: Wed Sep 30 21:30:03 2009
New Revision: 820460

URL: http://svn.apache.org/viewvc?rev=820460&view=rev
Log:
Pass the outer component to configure the @source of property (taking value from the composite
property which can be further configured by the outer component) 

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
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.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=820460&r1=820459&r2=820460&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
Wed Sep 30 21:30:03 2009
@@ -111,7 +111,7 @@
      * @Param parentComposite the composite that contains the component being configured.
Required for property processing
      * @param component the component to be configured
      */
-    public void configureComponentFromComponentType(Composite parentComposite, Component
component) {
+    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
@@ -131,7 +131,7 @@
         // 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(parentComposite, component);
+        configureProperties(outerComponent, parentComposite, component);
 
         // create the component type for this component 
         // taking any nested composites into account
@@ -153,7 +153,7 @@
     private void createComponentType(Component component) {
         Implementation implementation = component.getImplementation();
         if (implementation instanceof Composite) {
-            componentTypeBuilder.createComponentType((Composite)implementation);
+            componentTypeBuilder.createComponentType(component, (Composite)implementation);
         }
     }
 
@@ -274,7 +274,7 @@
      * 
      * @param component
      */
-    private void configureProperties(Composite parentComposite, Component component) {
+    private void configureProperties(Component outerComponent, Composite parentComposite,
Component component) {
         // If the component type has properties that are not described in this
         // component then create properties for this component
         addPropertiesFromComponentType(component);
@@ -290,7 +290,7 @@
             // configure the property value based on the @source attribute
             // At the moment this is done in the parent composite component
             // type calculation a
-            processPropertySourceAttribute(parentComposite, component, componentProperty);
+            processPropertySourceAttribute(outerComponent, parentComposite, component, componentProperty);
 
             // configure the property value based on the @file attribute
             processPropertyFileAttribute(component, componentProperty);
@@ -522,7 +522,8 @@
      * @param component
      * @param componentProperty
      */
-    private void processPropertySourceAttribute(Composite parentComposite,
+    private void processPropertySourceAttribute(Component outerComponent,
+                                                Composite parentComposite,
                                                 Component component,
                                                 ComponentProperty componentProperty) {
         String source = componentProperty.getSource();
@@ -537,8 +538,13 @@
             }
             if (source.charAt(0) == '$') {
                 String name = source.substring(1, index);
-                Property compositeProp = parentComposite.getProperty(name);
-                if (compositeProp == null) {
+                Property sourceProp = null;
+                if (outerComponent != null) {
+                    sourceProp = outerComponent.getProperty(name);
+                } else {
+                    sourceProp = parentComposite.getProperty(name);
+                }
+                if (sourceProp == null) {
                     Monitor.error(monitor,
                                   this,
                                   "assembly-validation-messages",
@@ -548,12 +554,12 @@
                                   component.getName());
                 }
 
-                Document compositePropDefValues = (Document)compositeProp.getValue();
+                Document sourcePropValue = (Document)sourceProp.getValue();
 
                 try {
                     // FIXME: How to deal with namespaces?
                     Document node =
-                        evaluateXPath(compositePropDefValues,
+                        evaluateXPath(sourcePropValue,
                                       componentProperty.getSourceXPathExpression(),
                                       documentBuilderFactory);
 
@@ -568,7 +574,7 @@
                                   source,
                                   componentProperty.getName(),
                                   component.getName(),
-                                  ex.toString());
+                                  ex);
                 }
             } else {
                 Monitor.error(monitor,

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=820460&r1=820459&r2=820460&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
Wed Sep 30 21:30:03 2009
@@ -35,7 +35,6 @@
 import org.apache.tuscany.sca.assembly.CompositeReference;
 import org.apache.tuscany.sca.assembly.CompositeService;
 import org.apache.tuscany.sca.assembly.Contract;
-import org.apache.tuscany.sca.assembly.Implementation;
 import org.apache.tuscany.sca.assembly.Reference;
 import org.apache.tuscany.sca.assembly.SCABinding;
 import org.apache.tuscany.sca.assembly.SCABindingFactory;
@@ -95,15 +94,7 @@
      * @param implementation
      * @return component type
      */
-    public void createComponentType(Implementation implementation) {
-        if (!(implementation instanceof Composite)) {
-            // component type will have been calculated at resolve time
-            return;
-        }
-
-        // create the composite component type as this was not
-        // calculated at resolve time
-        Composite composite = (Composite)implementation;
+    public void createComponentType(Component outerComponent, Composite composite) {
 
         // first make sure that each child component has been properly configured based
         // on its own component type
@@ -125,7 +116,7 @@
             }
 
             // configure the component from its component type
-            componentBuilder.configureComponentFromComponentType(composite, component);
+            componentBuilder.configureComponentFromComponentType(outerComponent, composite,
component);
         }
 
         // create the composite component type based on the promoted artifacts

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java?rev=820460&r1=820459&r2=820460&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java
(original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java
Wed Sep 30 21:30:03 2009
@@ -109,7 +109,7 @@
             // for the top level implementation (composite). This has the effect of
             // recursively calculating component types and configuring the 
             // components that depend on them
-            compositeComponentTypeBuilder.createComponentType(composite);
+            compositeComponentTypeBuilder.createComponentType(null, composite);
 
             // create the runtime model by updating the static model we have just 
             // created. This involves things like creating



Mime
View raw message