*/
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;
*/
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.
*/
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()
{
{
return options;
}
-
- public void initialize()
- throws InitializationException
- {
- urlFailureCache = (UrlFailureCache) springFactory.lookup( "urlFailureCache" );
- }
}
* 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
*
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()
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" } );
}
}
<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