users@glassfish.java.net

Re: Access to BundleContext from Servlet /Seam in OSGI glassfish

From: <glassfish_at_javadesktop.org>
Date: Wed, 26 Nov 2008 19:27:52 PST

2 solutions proposed by vladrin_at_gmail.com from www.dynamicjava.org:


1- The package "javax.servlet" is provided by Thread Context Classloader in Tomcat, this ClassLoader is used to launch the OSGi-based application using DA-Launcher, so the package will mostly be available in the System Bundle. Something like Fragment-Host will work, but the solution is quite dirty and it's more like a hack since it can bring chaos to your application. Anyway, the link below presents an example of this approach.
http://regumindtrail.wordpress.com/2008/06/10/acessing-osgi-service-from-non-osgi-client/

2- I had this problem while working on DynamicServlet-Bridge, I have Servlets in the OSGi Environment that I invoke them from a non-osgi Web Application. For that I developer API-Bridge (which unfortunately has no documentation). I used the solution there and it proved to work, I mean it worked there and in Dynamic-WS too. To use the API-Bridge you will need to write only few lines of code (about 10). The zip file below contains the source code for DynamicServlet-Bridge, from there check the method 'createOsgiServletService' of the class 'org.dynamicjava.osgi.servlet_bridge.internal.ServletBridgeFactory'. As you will see that the Servlet was casted because I used API-Bridge.
http://www.dynamicjava.org/downloads/projects/dynamicservlet-bridge/dynamic-servlet-bridge-1.0.0-src.zip
[Message sent by forum member 'christian_cadieux' (christian_cadieux)]

http://forums.java.net/jive/thread.jspa?messageID=318922