From: Nicolas De Loof Date: Thu, 21 Feb 2008 16:33:10 +0000 (+0000) Subject: - plexus compilant ClassPathXmlApplicationContext X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ae5e322b02df5eca2d760c963d021c698803551f;p=archiva.git - plexus compilant ClassPathXmlApplicationContext - plexus-2-spring xslt now creates simple class name aliases for plexus FQCN roles - attempt to use plexus to spring bridge in CachedFailuresPolicyTest git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@629852 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/springy/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java b/springy/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java index 140955ee4..4ebfb9e52 100644 --- a/springy/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java +++ b/springy/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java @@ -20,7 +20,6 @@ package org.apache.maven.archiva.policies; */ import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.common.spring.SpringFactory; import org.apache.maven.archiva.policies.urlcache.UrlFailureCache; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; @@ -41,7 +40,7 @@ import java.util.Properties; */ public class CachedFailuresPolicy extends AbstractLogEnabled - implements PreDownloadPolicy, Initializable + implements PreDownloadPolicy { /** * The NO policy setting means that the the existence of old failures is not checked. @@ -55,14 +54,12 @@ public class CachedFailuresPolicy */ public static final String YES = "yes"; - private UrlFailureCache urlFailureCache; - - private List options = new ArrayList(); - /** * @plexus.requirement */ - private SpringFactory springFactory; + private UrlFailureCache urlFailureCache; + + private List options = new ArrayList(); public CachedFailuresPolicy() { @@ -115,10 +112,4 @@ public class CachedFailuresPolicy { return options; } - - public void initialize() - throws InitializationException - { - urlFailureCache = (UrlFailureCache) springFactory.lookup( "urlFailureCache" ); - } } diff --git a/springy/archiva-base/archiva-policies/src/test/java/org/apache/maven/archiva/policies/CachedFailuresPolicyTest.java b/springy/archiva-base/archiva-policies/src/test/java/org/apache/maven/archiva/policies/CachedFailuresPolicyTest.java index edb85b8ab..954a99e57 100644 --- a/springy/archiva-base/archiva-policies/src/test/java/org/apache/maven/archiva/policies/CachedFailuresPolicyTest.java +++ b/springy/archiva-base/archiva-policies/src/test/java/org/apache/maven/archiva/policies/CachedFailuresPolicyTest.java @@ -19,16 +19,14 @@ package org.apache.maven.archiva.policies; * under the License. */ -import org.apache.maven.archiva.common.spring.PlexusFactory; -import org.apache.maven.archiva.policies.urlcache.UrlFailureCache; -import org.codehaus.plexus.PlexusTestCase; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.ClassPathResource; - import java.io.File; import java.util.Properties; +import org.apache.maven.archiva.common.spring.PlexusClassPathXmlApplicationContext; +import org.apache.maven.archiva.policies.urlcache.UrlFailureCache; +import org.codehaus.plexus.PlexusTestCase; +import org.springframework.context.ApplicationContext; + /** * CachedFailuresPolicyTest * @@ -38,12 +36,12 @@ import java.util.Properties; public class CachedFailuresPolicyTest extends PlexusTestCase { - private BeanFactory factory; + private ApplicationContext factory; private DownloadPolicy lookupPolicy() throws Exception { - return (DownloadPolicy) lookup( PreDownloadPolicy.class.getName(), "cache-failures" ); + return (DownloadPolicy) factory.getBean( PreDownloadPolicy.class.getName() + "#cache-failures" ); } private File getFile() @@ -111,10 +109,11 @@ public class CachedFailuresPolicyTest throws Exception { super.setUp(); - factory = new XmlBeanFactory( - new ClassPathResource( "/org/apache/maven/archiva/policies/CachedFailuresPolicyTest-context.xml" ) ); - getContainer().getContext().put( BeanFactory.class, factory ); - PlexusFactory plexusFactory = (PlexusFactory) factory.getBean( "plexusCacheFactory" ); - plexusFactory.setContainer( container ); + + factory = new PlexusClassPathXmlApplicationContext( + new String[] { + "classpath*:META-INF/plexus/components.xml", + "classpath*:META-INF/plexus/components-fragment.xml", + "/org/apache/maven/archiva/policies/CachedFailuresPolicyTest-context.xml" } ); } } diff --git a/springy/archiva-base/archiva-policies/src/test/resources/org/apache/maven/archiva/policies/CachedFailuresPolicyTest-context.xml b/springy/archiva-base/archiva-policies/src/test/resources/org/apache/maven/archiva/policies/CachedFailuresPolicyTest-context.xml index 055e8f93c..b054113c4 100644 --- a/springy/archiva-base/archiva-policies/src/test/resources/org/apache/maven/archiva/policies/CachedFailuresPolicyTest-context.xml +++ b/springy/archiva-base/archiva-policies/src/test/resources/org/apache/maven/archiva/policies/CachedFailuresPolicyTest-context.xml @@ -6,11 +6,6 @@ - - - - - - + \ No newline at end of file