congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ServletContextListener.contextInitialized
Code IndexAdd Tabnine to your IDE (free)

How to use
contextInitialized
method
in
javax.servlet.ServletContextListener

Best Java code snippets using javax.servlet.ServletContextListener.contextInitialized (Showing top 20 results out of 765)

origin: org.freemarker/freemarker

public void contextInitialized(ServletContextEvent arg0) {
  arg0.getServletContext().setAttribute(ATTR_NAME, this);
  
  synchronized (servletContextListeners) {
    int s = servletContextListeners.size();
    for (int i = 0; i < s; ++i) {
      ((ServletContextListener) servletContextListeners.get(i)).contextInitialized(arg0);
    }
  }
}
origin: spring-projects/spring-framework

@Override
public <T extends EventListener> void addListener(T t) {
  if (t instanceof ServletContextListener) {
    ((ServletContextListener) t).contextInitialized(new ServletContextEvent(this));
  }
}
origin: spring-projects/spring-framework

/**
 * Addresses the issues raised in <a
 * href="http://opensource.atlassian.com/projects/spring/browse/SPR-4008"
 * target="_blank">SPR-4008</a>: <em>Supply an opportunity to customize
 * context before calling refresh in ContextLoaders</em>.
 */
@Test
public void testContextLoaderListenerWithCustomizedContextLoader() {
  final StringBuffer buffer = new StringBuffer();
  final String expectedContents = "customizeContext() was called";
  final MockServletContext sc = new MockServletContext("");
  sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
      "/org/springframework/web/context/WEB-INF/applicationContext.xml");
  ServletContextListener listener = new ContextLoaderListener() {
    @Override
    protected void customizeContext(ServletContext sc, ConfigurableWebApplicationContext wac) {
      assertNotNull("The ServletContext should not be null.", sc);
      assertEquals("Verifying that we received the expected ServletContext.", sc, sc);
      assertFalse("The ApplicationContext should not yet have been refreshed.", wac.isActive());
      buffer.append(expectedContents);
    }
  };
  listener.contextInitialized(new ServletContextEvent(sc));
  assertEquals("customizeContext() should have been called.", expectedContents, buffer.toString());
}
origin: spring-projects/spring-framework

@Test
public void testContextLoaderWithDefaultLocation() throws Exception {
  MockServletContext sc = new MockServletContext("");
  ServletContextListener listener = new ContextLoaderListener();
  ServletContextEvent event = new ServletContextEvent(sc);
  try {
    listener.contextInitialized(event);
    fail("Should have thrown BeanDefinitionStoreException");
  }
  catch (BeanDefinitionStoreException ex) {
    // expected
    assertTrue(ex.getCause() instanceof IOException);
    assertTrue(ex.getCause().getMessage().contains("/WEB-INF/applicationContext.xml"));
  }
}
origin: spring-projects/spring-framework

@Test
public void testContextLoaderWithCustomContext() throws Exception {
  MockServletContext sc = new MockServletContext("");
  sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM,
      "org.springframework.web.servlet.SimpleWebApplicationContext");
  ServletContextListener listener = new ContextLoaderListener();
  ServletContextEvent event = new ServletContextEvent(sc);
  listener.contextInitialized(event);
  String contextAttr = WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE;
  WebApplicationContext wc = (WebApplicationContext) sc.getAttribute(contextAttr);
  assertTrue("Correct WebApplicationContext exposed in ServletContext",
      wc instanceof SimpleWebApplicationContext);
}
origin: spring-projects/spring-framework

@Test
public void testContextLoaderWithInvalidLocation() throws Exception {
  MockServletContext sc = new MockServletContext("");
  sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "/WEB-INF/myContext.xml");
  ServletContextListener listener = new ContextLoaderListener();
  ServletContextEvent event = new ServletContextEvent(sc);
  try {
    listener.contextInitialized(event);
    fail("Should have thrown BeanDefinitionStoreException");
  }
  catch (BeanDefinitionStoreException ex) {
    // expected
    assertTrue(ex.getCause() instanceof FileNotFoundException);
  }
}
origin: spring-projects/spring-framework

@Test
public void testContextLoaderWithInvalidContext() throws Exception {
  MockServletContext sc = new MockServletContext("");
  sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM,
      "org.springframework.web.context.support.InvalidWebApplicationContext");
  ServletContextListener listener = new ContextLoaderListener();
  ServletContextEvent event = new ServletContextEvent(sc);
  try {
    listener.contextInitialized(event);
    fail("Should have thrown ApplicationContextException");
  }
  catch (ApplicationContextException ex) {
    // expected
    assertTrue(ex.getCause() instanceof ClassNotFoundException);
  }
}
origin: awslabs/aws-serverless-java-container

private void notifyStartListeners(ServletContext context) {
  for (ServletContextListener listener : contextListeners) {
    listener.contextInitialized(new ServletContextEvent(context));
  }
}
origin: spring-projects/spring-framework

@Test
public void testContextLoaderListenerWithDefaultContext() {
  MockServletContext sc = new MockServletContext("");
  sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
      "/org/springframework/web/context/WEB-INF/applicationContext.xml " +
      "/org/springframework/web/context/WEB-INF/context-addition.xml");
  ServletContextListener listener = new ContextLoaderListener();
  ServletContextEvent event = new ServletContextEvent(sc);
  listener.contextInitialized(event);
  String contextAttr = WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE;
  WebApplicationContext context = (WebApplicationContext) sc.getAttribute(contextAttr);
  assertTrue("Correct WebApplicationContext exposed in ServletContext", context instanceof XmlWebApplicationContext);
  assertTrue(WebApplicationContextUtils.getRequiredWebApplicationContext(sc) instanceof XmlWebApplicationContext);
  LifecycleBean lb = (LifecycleBean) context.getBean("lifecycle");
  assertTrue("Has father", context.containsBean("father"));
  assertTrue("Has rod", context.containsBean("rod"));
  assertTrue("Has kerry", context.containsBean("kerry"));
  assertTrue("Not destroyed", !lb.isDestroyed());
  assertFalse(context.containsBean("beans1.bean1"));
  assertFalse(context.containsBean("beans1.bean2"));
  listener.contextDestroyed(event);
  assertTrue("Destroyed", lb.isDestroyed());
  assertNull(sc.getAttribute(contextAttr));
  assertNull(WebApplicationContextUtils.getWebApplicationContext(sc));
}
origin: com.liferay.portal/com.liferay.portal.kernel

  servletContext);
servletContextListener.contextInitialized(servletContextEvent);
origin: haraldk/TwelveMonkeys

@Test
public void testContextDestroyed() {
  ServletContext context = mock(ServletContext.class);
  ServletContextEvent destroyed = mock(ServletContextEvent.class);
  when(destroyed.getServletContext()).thenReturn(context);
  ServletContextListener listener = new IIOProviderContextListener();
  listener.contextInitialized(mock(ServletContextEvent.class));
  listener.contextDestroyed(destroyed);
}
origin: haraldk/TwelveMonkeys

@Test
public void testContextInitialized() {
  ServletContextListener listener = new IIOProviderContextListener();
  listener.contextInitialized(mock(ServletContextEvent.class));
}
origin: org.tinygroup/org.tinygroup.weblayerbase

private void startListeners() {
  for (ServletContextListener listener : listeners) {
    listener.contextInitialized(event);
  }
}
origin: com.vaadin/flow-server

@Override
public void contextInitialized(ServletContextEvent sce) {
  for (ServletContextListener listener : listeners) {
    listener.contextInitialized(sce);
  }
}
origin: org.apache.myfaces.test/myfaces-test22

public void contextInitialized(ServletContextEvent sce)
{
  if (contextListeners != null && !contextListeners.isEmpty())
  {
    for (ServletContextListener listener : contextListeners)
    {
      listener.contextInitialized(sce);
    }
  }
}

origin: haraldk/TwelveMonkeys

@Test
public void testDestroyConcurrentModRegression() {
  ServletContext context = mock(ServletContext.class);
  ServletContextEvent destroyed = mock(ServletContextEvent.class);
  when(destroyed.getServletContext()).thenReturn(context);
  ServletContextListener listener = new IIOProviderContextListener();
  listener.contextInitialized(mock(ServletContextEvent.class));
  ImageReaderSpi provider1 = new MockImageReaderSpiOne();
  ImageReaderSpi provider2 = new MockImageReaderSpiToo();
  // NOTE: Fake registering for simplicity, but it still exposes the original problem with de-registering
  IIORegistry registry = IIORegistry.getDefaultInstance();
  registry.registerServiceProvider(provider1);
  registry.registerServiceProvider(provider2);
  assertTrue(registry.contains(provider1));
  assertTrue(registry.contains(provider2));
  listener.contextDestroyed(destroyed);
  assertFalse(registry.contains(provider1));
  assertFalse(registry.contains(provider2));
}
origin: org.freemarker/com.springsource.freemarker

public void contextInitialized(ServletContextEvent arg0)
{
  arg0.getServletContext().setAttribute(ATTR_NAME, this);
  
  synchronized(servletContextListeners)
  {
    int s = servletContextListeners.size();
    for(int i = 0; i < s; ++i)
    {
      ((ServletContextListener)servletContextListeners.get(i)).contextInitialized(arg0);
    }
  }
}
origin: com.haulmont.cuba/cuba-web

protected void initWebServletContextListener(ServletContextEvent servletContextEvent, ServletContext sc) {
  String className = sc.getInitParameter("webServletContextListener");
  if (!Strings.isNullOrEmpty(className)) {
    try {
      Class<?> clazz = this.getClass().getClassLoader().loadClass(className);
      webServletContextListener = (ServletContextListener) clazz.newInstance();
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
      throw new RuntimeException("An error occurred while starting single WAR application", e);
    }
    webServletContextListener.contextInitialized(servletContextEvent);
  }
}
origin: com.ovea.tajin.servers/tajin-server-jetty9

protected void callContextInitialized (ServletContextListener l, ServletContextEvent e)
{
  LOG.debug("contextInitialized: {}->{}",e,l);
  l.contextInitialized(e);
}
origin: sonatype/nexus-public

@Override
public ServletContextListener addingService(ServiceReference<ServletContextListener> reference) {
 ServletContextListener service = super.addingService(reference);
 service.contextInitialized(new ServletContextEvent(servletContext));
 return service;
}
javax.servletServletContextListenercontextInitialized

Javadoc

Receives notification that the web application initialization process is starting.

All ServletContextListeners are notified of context initialization before any filters or servlets in the web application are initialized.

Popular methods of ServletContextListener

  • contextDestroyed
    Receives notification that the ServletContext is about to be shut down.All servlets and filters will

Popular in Java

  • Finding current android device location
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSharedPreferences (Context)
  • onCreateOptionsMenu (Activity)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • JLabel (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now