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.apache.continuum.builder.distributed.manager.DistributedBuildManager;
23  import org.apache.continuum.buildmanager.BuildsManager;
24  import org.apache.maven.continuum.Continuum;
25  import org.codehaus.plexus.spring.PlexusToSpringUtils;
26  import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
27  import org.slf4j.Logger;
28  import org.slf4j.LoggerFactory;
29  import org.springframework.web.context.WebApplicationContext;
30  import org.springframework.web.context.support.WebApplicationContextUtils;
31  
32  import javax.servlet.ServletContextEvent;
33  import javax.servlet.ServletContextListener;
34  
35  /**
36   * @author <a href="mailto:olamy@apache.org">olamy</a>
37   * @version $Id: ContinuumStartup.java 1372260 2012-08-13 04:29:09Z brett $
38   * @since 15 mars 2008
39   */
40  public class ContinuumStartup
41      implements ServletContextListener
42  {
43  
44      private Logger log = LoggerFactory.getLogger( getClass() );
45  
46      /**
47       * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
48       */
49      public void contextDestroyed( ServletContextEvent sce )
50      {
51          // nothing to do here
52  
53      }
54  
55      /**
56       * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
57       */
58      public void contextInitialized( ServletContextEvent sce )
59      {
60          WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(
61              sce.getServletContext() );
62  
63          // to simulate Plexus load on start with Spring
64          Continuum continuum = (Continuum) wac.getBean( PlexusToSpringUtils.buildSpringId( Continuum.class ) );
65  
66          BuildsManager buildsManager = (BuildsManager) wac.getBean( PlexusToSpringUtils.buildSpringId(
67              BuildsManager.class, "parallel" ) );
68  
69          TaskQueueExecutor prepareRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId(
70              TaskQueueExecutor.class, "prepare-release" ) );
71  
72          TaskQueueExecutor performRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId(
73              TaskQueueExecutor.class, "perform-release" ) );
74  
75          TaskQueueExecutor rollbackRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId(
76              TaskQueueExecutor.class, "rollback-release" ) );
77  
78          TaskQueueExecutor purge = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId(
79              TaskQueueExecutor.class, "purge" ) );
80  
81          TaskQueueExecutor prepareBuildProject = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId(
82              TaskQueueExecutor.class, "prepare-build-project" ) );
83  
84          DistributedBuildManager distributedBuildManager = (DistributedBuildManager) wac.getBean(
85              PlexusToSpringUtils.buildSpringId( DistributedBuildManager.class ) );
86      }
87  }