1 package org.apache.maven.archiva.repository;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.commons.collections.CollectionUtils;
23 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
24 import org.apache.maven.archiva.configuration.ConfigurationNames;
25 import org.apache.maven.archiva.configuration.functors.LocalRepositoryPredicate;
26 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
27 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
28 import org.codehaus.plexus.registry.Registry;
29 import org.codehaus.plexus.registry.RegistryListener;
31 import java.util.ArrayList;
32 import java.util.Collections;
33 import java.util.List;
36 * A component that provides a real-time listing of the active managed repositories within archiva.
37 * This object is internally consistent and will return maintain a consistent list of managed repositories internally.
39 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
42 * @plexus.component role="org.apache.maven.archiva.repository.ActiveManagedRepositories"
44 public class ActiveManagedRepositories
45 implements RegistryListener, Initializable
50 private ArchivaConfiguration archivaConfiguration;
52 private List allManagedRepositories = new ArrayList();
54 public List getAllManagedRepositories()
56 synchronized ( allManagedRepositories )
58 return Collections.unmodifiableList( allManagedRepositories );
62 public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
64 if ( ConfigurationNames.isRepositories( propertyName ) )
70 public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
72 /* nothing to do here */
75 public void initialize()
76 throws InitializationException
79 archivaConfiguration.addChangeListener( this );
84 synchronized ( allManagedRepositories )
86 allManagedRepositories.clear();
88 List configRepos = archivaConfiguration.getConfiguration().getRepositories();
89 CollectionUtils.select( configRepos, LocalRepositoryPredicate.getInstance() );