Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
always use a template method cache even if the template cache flag is set to false. This flag is only used to make dynamic updates to the template files, to not dynamic updates to the rewrite methods (which is not possible without recompiling). low memory usage is guaranteed by the usage of soft references which are dropped before an OOM is thrown
orbiterd1dbbd956a4e
diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.javaindex 36728339a..63dee4f34 100644--- a/source/de/anomic/http/server/HTTPDFileHandler.java+++ b/source/de/anomic/http/server/HTTPDFileHandler.java@@ -145,7 +145,7 @@ public final class HTTPDFileHandler {final serverSwitch theSwitchboard = Switchboard.getSwitchboard();useTemplateCache = theSwitchboard.getConfig("enableTemplateCache","true").equalsIgnoreCase("true");templateCache = (useTemplateCache)? new ConcurrentHashMap<File, SoftReference<TemplateCacheEntry>>() : new ConcurrentHashMap<File, SoftReference<TemplateCacheEntry>>(0);- templateMethodCache = (useTemplateCache) ? new ConcurrentHashMap<File, SoftReference<Method>>() : new ConcurrentHashMap<File, SoftReference<Method>>(0);+ templateMethodCache = new ConcurrentHashMap<File, SoftReference<Method>>();if (switchboard == null) {switchboard = theSwitchboard;@@ -1217,7 +1217,7 @@ public final class HTTPDFileHandler {Method m = null;// now make a class out of the streamtry {- if (useTemplateCache) {+ if (templateMethodCache != null) {final SoftReference<Method> ref = templateMethodCache.get(classFile);if (ref != null) {m = ref.get();@@ -1226,7 +1226,7 @@ public final class HTTPDFileHandler {} else {return m;}- }+ }}final Class<?> c = provider.loadClass(classFile);@@ -1236,10 +1236,11 @@ public final class HTTPDFileHandler {serverSwitch.class };m = c.getMethod("respond", params);- if (useTemplateCache) {+ if (MemoryControl.shortStatus()) {+ templateMethodCache.clear();+ } else {// storing the method into the cachefinal SoftReference<Method> ref = new SoftReference<Method>(m);- if (MemoryControl.shortStatus()) templateMethodCache.clear();templateMethodCache.put(classFile, ref);}