mirror of
https://github.com/apache/archiva.git
synced 2025-02-14 14:06:36 +00:00
workaround the fact that load-on-start doesn't work with the spring integration (and this is better anyway)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@637010 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c11ef56f1d
commit
4da871b7f9
@ -19,56 +19,54 @@
|
||||
* 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;
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="default"
|
||||
*/
|
||||
private ResolverFactoryInit resolverFactory;
|
||||
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));
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="default"
|
||||
*/
|
||||
private ArchivaTaskScheduler taskScheduler;
|
||||
|
||||
public void initialize()
|
||||
throws InitializationException
|
||||
{
|
||||
Banner.display( getLogger(), ArchivaVersion.determineVersion( this.getClass().getClassLoader() ) );
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -224,15 +224,8 @@ public static String getBanner( String version )
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
@ -19,21 +19,6 @@
|
||||
-->
|
||||
|
||||
<plexus>
|
||||
<load-on-start>
|
||||
<component>
|
||||
<role>org.apache.maven.archiva.web.startup.ArchivaStartup</role>
|
||||
<role-hint>default</role-hint>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
|
||||
<role-hint>database-update</role-hint>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
|
||||
<role-hint>repository-scanning</role-hint>
|
||||
</component>
|
||||
</load-on-start>
|
||||
|
||||
<components>
|
||||
<component>
|
||||
<role>org.codehaus.plexus.registry.Registry</role>
|
||||
|
@ -11,4 +11,4 @@
|
||||
<constructor-arg ref="cache#url-failures-cache" type="org.codehaus.plexus.cache.Cache"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
</beans>
|
||||
|
@ -58,6 +58,10 @@
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
<listener>
|
||||
<!-- TODO: some Spring technique for this? -->
|
||||
<listener-class>org.apache.maven.archiva.web.startup.ArchivaStartup</listener-class>
|
||||
</listener>
|
||||
|
||||
<context-param>
|
||||
<param-name>contextClass</param-name>
|
||||
|
Loading…
x
Reference in New Issue
Block a user