Well, sorry for the dumb question.
It was literally written down two lines below from where I stopped reading in the Compendium specification.

I just had to name the property like:
<referencename>_cardinality_minimum

and it just worked.
OSGi is great ;)

------ Originalnachricht ------
Von: "Thomas Driessen" <thomas.driessen...@gmail.com>
An: "OSGi Developer Mail List" <osgi-dev@mail.osgi.org>
Gesendet: 13.04.2017 15:24:21
Betreff: Configuring reference.cardinality.minimum / reference.target via Metatypes

Hi,

I was wondering if one can configure the @Reference cardinality.minimum property of a service vie Metatypes somehow?

In my example (written in Xtend) I'd like to configure the minimum cardinality of 'stuff'. So is there a magic property name/pattern (like in the commented code below) that I can use in MyConfiguration in order to achieve that?

@ObjectClassDefinition
annotation MyConfiguration{
        String name
        // String stuffCardinalityMinimum
}

@Designate(ocd = MyConfiguration)
@Component(configurationPid = 'configurable')
class ConfigurableTest{
@Reference(
cardinality = ReferenceCardinality.MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY
)
volatile List<IStuff> stuff
@Activate
private def void activate(MyConfiguration config){
println('''Activated: «config.name»''')
}
@Modified
private def void update(MyConfiguration config){
println('''Updated: «config.name»''')
}
@Deactivate
private def void deactivate(){
println('''Deactivated''')
}
}

@Component
class Stuff implements IStuff{}

interface IStuff{}

Any advice is appreciated :)

Kind regards,
Thomas
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to