]> source.dussan.org Git - archiva.git/commitdiff
- plexus compilant ClassPathXmlApplicationContext
authorNicolas De Loof <nicolas@apache.org>
Thu, 21 Feb 2008 16:33:10 +0000 (16:33 +0000)
committerNicolas De Loof <nicolas@apache.org>
Thu, 21 Feb 2008 16:33:10 +0000 (16:33 +0000)
- 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

springy/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java
springy/archiva-base/archiva-policies/src/test/java/org/apache/maven/archiva/policies/CachedFailuresPolicyTest.java
springy/archiva-base/archiva-policies/src/test/resources/org/apache/maven/archiva/policies/CachedFailuresPolicyTest-context.xml

index 140955ee4b7ab3b6fe9cfb2841d41d1a2d6b4c4c..4ebfb9e52117a97b4b071283930e9319a6622389 100644 (file)
@@ -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 <strong>not</strong> checked.
@@ -55,14 +54,12 @@ public class CachedFailuresPolicy
      */
     public static final String YES = "yes";
 
-    private UrlFailureCache urlFailureCache;
-
-    private List<String> options = new ArrayList<String>();
-
     /**
      * @plexus.requirement
      */
-    private SpringFactory springFactory;
+    private UrlFailureCache urlFailureCache;
+
+    private List<String> options = new ArrayList<String>();
 
     public CachedFailuresPolicy()
     {
@@ -115,10 +112,4 @@ public class CachedFailuresPolicy
     {
         return options;
     }
-
-    public void initialize()
-        throws InitializationException
-    {
-        urlFailureCache = (UrlFailureCache) springFactory.lookup( "urlFailureCache" );
-    }
 }
index edb85b8ab41d2ba1d9917887cdfadd45ff44d974..954a99e5784fa98109bba27644f1ad64947baa9f 100644 (file)
@@ -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" } );
     }
 }
index 055e8f93c9f8e8c3213101802ced162ae2820c7e..b054113c4b456a0a25ea2672b6eeb630c3be9548 100644 (file)
@@ -6,11 +6,6 @@
 
   <bean id="urlFailureCache" class="org.apache.maven.archiva.policies.urlcache.DefaultUrlFailureCache">
     <!-- collaborators and configuration for this bean go here -->
-    <constructor-arg ref="urlCache" type="org.codehaus.plexus.cache.Cache"/>
-  </bean>
-  <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"/>
+    <constructor-arg ref="cache#url-failures-cache" type="org.codehaus.plexus.cache.Cache"/>
   </bean>
 </beans>
\ No newline at end of file