1 4 5 9 10 package org.openlaszlo.servlets.responders; 11 12 import java.io.*; 13 import java.util.Properties ; 14 import javax.servlet.ServletConfig ; 15 import javax.servlet.ServletException ; 16 import javax.servlet.http.HttpServletRequest ; 17 import javax.servlet.http.HttpServletResponse ; 18 import javax.servlet.ServletOutputStream ; 19 import org.openlaszlo.utils.FileUtils; 20 import org.openlaszlo.cache.RequestCache; 21 import org.openlaszlo.cache.Cache; 22 import org.openlaszlo.cm.CompilationManager; 23 import org.openlaszlo.sc.ScriptCompiler; 24 import org.apache.log4j.Logger; 25 26 public final class ResponderCACHEINFO extends ResponderAdmin 27 { 28 private static Logger mLogger = Logger.getLogger(ResponderCACHEINFO.class); 29 30 protected void respondAdmin(HttpServletRequest req, HttpServletResponse res) 31 throws IOException 32 { 33 res.setContentType ("text/xml"); 34 ServletOutputStream out = res.getOutputStream(); 35 String details = req.getParameter("details"); 36 String sc = req.getParameter("sc"); try { 38 String msg = cacheInfo(details != null, sc != null); 39 out.println(msg); 40 } finally { 41 FileUtils.close(out); 42 } 43 } 44 45 48 public static String cacheInfo(boolean doDetails, boolean doSC) 49 throws IOException 50 { 51 Cache mediaCache = ResponderMEDIA.getCache(); 52 Cache dataCache = ResponderDATA.getCache(); 53 CompilationManager compilerCache = ResponderCompile.getCompilationManager(); 54 Cache compilerMediaCache = null; 55 Cache scriptCache = ScriptCompiler.getScriptCompilerCache(); 56 57 if (compilerCache != null) { 58 compilerMediaCache = compilerCache.getCompilerMediaCache(); 59 } 60 61 StringBuffer buf = new StringBuffer (""); 62 buf.append("<lps-cacheinfo>\n"); 63 if (mediaCache != null) { 64 mediaCache.dumpXML(buf, "media-cache", doDetails); 65 } 66 if (dataCache != null) { 67 dataCache.dumpXML(buf, "data-cache", doDetails); 68 } 69 if (compilerCache != null) { 70 compilerCache.dumpXML(buf, "compiler-cache", doDetails); 71 } 72 if (compilerMediaCache != null) { 73 compilerMediaCache.dumpXML(buf, "compiler-media-cache", doDetails); 74 } 75 if (doSC) { 76 if (scriptCache != null) { 77 scriptCache.dumpXML(buf, "script-cache", doDetails); 78 } 79 } 80 81 buf.append("</lps-cacheinfo>\n"); 82 return buf.toString(); 83 } 84 85 public int getMimeType() 86 { 87 return MIME_TYPE_XML; 88 } 89 } 90 | Popular Tags |