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

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7735 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 0d040ff6bb
commit d1dbbd956a

@ -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 stream
try {
if (useTemplateCache) {
if (templateMethodCache != null) {
final SoftReference<Method> ref = templateMethodCache.get(classFile);
if (ref != null) {
m = ref.get();
@ -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 cache
final SoftReference<Method> ref = new SoftReference<Method>(m);
if (MemoryControl.shortStatus()) templateMethodCache.clear();
templateMethodCache.put(classFile, ref);
}

Loading…
Cancel
Save