spring has good integration with OSGi to enable Spring beans to be OSGi services.
On Mon, Feb 25, 2008 at 11:05 AM, Ludovic Maitre <[EMAIL PROTECTED]> wrote: > Hi Brett, all, > > Have you considered using OSGi instead of [Plexus|Spring] ? I'm not an > expert of one or the other, but i try to do some projects with OSGi > since a few months and i like it. > Best regards, > > Brett Porter a écrit : > > Hi, > > > > Given the discussion yesterday, I played around with some changes on a > > branch when I got up early this morning to show how we could do a > > partial migration to Spring without having to do it all at once. > > > > https://svn.apache.org/repos/asf/maven/archiva/branches/springy > > > > This shows: > > - ability to lookup plexus components via spring IoC > > - ability to lookup spring beans during the Plexus component lifecycle > > - basic functional setup for Spring in the Archiva application > > > > Eventually, as whole subsystems no longer require plexus it will be > > possible to clean it up, such as: > > - get rid of the additional lookups > > - use annotations for configuration > > - use testng + get/set + mocks for the tests where possible (and > > spring testcontext where integration testing is needed) > > > > Here is how to obtain a plexus object from Spring (note there is some > > pre-req setup in test cases you'll see in the commit, as there is in > > the additional servlet listener): > > <bean id="urlCache" factory-bean="plexusCacheFactory" > > factory-method="createInstance" /> > > <bean id="plexusCacheFactory" > > class="org.apache.maven.archiva.common.spring.PlexusFactory"> > > <constructor-arg index="0" value="org.codehaus.plexus.cache.Cache"/> > > <constructor-arg index="1" value="url-failures-cache"/> > > </bean> > > > > To get a spring bean inside a plexus component, it is like this (make > > sure to implement Initializable): > > > > /** > > * @plexus.requirement > > */ > > private SpringFactory springFactory; > > > > public void initialize() > > throws InitializationException > > { > > urlFailureCache = (UrlFailureCache) springFactory.lookup( > > "urlFailureCache" ); > > } > > > > The next thing we should probably try is using something like > > SpringCache as suggested to remove the plexus-cache dependency. > > > > Have fun! > > > > Cheers, > > Brett > > > > -- > > Brett Porter > > [EMAIL PROTECTED] > > http://blogs.exist.com/bporter/ > > > > > > > > > -- > Cordialement, > Ludo - http://www.ubik-products.com > --- > "L'amour pour principe et l'ordre pour base; le progres pour but" (A.Comte) > > -- I could give you my word as a Spaniard. No good. I've known too many Spaniards. -- The Princess Bride