Example usage for javax.servlet ServletContextAttributeListener attributeRemoved

List of usage examples for javax.servlet ServletContextAttributeListener attributeRemoved

Introduction

In this page you can find the example usage for javax.servlet ServletContextAttributeListener attributeRemoved.

Prototype

default public void attributeRemoved(ServletContextAttributeEvent event) 

Source Link

Document

Receives notification that an attribute has been removed from the ServletContext.

Usage

From source file:org.ireland.jnetty.webapp.ServletContextImpl.java

/**
 * Removes an attribute from the servlet context.
 * // ww w . j a v  a 2  s. c om
 * @param name
 *            the name of the attribute to remove.
 */
@Override
public void removeAttribute(String name) {
    Object oldValue;

    synchronized (_attributes) {
        oldValue = _attributes.remove(name);
    }

    // Call any listeners
    if (_applicationAttributeListeners != null) {
        ServletContextAttributeEvent event;

        event = new ServletContextAttributeEvent(this, name, oldValue);

        for (int i = 0; i < _applicationAttributeListeners.size(); i++) {
            ServletContextAttributeListener listener;

            Object objListener = _applicationAttributeListeners.get(i);
            listener = (ServletContextAttributeListener) objListener;

            try {
                listener.attributeRemoved(event);
            } catch (Throwable e) {
                log.debug(e.toString(), e);
            }
        }
    }
}

From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.WebApplicationHandler.java

public synchronized void removeContextAttribute(String name) {
    Object old = super.getContextAttribute(name);
    super.removeContextAttribute(name);

    if (old != null && _contextAttributeListeners != null) {
        ServletContextAttributeEvent event = new ServletContextAttributeEvent(getServletContext(), name, old);
        for (int i = 0; i < LazyList.size(_contextAttributeListeners); i++) {
            ServletContextAttributeListener l = (ServletContextAttributeListener) LazyList
                    .get(_contextAttributeListeners, i);
            l.attributeRemoved(event);
        }// www  . ja va  2  s .  c  o  m
    }
}

From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.WebApplicationHandler.java

public synchronized void setContextAttribute(String name, Object value) {
    Object old = super.getContextAttribute(name);
    super.setContextAttribute(name, value);

    if (_contextAttributeListeners != null) {
        ServletContextAttributeEvent event = new ServletContextAttributeEvent(getServletContext(), name,
                old != null ? old : value);
        for (int i = 0; i < LazyList.size(_contextAttributeListeners); i++) {
            ServletContextAttributeListener l = (ServletContextAttributeListener) LazyList
                    .get(_contextAttributeListeners, i);
            if (old == null)
                l.attributeAdded(event);
            else if (value == null)
                l.attributeRemoved(event);
            else/*from w w  w  . j av a 2s  .  co  m*/
                l.attributeReplaced(event);
        }
    }
}