From 6fe39949dfe6f482e1fdee8c0c574155190e930c Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Fri, 21 Jul 2006 13:48:28 +0000 Subject: [PATCH] fix bug in initial startup git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@424318 13f79535-47bb-0310-9956-ffa450edef68 --- .../DefaultRepositoryTaskScheduler.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java index 2e31e56b5..2f0bf6647 100644 --- a/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java +++ b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java @@ -96,24 +96,31 @@ public class DefaultRepositoryTaskScheduler private void scheduleJobs( Configuration configuration ) throws ParseException, SchedulerException { - JobDetail jobDetail = new JobDetail( INDEXER_JOB, DISCOVERER_GROUP, RepositoryTaskJob.class ); - JobDataMap dataMap = new JobDataMap(); - dataMap.put( AbstractJob.LOGGER, getLogger() ); - dataMap.put( RepositoryTaskJob.TASK_KEY, indexerTask ); - jobDetail.setJobDataMap( dataMap ); - - getLogger().info( "Scheduling indexer: " + configuration.getIndexerCronExpression() ); - CronTrigger trigger = - new CronTrigger( INDEXER_JOB + "Trigger", DISCOVERER_GROUP, configuration.getIndexerCronExpression() ); - scheduler.scheduleJob( jobDetail, trigger ); - - try + if ( configuration.getIndexPath() != null ) { - indexerTask.executeNowIfNeeded(); + JobDetail jobDetail = new JobDetail( INDEXER_JOB, DISCOVERER_GROUP, RepositoryTaskJob.class ); + JobDataMap dataMap = new JobDataMap(); + dataMap.put( AbstractJob.LOGGER, getLogger() ); + dataMap.put( RepositoryTaskJob.TASK_KEY, indexerTask ); + jobDetail.setJobDataMap( dataMap ); + + getLogger().info( "Scheduling indexer: " + configuration.getIndexerCronExpression() ); + CronTrigger trigger = + new CronTrigger( INDEXER_JOB + "Trigger", DISCOVERER_GROUP, configuration.getIndexerCronExpression() ); + scheduler.scheduleJob( jobDetail, trigger ); + + try + { + indexerTask.executeNowIfNeeded(); + } + catch ( TaskExecutionException e ) + { + getLogger().error( "Error executing task first time, continuing anyway: " + e.getMessage(), e ); + } } - catch ( TaskExecutionException e ) + else { - getLogger().error( "Error executing task first time, continuing anyway: " + e.getMessage(), e ); + getLogger().info( "Not scheduling indexer - index path is not configured" ); } // TODO: wire in the converter @@ -159,6 +166,5 @@ public class DefaultRepositoryTaskScheduler throws TaskExecutionException { indexerTask.execute(); - } }