simplify inject of bean list

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1160293 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-08-22 15:11:34 +00:00
parent 0c7626a137
commit 30ebe43f59
9 changed files with 35 additions and 35 deletions

View File

@ -27,5 +27,5 @@ package org.apache.maven.archiva.consumers;
public interface KnownRepositoryContentConsumer
extends RepositoryContentConsumer
{
// no op
}

View File

@ -107,12 +107,13 @@ public class RepositoryPurgeConsumer
private boolean deleteReleasedSnapshots;
@Inject
private ApplicationContext applicationContext;
//@Inject
//private ApplicationContext applicationContext;
/**
* plexus.requirement role="org.apache.archiva.repository.events.RepositoryListener"
*/
@Inject
private List<RepositoryListener> listeners = Collections.emptyList();
/**
@ -250,8 +251,8 @@ public class RepositoryPurgeConsumer
@PostConstruct
public void initialize()
{
this.listeners =
new ArrayList<RepositoryListener>( applicationContext.getBeansOfType( RepositoryListener.class ).values() );
//this.listeners =
// new ArrayList<RepositoryListener>( applicationContext.getBeansOfType( RepositoryListener.class ).values() );
configuration.addChangeListener( this );
initIncludes();

View File

@ -116,22 +116,25 @@ public class DefaultRepositoryProxyConnectors
@Named( value = "metadataTools#default" )
private MetadataTools metadataTools;
@Inject
private ApplicationContext applicationContext;
//@Inject
//private ApplicationContext applicationContext;
/**
* plexus.requirement role="org.apache.maven.archiva.policies.PreDownloadPolicy"
*/
@Inject
private Map<String, PreDownloadPolicy> preDownloadPolicies;
/**
* plexus.requirement role="org.apache.maven.archiva.policies.PostDownloadPolicy"
*/
@Inject
private Map<String, PostDownloadPolicy> postDownloadPolicies;
/**
* plexus.requirement role="org.apache.maven.archiva.policies.DownloadErrorPolicy"
*/
@Inject
private Map<String, DownloadErrorPolicy> downloadErrorPolicies;
/**
@ -162,9 +165,9 @@ public class DefaultRepositoryProxyConnectors
{
initConnectorsAndNetworkProxies();
archivaConfiguration.addChangeListener( this );
this.postDownloadPolicies = applicationContext.getBeansOfType( PostDownloadPolicy.class );
this.preDownloadPolicies = applicationContext.getBeansOfType( PreDownloadPolicy.class );
this.downloadErrorPolicies = applicationContext.getBeansOfType( DownloadErrorPolicy.class );
//this.postDownloadPolicies = applicationContext.getBeansOfType( PostDownloadPolicy.class );
//his.preDownloadPolicies = applicationContext.getBeansOfType( PreDownloadPolicy.class );
//this.downloadErrorPolicies = applicationContext.getBeansOfType( DownloadErrorPolicy.class );
}
@SuppressWarnings( "unchecked" )

View File

@ -62,16 +62,17 @@ public abstract class AbstractDefaultRepositoryContent
/**
* plexus.requirement role="org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider"
*/
protected List<? extends ArtifactMappingProvider> artifactMappingProviders;
@Inject
protected ApplicationContext applicationContext;
protected List<ArtifactMappingProvider> artifactMappingProviders;
//@Inject
//protected ApplicationContext applicationContext;
@PostConstruct
protected void initialize()
{
artifactMappingProviders = new ArrayList<ArtifactMappingProvider>(
applicationContext.getBeansOfType( ArtifactMappingProvider.class ).values() );
//artifactMappingProviders = new ArrayList<ArtifactMappingProvider>(
// applicationContext.getBeansOfType( ArtifactMappingProvider.class ).values() );
}
public ArtifactReference toArtifactReference( String path )

View File

@ -58,6 +58,7 @@ public abstract class AbstractActionSupport
/**
* plexus.requirement role="org.apache.archiva.audit.AuditListener"
*/
@Inject
private List<AuditListener> auditListeners = new ArrayList<AuditListener>();
/**
@ -75,8 +76,7 @@ public abstract class AbstractActionSupport
@PostConstruct
public void initialize()
{
// TODO some caching here
this.auditListeners = Lists.newArrayList( applicationContext.getBeansOfType( AuditListener.class ).values() );
// no op
}
@SuppressWarnings( "unchecked" )

View File

@ -125,6 +125,7 @@ public class DeleteArtifactAction
/**
* plexus.requirement role="org.apache.archiva.repository.events.RepositoryListener"
*/
@Inject
private List<RepositoryListener> listeners;
private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };
@ -133,7 +134,6 @@ public class DeleteArtifactAction
public void initialize()
{
super.initialize();
listeners = Lists.newArrayList( applicationContext.getBeansOfType( RepositoryListener.class ).values() );
}
public String getGroupId()

View File

@ -110,6 +110,7 @@ public class ArchivaDavResourceFactory
/**
* plexus.requirement role="org.apache.archiva.audit.AuditListener"
*/
@Inject
private List<AuditListener> auditListeners = new ArrayList<AuditListener>();
/**
@ -145,7 +146,6 @@ public class ArchivaDavResourceFactory
/**
* plexus.requirement
*/
//Inject
private ArchivaConfiguration archivaConfiguration;
/**
@ -169,21 +169,16 @@ public class ArchivaDavResourceFactory
/**
* plexus.requirement
*/
//Inject
private ChecksumFile checksum;
/**
* plexus.requirement role-hint="sha1"
*/
//Inject
//Named( value = "digester#sha1" )
private Digester digestSha1;
/**
* plexus.requirement role-hint="md5";
*/
//Inject
//Named( value = "digester#md5" )
private Digester digestMd5;
/**
@ -193,7 +188,6 @@ public class ArchivaDavResourceFactory
@Named( value = "archivaTaskScheduler#repository" )
private RepositoryArchivaTaskScheduler scheduler;
//Inject
private ApplicationContext applicationContext;
@Inject
@ -209,8 +203,6 @@ public class ArchivaDavResourceFactory
this.digestSha1 = plexusSisuBridge.lookup( Digester.class, "sha1" );
repositoryRequest = new RepositoryRequest( new LegacyPathParser( archivaConfiguration ) );
this.auditListeners =
new ArrayList<AuditListener>( applicationContext.getBeansOfType( AuditListener.class ).values() );
}
@PostConstruct

View File

@ -82,17 +82,18 @@ public class DefaultMetadataResolver
/**
* plexus.requirement role="org.apache.archiva.repository.events.RepositoryListener"
*/
@Inject
private List<RepositoryListener> listeners;
@Inject
private ApplicationContext applicationContext;
//@Inject
//private ApplicationContext applicationContext;
@PostConstruct
private void initialize()
{
listeners =
new ArrayList<RepositoryListener>( applicationContext.getBeansOfType( RepositoryListener.class ).values() );
//listeners =
// new ArrayList<RepositoryListener>( applicationContext.getBeansOfType( RepositoryListener.class ).values() );
}
public ProjectVersionMetadata resolveProjectVersion( RepositorySession session, String repoId, String namespace,

View File

@ -46,13 +46,14 @@ public class Maven2RepositoryPathTranslator
private static final Pattern TIMESTAMP_PATTERN = Pattern.compile( "([0-9]{8}.[0-9]{6})-([0-9]+).*" );
@Inject
private ApplicationContext applicationContext;
//@Inject
//private ApplicationContext applicationContext;
/**
* plexus.requirement role="org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider"
* see #initialize
*/
@Inject
private List<ArtifactMappingProvider> artifactMappingProviders;
public Maven2RepositoryPathTranslator()
@ -63,8 +64,9 @@ public class Maven2RepositoryPathTranslator
@PostConstruct
public void initialize()
{
artifactMappingProviders = new ArrayList<ArtifactMappingProvider>(
applicationContext.getBeansOfType( ArtifactMappingProvider.class ).values() );
//artifactMappingProviders = new ArrayList<ArtifactMappingProvider>(
// applicationContext.getBeansOfType( ArtifactMappingProvider.class ).values() );
}