|
From: Pelle B. <pe...@us...> - 2004-04-02 23:17:15
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/cache In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4299/src/java/org/neuclear/id/cache Modified Files: NSCache.java Log Message: Got TransferOrder and Builder working with their test cases. Working on TransferReceipt which is the first embedded receipt. This is causing some problems at the moment. Index: NSCache.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/cache/NSCache.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NSCache.java 2 Apr 2004 17:33:31 -0000 1.10 --- NSCache.java 2 Apr 2004 23:05:02 -0000 1.11 *************** *** 1,10 **** package org.neuclear.id.cache; import org.neuclear.id.SignedNamedObject; - import java.lang.ref.WeakReference; - import java.util.HashMap; - import java.util.Map; - /** * The Idea of the NSCache is to have a quick cache of verified public NameSpaces. This is not stored, but is created from scratch --- 1,7 ---- package org.neuclear.id.cache; + import org.neuclear.commons.Cache; import org.neuclear.id.SignedNamedObject; /** * The Idea of the NSCache is to have a quick cache of verified public NameSpaces. This is not stored, but is created from scratch *************** *** 13,20 **** * This should help with both security and memory usage. */ ! public final class NSCache { ! public NSCache() { ! spaces = new HashMap(); ! } --- 10,14 ---- * This should help with both security and memory usage. */ ! public final class NSCache extends Cache { *************** *** 26,41 **** */ public SignedNamedObject fetchCached(final String name) { ! final WeakReference ref = (WeakReference) spaces.get(name); ! if (ref == null) ! return null; ! return (SignedNamedObject) ref.get(); } public SignedNamedObject cache(final SignedNamedObject obj) { ! if (!spaces.containsKey(obj.getDigest())) ! spaces.put(obj.getDigest(), new WeakReference(obj)); ! return obj; } - private final Map spaces; } --- 20,31 ---- */ public SignedNamedObject fetchCached(final String name) { ! System.out.println("Fetch:" + name); ! return (SignedNamedObject) lookup(name); } public SignedNamedObject cache(final SignedNamedObject obj) { ! System.out.println("Caching: " + obj.getDigest()); ! return (SignedNamedObject) cache(obj.getDigest(), obj); } } |