public void addChangeListener( RegistryListener listener )
{
- registry.addChangeListener( listener );
- }
-
- public synchronized void notifyOfConfigurationChange( Registry registry )
- {
- configuration = null;
+ Registry section = registry.getSection( KEY );
+ section.addChangeListener( listener );
}
public void initialize()
{
registry.addChangeListener( this );
}
+
+ public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ // nothing to do here
+ }
+
+ public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ configuration = null;
+ }
}
for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )\r
{\r
RepositoryConfiguration repository = (RepositoryConfiguration) i.next();\r
- if ( repository.getUrlName().equals( urlName ) )\r
+ if ( urlName.equals( repository.getUrlName() ) )\r
{\r
return repository;\r
}\r
for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )\r
{\r
RepositoryConfiguration repository = (RepositoryConfiguration) i.next();\r
- if ( repository.getId().equals( id ) )\r
+ if ( id.equals( repository.getId() ) )\r
{\r
return repository;\r
}\r
for ( java.util.Iterator i = getSyncedRepositories().iterator(); i.hasNext(); )\r
{\r
SyncedRepositoryConfiguration repository = (SyncedRepositoryConfiguration) i.next();\r
- if ( repository.getId().equals( id ) )\r
+ if ( id.equals( repository.getId() ) )\r
{\r
return repository;\r
}\r
for ( java.util.Iterator i = getProxiedRepositories().iterator(); i.hasNext(); )\r
{\r
ProxiedRepositoryConfiguration repository = (ProxiedRepositoryConfiguration) i.next();\r
- if ( repository.getId().equals( id ) )\r
+ if ( id.equals( repository.getId() ) )\r
{\r
return repository;\r
}\r
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
import org.codehaus.plexus.cache.Cache;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.codehaus.plexus.registry.Registry;
* @plexus.component role="org.apache.maven.archiva.repositories.ActiveManagedRepositories"
*/
public class DefaultActiveManagedRepositories
+ extends AbstractLogEnabled
implements ActiveManagedRepositories, Initializable, RegistryListener
{
/**
return path;
}
- public void notifyOfConfigurationChange( Registry registry )
+ public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
{
- configureSelf( archivaConfiguration.getConfiguration() );
+ // nothing to do
+ }
+
+ public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ if ( propertyName.startsWith( "repositories" ) || propertyName.startsWith( "localRepository" ) )
+ {
+ getLogger().debug( "Triggering managed repository configuration change with " + propertyName + " set to " +
+ propertyValue );
+ configureSelf( archivaConfiguration.getConfiguration() );
+ }
+ else
+ {
+ getLogger().debug( "Not triggering managed repository configuration change with " + propertyName );
+ }
}
}
try
{
- scheduleJobs( configuration );
+ scheduleJobs( configuration.getIndexPath(), configuration.getIndexerCronExpression() );
}
catch ( ParseException e )
{
}
}
- private void scheduleJobs( Configuration configuration )
+ private void scheduleJobs( String indexPath, String indexerCronExpression )
throws ParseException, SchedulerException
{
- if ( configuration.getIndexPath() != null )
+ if ( indexPath != null )
{
JobDetail jobDetail = createJobDetail( INDEXER_JOB );
- getLogger().info( "Scheduling indexer: " + configuration.getIndexerCronExpression() );
- CronTrigger trigger =
- new CronTrigger( INDEXER_JOB + "Trigger", DISCOVERER_GROUP, configuration.getIndexerCronExpression() );
+ getLogger().info( "Scheduling indexer: " + indexerCronExpression );
+ CronTrigger trigger = new CronTrigger( INDEXER_JOB + "Trigger", DISCOVERER_GROUP, indexerCronExpression );
scheduler.scheduleJob( jobDetail, trigger );
try
}
}
- public void notifyOfConfigurationChange( Registry registry )
+
+ public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
{
- try
- {
- stop();
- }
- catch ( StoppingException e )
- {
- getLogger().warn( "Error stopping task scheduler: " + e.getMessage(), e );
- }
+ // nothing to do
+ }
- try
- {
- scheduleJobs( archivaConfiguration.getConfiguration() );
- }
- catch ( ParseException e )
+ public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ if ( "indexPath".equals( propertyName ) || "indexerCronExpression".equals( propertyName ) )
{
- getLogger().error(
- "Error restarting task scheduler after configuration change, due to configuration error: " +
- e.getMessage(), e );
+ getLogger().debug( "Restarting task scheduler with new configuration after property change: " +
+ propertyName + " to " + propertyValue );
+ try
+ {
+ stop();
+ }
+ catch ( StoppingException e )
+ {
+ getLogger().warn( "Error stopping task scheduler: " + e.getMessage(), e );
+ }
+
+ try
+ {
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ scheduleJobs( configuration.getIndexPath(), configuration.getIndexerCronExpression() );
+ }
+ catch ( ParseException e )
+ {
+ getLogger().error(
+ "Error restarting task scheduler after configuration change, due to configuration error: " +
+ e.getMessage(), e );
+ }
+ catch ( SchedulerException e )
+ {
+ getLogger().error( "Error restarting task scheduler after configuration change: " + e.getMessage(), e );
+ }
}
- catch ( SchedulerException e )
+ else
{
- getLogger().error( "Error restarting task scheduler after configuration change: " + e.getMessage(), e );
+ getLogger().debug(
+ "Not restarting task scheduler with new configuration after property change: " + propertyName );
}
}
archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName() );
configuration = archivaConfiguration.getConfiguration();
archivaConfiguration.addChangeListener( this );
-
}
public void initServers( ServletConfig servletConfig )
return true;
}
- public void notifyOfConfigurationChange( Registry registry )
+ public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
{
- configuration = archivaConfiguration.getConfiguration();
+ // nothing to do
+ }
- getDavManager().removeAllServers();
+ public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ configuration = archivaConfiguration.getConfiguration();
- try
+ if ( propertyName.startsWith( "repositories" ) )
{
- initServers( getServletConfig() );
+ log( "Triggering managed repository configuration change with " + propertyName + " set to " +
+ propertyValue );
+ getDavManager().removeAllServers();
+
+ try
+ {
+ initServers( getServletConfig() );
+ }
+ catch ( DavServerException e )
+ {
+ log( "Error restarting WebDAV server after configuration change - service disabled: " + e.getMessage(),
+ e );
+ }
}
- catch ( DavServerException e )
+ else
{
- log( "Error restarting WebDAV server after configuration change - service disabled: " + e.getMessage(), e );
+ log( "Not triggering managed repository configuration change with " + propertyName );
}
}
}