]> source.dussan.org Git - archiva.git/commitdiff
use PlexusClassPathXmlApplicationContext
authorNicolas De Loof <nicolas@apache.org>
Fri, 22 Feb 2008 09:46:20 +0000 (09:46 +0000)
committerNicolas De Loof <nicolas@apache.org>
Fri, 22 Feb 2008 09:46:20 +0000 (09:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@630131 13f79535-47bb-0310-9956-ffa450edef68

springy/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
springy/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
springy/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/spring-context.xml

index 5039d4fbe287bfea3380150c95578c55ff977485..706266388f36d84a02ec731f02454b75c7ba3a5a 100644 (file)
@@ -19,10 +19,19 @@ package org.apache.maven.archiva.proxy;
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Map.Entry;
+
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.common.spring.SpringFactory;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.ConfigurationNames;
 import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
@@ -63,16 +72,6 @@ import org.codehaus.plexus.registry.Registry;
 import org.codehaus.plexus.registry.RegistryListener;
 import org.codehaus.plexus.util.SelectorUtils;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-
 /**
  * DefaultRepositoryProxyConnectors
  *
@@ -114,12 +113,10 @@ public class DefaultRepositoryProxyConnectors
      */
     private Map<String, PostDownloadPolicy> postDownloadPolicies;
 
-    private UrlFailureCache urlFailureCache;
-
     /**
      * @plexus.requirement
      */
-    private SpringFactory springFactory;
+    private UrlFailureCache urlFailureCache;
 
     private Map<String, List<ProxyConnector>> proxyConnectorMap = new HashMap<String, List<ProxyConnector>>();
 
@@ -619,7 +616,7 @@ public class DefaultRepositoryProxyConnectors
     {
         String url = remoteRepository.getURL().getUrl() + remotePath;
 
-        // Transfer checksum does not use the policy. 
+        // Transfer checksum does not use the policy.
         if ( urlFailureCache.hasFailedBefore( url + type ) )
         {
             return;
@@ -1026,7 +1023,5 @@ public class DefaultRepositoryProxyConnectors
     {
         initConnectorsAndNetworkProxies();
         archivaConfiguration.addChangeListener( this );
-
-        urlFailureCache = (UrlFailureCache) springFactory.lookup( "urlFailureCache" );
     }
 }
index 49e019bb7463173f2812cb90a678d2d0ad245a56..7eb34be69e0baae670bc1a52d50cbe761ea38ea1 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.maven.archiva.proxy;
  */
 
 import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.common.spring.PlexusClassPathXmlApplicationContext;
 import org.apache.maven.archiva.common.spring.PlexusFactory;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
@@ -381,11 +382,12 @@ public abstract class AbstractProxyTestCase
     {
         super.setUp();
 
-        factory = new XmlBeanFactory(
-            new ClassPathResource( "/org/apache/maven/archiva/proxy/spring-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",
+                "classpath*:META-INF/spring/applicationContext.xml",
+                "classpath:/org/apache/maven/archiva/proxy/spring-context.xml" } );
 
         config = (MockConfiguration) lookup( ArchivaConfiguration.class.getName(), "mock" );
 
@@ -496,7 +498,7 @@ public abstract class AbstractProxyTestCase
     {
         assertTrue( "Managed File should exist: ", managedFile.exists() );
         assertTrue( "Remote File should exist: ", remoteFile.exists() );
-        
+
         managedFile.setLastModified( remoteFile.lastModified() + 55000 );
     }
 
@@ -504,13 +506,13 @@ public abstract class AbstractProxyTestCase
     {
         assertTrue( "Managed File should exist: ", managedFile.exists() );
         assertTrue( "Remote File should exist: ", remoteFile.exists() );
-        
+
         managedFile.setLastModified( remoteFile.lastModified() - 55000 );
     }
 
     protected void assertNotModified( File file, long expectedModificationTime )
     {
-        assertEquals( "File <" + file.getAbsolutePath() + "> not have been modified.", 
+        assertEquals( "File <" + file.getAbsolutePath() + "> not have been modified.",
                       expectedModificationTime, file.lastModified() );
     }
 
@@ -519,11 +521,11 @@ public abstract class AbstractProxyTestCase
     {
         String managedLegacyPath = managedLegacyDir.getCanonicalPath();
         String testFile = file.getCanonicalPath();
-    
+
         assertTrue( "Unit Test Failure: File <" + testFile
             + "> should be have been defined within the legacy managed path of <" + managedLegacyPath + ">", testFile
             .startsWith( managedLegacyPath ) );
-    
+
         assertFalse( "File < " + testFile + "> should not exist in managed legacy repository.", file.exists() );
     }
 
@@ -532,11 +534,11 @@ public abstract class AbstractProxyTestCase
     {
         String managedDefaultPath = managedDefaultDir.getCanonicalPath();
         String testFile = file.getCanonicalPath();
-    
+
         assertTrue( "Unit Test Failure: File <" + testFile
             + "> should be have been defined within the managed default path of <" + managedDefaultPath + ">", testFile
             .startsWith( managedDefaultPath ) );
-    
+
         assertFalse( "File < " + testFile + "> should not exist in managed default repository.", file.exists() );
     }
 
index 055e8f93c9f8e8c3213101802ced162ae2820c7e..98fcd7fa168a7cbe65436a500bdf70bc99d22233 100644 (file)
@@ -5,12 +5,6 @@
            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
 
   <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