* under the License.
*/
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletException;
+
import org.apache.maven.archiva.common.ArchivaException;
import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
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.spring.PlexusToSpringUtils;
+import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
/**
* ArchivaStartup - the startup of all archiva features in a deterministic order.
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
- *
- * @plexus.component
- * role="org.apache.maven.archiva.web.startup.ArchivaStartup"
- * role-hint="default"
*/
public class ArchivaStartup
- extends AbstractLogEnabled
- implements Initializable
+ implements ServletContextListener
{
- /**
- * @plexus.requirement role-hint="default"
- */
- private SecuritySynchronization securitySync;
-
- /**
- * @plexus.requirement role-hint="default"
- */
- private ResolverFactoryInit resolverFactory;
-
- /**
- * @plexus.requirement role-hint="default"
- */
- private ArchivaTaskScheduler taskScheduler;
+ public void contextDestroyed(ServletContextEvent arg0) {
+ }
- public void initialize()
- throws InitializationException
- {
- Banner.display( getLogger(), ArchivaVersion.determineVersion( this.getClass().getClassLoader() ) );
+ public void contextInitialized(ServletContextEvent arg0) {
+ WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(arg0.getServletContext());
+
+ SecuritySynchronization securitySync = (SecuritySynchronization) wac.getBean(PlexusToSpringUtils.buildSpringId(SecuritySynchronization.class));
+ ResolverFactoryInit resolverFactory = (ResolverFactoryInit) wac.getBean(PlexusToSpringUtils.buildSpringId(ResolverFactoryInit.class));
+ ArchivaTaskScheduler taskScheduler = (ArchivaTaskScheduler) wac.getBean(PlexusToSpringUtils.buildSpringId(ArchivaTaskScheduler.class));
+ TaskQueueExecutor databaseUpdateQueue = (TaskQueueExecutor) wac.getBean(PlexusToSpringUtils.buildSpringId(TaskQueueExecutor.class, "database-update"));
+ TaskQueueExecutor repositoryScanningQueue = (TaskQueueExecutor) wac.getBean(PlexusToSpringUtils.buildSpringId(TaskQueueExecutor.class, "repository-scanning"));
+ Banner banner = (Banner) wac.getBean(PlexusToSpringUtils.buildSpringId(Banner.class));
- try
+ try
{
securitySync.startup();
resolverFactory.startup();
taskScheduler.startup();
+ banner.display();
}
catch ( ArchivaException e )
{
- throw new InitializationException( "Unable to properly startup archiva: " + e.getMessage(), e );
+ throw new RuntimeException( "Unable to properly startup archiva: " + e.getMessage(), e );
}
- }
+ }
}
return injectVersion( decode( encodedBanner ), version );
}
- public static void display( Logger logger, String version )
- {
- String banner = getBanner( version );
- logger.info( StringUtils.repeat( "_", 25 ) + "\n" + banner );
- }
-
- public void initialize()
- throws InitializationException
- {
- Banner.display( getLogger(), ArchivaVersion.determineVersion( this.getClass().getClassLoader() ) );
- }
+ public void display() {
+ String banner = getBanner( ArchivaVersion.determineVersion( this.getClass().getClassLoader() ) );
+ getLogger().info( StringUtils.repeat( "_", 25 ) + "\n" + banner );
+ }
}