diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-30 21:30:03 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-30 21:30:03 +0000 |
commit | 93ac398a871f4fbd3c43463fac7433f16eba6e9d (patch) | |
tree | 2e991086e6bf8ca16049eae96fefe8b123e1f9a3 /java/sca/modules/builder | |
parent | 1ae56f2f860eef8a199cba88d236bf131389ba29 (diff) |
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)
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@820460 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/builder')
3 files changed, 20 insertions, 23 deletions
diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java index 1603c80eb5..719eb64c74 100644 --- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java +++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java @@ -111,7 +111,7 @@ public class ComponentBuilderImpl { * @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 @@ public class ComponentBuilderImpl { // 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 @@ public class ComponentBuilderImpl { 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 @@ public class ComponentBuilderImpl { * * @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 @@ public class ComponentBuilderImpl { // 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 @@ public class ComponentBuilderImpl { * @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 @@ public class ComponentBuilderImpl { } 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 @@ public class ComponentBuilderImpl { 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 @@ public class ComponentBuilderImpl { source, componentProperty.getName(), component.getName(), - ex.toString()); + ex); } } else { Monitor.error(monitor, diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java index a05a90afa2..ad5ff31679 100644 --- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java +++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java @@ -35,7 +35,6 @@ import org.apache.tuscany.sca.assembly.Composite; 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 @@ public class CompositeComponentTypeBuilderImpl { * @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 @@ public class CompositeComponentTypeBuilderImpl { } // 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 diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java index 45df386aae..83bf62730b 100644 --- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java +++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java @@ -109,7 +109,7 @@ public class ModelBuilderImpl implements CompositeBuilder, DeployedCompositeBuil // 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 |