如何查找OSGi包的包依赖项

时间:2013-04-02 10:38:37

标签: osgi apache-felix obr

我有2个OSGi Bundle存储库。我想使用API​​来检查捆绑包是否存在任何依赖性问题,前提是2 obr。如何调用api来做到这一点? 似乎我可以使用以下代码与Felix API来做到这一点。但是如何获取RepositoryAdmin对象?

RepositoryAdmin repoAdmin = ...
repoAdmin.addRepository(new File("/home/chandler/ws/reliability/testParent/test.eba/target/localobr/repository.xml").toURI().toURL());
repoAdmin.addRepository(new File("/home/chandler/geronimo3/var/obr.xml").toURI().toURL());
List<Repository> repos = new ArrayList<Repository>();
for(Repository repo : repoAdmin.listRepositories()) {
repos.add(repo);
}       
repos.add(repoAdmin.getSystemRepository());
repos.add(getLocalRepository(repoAdmin));
Resolver resolver = repoAdmin.resolver(repos.toArray(new Repository[0]));
Resource resources[] = repoAdmin.discoverResources("(&(presentationname=*)(symbolicname=com.chandler.app.osgi.test))");
resolver.add(resources[0]);
boolean resolved = resolver.resolve();

1 个答案:

答案 0 :(得分:0)

应该在OSGi框架中安装并启动

org.apache.felix.bundlerepository-x.y.z.jar。您可以从BundleContext实例获取RepositoryAdmin服务。