Changed logging in CacheMap to be Logging framework independent

(just use the application's logEvent() method)
This commit is contained in:
hns 2003-11-28 18:08:06 +00:00
parent 1d73c147d0
commit 874d9fcf97
2 changed files with 12 additions and 10 deletions

View file

@ -59,7 +59,7 @@ public final class NodeManager {
// Make actual cache size bigger, since we use it only up to the threshold // Make actual cache size bigger, since we use it only up to the threshold
// cache = new CacheMap ((int) Math.ceil (cacheSize/0.75f), 0.75f); // cache = new CacheMap ((int) Math.ceil (cacheSize/0.75f), 0.75f);
cache = new CacheMap(cacheSize, 0.75f); cache = new CacheMap(cacheSize, 0.75f);
cache.setLogger(app.getLogger("event")); cache.setApplication(app);
app.logEvent("Setting up node cache (" + cacheSize + ")"); app.logEvent("Setting up node cache (" + cacheSize + ")");
safe = new WrappedNodeManager(this); safe = new WrappedNodeManager(this);

View file

@ -30,6 +30,8 @@
package helma.util; package helma.util;
import java.util.HashMap; import java.util.HashMap;
import helma.framework.core.Application;
/// A Hashtable that expires least-recently-used objects. /// A Hashtable that expires least-recently-used objects.
// <P> // <P>
@ -57,8 +59,8 @@ public class CacheMap {
private HashMap oldTable; private HashMap oldTable;
private HashMap newTable; private HashMap newTable;
// the logger to output messages to // the application to output messages to
private Logger logger = null; private Application app = null;
/// Constructs a new, empty hashtable with the specified initial /// Constructs a new, empty hashtable with the specified initial
// capacity and the specified load factor. // capacity and the specified load factor.
@ -118,8 +120,8 @@ public class CacheMap {
// initialCapacity/2 entries. // initialCapacity/2 entries.
int newThreshold = capacity / 2; int newThreshold = capacity / 2;
if (newThreshold != threshold) { if (newThreshold != threshold) {
if (logger != null) if (app != null)
logger.log ("Setting cache capacity to "+capacity); app.logEvent ("Setting cache capacity to "+capacity);
updateThreshold (newThreshold); updateThreshold (newThreshold);
} }
} }
@ -235,8 +237,8 @@ public class CacheMap {
// grew beyond the threshold // grew beyond the threshold
if (newTable.size() >= threshold) { if (newTable.size() >= threshold) {
// Rotate the tables. // Rotate the tables.
if (logger != null) if (app != null)
logger.log ("Rotating Cache tables at "+newTable.size()+ app.logEvent ("Rotating Cache tables at "+newTable.size()+
"/"+oldTable.size()+" (new/old)"); "/"+oldTable.size()+" (new/old)");
oldTable = newTable; oldTable = newTable;
newTable = new HashMap (eachCapacity, loadFactor); newTable = new HashMap (eachCapacity, loadFactor);
@ -261,9 +263,9 @@ public class CacheMap {
oldTable.clear (); oldTable.clear ();
} }
/// Set the logger to use for debug and profiling output /// Set the application to use for debug and profiling output
public void setLogger (Logger log) { public void setApplication (Application app) {
this.logger = log; this.app = app;
} }
public synchronized Object[] getEntryArray () { public synchronized Object[] getEntryArray () {