You don't need to write it manually in the xml file if you use Bndtools.
You just need to specify the property.

Please check my blog post where I show exactly that with bndtools.

Am 02.03.2017 2:36 PM schrieb "Thomas Driessen" <
thomas.driessen...@gmail.com>:

> Sorry. I received the Email from BJ Hargrave the moment I sent my own.
>
> Thank you guys for your answers!
>
> ------ Originalnachricht ------
> Von: "Thomas Driessen" <thomas.driessen...@gmail.com>
> An: "Dirk Fauth" <dirk.fa...@gmail.com>; "OSGi Developer Mail List" <
> osgi-dev@mail.osgi.org>
> Gesendet: 02.03.2017 14:35:16
> Betreff: Re[2]: [osgi-dev] Updating service properties at runtime
>
> I am using the annotations osgi.annotations 6.0.1.
> My Service looks like this:
>
> @Component
> public class ServiceAImpl implements IServiceA{
>     ...
>
>     @Reference(cardinality = ReferenceCardinality.Multiple)
>     public synchronized void addServiceB(IServiceB service){
>         ...
>     }
> }
>
> and I was just wondering if there is the possibility to write something
> like
> @Reference(cardinality = ReferenceCardinality, Multiple,
> minimumCardinality = 4)
>
> But Jens Kübler already wrote that I would have to add this information
> manually to the generated XML.
>
> Maybe the following is possible then?
>
> @Component(
>         property = "ServiceB.cardinality.minimum=4"
>     )
> public class ServiceAImpl implements IServiceA{
>     ...
> }
>
> Kind regards,
> Thomas
>
> ------ Originalnachricht ------
> Von: "Dirk Fauth" <dirk.fa...@gmail.com>
> An: "Thomas Driessen" <thomas.driessen...@gmail.com>; "OSGi Developer
> Mail List" <osgi-dev@mail.osgi.org>
> Gesendet: 02.03.2017 14:25:06
> Betreff: Re: [osgi-dev] Updating service properties at runtime
>
> Well if you use Bndtools you should be able to use the annotations. Maybe
> you use the wrong annotations in the configuration?
>
> Am 02.03.2017 2:18 PM schrieb "Thomas Driessen" <
> thomas.driessen...@gmail.com>:
>
> I'm using the version 5.6.1 of Felix as osgi framework if that does matter?
> Eclipse is only used as IDE in combination with bndtools 4
>
> Thomas
>
> ------ Originalnachricht ------
> Von: "Dirk Fauth" <dirk.fa...@gmail.com>
> An: "Thomas Driessen" <thomas.driessen...@gmail.com>; "OSGi Developer
> Mail List" <osgi-dev@mail.osgi.org>
> Gesendet: 02.03.2017 14:13:42
> Betreff: Re: [osgi-dev] Updating service properties at runtime
>
> Actually Oxygen in its current development state contains Felix SCR,  so
> it supports DS 1.3 under the hood.
>
> For the DS 1.3 annotations there is a Gerrit patch available that needs to
> be verified. I'm currently looking at this so it can be part of Eclipse
> Oxygen.
>
> Minimum cardinality is a DS 1.3 feature so it will not work with Eclipse
> in its current release state.
>
> Am 02.03.2017 2:07 PM schrieb "Thomas Driessen" <
> thomas.driessen...@gmail.com>:
>
>> Thank you very much!
>>
>> ------ Originalnachricht ------
>> Von: "Kübler, Jens" <jens.kueb...@vector.com>
>> An: "Thomas Driessen" <thomas.driessen...@gmail.com>; "OSGi Developer
>> Mail List" <osgi-dev@mail.osgi.org>
>> Gesendet: 02.03.2017 14:05:27
>> Betreff: RE: [osgi-dev] Updating service properties at runtime
>>
>> Eclipse does only support the DS 1.2 spec and this was added in a later
>> version.
>>
>> if you are running in a DS 1.3 environment you have to add it manually to
>> the xml and cannot use the annotations.
>>
>> Discussion is under way to add the functionality in Eclipse 4.7
>>
>>
>>
>> Kind Regards
>>
>> Jens
>>
>>
>>
>> *From:* osgi-dev-boun...@mail.osgi.org [mailto:osgi-dev-bounces@mail.
>> osgi.org] *On Behalf Of *Thomas Driessen
>> *Sent:* Thursday, March 02, 2017 2:01 PM
>> *To:* OSGi Developer Mail List
>> *Subject:* Re: [osgi-dev] Updating service properties at runtime
>>
>>
>>
>> Thank you both for your answers.
>>
>>
>>
>> Is it possible to directly annotate a reference with the minimum
>> cardinality, or do I have to do this via ConfigurationAdmin?
>>
>> In Eclipse autocomplete only shows the property cardinality which expects
>> a ReferenceCardinality (OPTIONAL, MANDATORY, etc.)
>>
>> 112.6.2.2 in the specification also only talks about how to adress this
>> property via ConfigurationAdmin.
>>
>>
>>
>> Kind regards,
>>
>> Thomas
>>
>>
>>
>> ------ Originalnachricht ------
>>
>> Von: "Dirk Fauth" <dirk.fa...@gmail.com>
>>
>> An: "OSGi Developer Mail List" <osgi-dev@mail.osgi.org>
>>
>> Gesendet: 02.03.2017 13:37:21
>>
>> Betreff: Re: [osgi-dev] Updating service properties at runtime
>>
>>
>>
>> You can find an example in one of my blog posts.
>>
>>
>>
>> http://blog.vogella.com/2016/09/26/configuring-osgi-declarative-services/
>>
>>
>>
>> At the bottom the usage of the minimum cardinality reference property is
>> shown.
>>
>>
>>
>> Am 02.03.2017 1:07 PM schrieb "Carsten Ziegeler" <cziege...@apache.org>:
>>
>> You can do this with DS, have a look at section 112.6.2.2 Minimum
>> Cardinality Property
>>
>> Regards
>> Carsten
>>
>> Thomas Driessen wrote
>> > Hi,
>> >
>> > I currently have the following usecase:
>> >
>> > Service A depends on Service B
>> > Service B depends on 4x Service C
>> > Service A may only become active when Service B has exactly 4x Service
>> > C, thus becoming active itself.
>> >
>> > I'm using declarative services which only support 0-*, 1-*, 0-1 and
>> > exactly 1 dependencies between services.
>> >
>> > One idea I came up with, was to count the C services in B's setC(C c)
>> > method and, on reaching the count of 4, setting a specific property on B
>> > (e.g. weirdUsecaseIsActive = true) and let A's reference to B filter
>> > with a corresponding target filter.
>> >
>> > I know this sound like a dirty hack, but I did not found any better
>> > solutions.
>> >
>> > Therefore, my questions are:
>> > 1) Is there a better solution for my usecase?
>> > 2) If not: How do I update properties of a service at runtime?
>> >
>> > Kind regards,
>> > Thomas
>> >
>> >
>> > _______________________________________________
>> > OSGi Developer Mail List
>> > osgi-dev@mail.osgi.org
>> > https://mail.osgi.org/mailman/listinfo/osgi-dev
>> >
>>
>>
>>
>>
>> --
>> Carsten Ziegeler
>> Adobe Research Switzerland
>> cziege...@apache.org
>> _______________________________________________
>> OSGi Developer Mail List
>> osgi-dev@mail.osgi.org
>> https://mail.osgi.org/mailman/listinfo/osgi-dev
>>
>>
>> _______________________________________________
>> OSGi Developer Mail List
>> osgi-dev@mail.osgi.org
>> https://mail.osgi.org/mailman/listinfo/osgi-dev
>>
>
> _______________________________________________
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
>
>
> _______________________________________________
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to