I'm fixing a problem with PersistentManager which affects how sessions are
removed from memory. This will require making a change to StandardSession,
which I'd like to get some feedback on. Looking at this issue makes me think
that StandardManager is also doing the wrong thing when unloading sessions,
namely sending sessionDestroyed() events to listeners.
The PersistentManager issue is how sessions are unloaded to the Store, which
currently copies StandardManager's algorithm of calling session.expire(). The expire()
method is really intended for sessions which are being destroyed, either through
invalidation or timeout. PersistentManager needs to be modified so it will remove
sessions from its Store when expire() is called, which can be done by overriding
the remove method:
public void remove(Session session) {
super.remove(session);
if (store != null)
try {
store.remove(session.getId());
} catch (IOException e) {
log("IOException removing session from Store: " + e.getMessage());
e.printStackTrace();
}
}
No problem, except that this method is also triggered from the swapOut() method
by a call to StandardSession.expire(), which neuters swapOut().
So I'm thinking the thing to do is break out StandardSession.expire() functionality
so there are two public methods, one for expiring/destroying a session, one to
simply release/recycle the session (perhaps release()?)
This should be straightforward, but looking at this makes me wonder whether
StandardManager's behaviour on unload() is correct: it is sending events to
any listeners which indicate the session is being destroyed. My reading of the
spec suggests it should just send passivation-related events. I'm not sure about
the unbinding of attributes.
Comments?
Kief