You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2009/09/30 23:30:04 UTC
svn commit: r820460 - in
/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl:
ComponentBuilderImpl.java CompositeComponentTypeBuilderImpl.java
ModelBuilderImpl.java
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
Re: svn commit: r820460 - in /tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl: ComponentBuilderImpl.java CompositeComponentTypeBuilderImpl.java ModelBuilderImpl.java
Posted by Raymond Feng <en...@gmail.com>.
Hi,
I had to make such changes to fix the property source calculation.
Taking an example,
<composite name="Composite1">
<component name="C1">
<implementation.composite name="ns1:Composite11"/>
<property name="p2" value="1"/>
</component>
<component name="C2">
<implementation.composite name="ns1:Composite11"/>
<property name="p2" value="2"/>
</component>
</composite>
<composite name="Composite11" ...>
<property name="p2" value="11"/>
<component name="C11">
<...>
<property name="p1" source="$p2"/>
</component>
</composite>
In the componentType for Composite11, the property value is set to 11. Both
component C1 and C2 have the same componentType, but they configure the
property p2 to different values. I understand that the component property
inherit its value from the componentType but I don't think we should push
the component property value into the componentType.
Thanks,
Raymond
--------------------------------------------------
From: "Simon Laws" <si...@googlemail.com>
Sent: Monday, October 05, 2009 7:09 AM
To: <de...@tuscany.apache.org>
Subject: Re: svn commit: r820460 - in
/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl:
ComponentBuilderImpl.java CompositeComponentTypeBuilderImpl.java
ModelBuilderImpl.java
> Hi Raymond
>
> Why was it necessary to pass in the outer component? The property
> values are pushed down into the outer component's component type, if
> appropriate, when the component properties are reconciled with those
> of its component type. Hence they are available in the parent
> composite. Have I missed something else?
>
> Regards
>
> Simon
Re: svn commit: r820460 - in /tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl:
ComponentBuilderImpl.java CompositeComponentTypeBuilderImpl.java
ModelBuilderImpl.java
Posted by Simon Laws <si...@googlemail.com>.
Hi Raymond
Why was it necessary to pass in the outer component? The property
values are pushed down into the outer component's component type, if
appropriate, when the component properties are reconciled with those
of its component type. Hence they are available in the parent
composite. Have I missed something else?
Regards
Simon