01: /******************************************************************************
02: * ResponderXMLRPCINFO.java
03: * ****************************************************************************/package org.openlaszlo.servlets.responders;
04:
05: import java.io.*;
06: import javax.servlet.http.HttpServletRequest;
07: import javax.servlet.http.HttpServletResponse;
08: import javax.servlet.ServletOutputStream;
09: import org.openlaszlo.data.XMLRPCDataSource;
10: import org.openlaszlo.utils.FileUtils;
11: import org.apache.log4j.Logger;
12:
13: public final class ResponderXMLRPCINFO extends ResponderAdmin {
14: private static Logger mLogger = Logger
15: .getLogger(ResponderXMLRPCINFO.class);
16:
17: boolean ok(String opt) {
18: return opt != null && opt.equals("1");
19: }
20:
21: /**
22: * Get XML-RPC load information.
23: */
24: protected void respondAdmin(HttpServletRequest req,
25: HttpServletResponse res) throws IOException {
26: res.setContentType("text/xml");
27: ServletOutputStream out = res.getOutputStream();
28: try {
29: if (ok(req.getParameter("clear"))) {
30: XMLRPCDataSource.clearLoadInfo();
31: }
32: StringBuffer sb = new StringBuffer();
33: XMLRPCDataSource.toXML(sb);
34: out.println(sb.toString());
35: } finally {
36: FileUtils.close(out);
37: }
38: }
39:
40: public int getMimeType() {
41: return MIME_TYPE_XML;
42: }
43: }
|