public CachingFileAccess(EnvJAXB env, String ... args) throws IOException {
super(null,"Caching File Access");
setEnv(env,args);
- content = new ConcurrentSkipListMap<String,Content>(); // multi-thread changes possible
+ content = new ConcurrentSkipListMap<>(); // multi-thread changes possible
- attachOnly = new HashSet<String>(); // short, unchanged
+ attachOnly = new HashSet<>(); // short, unchanged
- typeMap = new TreeMap<String,String>(); // Structure unchanged after Construction
+ typeMap = new TreeMap<>(); // Structure unchanged after Construction
typeMap.put("ico","image/icon");
typeMap.put("html","text/html");
typeMap.put("css","text/css");
public void handle(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws IOException {
String key = pathParam(req, ":key");
String cmd = pathParam(req,":cmd");
- System.out.print(key + clear_command);
if(key.equals(clear_command)) {
resp.setHeader("Content-Type",typeMap.get("txt"));
if("clear".equals(cmd)) {
}
public String toString() {
- return data.toString();
+ return Arrays.toString(data);
}
public void write(Writer writer) throws IOException {
public void run() {
int size = content.size();
if(size>maxSize) {
- ArrayList<Comp> scont = new ArrayList<Comp>(size);
+ ArrayList<Comp> scont = new ArrayList<>(size);
Object[] entries = content.entrySet().toArray();
for(int i=0;i<size;++i) {
scont.add(i, new Comp((Map.Entry<String,Content>)entries[i]));
}
Collections.sort(scont);
int end = size - ((maxSize/4)*3); // reduce to 3/4 of max size
- System.out.println("------ Cleanup Cycle ------ " + new Date().toString() + " -------");
+ //System.out.println("------ Cleanup Cycle ------ " + new Date().toString() + " -------");
for(int i=0;i<end;++i) {
Entry<String, Content> entry = scont.get(i).entry;
content.remove(entry.getKey());
- System.out.println("removed Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString());
+ //System.out.println("removed Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString());
}
for(int i=end;i<size;++i) {
Entry<String, Content> entry = scont.get(i).entry;
- System.out.println("remaining Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString());
+ //System.out.println("remaining Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString());
}
}
}