KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > servlets > responders > ResponderSOAPINFO


1 /******************************************************************************
2  * ResponderSOAPINFO.java
3  * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

9
10 package org.openlaszlo.servlets.responders;
11
12 import java.io.*;
13 import javax.servlet.http.HttpServletRequest JavaDoc;
14 import javax.servlet.http.HttpServletResponse JavaDoc;
15 import javax.servlet.ServletOutputStream JavaDoc;
16 import org.openlaszlo.data.SOAPDataSource;
17 import org.openlaszlo.utils.FileUtils;
18 import org.apache.log4j.Logger;
19
20 public final class ResponderSOAPINFO extends ResponderAdmin
21 {
22     private static Logger mLogger = Logger.getLogger(ResponderSOAPINFO.class);
23
24     boolean ok(String JavaDoc opt) {
25         return opt != null && opt.equals("1");
26     }
27
28     /**
29      * If "service" param exists, returns service information. An url encoded
30      * name for the service is included in the standard XML lzt=soapinfo under
31      * <service name="NAME" urlname="URL_ENCODED_NAME" />.
32      */

33     protected void respondAdmin(HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res)
34         throws IOException {
35         res.setContentType ("text/xml");
36         ServletOutputStream JavaDoc out = res.getOutputStream();
37         try {
38             if (ok(req.getParameter("clear"))) {
39                 SOAPDataSource.clearLoadInfo();
40             }
41             String JavaDoc service = req.getParameter("service");
42             StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
43             if (service != null && ! service.equals("")) {
44                 SOAPDataSource.serviceXML(sb, service);
45             } else {
46                 SOAPDataSource.toXML(sb);
47             }
48             out.println(sb.toString());
49         } finally {
50             FileUtils.close(out);
51         }
52     }
53
54     public int getMimeType()
55     {
56         return MIME_TYPE_XML;
57     }
58 }
59
Popular Tags