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);
}
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());
}
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));
}
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());
}
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);
}
Aggregations