Also see...
http://opensource.atlassian.com/projects/spring/browse/SPR-1802

This is a hot item right now -- lots of activity. 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Benjamin Schmaus
> Sent: Wednesday, October 18, 2006 5:27 PM
> To: General OPS4J
> Subject: Re: OSGi Classloading
> 
> I believe that Spring 2.0 provides pretty solid support for 
> using Spring in an OSGi runtime.
> 
> More at http://www.springframework.org/osgi/specification
> 
> On 10/18/06, Cameron Fieber <[EMAIL PROTECTED]> wrote:
> > What I've done using Spring + OSGi is:
> >
> > 1) create a library bundle for Spring that just exports all 
> the spring 
> > classes
> >
> > 2) created some hooks following the patterns of the Spring Remoting
> > classes: OSGIExporter and OSGIImporter that publish spring beans as 
> > OSGI services or import OSGI services for use by spring beans
> >
> > 3) each bundle that wants to export beans creates an application 
> > context in its activator (Abstract class that does that) 
> and uses the 
> > OSGI Exporter to publish those beans
> >
> > The activator is set via a manifest entry as to which services are 
> > required before it can launch the application context, so 
> it waits to 
> > launch the application context until all required services are 
> > available, and restarts the application context if those services 
> > change.
> >
> > Basically it uses the OSGI service mechanism to integrate 
> spring beans 
> > in different bundles.  As far as classloading stuff goes, all it 
> > required was that any thing you are exposing for other application 
> > contexts to import has to be properly configured in your 
> manifest as 
> > an exported package and imported by the consuming bundle.
> >
> > It's not pretty but it works.  Unfortunately I can't 
> publish the code 
> > for it, but it wasn't too hard to build.
> >
> > -Cameron
> >
> > On 10/18/06, Joe Toth <[EMAIL PROTECTED]> wrote:
> > > I'm relatively new to OSGi, but I'm learning. I have a question 
> > > regarding classloading.
> > >
> > > I'm trying to have a Spring based plug-in/bundle serve up 
> beans to 
> > > other bundles.  In one bundle I add all the spring stuff 
> and spring 
> > > works fine in that one bundle (its called 
> > > org.omegaframework.system).  Now I'm trying to initialize Spring 
> > > with an applicationContext.xml from another bundle (called 
> > > org.omegaframework.example).  I know the 2 bundles have different 
> > > classloaders so I have to do something in the Spring 
> bundle to let it know about the classpath from the other bundle.
> > >
> > > I tried 2 methods:
> > > 1. Using Equinox's BuddyLoader by putting...
> > > Eclipse-RegisterBuddy: org.omegaframework.system   in the 
> example bundle.
> > > And Eclipse-BuddyPolicy: registered in the system bundle.
> > > This didn't work, plus I'm looking for a platform 
> independent way to 
> > > do it anyway, if possible.
> > >
> > > 2. Passing the classloader...This method is in the system 
> bundle and 
> > > is called from the example bundle.  I tried passing
> > > ExampleActivator.class.getClassloader() and
> > > this.getClassLoader()
> > >
> > >     public void init(String applicationContextXMLFile, ClassLoader
> > > classLoader) {
> > >
> > >         Thread current = Thread.currentThread();
> > >         ClassLoader original = current.getContextClassLoader();
> > >         current.setContextClassLoader(classLoader);
> > >         try {
> > >             context = new ClassPathXmlApplicationContext(
> > >                     new String[] { applicationContextXMLFile }, 
> > > this.getClass());
> > >         } catch (Exception e) {
> > >             e.printStackTrace();
> > >         } finally {
> > >             current.setContextClassLoader(original);
> > >         }
> > >
> > >     }
> > >
> > >
> > > I can't get either to work.  I've only tested on Equinox 3.3
> > >
> > > Is there a "standard" way to allow a bundle access to another 
> > > bundles classpath?
> > >
> > > Thanks
> > >
> > > _______________________________________________
> > > general mailing list
> > > [email protected]
> > > http://lists.ops4j.org/mailman/listinfo/general
> > >
> > >
> > >
> >
> > _______________________________________________
> > general mailing list
> > [email protected]
> > http://lists.ops4j.org/mailman/listinfo/general
> >
> 
> _______________________________________________
> general mailing list
> [email protected]
> http://lists.ops4j.org/mailman/listinfo/general
> 
>
 
     This message may contain privileged and/or confidential information.  If 
you have received this e-mail in error or are not the intended recipient, you 
may not use, copy, disseminate or distribute it; do not open any attachments, 
delete it immediately from your system and notify the sender promptly by e-mail 
that you have done so.  Thank you.

_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to