felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Gonzalez <davidjgonza...@gmail.com>
Subject Re: Few questions around Services under felix
Date Mon, 16 Jan 2012 14:27:17 GMT
Thanks Felix,

Many thanks Felix - that's makes much more sense now.

On Jan 16, 2012, at 2:22 AM, Felix Meschberger <fmeschbe@adobe.com> wrote:

> Hi,
>
> Am 16.01.2012 um 05:08 schrieb David G.:
>
>> Couple of questions
>>
>> 1) Im moving over to use the Java 5 annotations for my scr notations. I noticed that
there doesn't appear to be the equivalent to valueRef in this updated syntax. What is the
best practice around initializing properties?
>>
>> Previously i would have ...
>>
>> @scr.property .. valueRef="com.mine.svc.FOO"  nameRef="com.mine.svc.FOO_NAME"
>>
>> private static string FOO = "default foo value";
>> private static final string FOO_NAME = "config.foo";
>
> Now you can use the name constant as the value:
>
> @Property(value=FOO)
> private static final String FOO_NAME = "config.foo";
>
> and if you add the property on the class level do:
>
> @Property(name=MyClass.FOO_NAME, value=MyClass.FOO)
>
>>
>> activate() {
>> FOO = OsgiUtil.getString(properties.get(FOO_NAME), FOO);
>> }
>>
>> 2) I have ServiceA that all users (admins) to create multiple multiple configurations
for a service (configurationFactory=true)
>>
>> What is the best way to allow allow ServiceB to be configured to use ServiceA, using
a specific configuration. I would like to allow the Felix admin to configure ServiceB and
allow them to select/specify which configuration for ServiceA should be used.
>>
>> Ultimately i will extend this to allow ServiceB to have multiple configurations,
and each configuration could use a ServiceA with a specific configuration.
>
> If you register ServiceA with a specific service registration property (say "prop.intentB=bla"),
you can set a reference target (assuming you are using Declarative services) as in
>
> @Reference(name="ServiceA", referenceInterface=ServiceA.class, target="(prop.intentB=bla)")
>
> you can even make this configurable by adding a property:
>
> @Property(name="ServiceA.target", value="(prop.intentB=bla)")
>
> The "drawback" is, that the value of the property must be a valid OSGi filter. The name
of the property is derived from the name of the @Reference with the ".target" suffix.
>
> See the Declarative Services specification on reference targets for full details.
>
>>
>> 3) Where on earth are the javadocs online for Felix's APIs? I can't find anything
on the Felix site :(
>
> There is no such thing as a singl Felix API JavaDoc. If you refer to the documentation
of the Declarative Services annotation from the Maven SCR Plugin, you might want to refer
to http://felix.apache.org/site/scr-annotations.html (or http://felix.apache.org/site/apache-felix-maven-scr-plugin.html).
>
> Hope this helps.
>
> Regards
> Felix
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message