Millies, Sebastian wrote:
Hello there,
I have a COMPOSITE scoped component that I would like to configure using
some properties. The catch is, I
cannot set these properties immediately, because sensible values depend
on where this component is included
via “implementation. composite”. I’d just like to promote the
properties and set them later.
You can do this, but not by using promotion. Promotion is for services
and references, not properties.
That does not seem possible with Tuscany 1.6, it seems I have to fix the
values in the original component and
cannot override them in the included component.
Is there a way to achieve what I want?
Yes, there is. You need to define a composite property and reference
it in the component property by using the source attribute of the
component property element. Your example would look like this:
<sca:composite name="logger" targetNamespace="http://sca/logger/"/>
<sca:component name="Logger">
<!-- component included in many other composites -->
<sca:property name="capacity" source="$capacity"/>
<sca:property name="maxPoolSize" source="$maxPoolSize"/>
<sca:property name="shutdownTimeout" source="$shutdownTimeout"/>
</sca:component>
<sca:property name="capacity" type="xs:int"/>
<sca:property name="maxPoolSize" type="xs:int"/>
<sca:property name="shutdownTimeout" type="xs:int"/>
</sca:composite>
<sca:composite xmlns:logger="http://sca/logger/"
targetNamespace="http://sca/something/"/>
<sca:component name="IncludedLogger"/>
<sca:implementation.composite name="logger:logger"/>
<!-- property values suitable for this inclusion site -->
<sca:property name="capacity">20000</sca:property>
<sca:property name="maxPoolSize">2</sca:property>
<sca:property name="shutdownTimeout">30</sca:property>
</sca:component>
</sca:composite>
You could also specify default values for the properties in the
composite property elements. These values would be used if you
don't override them in the IncludedLogger component.
Simon
-- Sebastian
Here is an example of what I’d like (and doesn’t work):
<sca:composite name=/"logger"/ targetNamespace=/"http://sca/logger/"/>
<sca:component name=/"Logger"/>
<!-- component included in many other composites -->
<sca:property name=/"capacity"//>
<sca:property name=/"maxPoolSize"//>
<sca:property name=/"shutdownTimeout"//>
</sca:component>
<sca:property name=/"capacity"/ promote=/" Logger/capacity"//>
<sca:property name=/"maxPoolSize"/ promote=/" Logger/maxPoolSize"//>
<sca:property name=/"shutdownTimeout"/ promote=/"
Logger/shutdownTimeout"//>
</sca:composite>
<sca:composite xmlns:logger=/"http://sca/log"/
targetNamespace=/"http://sca/something/"/>
<sca:component name=/"IncludedLogger"/>
<sca:implementation.composite name=/"logger:logger"//>
<!-- property values suitable for this inclusion site -->
<sca:property name=/"capacity"/>20000</sca:property>
<sca:property name=/"maxPoolSize"/>2</sca:property>
<sca:property name=/"shutdownTimeout"/>30</sca:property>
</sca:component>
</sca:composite>
IDS Scheer Consulting GmbH
Geschäftsführer/Managing Directors: Kamyar Niroumand, Ivo Totev
Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken,
Germany - Registergericht/Commercial register: Saarbrücken HRB 19681
*http://www.softwareag.com*