1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.archive.crawler;
24
25 import java.io.IOException;
26
27 import javax.servlet.ServletContextEvent;
28 import javax.servlet.ServletContextListener;
29
30
31 /***
32 * Calls start and stop of Heritrix when Heritrix is bundled as a webapp.
33 * @author stack
34 * @version $Date: 2005-11-17 00:55:56 +0000 (Thu, 17 Nov 2005) $, $Revision: 3959 $
35 */
36 public class WebappLifecycle implements ServletContextListener {
37 private Heritrix heritrix = null;
38 public void contextInitialized(ServletContextEvent sce) {
39 if (!Heritrix.isCommandLine()) {
40 try {
41 this.heritrix = new Heritrix(true);
42 } catch (IOException e) {
43 e.printStackTrace();
44 }
45 if (this.heritrix != null) {
46 this.heritrix.start();
47 }
48 }
49 }
50
51 public void contextDestroyed(ServletContextEvent sce) {
52 if (this.heritrix != null) {
53 this.heritrix.destroy();
54 this.heritrix = null;
55 }
56 }
57 }