启动组件时未调用@Activate
@Activate not called when starting component
在 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
。
默认情况下,声明式服务中的组件只有在其服务被另一个包引用时才会被激活。
如果您希望它立即开始使用 immediate=true
在 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
。
默认情况下,声明式服务中的组件只有在其服务被另一个包引用时才会被激活。
如果您希望它立即开始使用 immediate=true