if(resp == null) {
resp = create(sess);
sess.put(rcl, resp);
- if(resp instanceof Destroyable) {
- final Destroyable cr = (Destroyable)resp;
- sess.listen(new Session.Listener() {
- public void destroy(Session sess) {
- cr.destroy();
- }
- });
- }
}
}
resp.respond(req);
private static final Map<Request, Session> cache = new WeakHashMap<Request, Session>();
private final Map<Object, Object> props = new IdentityHashMap<Object, Object>();
public long ctime = System.currentTimeMillis(), atime = ctime, etime = 86400 * 1000;
- private Collection<Listener> ll = new HashSet<Listener>();
-
- public static interface Listener {
- public void destroy(Session sess);
- }
public static interface Storage {
public Session get(Request req);
public abstract String id();
- public void listen(Listener l) {
- synchronized(ll) {
- ll.add(l);
- }
- }
-
public Object get(Object key, Object def) {
synchronized(props) {
if(props.containsKey(key))
}
public void destroy() {
- synchronized(ll) {
- for(Listener l : ll)
- l.destroy(this);
+ synchronized(props) {
+ for(Object val : props.values()) {
+ if(val instanceof Destroyable)
+ ((Destroyable)val).destroy();
+ }
}
}