From 3ee1c5f9ff73060a6e977c744af93baf0a0c02c8 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 10 Dec 2013 01:29:51 +0000 Subject: [PATCH] cleanup logging on shutdown git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1549732 13f79535-47bb-0310-9956-ffa450edef68 --- .../indexing/ArchivaIndexingTaskExecutor.java | 3 -- ...ArchivaRepositoryScanningTaskExecutor.java | 12 -------- .../archiva/web/startup/ArchivaStartup.java | 28 ++++++++++--------- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java index 3fc0981e9..ed455b08b 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java @@ -60,9 +60,6 @@ public class ArchivaIndexingTaskExecutor { private Logger log = LoggerFactory.getLogger( ArchivaIndexingTaskExecutor.class ); - /** - * - */ private IndexPacker indexPacker; private ArtifactContextProducer artifactContextProducer; diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java index 53cfd5558..cb8fb21e0 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java @@ -57,29 +57,17 @@ public class ArchivaRepositoryScanningTaskExecutor { private Logger log = LoggerFactory.getLogger( ArchivaRepositoryScanningTaskExecutor.class ); - /** - * - */ @Inject private ManagedRepositoryAdmin managedRepositoryAdmin; - /** - * The repository scanner component. - */ @Inject private RepositoryScanner repoScanner; - /** - * - */ @Inject private RepositoryContentConsumers consumers; private Task task; - /** - * - */ @Inject private RepositoryStatisticsManager repositoryStatisticsManager; diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/ArchivaStartup.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/ArchivaStartup.java index 3d4a444ee..1f61425ca 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/ArchivaStartup.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/ArchivaStartup.java @@ -32,6 +32,7 @@ import org.quartz.SchedulerException; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; +import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import java.lang.reflect.Field; @@ -40,8 +41,6 @@ import java.util.concurrent.ExecutorService; /** * ArchivaStartup - the startup of all archiva features in a deterministic order. - * - * */ public class ArchivaStartup implements ServletContextListener @@ -101,6 +100,9 @@ public class ArchivaStartup WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext( contextEvent.getServletContext() ); + + ServletContext servletContext = contextEvent.getServletContext(); + // TODO check this stop /* @@ -112,9 +114,9 @@ public class ArchivaStartup if ( applicationContext != null ) //&& applicationContext instanceof PlexusWebApplicationContext ) { // stop task queue executors - stopTaskQueueExecutor( tqeDbScanning ); - stopTaskQueueExecutor( tqeRepoScanning ); - stopTaskQueueExecutor( tqeIndexing ); + stopTaskQueueExecutor( tqeDbScanning, servletContext ); + stopTaskQueueExecutor( tqeRepoScanning, servletContext ); + stopTaskQueueExecutor( tqeIndexing, servletContext ); // stop the DefaultArchivaTaskScheduler and its scheduler if ( repositoryTaskScheduler != null ) @@ -125,7 +127,7 @@ public class ArchivaStartup } catch ( SchedulerException e ) { - e.printStackTrace(); + servletContext.log( e.getMessage(), e ); } try @@ -139,7 +141,7 @@ public class ArchivaStartup } catch ( Exception e ) { - e.printStackTrace(); + servletContext.log( e.getMessage(), e ); } } @@ -158,13 +160,13 @@ public class ArchivaStartup } catch ( Exception e ) { - contextEvent.getServletContext().log( "skip error closing indexingContext " + e.getMessage() ); + servletContext.log( "skip error closing indexingContext " + e.getMessage(), e ); } } } - private void stopTaskQueueExecutor( ThreadedTaskQueueExecutor taskQueueExecutor ) + private void stopTaskQueueExecutor( ThreadedTaskQueueExecutor taskQueueExecutor, ServletContext servletContext ) { if ( taskQueueExecutor != null ) { @@ -177,7 +179,7 @@ public class ArchivaStartup try { taskQueueExecutor.stop(); - ExecutorService service = getExecutorServiceForTTQE( taskQueueExecutor ); + ExecutorService service = getExecutorServiceForTTQE( taskQueueExecutor, servletContext ); if ( service != null ) { service.shutdown(); @@ -185,12 +187,12 @@ public class ArchivaStartup } catch ( Exception e ) { - e.printStackTrace(); + servletContext.log( e.getMessage(), e ); } } } - private ExecutorService getExecutorServiceForTTQE( ThreadedTaskQueueExecutor ttqe ) + private ExecutorService getExecutorServiceForTTQE( ThreadedTaskQueueExecutor ttqe, ServletContext servletContext ) { ExecutorService service = null; try @@ -201,7 +203,7 @@ public class ArchivaStartup } catch ( Exception e ) { - e.printStackTrace(); + servletContext.log( e.getMessage(), e ); } return service; } -- 2.39.5