What about a Combined Plexus context, where the lookup method both search in the plexus components and the springFactory ?
This would make initialization more complex, but we could use @ plexus.requirement as is to get spring beans without having to know they are managed by spring. Nico. 2008/2/20, Brett Porter <[EMAIL PROTECTED]>: > > 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/ > >