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;
/**
* ArchivaStartup - the startup of all archiva features in a deterministic order.
- *
- *
*/
public class ArchivaStartup
implements ServletContextListener
WebApplicationContext applicationContext =
WebApplicationContextUtils.getRequiredWebApplicationContext( contextEvent.getServletContext() );
+
+ ServletContext servletContext = contextEvent.getServletContext();
+
// TODO check this stop
/*
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 )
}
catch ( SchedulerException e )
{
- e.printStackTrace();
+ servletContext.log( e.getMessage(), e );
}
try
}
catch ( Exception e )
{
- e.printStackTrace();
+ servletContext.log( e.getMessage(), e );
}
}
}
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 )
{
try
{
taskQueueExecutor.stop();
- ExecutorService service = getExecutorServiceForTTQE( taskQueueExecutor );
+ ExecutorService service = getExecutorServiceForTTQE( taskQueueExecutor, servletContext );
if ( service != null )
{
service.shutdown();
}
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
}
catch ( Exception e )
{
- e.printStackTrace();
+ servletContext.log( e.getMessage(), e );
}
return service;
}