Java Reference
In-Depth Information
bundles. You don't need to package the bundles already present in the core package,
but you still need to mention them in the manifest. You use the DeploymentPackage-
Missing header to do this. Then you specify the shape bundles in the same fashion as
before. To use the deployment packages, you need to make each available via a URL .
NOTE If you make deployment packages available via a protocol that supports
MIME types, the standard MIME type for deployment packages is application/
vnd.osgi.dp .
Next, you can use the provided DeploymentAdmin service in your management agent
to install, update, and uninstall deployment packages.
MANAGING DEPLOYMENT PACKAGES
To d e m o n s t r a t e h o w a m a n a g e m e n t a g e n t c a n u s e D e p l o y m e n t A d m i n , y o u ' l l a g a i n
return to the shell and create a new dpa shell command to list, install, and uninstall
deployment packages. This command will use the DeploymentAdmin service, which is
represented by the following interface:
public interface DeploymentAdmin {
DeploymentPackage installDeploymentPackage(InputStream in)
throws DeploymentException;
DeploymentPackage[] listDeploymentPackages();
DeploymentPackage getDeploymentPackage(String symbName);
DeploymentPackage getDeploymentPackage(Bundle bundle);
boolean cancel();
}
The following listing shows the implementation of the command.
Listing 10.4 Deployment Admin shell command example
public class DeploymentPackageCommand extends BasicCommand {
public void exec(String args, PrintStream out, PrintStream err)
throws Exception {
DeploymentAdmin admin = getDeploymentAdmin();
if (admin == null) {
out.println("No DeploymentAdmin service found.");
return;
}
if (args != null) {
if (args.trim().equalsIgnoreCase("list")) {
for (DeploymentPackage dp : admin.listDeploymentPackages()) {
out.println(dp.getName() + " " + dp.getVersion());
}
} else if (args.trim().startsWith("uninstall ")) {
DeploymentPackage dp = admin.getDeploymentPackage(
args.trim().substring("uninstall ".length()));
if (dp != null) {
dp.uninstall();
} else {
out.println("No such package");
}
B
Gets installed
deployment packages
C Uninstalls
deployment
package
 
Search WWH ::




Custom Search