Search in sources :

Example 66 with EventListener

use of java.util.EventListener in project Payara by payara.

the class StandardContext method addListener.

/**
 * Adds a listener of the given class type to this ServletContext.
 */
@Override
public void addListener(Class<? extends EventListener> listenerClass) {
    EventListener listener = null;
    try {
        listener = createListenerInstance(listenerClass);
    } catch (Throwable t) {
        throw new IllegalArgumentException(t);
    }
    addListener(listener);
}
Also used : EventListener(java.util.EventListener)

Example 67 with EventListener

use of java.util.EventListener in project scout.rt by eclipse.

the class SimpleEventListenerListTest method testAdd.

/**
 * Test for {@link SimpleEventListenerList#add( java.util.EventListener)}
 */
@Test
public void testAdd() {
    SimpleEventListenerList<EventListener> listenerList = new SimpleEventListenerList<>();
    EventListener listener = new EventListener() {
    };
    listenerList.add(listener);
    listenerList.add(listener);
    Assert.assertEquals(1, listenerList.indexes().size());
}
Also used : EventListener(java.util.EventListener) Test(org.junit.Test)

Example 68 with EventListener

use of java.util.EventListener in project scout.rt by eclipse.

the class SimpleEventListenerListTest method testRemoveOnFire.

@Test
public void testRemoveOnFire() {
    final SimpleEventListenerList<EventListener> listenerList = new SimpleEventListenerList<>();
    EventListener[] a = new EventListener[5];
    for (int i = 0; i < a.length; i++) {
        a[i] = new FixtureEventListenerThatRemovesOnFire() {

            @Override
            public void handle(Object event) {
                listenerList.remove(this);
            }
        };
        listenerList.add(a[i], true);
    }
    Assert.assertEquals(5, listenerList.indexes().size());
    Assert.assertEquals(expectedList(4, 3, 2, 1, 0), iteratorDump(a, listenerList));
    for (EventListener listener : listenerList.list()) {
        ((FixtureEventListenerThatRemovesOnFire) listener).handle(null);
    }
    Assert.assertEquals(0, listenerList.indexes().size());
    Assert.assertTrue(listenerList.isEmpty());
    Assert.assertEquals(expectedList(), iteratorDump(a, listenerList));
}
Also used : EventListener(java.util.EventListener) Test(org.junit.Test)

Example 69 with EventListener

use of java.util.EventListener in project scout.rt by eclipse.

the class SimpleEventListenerListTest method testRemove.

/**
 * Test for {@link SimpleEventListenerList#add( java.util.EventListener)}
 */
@Test
public void testRemove() {
    SimpleEventListenerList<EventListener> listenerList = new SimpleEventListenerList<>();
    EventListener listener = new EventListener() {
    };
    listenerList.add(listener);
    listenerList.add(listener);
    listenerList.remove(listener);
    Assert.assertEquals(0, listenerList.indexes().size());
}
Also used : EventListener(java.util.EventListener) Test(org.junit.Test)

Example 70 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(jakarta.servlet.ServletException) EventListener(java.util.EventListener)

Aggregations

EventListener (java.util.EventListener)71 Test (org.junit.Test)11 ListenerInfo (io.undertow.servlet.api.ListenerInfo)5 ServletRequestListener (javax.servlet.ServletRequestListener)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ServletContextListener (javax.servlet.ServletContextListener)3 HttpSessionListener (javax.servlet.http.HttpSessionListener)3 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)3 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)3 Bundle (org.osgi.framework.Bundle)3 BundleContext (org.osgi.framework.BundleContext)3 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 EventObject (java.util.EventObject)2 List (java.util.List)2 NamingException (javax.naming.NamingException)2 ServletRequestEvent (javax.servlet.ServletRequestEvent)2 HttpSessionIdListener (javax.servlet.http.HttpSessionIdListener)2