Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
TravelAppInitializeListener |
|
| 3.0;3 |
1 | /* | |
2 | * Copyright 2007 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package edu.sampleu.travel.infrastructure; | |
17 | ||
18 | import java.io.FileNotFoundException; | |
19 | ||
20 | import javax.servlet.ServletContextEvent; | |
21 | import javax.servlet.ServletContextListener; | |
22 | ||
23 | import org.apache.log4j.Logger; | |
24 | import org.springframework.util.Log4jConfigurer; | |
25 | ||
26 | /** | |
27 | * A ServletContextListener that fires up the Spring context. | |
28 | * This is used instead of a standard ContextLoaderListener in order to load | |
29 | * an extra test context if running in unit tests. | |
30 | * | |
31 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
32 | */ | |
33 | 0 | public class TravelAppInitializeListener implements ServletContextListener { |
34 | 0 | private static final Logger LOG = Logger.getLogger(TravelAppInitializeListener.class); |
35 | ||
36 | public void contextDestroyed(ServletContextEvent sce) { | |
37 | ||
38 | 0 | } |
39 | ||
40 | public void contextInitialized(ServletContextEvent sce) { | |
41 | try { | |
42 | 0 | Log4jConfigurer.initLogging("classpath:log4j.properties"); |
43 | 0 | } catch (FileNotFoundException e) { |
44 | 0 | throw new RuntimeException("Failed to start sample application.", e); |
45 | 0 | } |
46 | ||
47 | 0 | Object o = sce.getServletContext().getAttribute("JETTYSERVER_TESTMODE"); |
48 | 0 | boolean testMode = false; |
49 | 0 | if (o != null) { |
50 | 0 | testMode = Boolean.valueOf((String) o); |
51 | } | |
52 | 0 | LOG.info("Travel webapp starting up in " + (testMode ? "test" : "normal") + " mode"); |
53 | // this loads up the Spring context | |
54 | 0 | TravelServiceLocator.initialize(testMode); |
55 | 0 | } |
56 | } |