FYI, a similar question came up on the Equinox mailing list:
http://www.nabble.com/OSGi---RMI-t3733259.html On 16/05/07, Felix Meschberger <[EMAIL PROTECTED]> wrote:
Hi Guillaume, I have a use case where I create a JNDI InitialContext inside a bundle. Before calling the InitialContext, though, I had to set the current threads context loader to be the bundle's class loader (do not forget to reset the context loader afterwards). This allowed JNDI to load classes which are available from the bundle. Now, depending on how you get at the environment (HashMap) to give the InitialContext constructor, you will have to provide more in the bundle. For example, our use cases just takes a set of properties provided by an administrator. This set may include any class name, hence I set the Bundle with a "*" DynamicImport to provide InitialContextFactory class configured - provided it is available somewhere in the framework. Regards Felix On 5/15/07, Guillaume Nodet <[EMAIL PROTECTED]> wrote: > > Yeah, but what if the org.jnp.interfaces.NamingContextFactory is not in > the > classpath ? > That's what happen in my case. I guess in your case, the OSGI runs inside > JBoss > so there's no classpath problem. > What I want is to use OSGI as the container and start a JNDI from a > bundle. > > On 5/15/07, Rick Litton <[EMAIL PROTECTED]> wrote: > > > > Oops... my earlier response was for R3. For R4, I had to set the > > following in config.properties: > > > > # > > # JNDI properties. > > # > > java.naming.provider.url=localhost:1099 > > java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory > > java.naming.factory.url.pkgs=org.jboss.naming > > > > > > > > Rick Litton > > > > > > -----Original Message----- > > From: Rick Litton [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, May 15, 2007 1:06 PM > > To: [email protected] > > Subject: RE: Using felix on the server side > > > > Guillaume Nodet wrote: > > > > > Using a service may not always work. > > > For example the RMI JMX connector will access the JNDI > > > registry and will need the bundle in its classpath and this can > > > requirement can not be removed afaik (the code is in jmx). > > > > I'm not sure that this is entirely true. I created an RMI service > > bundle similar to what Richard suggested and it was not required to be > > declared in the classpath. What was just needed was to set the > > jndi.properties directory in the classpath so that the properties can > > easily be modified. Other than that, it was just like any *normal* > > bundle. > > > > Rick Litton > > > > > > -----Original Message----- > > From: Guillaume Nodet [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, May 15, 2007 12:53 PM > > To: [email protected] > > Subject: Re: Using felix on the server side > > > > Using a service may not always work. > > For example the RMI JMX connector will access the JNDI > > registry and will need the bundle in its classpath and this can > > requirement can not be removed afaik (the code is in jmx). > > > > What about extension bundles ? I've seen that in the spec. > > Could they help me somehow ? > > > > On 5/15/07, Richard S. Hall <[EMAIL PROTECTED]> wrote: > > > > > > Guillaume Nodet wrote: > > > > Hi everybody ! > > > > > > > > We 're considering building the next version of ServiceMix ( > > > > http://incubator.apache.org/servicemix/) > > > > on top of OSGI, and Felix sounds like a natural choice. > > > > I've downloaded the code and build it and discussed a bit with > > Carlos at > > > > JavaOne who told me > > > > about the new plugins. > > > > So I've written a few osgi bundles ( > > > > > > > > > http://svn.apache.org/repos/asf/incubator/servicemix/branches/osgi/servi > > cemix-osgi/ > > > > > > > > ) > > > > that are quite redundant with the MOSGi work. However when trying > > to > > > > work > > > > on a bundle for a JNDI implementation > > > > based on xbean-naming, i have problems where the needed classes (the > > > jndi > > > > initial factory class) are not available from > > > > the client osgi bundle. Is there any way to solve this problem ? I > > > > don't > > > > really want to import the needed package > > > > in all the bundles :-( > > > > > > I suppose there are ugly ways to solve it. You could put that stuff on > > > the class path and set boot class path delegation. You could have your > > > clients dynamically import "*". However, both of these approaches are > > > not very good. > > > > > > If your clients just need to use a JNDI service, you could have a JNDI > > > bundle that published a JNDI service into the service registry and > > > client bundles could look up the JNDI service in there, rather than > > > trying to create their own. > > > > > > Just some thoughts off the top of my head...perhaps other people have > > > more experience with it. > > > > > > > Btw, the MOSGi work seems nice, but there are some references to > > > > things not > > > > checked in. Is this part still > > > > maintain ? Can someone check in the needed modules or I can provide > > a > > > > patch > > > > to remove these references. > > > > > > Stephane Frenot is developing it, feel free to bug him. :-) > > > > > > -> richard > > > > > > > > > > > -- > > Cheers, > > Guillaume Nodet > > ------------------------ > > Principal Engineer, IONA > > Blog: http://gnodet.blogspot.com/ > > > > > > -- > Cheers, > Guillaume Nodet > ------------------------ > Principal Engineer, IONA > Blog: http://gnodet.blogspot.com/ >
-- Cheers, Stuart
