1 13 package mondrian.web.taglib; 14 15 import javax.servlet.ServletContextEvent ; 16 import javax.servlet.ServletContextListener ; 17 18 27 28 public class Listener implements ServletContextListener { 29 30 ApplicationContext applicationContext; 31 32 public Listener() { 33 } 34 35 public void contextInitialized(ServletContextEvent event) { 36 Class clazz; 37 try { 38 clazz = Class.forName("mondrian.web.taglib.ApplResources"); 39 } catch (ClassNotFoundException e) { 40 throw new Error ( 41 "Received [" + e.toString() + "] while initializing servlet"); 42 } 43 Object o = null; 44 try { 45 o = clazz.newInstance(); 46 } catch (InstantiationException e) { 47 throw new Error ( 48 "Received [" + e.toString() + "] while initializing servlet"); 49 } catch (IllegalAccessException e) { 50 throw new Error ( 51 "Received [" + e.toString() + "] while initializing servlet"); 52 } 53 ApplicationContext applicationContext = (ApplicationContext) o; 54 applicationContext.init(event); 55 } 56 57 public void contextDestroyed(ServletContextEvent event) { 58 if (applicationContext != null) { 59 applicationContext.destroy(event); 60 } 61 } 62 63 interface ApplicationContext { 64 void init(ServletContextEvent event); 65 void destroy(ServletContextEvent event); 66 } 67 } 68 69 | Popular Tags |