archiva-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brett Porter <br...@apache.org>
Subject Re: An experiment with Spring
Date Wed, 20 Feb 2008 07:09:53 GMT

On 20/02/2008, at 6:03 PM, Olivier Lamy wrote:

> Hi,
> Interesting, could you move this Spring/Plexus to a component in the
> plexus svn @ codehaus ?

That's a possibility - though it's really just a first draft right  
now :)

Cheers,
Brett

>
>
> Thanks,
> --
> Olivier
>
> 2008/2/20, Brett Porter <brett@apache.org>:
>> 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
>> brett@apache.org
>> http://blogs.exist.com/bporter/
>>
>>

--
Brett Porter
brett@apache.org
http://blogs.exist.com/bporter/


Mime
View raw message