1 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 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 } 58 | Popular Tags |