Class Listener

java.lang.Object
org.jboss.weld.servlet.api.helpers.ForwardingServletListener
org.jboss.weld.environment.servlet.Listener
All Implemented Interfaces:
jakarta.servlet.http.HttpSessionListener, jakarta.servlet.ServletContextListener, jakarta.servlet.ServletRequestListener, EventListener, org.jboss.weld.servlet.api.ServletListener

public class Listener extends org.jboss.weld.servlet.api.helpers.ForwardingServletListener
This is the original listener which had to be defined in web.xml. It's not necessary to register this listener in Servlet 3.0 compliant containers unless there are listener ordering conflicts. E.g. if a user provides a custom listener the request context will not be active during its notifications. In this case place this listener before any other listener definitions in web.xml. ServletContextListener.contextInitialized(ServletContextEvent) is no-op in case of the EnhancedListener is registered as well.
Author:
Pete Muir, Ales Justin
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    contextDestroyed(jakarta.servlet.ServletContextEvent sce)
     
    void
    contextInitialized(jakarta.servlet.ServletContextEvent sce)
     
    protected org.jboss.weld.servlet.api.ServletListener
     
    void
    requestDestroyed(jakarta.servlet.ServletRequestEvent sre)
     
    void
    requestInitialized(jakarta.servlet.ServletRequestEvent sre)
     
    void
    sessionCreated(jakarta.servlet.http.HttpSessionEvent se)
     
    void
    sessionDestroyed(jakarta.servlet.http.HttpSessionEvent se)
     
    static Listener
    using(jakarta.enterprise.inject.spi.BeanManager manager)
    Creates a new Listener that uses the given BeanManager instead of initializing a new Weld container instance.
    static Listener
    using(org.jboss.weld.environment.ContainerInstance container)
    Creates a new Listener that uses the given ContainerInstance (e.g.
    static Listener
    using(org.jboss.weld.environment.ContainerInstanceFactory container)
    Creates a new Listener that uses the given ContainerInstanceFactory for initializing Weld instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CONTAINER_ATTRIBUTE_NAME

      public static final String CONTAINER_ATTRIBUTE_NAME
  • Constructor Details

    • Listener

      public Listener()
  • Method Details

    • using

      public static Listener using(jakarta.enterprise.inject.spi.BeanManager manager)
      Creates a new Listener that uses the given BeanManager instead of initializing a new Weld container instance.
      Parameters:
      manager - the bean manager to be used
      Returns:
      a new Listener instance
    • using

      public static Listener using(org.jboss.weld.environment.ContainerInstance container)
      Creates a new Listener that uses the given ContainerInstance (e.g. org.jboss.weld.environment.se.WeldContainer) instead of initializing a new Weld container instance. The listener does not take over the responsibility for container instance lifecycle management. It is the caller's responsibility to shut down the container instance properly. The listener will not shut down the container instance when the Servlet context is destroyed.
      Parameters:
      container - the container instance to be used
      Returns:
      a new Listener instance
    • using

      public static Listener using(org.jboss.weld.environment.ContainerInstanceFactory container)
      Creates a new Listener that uses the given ContainerInstanceFactory for initializing Weld instance. A new Weld instance will be initialized using ContainerInstanceFactory.initialize() when the Servlet context is initialized. The Weld instance will be shut down when Servlet context is destroyed.
      Parameters:
      container - the container factory to be used
      Returns:
      a new Listener instance
    • contextInitialized

      public void contextInitialized(jakarta.servlet.ServletContextEvent sce)
      Specified by:
      contextInitialized in interface jakarta.servlet.ServletContextListener
      Overrides:
      contextInitialized in class org.jboss.weld.servlet.api.helpers.ForwardingServletListener
    • contextDestroyed

      public void contextDestroyed(jakarta.servlet.ServletContextEvent sce)
      Specified by:
      contextDestroyed in interface jakarta.servlet.ServletContextListener
      Overrides:
      contextDestroyed in class org.jboss.weld.servlet.api.helpers.ForwardingServletListener
    • requestDestroyed

      public void requestDestroyed(jakarta.servlet.ServletRequestEvent sre)
      Specified by:
      requestDestroyed in interface jakarta.servlet.ServletRequestListener
      Overrides:
      requestDestroyed in class org.jboss.weld.servlet.api.helpers.ForwardingServletListener
    • requestInitialized

      public void requestInitialized(jakarta.servlet.ServletRequestEvent sre)
      Specified by:
      requestInitialized in interface jakarta.servlet.ServletRequestListener
      Overrides:
      requestInitialized in class org.jboss.weld.servlet.api.helpers.ForwardingServletListener
    • sessionCreated

      public void sessionCreated(jakarta.servlet.http.HttpSessionEvent se)
      Specified by:
      sessionCreated in interface jakarta.servlet.http.HttpSessionListener
      Overrides:
      sessionCreated in class org.jboss.weld.servlet.api.helpers.ForwardingServletListener
    • sessionDestroyed

      public void sessionDestroyed(jakarta.servlet.http.HttpSessionEvent se)
      Specified by:
      sessionDestroyed in interface jakarta.servlet.http.HttpSessionListener
      Overrides:
      sessionDestroyed in class org.jboss.weld.servlet.api.helpers.ForwardingServletListener
    • delegate

      protected org.jboss.weld.servlet.api.ServletListener delegate()
      Specified by:
      delegate in class org.jboss.weld.servlet.api.helpers.ForwardingServletListener