I tried another way by assigning an inlined bean to the service
property. And it seems to work. I hope it is compliant with blueprint
specification which is not very clear about the allowed service property
types: only primitive and scalar types ? However it is compliant with
the blueprint XML schema.
The blueprint XML definition is:
<service ref="..." interface="...">
<service-properties>
<entry key="uriResolverBean">
<bean class="UriResolverBean">
<property name="uriResolver" ref="uriResolverRef" />
</bean>
</entry>
</service-properties>
</service>
<reference id="uriResolverRef" interface="UriResolverService" />
Is it allowed by Aries and blueprint specification to assign a bean to a
service property?
Thank you,
Regards,
David
Le 25/10/2011 15:42, Timothy Ward a écrit :
I apologise for the confusion, I was under the impression that the
service properties element extended the map element, but apparently it
doesn't. As such it won't let you specify a value-type...
I suggest you raise a bug for the problem you're seeing. Whatever
happens you shouldn't end up with an internal blueprint recipe object
in there.
Tim
------------------------------------------------------------------------
Date: Tue, 25 Oct 2011 14:40:54 +0200
From: david.fel...@scalagent.com
To: user@aries.apache.org
Subject: Re: Service property assigned with a service reference
If the service is a String, then an exception is raised because the
String class is final:
org.apache.aries.proxy.FinalModifierException: The class
java.lang.String is final.
at
org.apache.aries.blueprint.container.ReferenceRecipe.internalCreate(ReferenceRecipe.java:98)
...
If the service is not a String, then I don't see how I can "add a type
of java.lang.String" because such a type indication is only available
with <value> and not <ref>.
<service-properties>
<entry key="Property1">
<ref component-id="serviceRef"/>
</entry>
</service-properties>
Regards,
David
Le 25/10/2011 13:19, Timothy Ward a écrit :
I think that what you're doing should work fine (assuming the
service is actually of type String) and this indcates a blueprint
bug. If your service is actually not a String then if you add a
type of java.lang.String (to tell blueprint to toString your
object) things should probably work ok. The property will only be
set once though, regardless of whether the reference changes, (no
dynamism) because of what the spec says.
Regards,
Tim
------------------------------------------------------------------------
Date: Tue, 25 Oct 2011 10:26:46 +0200
From: david.fel...@scalagent.com <mailto:david.fel...@scalagent.com>
To: user@aries.apache.org <mailto:user@aries.apache.org>
Subject: Re: Service property assigned with a service reference
My object is a String (a URI) that needs to be dynamically
resolved as a reference (<reference>) and passed as a service
property.
So if I correctly understood what you said, there's no way to do
that with blueprint?
It worked with Aries but it's only by chance, isn't it?
Thanks again,
Regards,
David
Le 24/10/2011 15:55, Timothy Ward a écrit :
Hi,
It is allowed to use a component instance as a service
property, however the following rules apply (from 121.6.6 of
the enterprise specification)
Each service can optionally be registered with service
properties. The serviceProperties is a list of
MapEntry, see <entry> on page 236. This metadata must be used
to create the service properties. Service
properties creation can have side effects because they can use
component instances. The service
properties must therefore be created once before the first
time the first time the service is registered.
....
Service properties should specify the valueType of the entry
unless the value to be registered needs to
be a String object. The service property types should be one of:
• Primitives Number – int, long, float, double, byte, short,
char, boolean
• Scalar – String, Integer, Long, Float, Double, Byte, Short,
Character, Boolean.
• Array – An array of either the allowable primitive or scalar
types.
• Collection – An object implementing the Collection interface
that contains scalar types.
If your object is of any other type then it should be being
turned into a String, which does indicate an issue with the
blueprint container. On the other hand, it may not be possible
to do what you actually want to do.
Aries blueprint will probably cope with some other property
types as well (things that have a String constructor), but I
couldn't give you a complete list.
Regards,
Tim
> Date: Mon, 24 Oct 2011 10:14:03 +0200
> From: david.fel...@scalagent.com
<mailto:david.fel...@scalagent.com>
> To: user@aries.apache.org <mailto:user@aries.apache.org>
> Subject: Service property assigned with a service reference
>
> Hi,
>
> when defining a service property with a reference as a
value, the
> property is assigned with a ServiceProxyWrapper (inner class of
> ReferenceRecipe).
>
> Here is the way it is defined:
>
> <service ref="..." interface="...">
> <service-properties>
> <entry key="Property1">
> <ref component-id="serviceRef"/>
> </entry>
> </service-properties>
> </service>
>
> <reference id="serviceRef" interface="A" />
>
> I would have expected the service property "Property1" to be
assigned
> with an instance of "A" instead of a ServiceProxyWrapper.
However I
> could get the instance of "A" by calling the method
'convert' and
> passing a ReifiedType.
>
> I would like to know if defining such a service property
(containing a
> <ref>) is correct according to Blueprint specification and
Aries
> implementation?
>
> I would also like to know why the 'convert' has to be done
explicitly?
>
> Thank you.
> Regards,
> David
>
>
>