Package javax.servlet.http

Examples of javax.servlet.http.HttpSessionBindingEvent


      Object oldValue = value != null ? put((Object) name, value)
          : remove(name);
      if (oldValue != null) {
        if (oldValue instanceof HttpSessionBindingListener)
          ((HttpSessionBindingListener) oldValue)
              .valueUnbound(new HttpSessionBindingEvent(this,
                  name));
      }
      if (value != null) {
        if (value instanceof HttpSessionBindingListener)
          ((HttpSessionBindingListener) value)
              .valueBound(new HttpSessionBindingEvent(this, name));
        notifyListeners(name, oldValue, value);
      } else
        notifyListeners(name, oldValue);
    }
View Full Code Here


        throw new IllegalStateException();
      Object value = remove((Object) name);
      if (value != null) {
        if (value instanceof HttpSessionBindingListener)
          ((HttpSessionBindingListener) value)
              .valueUnbound(new HttpSessionBindingEvent(this,
                  name));
        notifyListeners(name, value);
      }
    }
View Full Code Here

      }
    }

    private void notifyListeners(String name, Object value) {
      if (listeners != null) {
        HttpSessionBindingEvent event = new HttpSessionBindingEvent(
            this, name, value);
        for (int i = 0, n = listeners.size(); i < n; i++)
          try {
            ((HttpSessionAttributeListener) listeners.get(i))
                .attributeRemoved(event);
View Full Code Here

      }
    }

    private void notifyListeners(String name, Object oldValue, Object value) {
      if (listeners != null) {
        HttpSessionBindingEvent event = new HttpSessionBindingEvent(
            this, name, value);
        HttpSessionBindingEvent oldEvent = oldValue == null ? null
            : new HttpSessionBindingEvent(this, name, oldValue);
        for (int i = 0, n = listeners.size(); i < n; i++)
          try {
            HttpSessionAttributeListener l = (HttpSessionAttributeListener) listeners
                .get(i);
            if (oldEvent != null)
View Full Code Here

    vomitIfInvalidated();
    Object existingObject = fAttributes.put(aName, aObject);
    if( aObject instanceof HttpSessionBindingListener) {
      HttpSessionBindingListener listener = (HttpSessionBindingListener)aObject;
      Object value = (existingObject != null ? existingObject : aObject);
      listener.valueBound(new HttpSessionBindingEvent(this, aName, value));
    }
  }
View Full Code Here

  public void removeAttribute(String aName) {
    vomitIfInvalidated();
    Object existingObject = fAttributes.remove(aName);
    if( existingObject instanceof HttpSessionBindingListener) {
      HttpSessionBindingListener listener = (HttpSessionBindingListener)existingObject;
      listener.valueUnbound(new HttpSessionBindingEvent(this, aName, existingObject));
    }
  }
View Full Code Here

        // valueBound must be before binding
        if (value instanceof HttpSessionBindingListener) {
            HttpSessionBindingListener hsbl = (HttpSessionBindingListener) value;
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(this.webAppConfig.getLoader());
            hsbl.valueBound(new HttpSessionBindingEvent(this, name, value));
            Thread.currentThread().setContextClassLoader(cl);
        }

        Object oldValue = null;
        synchronized (this.sessionMonitor) {
            oldValue = this.sessionData.get(name);
            if (value == null) {
                this.sessionData.remove(name);
            } else {
                this.sessionData.put(name, value);
            }
        }

        // valueUnbound must be after unbinding
        if (oldValue instanceof HttpSessionBindingListener) {
            HttpSessionBindingListener hsbl = (HttpSessionBindingListener) oldValue;
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(this.webAppConfig.getLoader());
            hsbl.valueUnbound(new HttpSessionBindingEvent(this, name, oldValue));
            Thread.currentThread().setContextClassLoader(cl);
        }

        // Notify other listeners
        if (oldValue != null)
            for (int n = 0; n < this.sessionAttributeListeners.length; n++) {
                ClassLoader cl = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(this.webAppConfig.getLoader());
                this.sessionAttributeListeners[n].attributeReplaced(
                        new HttpSessionBindingEvent(this, name, oldValue));
                Thread.currentThread().setContextClassLoader(cl);
            }
               
        else
            for (int n = 0; n < this.sessionAttributeListeners.length; n++) {
                ClassLoader cl = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(this.webAppConfig.getLoader());
                this.sessionAttributeListeners[n].attributeAdded(
                        new HttpSessionBindingEvent(this, name, value));
                Thread.currentThread().setContextClassLoader(cl);
               
            }
    }
View Full Code Here

        // Notify listeners
        if (value instanceof HttpSessionBindingListener) {
            HttpSessionBindingListener hsbl = (HttpSessionBindingListener) value;
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(this.webAppConfig.getLoader());
            hsbl.valueUnbound(new HttpSessionBindingEvent(this, name));
            Thread.currentThread().setContextClassLoader(cl);
        }
        if (value != null)
            for (int n = 0; n < this.sessionAttributeListeners.length; n++) {
                ClassLoader cl = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(this.webAppConfig.getLoader());
                this.sessionAttributeListeners[n].attributeRemoved(
                        new HttpSessionBindingEvent(this, name, value));
                Thread.currentThread().setContextClassLoader(cl);
            }
    }
View Full Code Here

         throw new IllegalArgumentException
            (sm.getString("clusteredSession.setAttribute.iae"));
      }
     
      // Construct an event with the new value
      HttpSessionBindingEvent event = null;

      // Call the valueBound() method if necessary
      if (value instanceof HttpSessionBindingListener
            && notificationPolicy.isHttpSessionBindingListenerInvocationAllowed(this.clusterStatus, ClusteredSessionNotificationCause.MODIFY, name, true))
      {
         event = new HttpSessionBindingEvent(getSession(), name, value);
         try
         {
            ((HttpSessionBindingListener) value).valueBound(event);
         }
         catch (Throwable t)
         {
             manager.getContainer().getLogger().error(sm.getString("clusteredSession.bindingEvent"), t);
         }
      }
     
      if (value instanceof HttpSessionActivationListener)
         hasActivationListener = Boolean.TRUE;

      // Replace or add this attribute
      Object unbound = setAttributeInternal(name, value);

      // Call the valueUnbound() method if necessary
      if ((unbound != null) && (unbound != value) &&
         (unbound instanceof HttpSessionBindingListener) &&
         notificationPolicy.isHttpSessionBindingListenerInvocationAllowed(this.clusterStatus, ClusteredSessionNotificationCause.MODIFY, name, true))
      {
         try
         {
            ((HttpSessionBindingListener) unbound).valueUnbound
               (new HttpSessionBindingEvent(getSession(), name));
         }
         catch (Throwable t)
         {
             manager.getContainer().getLogger().error(sm.getString("clusteredSession.bindingEvent"), t);
         }
      }

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

      {
         return;
      }

      // Call the valueUnbound() method if necessary
      HttpSessionBindingEvent event = null;
      if (value instanceof HttpSessionBindingListener
            && notificationPolicy.isHttpSessionBindingListenerInvocationAllowed(this.clusterStatus, cause, name, localCall))
      {
         event = new HttpSessionBindingEvent(getSession(), name, value);
         ((HttpSessionBindingListener) value).valueUnbound(event);
      }

      // Notify interested application event listeners
      if (notificationPolicy.isHttpSessionAttributeListenerInvocationAllowed(this.clusterStatus, cause, name, localCall))
      {
         Context context = (Context) manager.getContainer();
         Object lifecycleListeners[] = context.getApplicationEventListeners();
         if (lifecycleListeners != null)
         {
            // SRV.10.6 (2.5) 11.6 (3.0) Propagate listener exceptions
            RuntimeException listenerException = null;
           
            for (int i = 0; i < lifecycleListeners.length; i++)
            {
               if (!(lifecycleListeners[i] instanceof HttpSessionAttributeListener))
                  continue;
               HttpSessionAttributeListener listener =
                  (HttpSessionAttributeListener) lifecycleListeners[i];
               try
               {
                  fireContainerEvent(context,
                     "beforeSessionAttributeRemoved",
                     listener);
                  if (event == null)
                  {
                     event = new HttpSessionBindingEvent
                        (getSession(), name, value);
                  }
                  try
                  {
                     listener.attributeRemoved(event);
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.