tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Blomquist" <>
Subject Re: Reading Sessions from Persistent Store
Date Tue, 10 Jan 2006 19:45:14 GMT
I forgot to mention I would only reload the session from the store if it
was dirty (based on last access time).


From: Gary Blomquist 
Sent: Tuesday, January 10, 2006 2:14 PM
To: ''
Subject: Reading Sessions from Persistent Store

I am attempting to use non-sticky sessions using a syncronous Persistent
Manager and a JDBC Store.  
I have written a class SyncPersistentManager that extends
PersistentManagerBase and implements HttpSessionAttributeListener to
store the sessions in the JDBC store each time an attribute in the
HttpSession is modified.
Is there a simple extension point that I can use to get Tomcat to read
the session from the store if HttpSession.getAttribute is called.  I was
hoping to be able to implement this functionality via some extension
point rather than having to modify the StandardSession object as the
Session object does not appear to be pluggable (unless I'm missing
Anyone have any ideas?
Gary Blomquist
Source for SyncPersistentManager
public class SyncPersistentManager extends PersistentManagerBase
implements HttpSessionAttributeListener {
 boolean registered = false;
 private static final String info = "SyncPersistentManager/1.0";
 protected static String name = "SyncPersistentManager";
 public SyncPersistentManager() {
 public String getInfo() {
  return info;
 public String getName() {
  return name;
 public void attributeAdded(HttpSessionBindingEvent event) {
 public void attributeRemoved(HttpSessionBindingEvent event) {
 public void attributeReplaced(HttpSessionBindingEvent event) {
 private void persistSession(HttpSessionBindingEvent event) {
  HttpSession httpSession = event.getSession();
  try {
     StandardSession standardSession =
  } catch (IOException e) {
   System.out.println("SyncPersistentManager::error persisting session "
+ e.getMessage());
  } catch (Exception e) {
   System.out.println("SyncPersistentManager::error persisting session "
+ e.getMessage());
 protected synchronized void writeSession(Session session) throws
IOException {
  if ( ! registered ) {
 private void register() {
  Context context = (Context)getContainer();
  Object listeners[] = context.getApplicationEventListeners();
  Object updatedListeners[] = new Object[listeners.length + 1];
  for (int i=0; i<(updatedListeners.length - 1); i++) {
   updatedListeners[i] = listeners[i];
  updatedListeners[updatedListeners.length -1] = this;
  registered = true;

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message