我有2个OSGi Bundle Repositories。我想使用API来检查一个bundle是否有任何依赖问题。我怎么调用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();
org.apache.felix.bundlerepository-x.y.z.jar应该在OSGi框架中安装并启动。你可以从BundleContext实例中获取RepositoryAdmin服务