Java 类javax.servlet.ServletContextAttributeListener 实例源码

项目:tomee    文件:WebContext.java   
private static boolean isWeb(final Class<?> beanClass) {
    if (Servlet.class.isAssignableFrom(beanClass)
        || Filter.class.isAssignableFrom(beanClass)) {
        return true;
    }
    if (EventListener.class.isAssignableFrom(beanClass)) {
        return HttpSessionAttributeListener.class.isAssignableFrom(beanClass)
               || ServletContextListener.class.isAssignableFrom(beanClass)
               || ServletRequestListener.class.isAssignableFrom(beanClass)
               || ServletContextAttributeListener.class.isAssignableFrom(beanClass)
               || HttpSessionListener.class.isAssignableFrom(beanClass)
               || HttpSessionBindingListener.class.isAssignableFrom(beanClass)
               || HttpSessionActivationListener.class.isAssignableFrom(beanClass)
               || HttpSessionIdListener.class.isAssignableFrom(beanClass)
               || ServletRequestAttributeListener.class.isAssignableFrom(beanClass);
    }

    return false;
}
项目:tomcat7    文件:ApplicationContext.java   
@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()));
    }
}
项目:lazycat    文件:ApplicationContext.java   
/**
 * Remove the context attribute with the specified name, if any.
 *
 * @param name
 *            Name of the context attribute to be removed
 */
@Override
public void removeAttribute(String name) {

    Object value = null;

    // Remove the specified attribute
    // Check for read only attribute
    if (readOnlyAttributes.containsKey(name)) {
        return;
    }
    value = attributes.remove(name);
    if (value == null) {
        return;
    }

    // Notify interested application event listeners
    Object listeners[] = context.getApplicationEventListeners();
    if ((listeners == null) || (listeners.length == 0))
        return;
    ServletContextAttributeEvent event = new ServletContextAttributeEvent(context.getServletContext(), name, value);
    for (int i = 0; i < listeners.length; i++) {
        if (!(listeners[i] instanceof ServletContextAttributeListener))
            continue;
        ServletContextAttributeListener listener = (ServletContextAttributeListener) listeners[i];
        try {
            context.fireContainerEvent("beforeContextAttributeRemoved", listener);
            listener.attributeRemoved(event);
            context.fireContainerEvent("afterContextAttributeRemoved", listener);
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            context.fireContainerEvent("afterContextAttributeRemoved", listener);
            // FIXME - should we do anything besides log these?
            log(sm.getString("applicationContext.attributeEvent"), t);
        }
    }

}
项目:lazycat    文件:ApplicationContext.java   
@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()));
    }
}
项目:opengse    文件:WebAppImpl.java   
private void loadListeners(WebAppConfiguration wac)
    throws ClassNotFoundException, IllegalAccessException,
    InstantiationException, WebAppConfigurationException {
  for (WebAppListener listener : wac.getListeners()) {
    String className = listener.getListenerClass();
    Class<?> clazz = classLoader.loadClass(className);
    Object obj = clazz.newInstance();
    boolean used = false;
    if (obj instanceof ServletContextAttributeListener) {
      scaListeners.add((ServletContextAttributeListener) obj);
      used = true;
    }
    if (obj instanceof ServletContextListener) {
      scListeners.add((ServletContextListener) obj);
      used = true;
    }
    if (obj instanceof ServletRequestListener) {
      srListeners.add((ServletRequestListener) obj);
      used = true;
    }
    if (obj instanceof ServletRequestAttributeListener) {
      sraListeners.add((ServletRequestAttributeListener) obj);
      used = true;
    }
    if (obj instanceof HttpSessionAttributeListener) {
      sessionAttributeListeners.add((HttpSessionAttributeListener) obj);
      used = true;
    }
    if (obj instanceof HttpSessionListener) {
      sessionListeners.add((HttpSessionListener) obj);
      used = true;
    }
    if (!used) {
      throw new WebAppConfigurationException("Don't know what to do with '"
          + className + "'");
    }
  }
}
项目:winstone    文件:WebAppConfiguration.java   
private void addListenerInstance(final Object listenerInstance,
        final List<ServletContextAttributeListener> contextAttributeListeners,
        final List<ServletContextListener> contextListeners,
        final List<ServletRequestAttributeListener> requestAttributeListeners,
        final List<ServletRequestListener> requestListeners, final List<HttpSessionActivationListener> sessionActivationListeners,
        final List<HttpSessionAttributeListener> sessionAttributeListeners, final List<HttpSessionListener> sessionListeners) {
    if (listenerInstance instanceof ServletContextAttributeListener) {
        contextAttributeListeners.add((ServletContextAttributeListener) listenerInstance);
    }
    if (listenerInstance instanceof ServletContextListener) {
        contextListeners.add((ServletContextListener) listenerInstance);
    }
    if (listenerInstance instanceof ServletRequestAttributeListener) {
        requestAttributeListeners.add((ServletRequestAttributeListener) listenerInstance);
    }
    if (listenerInstance instanceof ServletRequestListener) {
        requestListeners.add((ServletRequestListener) listenerInstance);
    }
    if (listenerInstance instanceof HttpSessionActivationListener) {
        sessionActivationListeners.add((HttpSessionActivationListener) listenerInstance);
    }
    if (listenerInstance instanceof HttpSessionAttributeListener) {
        sessionAttributeListeners.add((HttpSessionAttributeListener) listenerInstance);
    }
    if (listenerInstance instanceof HttpSessionListener) {
        sessionListeners.add((HttpSessionListener) listenerInstance);
    }
}
项目:osgi.ee    文件:OurServletContext.java   
@Override
public void setAttribute(String attr, Object value) {
    Object original = attributes.get(attr);
    attributes.put(attr, value);
    ServletContextAttributeEvent event = new ServletContextAttributeEvent(this, attr, value);
    if (original != null) {
        call(ServletContextAttributeListener.class, (l) -> l.attributeReplaced(event));
    }
    else {
        call(ServletContextAttributeListener.class, (l) -> l.attributeAdded(event));
    }
}
项目:class-guard    文件:ApplicationContext.java   
@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()));
    }
}
项目:apache-tomcat-7.0.57    文件:ApplicationContext.java   
@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()));
    }
}
项目:apache-tomcat-7.0.57    文件:ApplicationContext.java   
@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()));
    }
}
项目:opennmszh    文件:ServletContextAttributeListenerManager.java   
@Override
public void attributeAdded(final ServletContextAttributeEvent scab)
{
    final Iterator<ServletContextAttributeListener> listeners = getContextListeners();
    while (listeners.hasNext())
    {
        listeners.next().attributeAdded(scab);
    }
}
项目:opennmszh    文件:ServletContextAttributeListenerManager.java   
@Override
public void attributeRemoved(final ServletContextAttributeEvent scab)
{
    final Iterator<ServletContextAttributeListener> listeners = getContextListeners();
    while (listeners.hasNext())
    {
        listeners.next().attributeRemoved(scab);
    }
}
项目:opennmszh    文件:ServletContextAttributeListenerManager.java   
@Override
public void attributeReplaced(final ServletContextAttributeEvent scab)
{
    final Iterator<ServletContextAttributeListener> listeners = getContextListeners();
    while (listeners.hasNext())
    {
        listeners.next().attributeReplaced(scab);
    }
}
项目:opennmszh    文件:ServletContextImpl.java   
public ServletContextImpl(Bundle bundle, ServletContext context, HttpContext httpContext,
    ServletContextAttributeListener attributeListener, boolean sharedAttributes)
{
    this.bundle = bundle;
    this.context = context;
    this.httpContext = httpContext;
    this.attributeListener = attributeListener;
    this.attributes = sharedAttributes ? null : new ConcurrentHashMap<String, Object>();
}
项目:opennmszh    文件:ServletContextManager.java   
public ServletContextManager(Bundle bundle, ServletContext context,
    ServletContextAttributeListener attributeListener, boolean sharedAttributes)
{
    this.bundle = bundle;
    this.context = context;
    this.attributeListener = attributeListener;
    this.contextMap = new HashMap<HttpContext, ExtServletContext>();
    this.sharedAttributes = sharedAttributes;
}
项目:opennmszh    文件:HttpServiceFactory.java   
public HttpServiceFactory(ServletContext context, HandlerRegistry handlerRegistry,
    ServletContextAttributeListener attributeListener, boolean sharedContextAttributes)
{
    this.context = context;
    this.attributeListener = attributeListener;
    this.handlerRegistry = handlerRegistry;
    this.sharedContextAttributes = sharedContextAttributes;
}
项目:tomcat7    文件:ApplicationContext.java   
/**
 * Remove the context attribute with the specified name, if any.
 *
 * @param name Name of the context attribute to be removed
 */
@Override
public void removeAttribute(String name) {

    Object value = null;

    // Remove the specified attribute
    // Check for read only attribute
    if (readOnlyAttributes.containsKey(name)){
        return;
    }
    value = attributes.remove(name);
    if (value == null) {
        return;
    }

    // Notify interested application event listeners
    Object listeners[] = context.getApplicationEventListeners();
    if ((listeners == null) || (listeners.length == 0))
        return;
    ServletContextAttributeEvent event =
      new ServletContextAttributeEvent(context.getServletContext(),
                                        name, value);
    for (int i = 0; i < listeners.length; i++) {
        if (!(listeners[i] instanceof ServletContextAttributeListener))
            continue;
        ServletContextAttributeListener listener =
            (ServletContextAttributeListener) listeners[i];
        try {
            context.fireContainerEvent("beforeContextAttributeRemoved",
                                       listener);
            listener.attributeRemoved(event);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
            // FIXME - should we do anything besides log these?
            log(sm.getString("applicationContext.attributeEvent"), t);
        }
    }

}
项目:lams    文件:ApplicationContext.java   
/**
 * Remove the context attribute with the specified name, if any.
 *
 * @param name Name of the context attribute to be removed
 */
public void removeAttribute(String name) {

    Object value = null;
    boolean found = false;

    // Remove the specified attribute
    // Check for read only attribute
    if (readOnlyAttributes.containsKey(name))
        return;
    found = attributes.containsKey(name);
    if (found) {
        value = attributes.get(name);
        attributes.remove(name);
    } else {
        return;
    }

    // Notify interested application event listeners
    Object listeners[] = context.getApplicationEventListeners();
    if ((listeners == null) || (listeners.length == 0))
        return;
    ServletContextAttributeEvent event =
      new ServletContextAttributeEvent(context.getServletContext(),
                                        name, value);
    for (int i = 0; i < listeners.length; i++) {
        if (!(listeners[i] instanceof ServletContextAttributeListener))
            continue;
        ServletContextAttributeListener listener =
            (ServletContextAttributeListener) listeners[i];
        try {
            context.fireContainerEvent("beforeContextAttributeRemoved",
                                       listener);
            listener.attributeRemoved(event);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
        } catch (Throwable t) {
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
            // FIXME - should we do anything besides log these?
            log(sm.getString("applicationContext.attributeEvent"), t);
        }
    }

}
项目:lams    文件:ApplicationListeners.java   
public void servletContextAttributeAdded(final String name, final Object value) {
    final ServletContextAttributeEvent sre = new ServletContextAttributeEvent(servletContext, name, value);
    for (int i = 0; i < servletContextAttributeListeners.length; ++i) {
        this.<ServletContextAttributeListener>get(servletContextAttributeListeners[i]).attributeAdded(sre);
    }
}
项目:lams    文件:ApplicationListeners.java   
public void servletContextAttributeRemoved(final String name, final Object value) {
    final ServletContextAttributeEvent sre = new ServletContextAttributeEvent(servletContext, name, value);
    for (int i = 0; i < servletContextAttributeListeners.length; ++i) {
        this.<ServletContextAttributeListener>get(servletContextAttributeListeners[i]).attributeRemoved(sre);
    }
}
项目:lams    文件:ApplicationListeners.java   
public void servletContextAttributeReplaced(final String name, final Object value) {
    final ServletContextAttributeEvent sre = new ServletContextAttributeEvent(servletContext, name, value);
    for (int i = 0; i < servletContextAttributeListeners.length; ++i) {
        this.<ServletContextAttributeListener>get(servletContextAttributeListeners[i]).attributeReplaced(sre);
    }
}
项目:jerrydog    文件:ApplicationContext.java   
/**
 * Remove the context attribute with the specified name, if any.
 *
 * @param name Name of the context attribute to be removed
 */
public void removeAttribute(String name) {

    Object value = null;
    boolean found = false;

    // Remove the specified attribute
    synchronized (attributes) {
        // Check for read only attribute
       if (readOnlyAttributes.containsKey(name))
            return;
        found = attributes.containsKey(name);
        if (found) {
            value = attributes.get(name);
            attributes.remove(name);
        } else {
            return;
        }
    }

    // Notify interested application event listeners
    Object listeners[] = context.getApplicationListeners();
    if ((listeners == null) || (listeners.length == 0))
        return;
    ServletContextAttributeEvent event =
      new ServletContextAttributeEvent(context.getServletContext(),
                                        name, value);
    for (int i = 0; i < listeners.length; i++) {
        if (!(listeners[i] instanceof ServletContextAttributeListener))
            continue;
        ServletContextAttributeListener listener =
            (ServletContextAttributeListener) listeners[i];
        try {
            context.fireContainerEvent("beforeContextAttributeRemoved",
                                       listener);
            listener.attributeRemoved(event);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
        } catch (Throwable t) {
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
            // FIXME - should we do anything besides log these?
            log(sm.getString("applicationContext.attributeEvent"), t);
        }
    }

}
项目:opengse    文件:WebAppImpl.java   
ServletContextAttributeListener getGlobalServletContextAttributeListener() {
  return scaListeners;
}
项目:opengse    文件:ServletContextAttributeListenerList.java   
public ServletContextAttributeListenerList() {
  listeners = new ArrayList<ServletContextAttributeListener>();
}
项目:opengse    文件:ServletContextAttributeListenerList.java   
public void add(ServletContextAttributeListener listener) {
  listeners.add(listener);
}
项目:opengse    文件:ServletContextAttributeListenerList.java   
public void attributeAdded(ServletContextAttributeEvent event) {
  for (ServletContextAttributeListener listener : listeners) {
    listener.attributeAdded(event);
  }
}
项目:opengse    文件:ServletContextAttributeListenerList.java   
public void attributeRemoved(ServletContextAttributeEvent event) {
  for (ServletContextAttributeListener listener : listeners) {
    listener.attributeRemoved(event);
  }
}
项目:opengse    文件:ServletContextAttributeListenerList.java   
public void attributeReplaced(ServletContextAttributeEvent event) {
  for (ServletContextAttributeListener listener : listeners) {
    listener.attributeReplaced(event);
  }
}
项目:osgi.ee    文件:OurServletContext.java   
@Override
public void removeAttribute(String attr) {
    ServletContextAttributeEvent event = new ServletContextAttributeEvent(this, attr, attributes.remove(attr));
    call(ServletContextAttributeListener.class, (l) -> l.attributeRemoved(event));
}
项目:class-guard    文件:ApplicationContext.java   
/**
 * Remove the context attribute with the specified name, if any.
 *
 * @param name Name of the context attribute to be removed
 */
@Override
public void removeAttribute(String name) {

    Object value = null;

    // Remove the specified attribute
    // Check for read only attribute
    if (readOnlyAttributes.containsKey(name)){
        return;
    }
    value = attributes.remove(name);
    if (value == null) {
        return;
    }

    // Notify interested application event listeners
    Object listeners[] = context.getApplicationEventListeners();
    if ((listeners == null) || (listeners.length == 0))
        return;
    ServletContextAttributeEvent event =
      new ServletContextAttributeEvent(context.getServletContext(),
                                        name, value);
    for (int i = 0; i < listeners.length; i++) {
        if (!(listeners[i] instanceof ServletContextAttributeListener))
            continue;
        ServletContextAttributeListener listener =
            (ServletContextAttributeListener) listeners[i];
        try {
            context.fireContainerEvent("beforeContextAttributeRemoved",
                                       listener);
            listener.attributeRemoved(event);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
            // FIXME - should we do anything besides log these?
            log(sm.getString("applicationContext.attributeEvent"), t);
        }
    }

}
项目:apache-tomcat-7.0.57    文件:ApplicationContext.java   
/**
 * Remove the context attribute with the specified name, if any.
 *
 * @param name Name of the context attribute to be removed
 */
@Override
public void removeAttribute(String name) {

    Object value = null;

    // Remove the specified attribute
    // Check for read only attribute
    if (readOnlyAttributes.containsKey(name)){
        return;
    }
    value = attributes.remove(name);
    if (value == null) {
        return;
    }

    // Notify interested application event listeners
    Object listeners[] = context.getApplicationEventListeners();
    if ((listeners == null) || (listeners.length == 0))
        return;
    ServletContextAttributeEvent event =
      new ServletContextAttributeEvent(context.getServletContext(),
                                        name, value);
    for (int i = 0; i < listeners.length; i++) {
        if (!(listeners[i] instanceof ServletContextAttributeListener))
            continue;
        ServletContextAttributeListener listener =
            (ServletContextAttributeListener) listeners[i];
        try {
            context.fireContainerEvent("beforeContextAttributeRemoved",
                                       listener);
            listener.attributeRemoved(event);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
            // FIXME - should we do anything besides log these?
            log(sm.getString("applicationContext.attributeEvent"), t);
        }
    }

}
项目:apache-tomcat-7.0.57    文件:ApplicationContext.java   
/**
 * Remove the context attribute with the specified name, if any.
 *
 * @param name Name of the context attribute to be removed
 */
@Override
public void removeAttribute(String name) {

    Object value = null;

    // Remove the specified attribute
    // Check for read only attribute
    if (readOnlyAttributes.containsKey(name)){
        return;
    }
    value = attributes.remove(name);
    if (value == null) {
        return;
    }

    // Notify interested application event listeners
    Object listeners[] = context.getApplicationEventListeners();
    if ((listeners == null) || (listeners.length == 0))
        return;
    ServletContextAttributeEvent event =
      new ServletContextAttributeEvent(context.getServletContext(),
                                        name, value);
    for (int i = 0; i < listeners.length; i++) {
        if (!(listeners[i] instanceof ServletContextAttributeListener))
            continue;
        ServletContextAttributeListener listener =
            (ServletContextAttributeListener) listeners[i];
        try {
            context.fireContainerEvent("beforeContextAttributeRemoved",
                                       listener);
            listener.attributeRemoved(event);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
            // FIXME - should we do anything besides log these?
            log(sm.getString("applicationContext.attributeEvent"), t);
        }
    }

}
项目:opennmszh    文件:ServletContextAttributeListenerManager.java   
public ServletContextAttributeListenerManager(BundleContext context)
{
    super(context, ServletContextAttributeListener.class);
}
项目:HowTomcatWorks    文件:ApplicationContext.java   
/**
 * Remove the context attribute with the specified name, if any.
 *
 * @param name Name of the context attribute to be removed
 */
public void removeAttribute(String name) {

    Object value = null;
    boolean found = false;

    // Remove the specified attribute
    synchronized (attributes) {
        // Check for read only attribute
       if (readOnlyAttributes.containsKey(name))
            return;
        found = attributes.containsKey(name);
        if (found) {
            value = attributes.get(name);
            attributes.remove(name);
        } else {
            return;
        }
    }

    // Notify interested application event listeners
    Object listeners[] = context.getApplicationListeners();
    if ((listeners == null) || (listeners.length == 0))
        return;
    ServletContextAttributeEvent event =
      new ServletContextAttributeEvent(context.getServletContext(),
                                        name, value);
    for (int i = 0; i < listeners.length; i++) {
        if (!(listeners[i] instanceof ServletContextAttributeListener))
            continue;
        ServletContextAttributeListener listener =
            (ServletContextAttributeListener) listeners[i];
        try {
            context.fireContainerEvent("beforeContextAttributeRemoved",
                                       listener);
            listener.attributeRemoved(event);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
        } catch (Throwable t) {
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
            // FIXME - should we do anything besides log these?
            log(sm.getString("applicationContext.attributeEvent"), t);
        }
    }

}
项目:WBSAirback    文件:ApplicationContext.java   
/**
 * Remove the context attribute with the specified name, if any.
 *
 * @param name Name of the context attribute to be removed
 */
@Override
public void removeAttribute(String name) {

    Object value = null;
    boolean found = false;

    // Remove the specified attribute
    // Check for read only attribute
    if (readOnlyAttributes.containsKey(name))
        return;
    found = attributes.containsKey(name);
    if (found) {
        value = attributes.get(name);
        attributes.remove(name);
    } else {
        return;
    }

    // Notify interested application event listeners
    Object listeners[] = context.getApplicationEventListeners();
    if ((listeners == null) || (listeners.length == 0))
        return;
    ServletContextAttributeEvent event =
      new ServletContextAttributeEvent(context.getServletContext(),
                                        name, value);
    for (int i = 0; i < listeners.length; i++) {
        if (!(listeners[i] instanceof ServletContextAttributeListener))
            continue;
        ServletContextAttributeListener listener =
            (ServletContextAttributeListener) listeners[i];
        try {
            context.fireContainerEvent("beforeContextAttributeRemoved",
                                       listener);
            listener.attributeRemoved(event);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            context.fireContainerEvent("afterContextAttributeRemoved",
                                       listener);
            // FIXME - should we do anything besides log these?
            log(sm.getString("applicationContext.attributeEvent"), t);
        }
    }

}
项目:WBSAirback    文件:ApplicationContext.java   
@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()));
    }

    // TODO SERVLET3
    // throw UnsupportedOperationException - if this context was passed to the
    // {@link ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)}
    // method of a {@link ServletContextListener} that was not declared
    // in web.xml, a web-fragment or annotated with
    // {@link javax.servlet.annotation.WebListener}.

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