Well, it's not an all-or-nothing proposal. You can use the bnd
annotations in just a single component, but continue using the Felix
SCR annotations everywhere else.

Anyway I understand your desire to keep things simple, I just wanted
to make you aware of the possibility.

Regards,
Neil


On Mon, May 6, 2013 at 6:13 AM, Thomas Joseph <[email protected]> wrote:
> Thanks Neil.
>
> At this stage of project, it is difficult to think of using bnd
> annotations, but will definitely consider this in my next assignment.
>
>
>
> On Fri, May 3, 2013 at 6:19 PM, Neil Bartlett <[email protected]> wrote:
>
>> For what it's worth... I assume you're building with
>> maven-bundle-plugin, so you could use the bnd annotations as an
>> alternative:
>>
>> @Component(properties = {
>>     "singletonProp:String=val1", // this is the default type
>>     "singleElementListProp:List<String>=val1",
>>     "multiElementListProp:List<String>=val1|val2|val3"
>> })
>>
>> Regards
>> Neil
>>
>> On Fri, May 3, 2013 at 1:40 PM, Thomas Joseph <[email protected]>
>> wrote:
>> > Sure!
>> >
>> > https://issues.apache.org/jira/browse/FELIX-4047
>> >
>> > Thanks,
>> > Thomas Joseph
>> >
>> >
>> > On Fri, May 3, 2013 at 5:32 PM, Carsten Ziegeler <[email protected]
>> >wrote:
>> >
>> >> Ah, yes - you're right; I think you've hit a bug in the SCR plugin. With
>> >> cardinality or the unbounded property you influence the generation of
>> the
>> >> metatype information, but not the ds xml file.
>> >> Could you please create an issue for this?
>> >>
>> >> Thanks
>> >> Carsten
>> >>
>> >> 2013/5/3 Thomas Joseph <[email protected]>
>> >>
>> >> > Thanks Carsten!
>> >> >
>> >> > I tried both the options (unbounded=PropertyUnbounded.ARRAY and
>> >> > cardinality=N)
>> >> > independently, but unfortunately it doesn't seem to work. The scr xml
>> >> still
>> >> > generates <property name="multivalued.property"
>> >> value="only-single-value"/>
>> >> >
>> >> > I even upgraded to SCR annotations v1.9.2 and Maven SCR plugin 1.12.0,
>> >> and
>> >> > still it won't work. Can I have a code sample somewhere, so that I can
>> >> try
>> >> > it out?
>> >> >
>> >> >
>> >> > Thanks,
>> >> > Thomas Joseph
>> >> >
>> >> >
>> >> >
>> >> > On Fri, May 3, 2013 at 11:44 AM, Carsten Ziegeler <
>> [email protected]
>> >> > >wrote:
>> >> >
>> >> > > Hi,
>> >> > >
>> >> > > unfortunately, the java annotations do not distinguish between a
>> single
>> >> > > value and an array, so it's impossible by looking at {"single
>> value"}
>> >> if
>> >> > > this is should be a single value or an array. For the tooling
>> >> inspecting
>> >> > > the annotations "single value" looks exactly the same. Therefore the
>> >> SCR
>> >> > > plugin assumes a single value to be exactly this: a single value :)
>> >> > > If you just want to specify a single default value for a multi value
>> >> > > property, you can either use cardinality=N if you want to limit the
>> >> > number
>> >> > > of values, or unbounded=PropertyUnbounded.ARRAY. We usually the
>> latter
>> >> > > option.
>> >> > >
>> >> > > Carsten
>> >> > >
>> >> > >
>> >> > > 2013/5/3 Thomas Joseph <[email protected]>
>> >> > >
>> >> > > > Hi All,
>> >> > > >
>> >> > > > I am using Felix SCR annotations v1.7.0 and Maven SCR plugin
>> 1.8.0,
>> >> and
>> >> > > > declaring a OSGi property as:
>> >> > > >
>> >> > > > @Property(label="Multivalued Property",
>> value={"only-single-value"})
>> >> > > > private static final String MV_PROPERTY= "multivalued.property";
>> >> > > >
>> >> > > > And then try to retrieve the property value as:
>> >> > > >
>> >> > > >
>> >> > > > @Activate
>> >> > > > @Modified
>> >> > > > protected void activate(*final ComponentContext context*) throws
>> >> > > Exception
>> >> > > > {
>> >> > > >    Object prop = context.getProperties().get(MV_PROPERTY);
>> >> > > > }
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > > But I observe that the value is retrieved as a String and not a
>> >> String
>> >> > > > array. The generated SCR xml itself is generated for a String and
>> >> not a
>> >> > > > String array.
>> >> > > >  <property name="multivalued.property" value="only-single-value"/>
>> >> > > >
>> >> > > > However, if I declare the property as below, I get the value as an
>> >> > array.
>> >> > > >
>> >> > > > @Property(label="Multivalued Property",
>> value={"only-single-value"*,
>> >> > > ""*})
>> >> > > > private static final String MV_PROPERTY= "multivalued.property";
>> >> > > >
>> >> > > > I Googled around but could not find anything conclusive. Am I
>> missing
>> >> > > > something here? How can I get a String array without a workaround
>> >> done
>> >> > > > above.
>> >> > > >
>> >> > > > --
>> >> > > > Thanks,
>> >> > > > /Thomas Joseph
>> >> > > >
>> >> > >
>> >> > >
>> >> > >
>> >> > > --
>> >> > > Carsten Ziegeler
>> >> > > [email protected]
>> >> > >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Carsten Ziegeler
>> >> [email protected]
>> >>
>> >
>> >
>> >
>> > --
>> > Thanks and Regards,
>> > /Thomas Joseph
>> >
>> > LinkedIn: http://www.linkedin.com/in/ethomasjoseph
>> > Twitter: http://twitter.com/ethomasjoseph
>> >
>> > ------------------------------------------------------------
>> > Promote Open Source - Promote Liberty of Ideas and Software.
>> > ------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
> --
> Thanks and Regards,
> /Thomas Joseph
>
> LinkedIn: http://www.linkedin.com/in/ethomasjoseph
> Twitter: http://twitter.com/ethomasjoseph
>
> ------------------------------------------------------------
> Promote Open Source - Promote Liberty of Ideas and Software.
> ------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to