I'm Migrating Apache Felix SCR Annotations to OSGI Declarative Services[AEM]. While Migration I cant find exact replacement for cardinality in DS .
Existing SCR Implementation :
@Component (ds = true, immediate = true, metatype = false, policy = ConfigurationPolicy.OPTIONAL)
@Service (SampleService.class)
public class SampleServiceImpl implements SampleService
{
private static final int VECTOR = Integer.MIN_VALUE + 1;
@Property (value = REPOSTING_PATTERN, cardinality = VECTOR,description = "Event reposting pattern for QueuePosting ")
private static String EVENT_REPOSTING_PATTERN = "eventRepostingPattern";
}
Now it is migrated as Below in OSGi Declarative services
@Component (configurationPolicy = ConfigurationPolicy.OPTIONAL, immediate = true, service =SampleService.class,
property = {SampleServiceImpl .EVENT_REPOSTING_PATTERN +"="+SampleServiceImpl .EVENT_REPOSTING_PATTERN_VALUE })
public class SampleServiceImpl implements SampleService
{
private static String EVENT_REPOSTING_PATTERN = "eventRepostingPattern";
private static String EVENT_REPOSTING_PATTERN = "eventRepostingPatternValue";
}
In DS annotation Implementation How I have to map the parameter cardinality which is present in @Property.Kindly suggest me
Documentation about the
@Propertyandcardinalityis confusing as usual but I am assuming based on this that these are somehow related to configurations. You can setup Type-safe configurations for your service(s) with@Designateand@ObjectClassDefinitionannotations. Thecardinalityoption can be found in@AttributeDefinitionannotation.ExampleServiceimpl.java
ExampleServiceConfig.java
Now as disclaimer I've never managed to used
@AttributeDefinitionorcardinalityannotation myself yet so might be off here. Encountered thecardinalityoption when I tried to use@AttributeDefinitionto see if I could use it to make my service configurations pretty in hawtio but probably missing some steps.But hopefully this points you to right direction.