Java ManagedService赢得';无法从文件安装中调用
我的Felix设置如下:Java ManagedService赢得';无法从文件安装中调用,java,osgi,apache-felix,Java,Osgi,Apache Felix,我的Felix设置如下: ID|State |Level|Name 0|Active | 0|System Bundle (5.0.1) 1|Active | 1|Apache Felix Bundle Repository (2.0.4) 2|Active | 1|Apache Felix Configuration Admin Service (1.8.8) 3|Resolved | 1|Ap
ID|State |Level|Name
0|Active | 0|System Bundle (5.0.1)
1|Active | 1|Apache Felix Bundle Repository (2.0.4)
2|Active | 1|Apache Felix Configuration Admin Service (1.8.8)
3|Resolved | 1|Apache Felix File Install (3.5.0)
4|Active | 1|Apache Felix Gogo Command (0.14.0)
5|Active | 1|Apache Felix Gogo Runtime (0.16.2)
6|Active | 1|Apache Felix Gogo Shell (0.10.0)
7|Active | 1|g.db OSGi Bundle (1.0.0)
g.db
包基本上实现了以下功能:
public class Activator implements BundleActivator, ManagedService {
ServiceRegistration sr;
public void updated(Dictionary dict) throws ConfigurationException {
System.err.println("\nupdated " + this);
}
public void start(BundleContext context) throws Exception {
System.err.println("\nstart " + this);
Dictionary props = new Hashtable();
props.put(Constants.SERVICE_PID, "db");
sr = context.registerService(ManagedService.class.getName(), this, props);
}
}
如果我在/load
中修改db.cfg
,我正在等待调用updated()
。但不会
g! inspect cap service 7
g.db [7] provides:
------------------------------------
service; org.osgi.service.cm.ManagedService with properties:
service.bundleid = 7
service.id = 28
service.pid = db
service.scope = singleton
文件安装正在监视正确的文件。我在修改db.cfg
时收到日志消息:
Updating configuration from db.cfg
我提高了配置管理服务的日志级别,并得到以下结果:
*DEBUG* Scheduling task Update: pid=db
*DEBUG* Running task Update: pid=db
*DEBUG* UpdateConfiguration(db) scheduled
*DEBUG* Updating configuration db to revision #3
*DEBUG* No ManagedService[Factory] registered for updates to configuration db
我的服务注册似乎有问题(?)
最后这是NB项目POM中的一个错误:我在
compile
范围中使用了org.osgi.compendium
工件。更改到提供的范围,它就会工作。编译或提供的范围通常不会有任何区别。。。除非还嵌入所有编译范围依赖项
在这种情况下,嵌入spec包时出现的错误是正常的。因此,包看到的包和配置管理服务使用的包是不同的。因此,您的ManagedService将不会被config admin service impl获取。检查此pid下是否没有多个配置,一个由fileinstall管理,另一个注入服务。fileinstall首先搜索链接到该文件的配置,然后用PID询问该配置您的清单包含什么?@Christian good point!我把事情搞砸了。非常感谢。如果你能记录下你做错了什么,以及你是如何改正的,那就太好了。也许它能帮助其他人。