1 56 57 package org.objectstyle.cayenne.conf; 58 59 import javax.servlet.ServletContext ; 60 import javax.servlet.ServletContextEvent ; 61 import javax.servlet.ServletContextListener ; 62 import javax.servlet.http.HttpSessionEvent ; 63 import javax.servlet.http.HttpSessionListener ; 64 65 96 public class WebApplicationListener implements HttpSessionListener , 97 ServletContextListener { 98 99 104 public void contextInitialized(ServletContextEvent sce) { 105 ServletUtil.initializeSharedConfiguration(sce.getServletContext()); 106 } 107 108 113 public void contextDestroyed(ServletContextEvent sce) { 114 } 115 116 121 public void sessionCreated(HttpSessionEvent se) { 122 se.getSession().setAttribute( 123 ServletUtil.DATA_CONTEXT_KEY, 124 getConfiguration().getDomain().createDataContext()); 125 } 126 127 131 public void sessionDestroyed(HttpSessionEvent se) { 132 } 133 134 141 protected Configuration newConfiguration(ServletContext sc) { 142 return new BasicServletConfiguration(sc); 143 } 144 145 148 protected void setConfiguration(Configuration configuration) { 149 Configuration.initializeSharedConfiguration(configuration); 150 } 151 152 153 protected Configuration getConfiguration() { 154 return Configuration.getSharedConfiguration(); 155 } 156 } | Popular Tags |