- Timestamp:
- 10/15/12 14:53:44 (12 years ago)
- Location:
- trunk/autoquest-htmlmonitor
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-htmlmonitor
-
Property
svn:ignore
set to
target
-
Property
svn:ignore
set to
-
trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlMonitorServer.java
r874 r879 9 9 /** 10 10 * <p> 11 * this is the web server, that receives the client messages. It is initialized with a port on 12 * which it shall listen, as well as a message listener to forward the received messages to. 13 * Internally it starts a jetty web server with a single {@link HtmlMonitorServlet} to receive 14 * the messages. 11 * this is the web server, that receives the client messages. It also provides the java script 12 * that is used by the client via the URL /script/autoquest-htmlmonitor.js. It is initialized 13 * with a port on which it shall listen, as well as a message listener to forward the received 14 * messages to. Internally it starts a jetty web server with a single {@link HtmlMonitorServlet} 15 * to receive the messages as well as a . 15 16 * </p> 16 17 * -
trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlMonitorServlet.java
r873 r879 1 1 package de.ugoe.cs.autoquest.htmlmonitor; 2 2 3 import java.io.BufferedReader; 3 4 import java.io.IOException; 5 import java.io.InputStream; 4 6 import java.io.InputStreamReader; 7 import java.io.PrintWriter; 5 8 import java.net.MalformedURLException; 6 9 import java.net.URL; … … 24 27 /** 25 28 * <p> 26 * the servlet deployed in the web server that receives all client messages. The messages are 27 * parsed, validated, and forwarded to the provided message listener. If a message is not valid, 28 * it is discarded. If an event in a message is not valid, it is discarded. Messages are only 29 * received via the POST HTTP method. 29 * the servlet deployed in the web server that receives all client messages and returns the client 30 * java script. The messages are parsed, validated, and forwarded to the provided message listener. 31 * If a message is not valid, it is discarded. If an event in a message is not valid, it is 32 * discarded. Messages are only received via the POST HTTP method. The GET HTTP method is only 33 * implemented for returning the client java script. 30 34 * </p> 31 35 * … … 37 41 private static final long serialVersionUID = 1L; 38 42 43 /** */ 44 private static final boolean DO_TRACE = false; 45 39 46 /** 40 47 * the message listener to forward received messages to. … … 51 58 HtmlMonitorServlet(HtmlMonitorMessageListener messageListener) { 52 59 this.messageListener = messageListener; 60 } 61 62 /* (non-Javadoc) 63 * @see org.mortbay.jetty.servlet.DefaultServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 64 */ 65 @Override 66 protected void doGet(HttpServletRequest request, HttpServletResponse response) 67 throws ServletException, IOException 68 { 69 if ((request.getPathInfo() != null) && 70 (request.getPathInfo().endsWith("/script/autoquest-htmlmonitor.js"))) 71 { 72 InputStream script = null; 73 74 try { 75 script = this.getClass().getClassLoader().getResourceAsStream 76 ("autoquest-htmlmonitor.js"); 77 78 if (script == null) { 79 Console.printerrln("could not read autoquest-htmlmonitor.js from classpath"); 80 } 81 else { 82 BufferedReader reader = new BufferedReader(new InputStreamReader(script)); 83 PrintWriter output = response.getWriter(); 84 String line; 85 86 while ((line = reader.readLine()) != null) { 87 output.println(line); 88 } 89 90 output.close(); 91 } 92 } 93 catch (Exception e) { 94 Console.printerrln("could not read autoquest-htmlmonitor.js from classpath: " + e); 95 Console.logException(e); 96 } 97 finally { 98 if (script != null) { 99 script.close(); 100 } 101 } 102 } 53 103 } 54 104 … … 87 137 */ 88 138 private void handleJSONObject(JSONObject object) { 89 dumpJSONObject(object, ""); 139 if (DO_TRACE) { 140 dumpJSONObject(object, ""); 141 } 90 142 91 143 JSONObject message = assertValue(object, "message", JSONObject.class);
Note: See TracChangeset
for help on using the changeset viewer.