View Javadoc

1   package org.apache.continuum.web.startup;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.codehaus.plexus.spring.PlexusToSpringUtils;
23  import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  import org.springframework.web.context.WebApplicationContext;
27  import org.springframework.web.context.support.WebApplicationContextUtils;
28  
29  import javax.servlet.ServletContextEvent;
30  import javax.servlet.ServletContextListener;
31  
32  public class BuildAgentStartup
33      implements ServletContextListener
34  {
35      private static final Logger log = LoggerFactory.getLogger( BuildAgentStartup.class );
36  
37      /**
38       * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
39       */
40      public void contextDestroyed( ServletContextEvent sce )
41      {
42          // nothing to do here
43      }
44  
45      /**
46       * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
47       */
48      public void contextInitialized( ServletContextEvent sce )
49      {
50          log.info( "Initializing Build Agent Task Queue Executor" );
51  
52          WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(
53              sce.getServletContext() );
54  
55          TaskQueueExecutor buildAgent = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId(
56              TaskQueueExecutor.class, "build-agent" ) );
57  
58          TaskQueueExecutor prepareBuildAgent = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId(
59              TaskQueueExecutor.class, "prepare-build-agent" ) );
60  
61          TaskQueueExecutor prepareRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId(
62              TaskQueueExecutor.class, "prepare-release" ) );
63  
64          TaskQueueExecutor performRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId(
65              TaskQueueExecutor.class, "perform-release" ) );
66  
67          TaskQueueExecutor rollbackRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId(
68              TaskQueueExecutor.class, "rollback-release" ) );
69      }
70  }