diff options
author | Olivier Lamy <olamy@apache.org> | 2012-01-24 23:42:53 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-01-24 23:42:53 +0000 |
commit | 37382ef7886f2019e1f4604002c472eb98fe4704 (patch) | |
tree | 4100801553477db8684d435d3afe308434e32dc5 /archiva-modules/archiva-base/archiva-proxy-common/src | |
parent | 5eed5ccf55feee3d58bbd5307fd7795cde556f5e (diff) | |
download | archiva-37382ef7886f2019e1f4604002c472eb98fe4704.tar.gz archiva-37382ef7886f2019e1f4604002c472eb98fe4704.zip |
avoid using plexus-sisu bridge to get wagon instances: use now spring
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1235559 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-proxy-common/src')
3 files changed, 19 insertions, 4 deletions
diff --git a/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/DefaultWagonFactory.java b/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/DefaultWagonFactory.java index 3f8f311b9..1e9d6cdf4 100755 --- a/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/DefaultWagonFactory.java +++ b/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/DefaultWagonFactory.java @@ -23,6 +23,8 @@ import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.commons.lang.StringUtils; import org.apache.maven.wagon.Wagon; +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; import javax.inject.Inject; @@ -38,12 +40,15 @@ public class DefaultWagonFactory private PlexusSisuBridge plexusSisuBridge; + private ApplicationContext applicationContext; + private DebugTransferListener debugTransferListener = new DebugTransferListener(); @Inject - public DefaultWagonFactory( PlexusSisuBridge plexusSisuBridge ) + public DefaultWagonFactory( PlexusSisuBridge plexusSisuBridge, ApplicationContext applicationContext ) { this.plexusSisuBridge = plexusSisuBridge; + this.applicationContext = applicationContext; } public Wagon getWagon( String protocol ) @@ -53,12 +58,17 @@ public class DefaultWagonFactory { // with sisu inject bridge hint is file or http // so remove wagon# - protocol = StringUtils.remove( protocol, "wagon#" ); - Wagon wagon = plexusSisuBridge.lookup( Wagon.class, protocol ); + //protocol = StringUtils.remove( protocol, "wagon#" ); + // spring beans will be named wagon#protocol (http, https, file ) + protocol = StringUtils.startsWith( protocol, "wagon#" ) ? protocol : "wagon#" + protocol; + //Wagon wagon = plexusSisuBridge.lookup( Wagon.class, protocol ); + + Wagon wagon = applicationContext.getBean( protocol, Wagon.class ); wagon.addTransferListener( debugTransferListener ); return wagon; } - catch ( PlexusSisuBridgeException e ) + //catch ( PlexusSisuBridgeException e ) + catch ( BeansException e ) { throw new WagonFactoryException( e.getMessage(), e ); } diff --git a/archiva-modules/archiva-base/archiva-proxy-common/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-base/archiva-proxy-common/src/main/resources/META-INF/spring-context.xml index eaf7b4146..ef68e5561 100644 --- a/archiva-modules/archiva-base/archiva-proxy-common/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-base/archiva-proxy-common/src/main/resources/META-INF/spring-context.xml @@ -30,5 +30,8 @@ <context:annotation-config/> <context:component-scan base-package="org.apache.archiva.proxy.common"/> + <bean name="wagon#http" scope="prototype" class="org.apache.maven.wagon.providers.http.HttpWagon"/> + + <bean name="wagon#https" scope="prototype" class="org.apache.maven.wagon.providers.http.HttpWagon"/> </beans>
\ No newline at end of file diff --git a/archiva-modules/archiva-base/archiva-proxy-common/src/test/resources/META-INF/spring-context.xml b/archiva-modules/archiva-base/archiva-proxy-common/src/test/resources/META-INF/spring-context.xml index 011f375fb..c19b3e867 100644 --- a/archiva-modules/archiva-base/archiva-proxy-common/src/test/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-base/archiva-proxy-common/src/test/resources/META-INF/spring-context.xml @@ -27,4 +27,6 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-lazy-init="true"> + <bean name="wagon#file" scope="prototype" class="org.apache.maven.wagon.providers.file.FileWagon"/> + </beans>
\ No newline at end of file |