Search code examples
osgiblueprint-osgi

Maintaining OSGi bundle's state manually


Is there any approach via we can maintain and control OSGi bundles' state manually via code? I have a requirement where in I need to download, copy and install/activate/deactivate/delete OSGi bundles in run time environment.

Any help/references will be appreciated.

Thanks!


Solution

  • You install a bundle with BundleContext.install by supplying a URL or an InputStream. As result you get a Bundle. In Bundle you can then call start(), stop() and uninstall(). You get the BundleContext inside the Activator of any already existing bundle.

    http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html