如何在 OSGI 声明式服务中使用 @Property 注解的基数

问题描述

我正在将 Apache Felix SCR 注释迁移到 OSGI 声明式服务 [AEM]。在迁移时,我找不到 DS 中基数的确切替代品。

现有的 SCR 实施:

@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";
}

现在在 OSGi 声明式服务中迁移如下

  @Component (configurationPolicy = ConfigurationPolicy.OPTIONAL,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";
   }

在 DS 注释实现中,我必须如何映射@Property 中存在的参数 cardinality。请建议我

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)