Package javax.servlet.http

Examples of javax.servlet.http.HttpSessionBindingListener


  public void setAttribute(String aName, Object aObject) {
    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

                    "WinstoneSession.AttributeNotSerializable", new String[] {
                            name, value.getClass().getName() }));

        // 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)
View Full Code Here

            this.sessionData.remove(name);
        }

        // 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();
View Full Code Here

        final File tempSessionDownloadDirectory = new File(tempDownloadDirectory, session.getUser().getPrincipalName() + "."
            + session.getHttpSession().getId());
        if (!tempSessionDownloadDirectory.exists()) {
         
          // Hook for cleaning up on logout
          session.getHttpSession().setAttribute(DownloadContent.FILES_DOWNLOAD_CLEANUP_SESSION_HOOK, new HttpSessionBindingListener() {

        public void valueBound(HttpSessionBindingEvent event) {         
        }

        public void valueUnbound(HttpSessionBindingEvent event) {
View Full Code Here

      }
    } catch (Exception e) {
      throw new UserDatabaseException("Failed to initialise profiles.", e);
    }
    final String logonTicket = (String) session.getAttribute(Constants.LOGON_TICKET);
    session.setAttribute(Constants.LOGOFF_HOOK, new HttpSessionBindingListener() {
      public void valueBound(HttpSessionBindingEvent evt) {
      }

      public void valueUnbound(HttpSessionBindingEvent evt) {
        if (log.isDebugEnabled())
View Full Code Here

             * TODO This is probably no longer necessary as the list of
             * currently active SessionInfo objects should be sufficient
             * for all cases. Please investigate if it can be removed. 
             */
            sessions.put(session.getId(), session);
            session.setAttribute(Constants.SESSION_HOOK, new HttpSessionBindingListener() {

                public void valueBound(HttpSessionBindingEvent arg0) {
                }

                public void valueUnbound(HttpSessionBindingEvent arg0) {
View Full Code Here

            throw new IllegalStateException("Invalid session");

        attributes.setAttribute(name, value);

        if (value instanceof HttpSessionBindingListener) {
            HttpSessionBindingListener listener = (HttpSessionBindingListener) value;
            listener.valueBound(new HttpSessionBindingEvent(this, name));
        }
    }
View Full Code Here

            throw new IllegalStateException("Invalid session");

        Object value = attributes.removeAttribute(name);

        if (value != null && value instanceof HttpSessionBindingListener) {
            HttpSessionBindingListener listener = (HttpSessionBindingListener) value;
            listener.valueUnbound(new HttpSessionBindingEvent(this, name));
        }
    }
View Full Code Here

    // server/017p
    _isModified = true;

    if (oldValue instanceof HttpSessionBindingListener) {
      HttpSessionBindingListener listener;
      listener = (HttpSessionBindingListener) oldValue;

      listener.valueUnbound(new HttpSessionBindingEvent(SessionImpl.this,
                                                        name, oldValue));
    }

    if (value instanceof HttpSessionBindingListener) {
      HttpSessionBindingListener listener;
      listener = (HttpSessionBindingListener) value;

      listener.valueBound(new HttpSessionBindingEvent(SessionImpl.this,
                                                      name, value));
    }

    // Notify the attribute listeners
    ArrayList listeners = _manager.getAttributeListeners();

    if (listeners != null && listeners.size() > 0) {
      HttpSessionBindingEvent event;

      if (oldValue != null)
        event = new HttpSessionBindingEvent(this, name, oldValue);
      else
        event = new HttpSessionBindingEvent(this, name, value);

      for (int i = 0; i < listeners.size(); i++) {
        HttpSessionAttributeListener listener;
        listener = (HttpSessionAttributeListener) listeners.get(i);

        if (oldValue != null)
          listener.attributeReplaced(event);
        else
          listener.attributeAdded(event);
      }
    }
  }
View Full Code Here

TOP

Related Classes of javax.servlet.http.HttpSessionBindingListener

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.