2

我是 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();

可能这是我的一个简单错误。有人可以帮帮我吗?

谢谢!

4

2 回答 2

3

你为什么做这个?Felix 应该自动从系统包中导出这些包。

如果您需要从系统捆绑包中导出其他包,除了通常导出的包之外,请使用org.osgi.framework.system.packages.extra启动配置属性。

于 2012-08-21T13:04:17.627 回答
1

问题解决了。我在设置额外的包参数时犯了一个错误:

map.put ( "org.osgi.framework.system.packages.extra" , "" );

Felix 不接受空字符串(我最初使用的是空字符串,我想我稍后会添加包名称)。当我删除此声明时,一切正常。

正如 BJ Hargrave 所说,无需设置系统包。

另外,我们不应该将空字符串作为映射值传递,我没有意识到这一点。

于 2012-08-22T06:33:05.997 回答