启动组件时未调用@Activate

时间:2017-08-25 12:05:37

标签: liferay osgi liferay-7

关注Liferay's documentation about making modules configurable,我写了这个Liferay 7模块:

@Component(configurationPid = "myproject.api.TranslationConfiguration")
public class TranslationServiceImpl implements TranslationService {
    private volatile TranslationConfiguration configuration;

    public TranslationServiceImpl() {
        log.info("TranslationServiceImpl constructor");
    }

    @Activate
    @Modified
    protected void activate(Map<String, Object> properties) {
        log.info("Hello from activate");
    }
}

部署时,日志只显示:

TranslationServiceImpl constructor
Service registered.
STARTED myproject.impl_1.0.0 [538]

为什么没有调用activate方法?

在Gogo Shell中重新启动模块也不会调用activate

1 个答案:

答案 0 :(得分:3)

默认情况下,声明性服务中的组件仅在其服务由另一个bundle引用时才会被激活。

如果您希望立即开始使用To see a list of available tasks, run gradle tasks To see a list of command-line options, run gradle --help