private File dir;
private long tooOldChanging;
private long tooOldStable;
+ private TraceHandler tracer = new TraceHandler();
/**
* Create a new {@link Cache} object.
}
}
+ /**
+ * The traces handler for this {@link Cache}.
+ *
+ * @return the traces handler
+ */
+ public TraceHandler getTraceHandler() {
+ return tracer;
+ }
+
+ /**
+ * The traces handler for this {@link Cache}.
+ *
+ * @param tracer
+ * the new traces handler
+ */
+ public void setTraceHandler(TraceHandler tracer) {
+ this.tracer = tracer;
+ }
+
/**
* Check the resource to see if it is in the cache.
*
return clean(onlyOld, dir);
}
- /**
- * Trace information (info/error) generated by this class.
- * <p>
- * You can override it if you don't want the default sysout/syserr.
- *
- * @param message
- * the message
- * @param error
- * TRUE for error messages, FALSE for information messages
- */
- protected void trace(String message, boolean error) {
- if (error) {
- System.err.println(message);
- } else {
- System.out.println(message);
- }
- }
-
/**
* Clean the cache (delete the cached items) in the given cache directory.
*
if (file.delete()) {
num++;
} else {
- trace("Cannot delete temporary file: "
- + file.getAbsolutePath(), true);
+ tracer.error("Cannot delete temporary file: "
+ + file.getAbsolutePath());
}
}
}
long time = new Date().getTime() - file.lastModified();
if (time < 0) {
- trace("Timestamp in the future for file: " + file.getAbsolutePath(),
- true);
+ tracer.error("Timestamp in the future for file: "
+ + file.getAbsolutePath());
}
return time < 0 || time > max;