1) inject (either constructor or set based is fine) a bundle context or
services you need when you create the Servlet but before you register it.
2) create and stash the bundle context / services in a static when the
bundle is activated (e.g. the ever popular Activator.getBundleContext())
I tend to prefer the first approach but admit I have times used the static
stash approach on occassion.
-Simon
----- Original Message -----
From: "Pruitt, Byron S" <[email protected]>
To: "OSGi Developer Mail List" <[email protected]>
Sent: Thursday, January 08, 2009 2:55 PM
Subject: RE: [osgi-dev] Servlet design pattern
I use the OSGi Http Service Specification to register my Servlets. My
question addresses more of what to after the Servlet gets a request and
needs to access some OSGi service for instance. I can't figure out a clean
way to wire my Servlet up with the rest of the OSGi univers.
-S
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Niclas Hedhman
Sent: Wednesday, January 07, 2009 9:02 PM
To: OSGi Developer Mail List
Subject: Re: [osgi-dev] Servlet design pattern
On Thu, Jan 8, 2009 at 2:45 AM, Pruitt, Byron S <[email protected]>
wrote:
I'm developing an application with several bundles. Some of them use the
http service as the api for the outside world.
I haven't found a good pattern for integrating Servlets with the rest of
the OSGi framework. After a request is received, I want to invoke OSGi
services, etc. I have experimented with singletons or initializing the
Servlet with objects that "bridge" the Servlet to the services.
Is there something better? Am I missing something obvious?
Have you seen if the OSGi Http Service Specification meets your
requirements?
If not, take a look at the Servlet Bridge by Simon Kaegi.
Also, you can embed Felix so that framework extensions, which are
loaded from your servlet with the embedding, can expose and use
services in the Felix instance. I guess Equinox can do the same, but I
don't know the details.
Cheers
Niclas
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev