dev@glassfish.java.net

Re: SPI in an OSGi world

From: Richard S. Hall <heavy_at_ungoverned.org>
Date: Fri, 15 Apr 2011 12:28:40 -0400

On 4/15/11 11:19, Justin Lee wrote:
> I'd really like to use SPI for some stuff in grizzly but I have a
> sneaking suspicion that it's a major no-no in an OSGi environment.
> Can anyone (richard? jerome? sahoo?) comment on some nice way to get
> a service provider lookup that's workable in both OSGi and "normal"
> environments?

I think the simplest thing to do is to detect when you are running in an
OSGi environment and then do the "right thing" in that case. What
exactly that is depends on your approach. You could follow a
service-based or an extender-based approach. In either case, I think it
requires your bundle to be active so it can listen for changes in the
environment.

I believe that Sahoo actually created a bridge for META-INF/services to
do this...

-> richard