1
2
3
4
5
6
7
8
9
10
11
12
13
14
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.kuali.rice.core.web.jetty.JettyServer;
25 import org.springframework.util.Log4jConfigurer;
26
27 import uk.ltd.getahead.dwr.util.LoggingOutput;
28
29
30
31
32
33
34
35
36 public class TravelAppInitializeListener implements ServletContextListener {
37 private static final Logger LOG = Logger.getLogger(TravelAppInitializeListener.class);
38
39 public void contextDestroyed(ServletContextEvent sce) {
40
41 }
42
43 public void contextInitialized(ServletContextEvent sce) {
44 try {
45 Log4jConfigurer.initLogging("classpath:log4j.properties");
46 } catch (FileNotFoundException e) {
47 throw new RuntimeException("Failed to start sample application.", e);
48 }
49
50 Object o = sce.getServletContext().getAttribute(JettyServer.JETTYSERVER_TESTMODE_ATTRIB);
51 boolean testMode = false;
52 if (o != null) {
53 testMode = Boolean.valueOf((String) o);
54 }
55 LOG.info("Travel webapp starting up in " + (testMode ? "test" : "normal") + " mode");
56
57 TravelServiceLocator.initialize(testMode);
58 }
59 }