From: Fredrik Tolf Date: Tue, 29 Mar 2011 00:05:05 +0000 (+0200) Subject: Use Destroyable values instead of session listeners. X-Git-Url: http://dolda2000.com/gitweb/?p=jsvc.git;a=commitdiff_plain;h=919138305d240babf0ab7aaf51d70b8b23884cbd Use Destroyable values instead of session listeners. --- diff --git a/src/dolda/jsvc/util/PerSession.java b/src/dolda/jsvc/util/PerSession.java index 0bb1ab0..d4e4d73 100644 --- a/src/dolda/jsvc/util/PerSession.java +++ b/src/dolda/jsvc/util/PerSession.java @@ -93,14 +93,6 @@ public class PerSession implements Responder { 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); diff --git a/src/dolda/jsvc/util/Session.java b/src/dolda/jsvc/util/Session.java index 01c6d16..7b87d12 100644 --- a/src/dolda/jsvc/util/Session.java +++ b/src/dolda/jsvc/util/Session.java @@ -9,11 +9,6 @@ public abstract class Session implements java.io.Serializable { private static final Map cache = new WeakHashMap(); private final Map props = new IdentityHashMap(); public long ctime = System.currentTimeMillis(), atime = ctime, etime = 86400 * 1000; - private Collection ll = new HashSet(); - - public static interface Listener { - public void destroy(Session sess); - } public static interface Storage { public Session get(Request req); @@ -154,12 +149,6 @@ public abstract class Session implements java.io.Serializable { 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)) @@ -174,9 +163,11 @@ public abstract class Session implements java.io.Serializable { } 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(); + } } }