List of usage examples for javax.servlet ServletContextEvent ServletContextEvent
public ServletContextEvent(ServletContext source)
From source file:edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionSetupTest.java
@Before public void setup() { // setLoggerLevel(LocaleSelectionSetup.class, Level.DEBUG); // setLoggerLevel(StartupStatusStub.class, Level.DEBUG); setLoggerLevel(ConfigurationProperties.class, Level.WARN); ctx = new ServletContextStub(); sce = new ServletContextEvent(ctx); props = new ConfigurationPropertiesStub(); props.setBean(ctx);/*from www . ja va2s.c o m*/ ss = new StartupStatusStub(ctx); lss = new LocaleSelectionSetup(); }
From source file:org.jessma.ext.spring.SpringInjectFilter.java
@Override public void init() { servletContext = HttpHelper.getServletContext(); springMap = new HashMap<CoupleKey<Class<?>, Method>, SpringAttr[]>(); context = WebApplicationContextUtils.getWebApplicationContext(servletContext); if (context == null) { listener = new ContextLoaderListener(); listener.contextInitialized(new ServletContextEvent(servletContext)); context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); }// www. java2s .c o m }
From source file:ar.com.zauber.commons.spring.beans.factory.impl.ContextPathRegexCaseBlockTest.java
/** test */ public final void testCtxDefault() { final MockServletContext servletCtx = new MockServletContext("/laralara"); servletCtx.addInitParameter("contextConfigLocation", "classpath:/spring-test-switch-regex.xml"); final TestFriendlyContextLoaderListener listener = new TestFriendlyContextLoaderListener(); listener.contextInitialized(new ServletContextEvent(servletCtx)); final WebApplicationContext ctx = ((TestFriendlyContextLoader) listener.getContextLoader()).getCtx(); assertEquals("default", ctx.getBean("test1")); }
From source file:alpha.portal.webapp.listener.StartupListenerTest.java
@Override protected void setUp() throws Exception { super.setUp(); this.sc = new MockServletContext(""); this.sc.addInitParameter(Constants.CSS_THEME, "simplicity"); // initialize Spring this.sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "classpath:/applicationContext-dao.xml, " + "classpath:/applicationContext-service.xml, " + "classpath:/applicationContext-resources.xml"); this.springListener = new ContextLoaderListener(); this.springListener.contextInitialized(new ServletContextEvent(this.sc)); this.listener = new StartupListener(); }
From source file:com.jsmartframework.web.manager.ServletControl.java
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); WebContext.setServlet(this); // Call registered WebContextListeners for (ServletContextListener contextListener : HANDLER.contextListeners) { HANDLER.executeInjection(contextListener); contextListener.contextInitialized(new ServletContextEvent(servletConfig.getServletContext())); }//from w w w . j a v a 2s .co m }
From source file:org.jessma.ext.spring.SpringInjectFilter.java
@Override public void destroy() { if (listener != null) listener.contextDestroyed(new ServletContextEvent(servletContext)); springMap = null;/* www .j a v a 2 s. c o m*/ servletContext = null; listener = null; context = null; }
From source file:com.bekk.boss.pluto.embedded.util.PortalStartupListener.java
public void contextInitialized(ServletContextEvent sce) { Context.SContext servletContext = (Context.SContext) sce.getServletContext(); ContextHandler contextHandler = servletContext.getContextHandler(); Map initParams = contextHandler.getInitParams(); String configLocations = (String) initParams.get(ContextLoader.CONFIG_LOCATION_PARAM); if (configLocations != null) { configLocations = configLocations + " " + PLUTO_SERVICE_CONFIG_LOCATION; initParams.put(ContextLoader.CONFIG_LOCATION_PARAM, configLocations); } else {/*from w ww . ja v a2s. c o m*/ initParams.put(ContextLoader.CONFIG_LOCATION_PARAM, PLUTO_SERVICE_CONFIG_LOCATION); } // Traverse listeners to see if there's a configured // ContextLoaderListener EventListener[] listeners = contextHandler.getEventListeners(); if (listeners != null) { List newListenerList = new ArrayList(); for (int i = 0; i < listeners.length; i++) { EventListener listener = listeners[i]; if (!(listener instanceof ContextLoaderListener)) { newListenerList.add(listener); } } contextHandler.setEventListeners( (EventListener[]) newListenerList.toArray(new EventListener[newListenerList.size()])); } ServletContext wrapped = new WrappedServletContext(sce.getServletContext()); realStartupListener.contextInitialized(new ServletContextEvent(wrapped)); }
From source file:com.jsmartframework.web.manager.ServletControl.java
@Override public void destroy() { // Call registered WebContextListeners for (ServletContextListener contextListener : HANDLER.contextListeners) { contextListener.contextDestroyed(new ServletContextEvent(getServletContext())); }//ww w. j a v a 2s . c o m super.destroy(); }
From source file:alpha.portal.webapp.listener.StartupListenerTest.java
/** * Test context initialized.// w w w .j av a 2 s. co m */ public void testContextInitialized() { this.listener.contextInitialized(new ServletContextEvent(this.sc)); Assert.assertTrue(this.sc.getAttribute(Constants.CONFIG) != null); final Map config = (Map) this.sc.getAttribute(Constants.CONFIG); Assert.assertEquals(config.get(Constants.CSS_THEME), "simplicity"); Assert.assertTrue( this.sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null); Assert.assertTrue(this.sc.getAttribute(Constants.AVAILABLE_ROLES) != null); }