Example usage for javax.servlet.http HttpSessionBindingEvent getSource

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

Introduction

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

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:SessionBindListen.java

public void valueBound(HttpSessionBindingEvent be) {

    HttpSession session = be.getSession();
    String id = session.getId();//from   w  w  w  .  j a  v a  2s  .  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:SessionBindListen.java

public void valueUnbound(HttpSessionBindingEvent be) {

    HttpSession session = be.getSession();
    String id = session.getId();//from w  w w .  ja  v a 2  s  .c om
    String name = be.getName();
    if (name == null)
        name = "Unknown";
    String source = be.getSource().getClass().getName();
    String message = new StringBuffer("Attribute unbound from session in ").append(source)
            .append("\nThe attribute name: ").append(name).append("\n").append("The session id: ").append(id)
            .toString();
    //clear Map; send message
    info.clear();
    System.out.println(message + "\nThe size of the HashMap is: " + info.size());
}

From source file:org.kuali.rice.krad.web.listener.NonSerializableSessionListener.java

/**
 * Tests whether the attribute value is serializable and logs an error if it isn't.  Note, this can be expensive
 * so we avoid it in production environments.
 * @param se the session binding event//  w w w.jav  a2  s  .  com
 * @param action the listener event for logging purposes (added or replaced)
 */
protected void checkSerialization(final HttpSessionBindingEvent se, String action) {
    final Object o = se.getValue();
    if (o != null) {
        if (!isSerializable(o)) {
            LOG.error("Attribute of class " + o.getClass().getName() + " with name " + se.getName()
                    + " from source " + se.getSource().getClass().getName() + " was " + action
                    + " to session and does not implement " + Serializable.class.getName());
        } else if (!canBeSerialized((Serializable) o)) {
            LOG.error("Attribute of class " + o.getClass().getName() + " with name " + se.getName()
                    + " from source " + se.getSource().getClass().getName() + " was " + action
                    + " to session and cannot be Serialized");
        }
    }
}