【问题标题】:ServiceReference not fetching the all class names for activationServiceReference 未获取所有类名以进行激活
【发布时间】:2017-01-05 07:18:53
【问题描述】:

我正在使用下面的代码来获取所有引用类以激活它:

String filter = "(component.factory=com.requestclasses.mypack)";
bundleContext = componentContext.getBundleContext();
ServiceReference[] references = bundleContext.getAllServiceReferences(ComponentFactory.class.getCanonicalName(), filter);

但在 reference 中,我没有获得所有类。我不确定问题出在代码还是 AEM 5.6 上。 有什么建议吗?

【问题讨论】:

    标签: java aem crx


    【解决方案1】:

    我通常不建议使用此类低级 API 查询服务引用。

    您最好使用@Reference 注释检索这些引用,如下所示:

    @Reference(
       name = "componentFactories",
       referenceInterface = ComponentFactory.class,
       cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
       policy = ReferencePolicy.DYNAMIC
    )
    protected List<ComponentFactory> componentFactories = new ArrayList<ComponentFactory>();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-19
      • 2015-06-09
      • 2013-09-30
      • 2014-07-03
      • 1970-01-01
      • 2018-02-14
      • 1970-01-01
      相关资源
      最近更新 更多