From 30ebe43f5972c545bb3a1c4b4059a1e5b0684aeb Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 22 Aug 2011 15:11:34 +0000 Subject: [PATCH] simplify inject of bean list git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1160293 13f79535-47bb-0310-9956-ffa450edef68 --- .../consumers/KnownRepositoryContentConsumer.java | 2 +- .../core/repository/RepositoryPurgeConsumer.java | 9 +++++---- .../proxy/DefaultRepositoryProxyConnectors.java | 13 ++++++++----- .../content/AbstractDefaultRepositoryContent.java | 11 ++++++----- .../archiva/web/action/AbstractActionSupport.java | 4 ++-- .../archiva/web/action/DeleteArtifactAction.java | 2 +- .../archiva/webdav/ArchivaDavResourceFactory.java | 10 +--------- .../repository/DefaultMetadataResolver.java | 9 +++++---- .../maven2/Maven2RepositoryPathTranslator.java | 10 ++++++---- 9 files changed, 35 insertions(+), 35 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/KnownRepositoryContentConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/KnownRepositoryContentConsumer.java index b73209ec5..66d98459f 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/KnownRepositoryContentConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/KnownRepositoryContentConsumer.java @@ -27,5 +27,5 @@ package org.apache.maven.archiva.consumers; public interface KnownRepositoryContentConsumer extends RepositoryContentConsumer { - + // no op } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java index 0f1a99975..b52fc4eeb 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java @@ -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 listeners = Collections.emptyList(); /** @@ -250,8 +251,8 @@ public class RepositoryPurgeConsumer @PostConstruct public void initialize() { - this.listeners = - new ArrayList( applicationContext.getBeansOfType( RepositoryListener.class ).values() ); + //this.listeners = + // new ArrayList( applicationContext.getBeansOfType( RepositoryListener.class ).values() ); configuration.addChangeListener( this ); initIncludes(); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java index ec5042819..84782aef1 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java @@ -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 preDownloadPolicies; /** * plexus.requirement role="org.apache.maven.archiva.policies.PostDownloadPolicy" */ + @Inject private Map postDownloadPolicies; /** * plexus.requirement role="org.apache.maven.archiva.policies.DownloadErrorPolicy" */ + @Inject private Map 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" ) diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractDefaultRepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractDefaultRepositoryContent.java index 8c685a72c..a8556c9cc 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractDefaultRepositoryContent.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractDefaultRepositoryContent.java @@ -62,16 +62,17 @@ public abstract class AbstractDefaultRepositoryContent /** * plexus.requirement role="org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider" */ - protected List artifactMappingProviders; - @Inject - protected ApplicationContext applicationContext; + protected List artifactMappingProviders; + + //@Inject + //protected ApplicationContext applicationContext; @PostConstruct protected void initialize() { - artifactMappingProviders = new ArrayList( - applicationContext.getBeansOfType( ArtifactMappingProvider.class ).values() ); + //artifactMappingProviders = new ArrayList( + // applicationContext.getBeansOfType( ArtifactMappingProvider.class ).values() ); } public ArtifactReference toArtifactReference( String path ) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractActionSupport.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractActionSupport.java index 1c95e2c64..add5607e3 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractActionSupport.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractActionSupport.java @@ -58,6 +58,7 @@ public abstract class AbstractActionSupport /** * plexus.requirement role="org.apache.archiva.audit.AuditListener" */ + @Inject private List auditListeners = new ArrayList(); /** @@ -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" ) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java index dc619c212..e370066ec 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java @@ -125,6 +125,7 @@ public class DeleteArtifactAction /** * plexus.requirement role="org.apache.archiva.repository.events.RepositoryListener" */ + @Inject private List 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() diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java index b0eeed5fd..280c98376 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java @@ -110,6 +110,7 @@ public class ArchivaDavResourceFactory /** * plexus.requirement role="org.apache.archiva.audit.AuditListener" */ + @Inject private List auditListeners = new ArrayList(); /** @@ -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( applicationContext.getBeansOfType( AuditListener.class ).values() ); } @PostConstruct diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java index 27940a9f0..e6fb6888e 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java @@ -82,17 +82,18 @@ public class DefaultMetadataResolver /** * plexus.requirement role="org.apache.archiva.repository.events.RepositoryListener" */ + @Inject private List listeners; - @Inject - private ApplicationContext applicationContext; + //@Inject + //private ApplicationContext applicationContext; @PostConstruct private void initialize() { - listeners = - new ArrayList( applicationContext.getBeansOfType( RepositoryListener.class ).values() ); + //listeners = + // new ArrayList( applicationContext.getBeansOfType( RepositoryListener.class ).values() ); } public ProjectVersionMetadata resolveProjectVersion( RepositorySession session, String repoId, String namespace, diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java index 4ed4c0825..c1bb5cc2b 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java @@ -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 artifactMappingProviders; public Maven2RepositoryPathTranslator() @@ -63,8 +64,9 @@ public class Maven2RepositoryPathTranslator @PostConstruct public void initialize() { - artifactMappingProviders = new ArrayList( - applicationContext.getBeansOfType( ArtifactMappingProvider.class ).values() ); + + //artifactMappingProviders = new ArrayList( + // applicationContext.getBeansOfType( ArtifactMappingProvider.class ).values() ); } -- 2.39.5