]> www.dolda2000.com Git - jsvc.git/blobdiff - src/dolda/jsvc/util/Cookie.java
Added basic session support.
[jsvc.git] / src / dolda / jsvc / util / Cookie.java
index 8783427cd38cd421197bd9d6bf72c61b44fd3ff0..591289dcf3f0e76ff1c0c0ee52a59b06fa00dcc0 100644 (file)
@@ -6,6 +6,7 @@ import java.text.*;
 import java.io.*;
 
 public class Cookie {
+    private final static Map<Request, MultiMap<String, Cookie>> cache = new WeakHashMap<Request, MultiMap<String, Cookie>>();
     public final static DateFormat datefmt;
     static {
        datefmt = new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss z", Locale.ENGLISH);
@@ -88,6 +89,17 @@ public class Cookie {
        return(ret);
     }
     
+    public static MultiMap<String, Cookie> get(Request req) {
+       synchronized(cache) {
+           MultiMap<String, Cookie> ret = cache.get(req);
+           if(ret == null) {
+               ret = parse(req);
+               cache.put(req, ret);
+           }
+           return(ret);
+       }
+    }
+
     public String toString() {
        StringBuilder buf = new StringBuilder();
        buf.append("Cookie(");