Example usage for javax.servlet.http HttpSessionBindingEvent getValue

List of usage examples for javax.servlet.http HttpSessionBindingEvent getValue

Introduction

In this page you can find the example usage for javax.servlet.http HttpSessionBindingEvent getValue.

Prototype

public Object getValue() 

Source Link

Document

Returns the value of the attribute that has been added, removed or replaced.

Usage

From source file:com.liusoft.dlog4j.SessionUserObject.java

/**
 * /*from   ww  w . jav a  2  s  .c o  m*/
 * ???HibernateFilterSession
 */
public void valueUnbound(HttpSessionBindingEvent e) {
    SessionUserObject user = (SessionUserObject) e.getValue();
    if (user != null) {
        try {
            UserLoginManager.logoutUser(user);
        } catch (Exception excp) {
            log.error("Error when logout user, userid=" + user.getId(), excp);
        }
        try {
            //dlog_fck_upload_file
            FCKUploadFileDAO.cleanupOfSession(user.getSessionId(), user.getId());
        } catch (Exception excp) {
            log.error("Error when cleanup upload files, userid=" + user.getId(), excp);
        }
        //??HibernateFilter?????
        HibernateUtils.closeSession();
    }
}

From source file:SessionBindListen.java

public void valueBound(HttpSessionBindingEvent be) {

    HttpSession session = be.getSession();
    String id = session.getId();/*from  ww  w  .j a va  2 s  . c  o m*/
    String name = be.getName();
    Object value = be.getValue();
    String source = be.getSource().getClass().getName();
    String message = new StringBuffer("Attribute bound to session in ").append(source)
            .append("\nThe attribute name: ").append(name).append("\n").append("The attribute value: ")
            .append(value).append("\n").append("The session id: ").append(id).toString();

    System.out.println(message);
}

From source file:MyServlet.java

/**
 * Record the fact that a servlet context attribute was added.
 *
 * @param event The session attribute event
 *///from   www  . j a va2 s .co  m
public void attributeAdded(HttpSessionBindingEvent event) {

    log("attributeAdded('" + event.getSession().getId() + "', '" + event.getName() + "', '" + event.getValue()
            + "')");

}

From source file:MyServlet.java

/**
 * Record the fact that a servlet context attribute was removed.
 *
 * @param event The session attribute event
 *//*from w  w w  .  j a v  a 2 s. com*/
public void attributeRemoved(HttpSessionBindingEvent event) {

    log("attributeRemoved('" + event.getSession().getId() + "', '" + event.getName() + "', '" + event.getValue()
            + "')");

}

From source file:MyServlet.java

/**
 * Record the fact that a servlet context attribute was replaced.
 *
 * @param event The session attribute event
 *///  w  ww . ja v a  2  s. c  o m
public void attributeReplaced(HttpSessionBindingEvent event) {

    log("attributeReplaced('" + event.getSession().getId() + "', '" + event.getName() + "', '"
            + event.getValue() + "')");

}

From source file:org.musicrecital.webapp.listener.UserCounterListener.java

/**
 * This method is designed to catch when user's login and record their name
 *
 * @param event the event to process// ww  w .j  a v  a2  s . co m
 * @see javax.servlet.http.HttpSessionAttributeListener#attributeAdded(javax.servlet.http.HttpSessionBindingEvent)
 */
public void attributeAdded(HttpSessionBindingEvent event) {
    if (event.getName().equals(EVENT_KEY) && !isAnonymous()) {
        SecurityContext securityContext = (SecurityContext) event.getValue();
        if (securityContext != null && securityContext.getAuthentication().getPrincipal() instanceof User) {
            User user = (User) securityContext.getAuthentication().getPrincipal();
            addUsername(user);
        }
    }
}

From source file:org.musicrecital.webapp.listener.UserCounterListener.java

/**
 * When user's logout, remove their name from the hashMap
 *
 * @param event the session binding event
 * @see javax.servlet.http.HttpSessionAttributeListener#attributeRemoved(javax.servlet.http.HttpSessionBindingEvent)
 *//*from   w  w  w  .j ava2  s . com*/
public void attributeRemoved(HttpSessionBindingEvent event) {
    if (event.getName().equals(EVENT_KEY) && !isAnonymous()) {
        SecurityContext securityContext = (SecurityContext) event.getValue();
        Authentication auth = securityContext.getAuthentication();
        if (auth != null && (auth.getPrincipal() instanceof User)) {
            User user = (User) auth.getPrincipal();
            removeUsername(user);
        }
    }
}

From source file:org.musicrecital.webapp.listener.UserCounterListener.java

/**
 * Needed for Acegi Security 1.0, as it adds an anonymous user to the session and
 * then replaces it after authentication. http://forum.springframework.org/showthread.php?p=63593
 *
 * @param event the session binding event
 * @see javax.servlet.http.HttpSessionAttributeListener#attributeReplaced(javax.servlet.http.HttpSessionBindingEvent)
 *///  www  .j a va  2s. c  o m
public void attributeReplaced(HttpSessionBindingEvent event) {
    if (event.getName().equals(EVENT_KEY) && !isAnonymous()) {
        final SecurityContext securityContext = (SecurityContext) event.getValue();
        if (securityContext.getAuthentication() != null
                && securityContext.getAuthentication().getPrincipal() instanceof User) {
            final User user = (User) securityContext.getAuthentication().getPrincipal();
            addUsername(user);
        }
    }
}

From source file:alpha.portal.webapp.listener.UserCounterListener.java

/**
 * This method is designed to catch when user's login and record their name.
 * //from   w  w  w .  jav  a  2  s .c  om
 * @param event
 *            the event to process
 * @see javax.servlet.http.HttpSessionAttributeListener#attributeAdded(javax.servlet.http.HttpSessionBindingEvent)
 */
public void attributeAdded(final HttpSessionBindingEvent event) {
    if (event.getName().equals(UserCounterListener.EVENT_KEY) && !this.isAnonymous()) {
        final SecurityContext securityContext = (SecurityContext) event.getValue();
        if (securityContext.getAuthentication().getPrincipal() instanceof User) {
            final User user = (User) securityContext.getAuthentication().getPrincipal();
            this.addUsername(user);
        }
    }
}

From source file:alpha.portal.webapp.listener.UserCounterListener.java

/**
 * When user's logout, remove their name from the hashMap.
 * /*w w w  .j  a v  a2s  . c  om*/
 * @param event
 *            the session binding event
 * @see javax.servlet.http.HttpSessionAttributeListener#attributeRemoved(javax.servlet.http.HttpSessionBindingEvent)
 */
public void attributeRemoved(final HttpSessionBindingEvent event) {
    if (event.getName().equals(UserCounterListener.EVENT_KEY) && !this.isAnonymous()) {
        final SecurityContext securityContext = (SecurityContext) event.getValue();
        final Authentication auth = securityContext.getAuthentication();
        if ((auth != null) && (auth.getPrincipal() instanceof User)) {
            final User user = (User) auth.getPrincipal();
            this.removeUsername(user);
        }
    }
}