User Tools

Site Tools


bundlecontext_in_web_app

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
bundlecontext_in_web_app [2013/11/02 19:19]
mihael created
bundlecontext_in_web_app [2015/12/02 13:14] (current)
mihael
Line 1: Line 1:
 ====== BundleContext in Web Application ====== ====== BundleContext in Web Application ======
-Getting the BundleContext (and with it access to the OSGi container and services) in a normal Java web application is possible in at least two ways:+Getting the BundleContext (and with it access to the OSGi container and services) in a normal Java web application is possible in multiple ​ways:
  
   * Make a WAB (Web Application Bundle) from the WAR by specifying the web app path in the manifest file and using a bundle activator. The bundle activator has access to the bundle context in via that ''​start''​ and ''​stop''​ methods.   * Make a WAB (Web Application Bundle) from the WAR by specifying the web app path in the manifest file and using a bundle activator. The bundle activator has access to the bundle context in via that ''​start''​ and ''​stop''​ methods.
   * The BundleContext is available from the ServletContext attributes (OSGI Enterprise Spec chapter "128.6 Interacting with the OSGi Environment"​):​ ''​BundleContext ctxt = (BundleContext)   * The BundleContext is available from the ServletContext attributes (OSGI Enterprise Spec chapter "128.6 Interacting with the OSGi Environment"​):​ ''​BundleContext ctxt = (BundleContext)
 servletContext.getAttribute("​osgi-bundlecontext"​);''​ servletContext.getAttribute("​osgi-bundlecontext"​);''​
 +  * ''​FrameworkUtil.getBundle(class).getBundleContext()''​
  
 {{tag>​devel java osgi}} {{tag>​devel java osgi}}
  
bundlecontext_in_web_app.1383419970.txt.gz ยท Last modified: 2013/11/02 19:19 by mihael