首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尽管service.ranking很高,但Liferay没有看到我的服务实现。

尽管service.ranking很高,但Liferay没有看到我的服务实现。
EN

Stack Overflow用户
提问于 2017-11-06 08:03:03
回答 1查看 1.3K关注 0票数 0

我编写了一个模块,其中包含了com.liferay.portal.security.audit.AuditMessageProcessor服务的这个实现:

代码语言:javascript
复制
@Component(
    configurationPid = "my.MyAuditMessageProcessorConfiguration",
    immediate = true,
    property = {
            "eventTypes=*",
            "service.ranking:Integer=100000"
    },
    service = AuditMessageProcessor.class
)
public class MyElasticsearchAuditMessageProcessor
        implements AuditMessageProcessor {

    @Override
    public void process(AuditMessage auditMessage) {
        _log.info("This never appears even after login/logout");
        elasticsearch.send(auditMessage);
    }

    @Activate
    @Modified
    protected void activate(Map<String, Object> properties) {
        _myAuditMessageProcessorConfiguration = ConfigurableUtil
            .createConfigurable(
                MyAuditMessageProcessorConfiguration.class, properties);
    }

    @Reference(unbind = "-")
    protected my.Elasticsearch elasticsearch;

    private static final Log _log =
        LogFactoryUtil.getLog(MyAuditMessageProcessor.class);

    private volatile MyAuditMessageProcessorConfiguration
        _myAuditMessageProcessorConfiguration;
}

Elasticsearch.java:

代码语言:javascript
复制
@Component(
        immediate = true
    )
public class Elasticsearch {
    [...]
}

部署后,Gogo Shell认为我的模块没有实现该服务,如下所示。不过,我的模块实现的另外两个服务是可见的。

代码语言:javascript
复制
g! inspect capability service 548
myaudit_1.0.0 [548] provides:
---------------------------------
service; javax.servlet.Filter with properties:
   servlet-filter-name = Audit Download Filter
   url-pattern = /documents/*
   servlet-context-name = 
   component.name = my.DownloadFilter
   component.id = 2573
   service.id = 7181
   service.bundleid = 548
   service.scope = bundle
   Used by:
      org.eclipse.osgi_3.10.200.v20150831-0856 [0]
service; com.liferay.portal.kernel.portlet.bridges.mvc.MVCRenderCommand with properties:
   service.ranking = 100
   mvc.command.name = /document_library/view_file_entry
   javax.portlet.name = com_liferay_document_library_web_portlet_DLPortlet, com_liferay_document_library_web_portlet_DLAdminPortlet, com_liferay_document_library_web_portlet_IGDisplayPortlet
   component.name = my.MyViewFileEntryMVCRenderCommand
   component.id = 2576
   service.id = 7182
   service.bundleid = 548
   service.scope = bundle
   Used by:
      org.eclipse.osgi_3.10.200.v20150831-0856 [0]

我做错了什么?

关于信息,在我的模块的jar中存在这个OSGI-INF/my.MyAuditMessageProcessor.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="my.MyAuditMessageProcessor" immediate="true" activate="activate" modified="activate" configuration-pid="my.MyAuditMessageProcessorConfiguration">
  <implementation class="my.MyAuditMessageProcessor"/>
  <service>
    <provide interface="com.liferay.portal.security.audit.AuditMessageProcessor"/>
  </service>
  <property name="eventTypes" type="String" value="*"/>
  <property name="service.ranking" type="Integer" value="100000"/>
</scr:component>
EN

回答 1

Stack Overflow用户

发布于 2017-11-06 09:45:23

根据Christian的提示,问题是我的组件没有满足需求。请注意,这是不同的捆绑缺失的要求,它是一个级别以下。

我的包满足了所有的需求,但是我的模块缺少一个需求。我是这样发现的:

  1. 启动Gogo Shell
  2. scr:list
  3. 幸运的是,组件应该在长列表的末尾。
  4. 给出组件的id,例如2587
  5. scr:info 2587
  6. ,它将显示缺少依赖项的UnsatisfiedReferenceTarget: null

在我的例子中,我试图直接引用@组件,而不是服务。我通过创建一个ElasticsearchService接口并让Elasticsearch组件实现它来解决这个问题。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47132267

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档