Java Reference
In-Depth Information
out.println("Can not resolve " + resources[0].getId() +
" reason: ");
for (Requirement req : resolver.getUnsatisfiedRequirements()) {
out.println("missing " + req.getName()
+ " " + req.getFilter());
}
}
} else {
out.println("No such resource");
}
}
private RepositoryAdmin getRepositoryAdmin() {
...
}
}
You first get the
Resolver
from the
RepositoryAdmin
service. Then you use the
RepositoryAdmin.discoverResources()
method with a
LDAP
filter argument to dis-
cover a resource to deploy. If you find any resources, you add the first one to the
Resolver
and call
resolve()
to resolve its dependencies from the available reposito-
ries
B
. If the resource is successfully resolved, you print out all of the dependencies of
the resource you're deploying. Then you use
Resolver.deploy()
to install and start
the discovered bundle and its dependencies
C
. If the resource couldn't be resolved,
you print out the missing requirements.
To run this example, go to the chapter10/combined-example/ directory of the
companion code. Type
ant
to build the example and
java
-jar
launcher.jar
bundles
to execute it. To interact with the shell, use
telnet
localhost
7070
. This
apache-felix-osgi-bundle-repository.html
)
. The following session uses the
obr-repo
and
obr-resolver
commands:
->
obr-repo add-url file:repository.xml
->
obr-repo list-urls
Paint (file:repository.xml)
->
obr-repo list
circle (org.foo.shape.circle) 4.0.0
frame (org.foo.paint) 4.0.0
shape (org.foo.shape) 4.0.0
square (org.foo.shape.square) 4.0.0
triangle (org.foo.shape.triangle) 4.0.0
->
obr-resolver (symbolicname=org.foo.paint)
Deploying dependency: shape (org.foo.shape) 4.0.0
->
obr-resolver (symbolicname=org.foo.shape.circle)
In this session, you first use the
add-url
subcommand to add your repository contain-
ing the paint program bundles. You verify the configured repository using the
list-
url
subcommand. Using the
list
subcommand, you browse the bundles contained in
the repository. Then, you use the
obr-resolver
command with an
LDAP
filter to
select and deploy the paint-frame bundle, which also installs its dependencies. Finally,
you install the circle bundle.