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;
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;
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 );
catch ( RepositoryAdminException e )
{
throw new RepositoryScannerException( e.getMessage(), e );
+ } finally
+ {
+ repositoryContentConsumers.releaseSelectedKnownConsumers( knownContentConsumers );
}
}
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;
/**
* RepositoryContentConsumerUtil
*/
-@Service( "repositoryContentConsumers" )
+@Service("repositoryContentConsumers")
public class RepositoryContentConsumers
implements ApplicationContextAware
{
private List<InvalidRepositoryContentConsumer> selectedInvalidConsumers;
+ @Inject
+ private ArchivaConfiguration archivaConfiguration;
+
@Inject
public RepositoryContentConsumers( ArchivaAdministration archivaAdministration )
{
* @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
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.
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
CollectionUtils.forAllDo( availableKnownConsumers, triggerCompleteScan );
CollectionUtils.forAllDo( availableInvalidConsumers, triggerCompleteScan );
*/
+ releaseSelectedKnownConsumers( selectedKnownConsumers );
}
}