Hi
I try to understand how to use the bundle repository service with XML
Repository Files. As far as I understand the standard, it goes along these
lines:
RepositoryAdmin = repoAdmin ...
repoAdmin.addRepository(
new
URL("file:/home/p/kepler-osgi/cnf/releaserepo/index.xml"));
repoAdmin.addRepository(
new
URL("file:/home/p/kepler-osgi/cnf/localrepo/index.xml"));
String filter =
"(&(uri=*base.*.jar)(!(uri=*fwtest*))(version>=1.0.0))";
Requirement req = new RequirementBuilder("osgi.identity", filter);
Repository repo = repos.get(0);
Collection<Capability> result = repo
.findProviders(Collections.singleton(req)).get(req);
for ( Capability c: result) {
System.out.println(c.getAttributes());
}
This seems to work, I get what I expect in result.
What I don't understand is how to deploy these results in a framework.
The bundle repository website goes like this:
Resolver resolver = repoAdmin.resolver();
Resource resource = repoAdmin.discoverResources(filterStr);
resolver.add(resource);if (resolver.resolve())
{
resolver.deploy(true);
}
Note: resolver is *org.osgi.service.obr.Resolver*;
However, this seems not to be part of the standard , which mentions
something like this:
public class Provisioner {
File bundles = ...;
Map<String,Resource> resources = ...;
*Resolver resolver *= ...;
BundleContext context = ...;
public void install(String location) {
Resource resource = resources.get( location );
if ( resource == null ) error(...);
try {
*ResolveContextImpl *rc = ...
rc.addMandatory( resource );
Set<Resource> provision = resolver.resolve( rc ).keySet();
for ( Resource rb : provision ) {
String location = getLocation( rb );
Bundle bundle = context.installBundle( location );
if ( !isFragment( bundle ) )
bundle.start();
}
} catch(ResolutionException re) {
... // diagnostics
} catch(BundleException be) {
... // diagnostics
}
}
}
Note: resolver seems to be *org.osgi.service.resolver.Resolver;*
But where do I find import org.osgi.service.resolver.Resolver and
ResolveContextImpl ?
Note: I installed the resolver bundle from the apache felix download:
/cnf/localrepo/org.osgi.service.obr/org.osgi.service.obr-1.0.2.jar
Could somebody give me a pointer ?
Thanks
Peter