Package javax.servlet.http

Examples of javax.servlet.http.HttpSessionBindingEvent


    @Override
    public void attributeAdded(final Session session, final String name, final Object value) {
        final HttpSessionImpl httpSession = HttpSessionImpl.forSession(session, servletContext, false);
        applicationListeners.httpSessionAttributeAdded(httpSession, name, value);
        if (value instanceof HttpSessionBindingListener) {
            ((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(httpSession, name, value));
        }
    }
View Full Code Here


    @Override
    public void attributeUpdated(final Session session, final String name, final Object value, final Object old) {
        final HttpSessionImpl httpSession = HttpSessionImpl.forSession(session, servletContext, false);
        if (old != value) {
            if (old instanceof HttpSessionBindingListener) {
                ((HttpSessionBindingListener) old).valueUnbound(new HttpSessionBindingEvent(httpSession, name, old));
            }
            applicationListeners.httpSessionAttributeReplaced(httpSession, name, old);
        }
        if (value instanceof HttpSessionBindingListener) {
            ((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(httpSession, name, value));
        }
    }
View Full Code Here

    public void attributeRemoved(final Session session, final String name, final Object old) {
        final HttpSessionImpl httpSession = HttpSessionImpl.forSession(session, servletContext, false);
        if (old != null) {
            applicationListeners.httpSessionAttributeRemoved(httpSession, name, old);
            if (old instanceof HttpSessionBindingListener) {
                ((HttpSessionBindingListener) old).valueUnbound(new HttpSessionBindingEvent(httpSession, name, old));
            }
        }
    }
View Full Code Here

            this.<HttpSessionListener>get(listener).sessionDestroyed(sre);
        }
    }

    public void httpSessionAttributeAdded(final HttpSession session, final String name, final Object value) {
        final HttpSessionBindingEvent sre = new HttpSessionBindingEvent(session, name, value);
        for (final ManagedListener listener : httpSessionAttributeListeners) {
            this.<HttpSessionAttributeListener>get(listener).attributeAdded(sre);
        }
    }
View Full Code Here

            this.<HttpSessionAttributeListener>get(listener).attributeAdded(sre);
        }
    }

    public void httpSessionAttributeRemoved(final HttpSession session, final String name, final Object value) {
        final HttpSessionBindingEvent sre = new HttpSessionBindingEvent(session, name, value);
        for (final ManagedListener listener : httpSessionAttributeListeners) {
            this.<HttpSessionAttributeListener>get(listener).attributeRemoved(sre);
        }
    }
View Full Code Here

            this.<HttpSessionAttributeListener>get(listener).attributeRemoved(sre);
        }
    }

    public void httpSessionAttributeReplaced(final HttpSession session, final String name, final Object value) {
        final HttpSessionBindingEvent sre = new HttpSessionBindingEvent(session, name, value);
        for (final ManagedListener listener : httpSessionAttributeListeners) {
            this.<HttpSessionAttributeListener>get(listener).attributeReplaced(sre);
        }
    }
View Full Code Here

        if (!notify) {
            return;
        }

        // Call the valueUnbound() method if necessary
        HttpSessionBindingEvent event =
          new HttpSessionBindingEvent((HttpSession) this, name, value);
        if ((value != null) &&
            (value instanceof HttpSessionBindingListener)) {
            try {
                ((HttpSessionBindingListener) value).valueUnbound(event);
            } catch (Throwable t) {
View Full Code Here

          !(value instanceof Serializable))
            throw new IllegalArgumentException
                (sm.getString("standardSession.setAttribute.iae"));

        // Construct an event with the new value
        HttpSessionBindingEvent event = new HttpSessionBindingEvent
                ((HttpSession) this, name, value);

        // Call the valueBound() method if necessary
        if (value instanceof HttpSessionBindingListener) {
            try {
                ((HttpSessionBindingListener) value).valueBound(event);
            } catch (Throwable t) {
                log(sm.getString("standardSession.bindingEvent"), t);
            }
        }

        // Replace or add this attribute
        Object unbound = null;
        synchronized (attributes) {
            unbound = attributes.get(name);
            attributes.put(name, value);
        }

        // Call the valueUnbound() method if necessary
        if ((unbound != null) &&
                (unbound instanceof HttpSessionBindingListener)) {
            try {
                ((HttpSessionBindingListener) unbound).valueUnbound
                        (new HttpSessionBindingEvent((HttpSession) this, name));
            } catch (Throwable t) {
                log(sm.getString("standardSession.bindingEvent"), t);
            }
        }

        // Replace the current event with one containing
        // the old value if necesary
        if (unbound != null)
            event = new HttpSessionBindingEvent((HttpSession) this,
                                                name, unbound);

        // Notify interested application event listeners
        Context context = (Context) manager.getContainer();
        Object listeners[] = context.getApplicationListeners();
View Full Code Here

            throw new IllegalArgumentException
                (sm.getString("standardSession.setAttribute.iae"));

       
        // Construct an event with the new value
        HttpSessionBindingEvent event = null;
       
        // Call the valueBound() method if necessary
        if ( value instanceof HttpSessionBindingListener ) {
            event = new HttpSessionBindingEvent(this, name, value);
            try {
                ( (HttpSessionBindingListener) value).valueBound(event);
            } catch ( Exception x ) {
                log.error("Session binding listener throw an exception",x);
            }
        }
       
        // Replace or add this attribute
        Object unbound = attributes.put(name, value);

        // Call the valueUnbound() method if necessary
        if ((unbound != null) &&
            (unbound instanceof HttpSessionBindingListener)) {
            try {
                ( (HttpSessionBindingListener) unbound).valueUnbound
                    (new HttpSessionBindingEvent( (HttpSession)this, name));
            } catch ( Exception x ) {
                log.error("Session binding listener throw an exception",x);
            }

        }


        // Notify interested application event listeners
        Context context = (Context) manager.getContainer();
        Object listeners[] = context.getApplicationEventListeners();
        if (listeners == null)
            return;
        for (int i = 0; i < listeners.length; i++) {
            if (!(listeners[i] instanceof HttpSessionAttributeListener))
                continue;
            HttpSessionAttributeListener listener =
                (HttpSessionAttributeListener) listeners[i];
            try {
                if (unbound != null) {
                    fireContainerEvent(context,
                                       "beforeSessionAttributeReplaced",
                                       listener);
                    if ( event == null ) {
                        event = new HttpSessionBindingEvent
                            (this,name,unbound);
                    }
                    listener.attributeReplaced(event);
                    fireContainerEvent(context,
                                       "afterSessionAttributeReplaced",
                                       listener);
                } else {
                    fireContainerEvent(context,
                                       "beforeSessionAttributeAdded",
                                       listener);
                    if (event == null) {
                        event = new HttpSessionBindingEvent
                            (this, name, unbound);
                    }
                    listener.attributeAdded(event);
                    fireContainerEvent(context,
                                       "afterSessionAttributeAdded",
View Full Code Here

        if (!notify) {
            return;
        }

        // Call the valueUnbound() method if necessary
        HttpSessionBindingEvent event =
          new HttpSessionBindingEvent((HttpSession) this, name, value);
        if ((value != null) &&
            (value instanceof HttpSessionBindingListener))
            try {
                ( (HttpSessionBindingListener) value).valueUnbound(event);
            } catch ( Exception x ) {
View Full Code Here

TOP

Related Classes of javax.servlet.http.HttpSessionBindingEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.