我是OSGi的新手。我在Android上运行Apache Felix。我已将系统包设置为由系统包导出,如下所示:
/** Packages exported by the system bundle. */
String SYSTEM_PACKAGES =
"org.osgi.framework;version=\"1.6.0\"," +
"org.osgi.framework.launch;version=\"1.0.0\"," +
"org.osgi.framework.wiring;version=\"1.0.0\"," +
"org.osgi.framework.startlevel;version=\"1.0.0\"," +
"org.osgi.framework.hooks.bundle;version=\"1.0.0\"," +
"org.osgi.framework.hooks.resolver;version=\"1.0.0\"," +
"org.osgi.framework.hooks.service;version=\"1.1.0\"," +
"org.osgi.framework.hooks.weaving;version=\"1.0.0\"," +
"org.osgi.service.packageadmin;version=\"1.2.0\"," +
"org.osgi.service.startlevel;version=\"1.1.0\"," +
"org.osgi.service.url;version=\"1.0.0\"," +
"org.osgi.util.tracker;version=\"1.5.0\"";
Map map = new HashMap();
map.put ( "org.osgi.framework.system.packages" , SYSTEM_PACKAGES );
// I set more properties ...
felix = new Felix ( map );
felix.start();
但是,当我尝试安装ConfigAdmin包时,它会发出BundleException:
org.osgi.framework.BundleException: Unresolved constraint in bundle
org.apache.felix.configadmin [1]: Unable to resolve 1.0: missing requirement [1.0]
osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.4.0)
(!(version>=2.0.0)))
当我从版本1.6.0的系统包导出org.osgi.framework包时,为什么它缺少此要求? 我通过执行以下操作检查了系统属性是否已正确设置:
// DEBUG
Toast.makeText ( getApplicationContext() ,
felix.getBundleContext().getProperty ( "org.osgi.framework.system.packages" ) ,
Toast.LENGTH_LONG ).show();
就我而言,这可能是一个简单的错误。有人可以帮助我吗?
谢谢!
答案 0 :(得分:3)
你为什么要这样做? Felix应该自动从系统包中导出这些包。
如果您需要从系统包中导出其他包,除了通常导出的包之外,请使用org.osgi.framework.system.packages.extra
启动配置属性。
答案 1 :(得分:1)
问题解决了。我在设置额外的包参数时犯了一个错误:
map.put ( "org.osgi.framework.system.packages.extra" , "" );
Felix不接受空字符串(我最初使用过空字符串,以为我稍后会添加包名称)。当我删除此声明时,事情很好。
正如BJ Hargrave所说,无需设置系统包。
另外,我们不应该将空字符串作为地图值传递,我没有意识到这一点。