Search in sources :

Example 6 with EventListener

use of java.util.EventListener in project robovm by robovm.

the class OldEventListenerProxyTest method testGetListener.

public void testGetListener() {
    EventListener el = new Mock_EventListener();
    EventListenerProxy elp = new Mock_EventListenerProxy(el);
    assertSame(el, elp.getListener());
}
Also used : EventListenerProxy(java.util.EventListenerProxy) EventListener(java.util.EventListener)

Example 7 with EventListener

use of java.util.EventListener in project spring-boot by spring-projects.

the class ServletListenerRegistrationBeanTests method cannotRegisterUnsupportedType.

@Test
public void cannotRegisterUnsupportedType() throws Exception {
    this.thrown.expect(IllegalArgumentException.class);
    this.thrown.expectMessage("Listener is not of a supported type");
    new ServletListenerRegistrationBean<EventListener>(new EventListener() {
    });
}
Also used : EventListener(java.util.EventListener) Test(org.junit.Test)

Example 8 with EventListener

use of java.util.EventListener 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));
    deploymentInfo.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 9 with EventListener

use of java.util.EventListener in project tomcat by apache.

the class ApplicationContext method addListener.

@Override
public void addListener(Class<? extends EventListener> listenerClass) {
    EventListener listener;
    try {
        listener = createListener(listenerClass);
    } catch (ServletException e) {
        throw new IllegalArgumentException(sm.getString("applicationContext.addListener.iae.init", listenerClass.getName()), e);
    }
    addListener(listener);
}
Also used : ServletException(javax.servlet.ServletException) EventListener(java.util.EventListener)

Example 10 with EventListener

use of java.util.EventListener in project tomcat by apache.

the class ApplicationContext method addListener.

@Override
public void addListener(String className) {
    try {
        if (context.getInstanceManager() != null) {
            Object obj = context.getInstanceManager().newInstance(className);
            if (!(obj instanceof EventListener)) {
                throw new IllegalArgumentException(sm.getString("applicationContext.addListener.iae.wrongType", className));
            }
            EventListener listener = (EventListener) obj;
            addListener(listener);
        }
    } catch (InvocationTargetException e) {
        ExceptionUtils.handleThrowable(e.getCause());
        throw new IllegalArgumentException(sm.getString("applicationContext.addListener.iae.cnfe", className), e);
    } catch (IllegalAccessException | NamingException | InstantiationException | ClassNotFoundException e) {
        throw new IllegalArgumentException(sm.getString("applicationContext.addListener.iae.cnfe", className), e);
    }
}
Also used : NamingException(javax.naming.NamingException) EventListener(java.util.EventListener) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

EventListener (java.util.EventListener)19 FilterHolder (org.eclipse.jetty.servlet.FilterHolder)3 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)3 ListenerInfo (io.undertow.servlet.api.ListenerInfo)2 ServletException (javax.servlet.ServletException)2 ListenerHolder (org.eclipse.jetty.servlet.ListenerHolder)2 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)2 Source (org.eclipse.jetty.servlet.Source)2 MetaData (org.eclipse.jetty.webapp.MetaData)2 Injector (com.google.inject.Injector)1 GuiceServletContextListener (com.google.inject.servlet.GuiceServletContextListener)1 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)1 ManagedListener (io.undertow.servlet.core.ManagedListener)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URLClassLoader (java.net.URLClassLoader)1 EventListenerProxy (java.util.EventListenerProxy)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MBeanServer (javax.management.MBeanServer)1 NamingException (javax.naming.NamingException)1