@Override
public <T extends EventListener> void addListener(T t) {
if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
throw new IllegalStateException(sm.getString("applicationContext.addListener.ise", getContextPath()));
}
boolean match = false;
if (t instanceof ServletContextAttributeListener || t instanceof ServletRequestListener
|| t instanceof ServletRequestAttributeListener || t instanceof HttpSessionAttributeListener) {
context.addApplicationEventListener(t);
match = true;
}
if (t instanceof HttpSessionListener
|| (t instanceof ServletContextListener && newServletContextListenerAllowed)) {
// Add listener directly to the list of instances rather than to
// the list of class names.
context.addApplicationLifecycleListener(t);
match = true;
}
if (match)
return;
if (t instanceof ServletContextListener) {
throw new IllegalArgumentException(
sm.getString("applicationContext.addListener.iae.sclNotAllowed", t.getClass().getName()));
} else {
throw new IllegalArgumentException(
sm.getString("applicationContext.addListener.iae.wrongType", t.getClass().getName()));
}
}
ApplicationContext.java 文件源码
java
阅读 39
收藏 0
点赞 0
评论 0
项目:lazycat
作者:
评论列表
文章目录