【发布时间】:2016-08-26 02:06:27
【问题描述】:
我正在使用 felix osgi + ds +weld cdi + pax cdi。所以我有以下服务:
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ServiceScope;
@Component(
immediate = false,
property={"label=stub"},
scope=ServiceScope.PROTOTYPE
)
public class ServiceImpl implements ServiceI{
@Override
public String getMyString() {
Component t=null;
return "This is my string:"+t;
}
}
要生成 ds.xml 文件,我使用 maven-bundle-plugin,因为我知道这是生成 ds xml 文件的现代方式。所以一切似乎都奏效了。 ds xml文件由maven插件生成并放入OSGI-INF中。如果我删除这个 ds.xml 文件,我决定检查 felix 会做什么。所以我删除了这个xml文件并清理了osgi缓存。我对结果感到非常惊讶。该服务仍然有效并成功注入。我只是得到消息:找不到组件描述符条目'OSGI-INF/....xml'。此外,我认为 @Component 注释在编译后被删除。这就是为什么我没有在我的 osgi 中安装 org.osgi.service.component 包的原因。但是一切正常,所有捆绑包都已解决。
所以问题 -
- 为什么 DS 服务在没有 xml 文件的情况下工作?
- 为什么我的osgi框架不需要
org.osgi.service.component.annotations.Component? Felix 包有org.osgi.service.component.annotations包,但没有org.osgi.service.component.annotations.Component注释。
【问题讨论】:
标签: java maven osgi apache-felix