summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-repository-scanner
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2014-04-30 17:22:41 +1000
committerOlivier Lamy <olamy@apache.org>2014-04-30 17:22:41 +1000
commit7808ee5fafdb02b7d9e0b104fc4a8642bce4f8ac (patch)
treea3e6864c2bae520b49ff92e24f83bac6db966d15 /archiva-modules/archiva-base/archiva-repository-scanner
parent9bb8edc5c8a7c1ed93443350b7a902d35e7a04c3 (diff)
downloadarchiva-7808ee5fafdb02b7d9e0b104fc4a8642bce4f8ac.tar.gz
archiva-7808ee5fafdb02b7d9e0b104fc4a8642bce4f8ac.zip
[MRM-1837] cleanup registry listeners from Archiva Configuration
Diffstat (limited to 'archiva-modules/archiva-base/archiva-repository-scanner')
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java8
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java29
2 files changed, 33 insertions, 4 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java
index 492845d4f..56ef2fd42 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java
@@ -21,6 +21,7 @@ package org.apache.archiva.repository.scanner;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
@@ -32,6 +33,7 @@ import org.springframework.stereotype.Service;
import javax.inject.Inject;
import java.io.File;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -57,9 +59,10 @@ public class DefaultRepositoryScanner
public RepositoryScanStatistics scan( ManagedRepository repository, long changesSince )
throws RepositoryScannerException
{
+ List<KnownRepositoryContentConsumer> knownContentConsumers = null;
try
{
- List<KnownRepositoryContentConsumer> knownContentConsumers = repositoryContentConsumers.getSelectedKnownConsumers();
+ knownContentConsumers = repositoryContentConsumers.getSelectedKnownConsumers();
List<InvalidRepositoryContentConsumer> invalidContentConsumers = repositoryContentConsumers.getSelectedInvalidConsumers();
List<String> ignoredPatterns = filetypes.getFileTypePatterns( FileTypes.IGNORED );
@@ -68,6 +71,9 @@ public class DefaultRepositoryScanner
catch ( RepositoryAdminException e )
{
throw new RepositoryScannerException( e.getMessage(), e );
+ } finally
+ {
+ repositoryContentConsumers.releaseSelectedKnownConsumers( knownContentConsumers );
}
}
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java
index 4ce22d2c4..4c6077a69 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java
@@ -23,9 +23,11 @@ import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.common.utils.BaseFile;
+import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
+import org.apache.archiva.redback.components.registry.RegistryListener;
import org.apache.archiva.repository.scanner.functors.ConsumerProcessFileClosure;
import org.apache.archiva.repository.scanner.functors.TriggerBeginScanClosure;
import org.apache.archiva.repository.scanner.functors.TriggerScanCompletedClosure;
@@ -48,7 +50,7 @@ import java.util.Map;
/**
* RepositoryContentConsumerUtil
*/
-@Service( "repositoryContentConsumers" )
+@Service("repositoryContentConsumers")
public class RepositoryContentConsumers
implements ApplicationContextAware
{
@@ -63,6 +65,9 @@ public class RepositoryContentConsumers
private List<InvalidRepositoryContentConsumer> selectedInvalidConsumers;
@Inject
+ private ArchivaConfiguration archivaConfiguration;
+
+ @Inject
public RepositoryContentConsumers( ArchivaAdministration archivaAdministration )
{
this.archivaAdministration = archivaAdministration;
@@ -156,7 +161,7 @@ public class RepositoryContentConsumers
* @return the list of {@link KnownRepositoryContentConsumer} that have been selected
* by the active configuration.
*/
- public synchronized List<KnownRepositoryContentConsumer> getSelectedKnownConsumers()
+ public List<KnownRepositoryContentConsumer> getSelectedKnownConsumers()
throws RepositoryAdminException
{
// FIXME only for testing
@@ -178,6 +183,22 @@ public class RepositoryContentConsumers
return ret;
}
+ public void releaseSelectedKnownConsumers( List<KnownRepositoryContentConsumer> repositoryContentConsumers )
+ {
+ if ( repositoryContentConsumers == null )
+ {
+ return;
+ }
+ for ( KnownRepositoryContentConsumer knownRepositoryContentConsumer : repositoryContentConsumers )
+ {
+ if ( RegistryListener.class.isAssignableFrom( knownRepositoryContentConsumer.getClass() ) )
+ {
+ archivaConfiguration.removeChangeListener(
+ RegistryListener.class.cast( knownRepositoryContentConsumer ) );
+ }
+ }
+ }
+
/**
* Get the list of {@link InvalidRepositoryContentConsumer} objects that are
* selected according to the active configuration.
@@ -248,12 +269,13 @@ public class RepositoryContentConsumers
public void executeConsumers( ManagedRepository repository, File localFile, boolean updateRelatedArtifacts )
throws RepositoryAdminException
{
+ List<KnownRepositoryContentConsumer> selectedKnownConsumers = null;
// Run the repository consumers
try
{
Closure triggerBeginScan = new TriggerBeginScanClosure( repository, getStartTime(), false );
- List<KnownRepositoryContentConsumer> selectedKnownConsumers = getSelectedKnownConsumers();
+ selectedKnownConsumers = getSelectedKnownConsumers();
// MRM-1212/MRM-1197
// - do not create missing/fix invalid checksums and update metadata when deploying from webdav since these are uploaded by maven
@@ -307,6 +329,7 @@ public class RepositoryContentConsumers
CollectionUtils.forAllDo( availableKnownConsumers, triggerCompleteScan );
CollectionUtils.forAllDo( availableInvalidConsumers, triggerCompleteScan );
*/
+ releaseSelectedKnownConsumers( selectedKnownConsumers );
}
}