Search in sources :

Example 1 with ManagedListener

use of io.undertow.servlet.core.ManagedListener in project wildfly by wildfly.

the class UndertowContext method addSessionListener.

@Override
public void addSessionListener(HttpSessionListener listener) {
    ManagedListener ml = new ManagedListener(new ListenerInfo(HttpSessionListener.class, new ImmediateInstanceFactory<>(listener)), true);
    try {
        ml.start();
    } catch (ServletException e) {
        throw new RuntimeException(e);
    }
    this.deployment.getApplicationListeners().addListener(ml);
}
Also used : ServletException(javax.servlet.ServletException) ListenerInfo(io.undertow.servlet.api.ListenerInfo) HttpSessionListener(javax.servlet.http.HttpSessionListener) ManagedListener(io.undertow.servlet.core.ManagedListener) ImmediateInstanceFactory(io.undertow.servlet.util.ImmediateInstanceFactory)

Example 2 with ManagedListener

use of io.undertow.servlet.core.ManagedListener in project undertow by undertow-io.

the class ServletContextImpl method addListener.

@Override
public <T extends EventListener> void addListener(final T t) {
    ensureNotInitialized();
    ensureNotProgramaticListener();
    if (ApplicationListeners.listenerState() != NO_LISTENER && ServletContextListener.class.isAssignableFrom(t.getClass())) {
        throw UndertowServletMessages.MESSAGES.cannotAddServletContextListener();
    }
    ListenerInfo listener = new ListenerInfo(t.getClass(), new ImmediateInstanceFactory<EventListener>(t));
    getDeploymentInfo().addListener(listener);
    deployment.getApplicationListeners().addListener(new ManagedListener(listener, true));
}
Also used : ListenerInfo(io.undertow.servlet.api.ListenerInfo) ServletContextListener(javax.servlet.ServletContextListener) ManagedListener(io.undertow.servlet.core.ManagedListener) EventListener(java.util.EventListener)

Example 3 with ManagedListener

use of io.undertow.servlet.core.ManagedListener in project wildfly by wildfly.

the class UndertowContext method addRequestListener.

@Override
public void addRequestListener(org.jboss.modcluster.container.listeners.ServletRequestListener requestListener) {
    ServletRequestListener listener = new ServletRequestListener() {

        @Override
        public void requestInitialized(ServletRequestEvent sre) {
            requestListener.requestInitialized();
        }

        @Override
        public void requestDestroyed(ServletRequestEvent sre) {
            requestListener.requestDestroyed();
        }
    };
    ManagedListener ml = new ManagedListener(new ListenerInfo(ServletRequestListener.class, new ImmediateInstanceFactory<>(listener)), true);
    try {
        ml.start();
    } catch (ServletException e) {
        throw new RuntimeException(e);
    }
    this.deployment.getApplicationListeners().addListener(ml);
}
Also used : ServletException(javax.servlet.ServletException) ListenerInfo(io.undertow.servlet.api.ListenerInfo) ServletRequestListener(javax.servlet.ServletRequestListener) ManagedListener(io.undertow.servlet.core.ManagedListener) ServletRequestEvent(javax.servlet.ServletRequestEvent) ImmediateInstanceFactory(io.undertow.servlet.util.ImmediateInstanceFactory)

Example 4 with ManagedListener

use of io.undertow.servlet.core.ManagedListener in project wildfly by wildfly.

the class UndertowContext method addSessionListener.

@Override
public void addSessionListener(org.jboss.modcluster.container.listeners.HttpSessionListener sessionListener) {
    HttpSessionListener listener = new HttpSessionListener() {

        @Override
        public void sessionCreated(HttpSessionEvent se) {
            sessionListener.sessionCreated();
        }

        @Override
        public void sessionDestroyed(HttpSessionEvent se) {
            sessionListener.sessionDestroyed();
        }
    };
    ManagedListener ml = new ManagedListener(new ListenerInfo(HttpSessionListener.class, new ImmediateInstanceFactory<>(listener)), true);
    try {
        ml.start();
    } catch (ServletException e) {
        throw new RuntimeException(e);
    }
    this.deployment.getApplicationListeners().addListener(ml);
}
Also used : ServletException(javax.servlet.ServletException) HttpSessionListener(javax.servlet.http.HttpSessionListener) ListenerInfo(io.undertow.servlet.api.ListenerInfo) HttpSessionEvent(javax.servlet.http.HttpSessionEvent) ManagedListener(io.undertow.servlet.core.ManagedListener) ImmediateInstanceFactory(io.undertow.servlet.util.ImmediateInstanceFactory)

Example 5 with ManagedListener

use of io.undertow.servlet.core.ManagedListener in project wildfly by wildfly.

the class UndertowContext method addRequestListener.

@Override
public void addRequestListener(ServletRequestListener listener) {
    ManagedListener ml = new ManagedListener(new ListenerInfo(ServletRequestListener.class, new ImmediateInstanceFactory<>(listener)), true);
    try {
        ml.start();
    } catch (ServletException e) {
        throw new RuntimeException(e);
    }
    this.deployment.getApplicationListeners().addListener(ml);
}
Also used : ServletException(javax.servlet.ServletException) ListenerInfo(io.undertow.servlet.api.ListenerInfo) ServletRequestListener(javax.servlet.ServletRequestListener) ManagedListener(io.undertow.servlet.core.ManagedListener) ImmediateInstanceFactory(io.undertow.servlet.util.ImmediateInstanceFactory)

Aggregations

ListenerInfo (io.undertow.servlet.api.ListenerInfo)6 ManagedListener (io.undertow.servlet.core.ManagedListener)6 ServletException (javax.servlet.ServletException)5 ImmediateInstanceFactory (io.undertow.servlet.util.ImmediateInstanceFactory)4 ServletContextListener (javax.servlet.ServletContextListener)2 ServletRequestListener (javax.servlet.ServletRequestListener)2 HttpSessionListener (javax.servlet.http.HttpSessionListener)2 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 EventListener (java.util.EventListener)1 ServletRequestEvent (javax.servlet.ServletRequestEvent)1 HttpSessionEvent (javax.servlet.http.HttpSessionEvent)1