org.apache.catalina.core.ApplicationContext.checkListenerType()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中org.apache.catalina.core.ApplicationContext.checkListenerType()方法的一些代码示例,展示了ApplicationContext.checkListenerType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationContext.checkListenerType()方法的具体详情如下:
包路径:org.apache.catalina.core.ApplicationContext
类名称:ApplicationContext
方法名:checkListenerType

ApplicationContext.checkListenerType介绍

暂无

代码示例

代码示例来源:origin: jboss.web/jbossweb

public <T extends EventListener> void addListener(T listener) {
  if (restricted) {
    throw new UnsupportedOperationException(sm.getString("applicationContext.restricted"));
  }
  if (!context.isStarting()) {
    throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
            getContextPath()));
  }
  checkListenerType(listener);
  if (context.getApplicationLifecycleListeners() != null && listener instanceof ServletContextListener) {
    throw new IllegalArgumentException(sm.getString("applicationContext.badListenerClass", 
        listener.getClass().getName(), getContextPath()));
  }
  context.addApplicationListenerInstance(listener);
}

代码示例来源:origin: jboss.web/jbossweb

public <T extends EventListener> T createListener(Class<T> clazz)
    throws ServletException {
  if (restricted) {
    throw new UnsupportedOperationException(sm.getString("applicationContext.restricted"));
  }
  if (!context.isStarting()) {
    throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
            getContextPath()));
  }
  T listenerInstance = null;
  try {
    listenerInstance = (T) context.getInstanceManager().newInstance(clazz);
  } catch (Throwable t) {
    throw new ServletException(sm.getString("applicationContext.create"), t);
  }
  checkListenerType(listenerInstance);
  return listenerInstance;
}

代码示例来源:origin: org.jboss.web/jbossweb

public <T extends EventListener> void addListener(T listener) {
  if (restricted) {
    throw MESSAGES.restrictedListenerCannotCallMethod();
  }
  if (!context.isStarting()) {
    throw MESSAGES.contextAlreadyInitialized(getContextPath());
  }
  checkListenerType(listener);
  if (context.getApplicationLifecycleListeners() != null && listener instanceof ServletContextListener) {
    throw MESSAGES.invalidContextListener(listener.getClass().getName(), getContextPath());
  }
  context.addApplicationListenerInstance(listener);
}

代码示例来源:origin: jboss.web/jbossweb

public void addListener(Class<? extends EventListener> listenerClass) {
  if (restricted) {
    throw new UnsupportedOperationException(sm.getString("applicationContext.restricted"));
  }
  if (!context.isStarting()) {
    throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
            getContextPath()));
  }
  EventListener listenerInstance = null;
  try {
    listenerInstance = (EventListener) context.getInstanceManager().newInstance(listenerClass);
  } catch (Exception e) {
    throw new IllegalArgumentException(sm.getString("applicationContext.badListenerClass", 
        listenerClass.getName(), getContextPath()), e);
  }
  checkListenerType(listenerInstance);
  if (context.getApplicationLifecycleListeners() != null && listenerInstance instanceof ServletContextListener) {
    throw new IllegalArgumentException(sm.getString("applicationContext.badListenerClass", 
        listenerClass.getName(), getContextPath()));
  }
  context.addApplicationListenerInstance(listenerInstance);
}

代码示例来源:origin: org.jboss.web/jbossweb

public <T extends EventListener> T createListener(Class<T> clazz)
    throws ServletException {
  if (restricted) {
    throw MESSAGES.restrictedListenerCannotCallMethod();
  }
  if (!context.isStarting()) {
    throw MESSAGES.contextAlreadyInitialized(getContextPath());
  }
  T listenerInstance = null;
  try {
    listenerInstance = (T) context.getInstanceManager().newInstance(clazz);
  } catch (Throwable t) {
    throw new ServletException(MESSAGES.contextObjectCreationError(), t);
  }
  checkListenerType(listenerInstance);
  return listenerInstance;
}

代码示例来源:origin: jboss.web/jbossweb

public void addListener(String className) {
  if (restricted) {
    throw new UnsupportedOperationException(sm.getString("applicationContext.restricted"));
  }
  if (!context.isStarting()) {
    throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
            getContextPath()));
  }
  EventListener listenerInstance = null;
  try {
    Class<?> clazz = context.getLoader().getClassLoader().loadClass(className);
    listenerInstance = (EventListener) context.getInstanceManager().newInstance(clazz);
  } catch (Throwable t) {
    throw new IllegalArgumentException(sm.getString("applicationContext.badListenerClass", 
        className, getContextPath()), t);
  }
  checkListenerType(listenerInstance);
  if (context.getApplicationLifecycleListeners() != null && listenerInstance instanceof ServletContextListener) {
    throw new IllegalArgumentException(sm.getString("applicationContext.badListenerClass", 
        className, getContextPath()));
  }
  context.addApplicationListenerInstance(listenerInstance);
}

代码示例来源:origin: org.jboss.web/jbossweb

public void addListener(Class<? extends EventListener> listenerClass) {
  if (restricted) {
    throw MESSAGES.restrictedListenerCannotCallMethod();
  }
  if (!context.isStarting()) {
    throw MESSAGES.contextAlreadyInitialized(getContextPath());
  }
  EventListener listenerInstance = null;
  try {
    listenerInstance = (EventListener) context.getInstanceManager().newInstance(listenerClass);
  } catch (Exception e) {
    throw MESSAGES.invalidContextListenerWithException(listenerClass.getName(), getContextPath(), e);
  }
  checkListenerType(listenerInstance);
  if (context.getApplicationLifecycleListeners() != null && listenerInstance instanceof ServletContextListener) {
    throw MESSAGES.invalidContextListener(listenerClass.getName(), getContextPath());
  }
  context.addApplicationListenerInstance(listenerInstance);
}

代码示例来源:origin: org.jboss.web/jbossweb

public void addListener(String className) {
  if (restricted) {
    throw MESSAGES.restrictedListenerCannotCallMethod();
  }
  if (!context.isStarting()) {
    throw MESSAGES.contextAlreadyInitialized(getContextPath());
  }
  EventListener listenerInstance = null;
  try {
    Class<?> clazz = context.getLoader().getClassLoader().loadClass(className);
    listenerInstance = (EventListener) context.getInstanceManager().newInstance(clazz);
  } catch (Throwable t) {
    throw MESSAGES.invalidContextListenerWithException(className, getContextPath(), t);
  }
  checkListenerType(listenerInstance);
  if (context.getApplicationLifecycleListeners() != null && listenerInstance instanceof ServletContextListener) {
    throw MESSAGES.invalidContextListener(className, getContextPath());
  }
  context.addApplicationListenerInstance(listenerInstance);
}

相关文章

微信公众号

最新文章

更多

ApplicationContext类方法