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