Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2006 BEA Systems, Inc. All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.p13n.http
Class SessionMonitor

    java.lang.Object
      com.bea.p13n.http.SessionMonitor

Direct Known Subclasses:
  SessionMonitor.AttributeInfoOnly, SessionMonitor.TotalSessionSizeOnly

    public class SessionMonitor

extends Object

Monitor changes to the Http Session. Useful for debugging session problems, especially as they affect cluster session replication. Can be used to find large and non-serializable session attributes, as well as what code is responsible for these attributes.

This class will report when an attribute is added, replaced, or removed in the session. It also attempts to look up the stack trace and report a line of code where the session change originated. For additions and removals, it also reports the size of the attribute. If an added attribute is non-serializable, this is reported as a warning.

On every change, the current total session size is also reported.

All reports are logged to the server log as Info level messages, except for non-serializable attributes which are Warnings. The subsystem name for the messages is this class name (com.bea.p13n.http.SessionMonitor). Note that the configuration for your server may not output Info messages to stdout, but only to the log file. So you should check the logging configuration for your server.

To use this class, add the following to your WebApp's web.xml:

         <listener>
             <listener-class> com.bea.p13n.http.SessionMonitor </listener-class>
         </listener>

It is important to note that this class should be used only for debugging, because the serialization and stack trace lookups can be expensive operations.

Note: Sizes are in bytes, and based on the serialization of the attribute to a stream. This will thus include all referenced objects, and will detect non-serializable objects contained within serializable containers (such as a non-serializable object contained in a Map), which can not generally be detected by looking at "myAttribute instanceof Serializable". A size obtained this way is not the same as the memory (heap) occupied by this attribute, but does indicate the cost of replicating or persisting the attribute in a cluster.

Nested Class Summary
`static class` | `SessionMonitor.AttributeInfoOnly` Use this class instead of SessionMonitor if you only want attribute info (add/remove/replace, serialization test, and size) without logging the total session size each time.
`static class` | `SessionMonitor.TotalSessionSizeOnly` Use this class instead of SessionMonitor if you only want total session size (on each session change) without any attribute info.

Constructor Summary
`SessionMonitor()` Public default constructor required by HttpSessionAttributeListener

Method Summary
`void` | `attributeAdded(HttpSessionBindingEvent bindingEvent)` HttpSessionAttributeListener.attributeAdded() implementation.
`void` | `attributeRemoved(HttpSessionBindingEvent bindingEvent)` HttpSessionAttributeListener.attributeRemoved() implementation.
`void` | `attributeReplaced(HttpSessionBindingEvent bindingEvent)` HttpSessionAttributeListener.attributeReplaced() implementation.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SessionMonitor

    public SessionMonitor()

  Public default constructor required by HttpSessionAttributeListener

Method Detail

### attributeAdded

    public void attributeAdded(HttpSessionBindingEvent bindingEvent)

  HttpSessionAttributeListener.attributeAdded() implementation. Logs information about attributes added to the session.

### attributeRemoved

    public void attributeRemoved(HttpSessionBindingEvent bindingEvent)

  HttpSessionAttributeListener.attributeRemoved() implementation. Logs information about attributes removed from the session.

### attributeReplaced

    public void attributeReplaced(HttpSessionBindingEvent bindingEvent)

  HttpSessionAttributeListener.attributeReplaced() implementation. Logs information about attrubutes replaced in the session

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 BEA Systems, Inc. All Rights Reserved