1 package dolda.jsvc.store;
4 import dolda.jsvc.util.Misc;
6 import java.security.*;
7 import java.security.cert.Certificate;
11 private static Map<Package, Store> interned = new WeakHashMap<Package, Store>();
12 private final Package pkg;
13 private final File base;
15 private Store(Package pkg, File root) {
17 String nm = pkg.getName();
21 while((p2 = nm.indexOf('.', p)) >= 0) {
22 base = new File(base, nm.substring(p, p2));
25 this.base = new File(base, nm.substring(p));
28 private static File getstoreroot() {
29 ThreadContext ctx = ThreadContext.current();
31 throw(new RuntimeException("Not running in jsvc context"));
32 String bn = ctx.server().config("jsvc.storage");
34 throw(new RuntimeException("No storage root has been configured"));
38 public static Store forclass(final Class<?> cl) {
39 Package pkg = cl.getPackage();
40 File root = getstoreroot();
42 synchronized(interned) {
43 s = interned.get(pkg);
45 s = new Store(pkg, root);