1 37 38 39 40 41 package com.lutris.appserver.debugger.presentation; 42 43 import java.io.ObjectOutputStream ; 44 import com.lutris.appserver.server.*; 45 import com.lutris.appserver.server.httpPresentation.*; 46 import com.lutris.appserver.debugger.Debugger; 47 48 import com.lutris.appserver.debugger.spec.*; 49 50 51 52 public class DebugServer implements HttpPresentation { 53 54 55 public void run(HttpPresentationComms comms) throws Exception { 56 57 58 59 60 61 String action = comms.request.getParameter("action"); 62 if ((action == null) || (action.length() == 0)) 63 return; 64 if(action.equals("getSnapshot")) 65 { 66 sendSnapshot(comms); 67 return; 68 } 69 if(action.equals("start")) 70 { 71 startDebugging(comms); 72 return; 73 } 74 if(action.equals("stop")) 75 { 76 stopDebugging(comms); 77 return; 78 } else 79 { 80 return; 81 } 82 } 83 84 85 private void sendSnapshot(HttpPresentationComms comms) throws Exception { 86 long id = -1; 87 88 89 try { 90 String ids = comms.request.getParameter("id"); 91 id = Long.parseLong(ids); 92 } catch (Exception e) { 93 } 94 95 int wait = 0; 96 try { 97 String waitStr = comms.request.getParameter("wait"); 98 wait = Integer.parseInt(waitStr); 99 } catch (Exception e) { 100 } 101 ServletMonitor sm=ServletMonitorFactory.getServletMonitor("com.lutris.appserver.debugger.business.ServletMonitorImpl"); 102 103 sm.takeSnapshotAndWrite(comms,id, wait); 104 105 106 107 108 } 109 110 private void startDebugging(HttpPresentationComms comms) throws Exception { 111 112 113 114 115 String response = "ERR"; 116 String name = comms.request.getParameter("name"); 117 if (name != null) { 118 ServletMonitor sm=ServletMonitorFactory.getServletMonitor("com.lutris.appserver.debugger.business.ServletMonitorImpl"); 119 120 boolean ok = sm.start(name); 121 if (ok) 122 response = "OK"; 123 } 124 125 126 comms.response.setContentType("text/ascii"); 127 comms.response.setContentLength(response.length()); 128 comms.response.getOutputStream().println(response); 129 130 131 } 132 133 private void stopDebugging(HttpPresentationComms comms) throws Exception { 134 String response = "ERR"; 135 String name = comms.request.getParameter("name"); 136 if (name != null) { 137 ServletMonitor sm=ServletMonitorFactory.getServletMonitor("com.lutris.appserver.debugger.business.ServletMonitorImpl"); 138 139 boolean ok = sm.stop(name); 140 if (ok) 141 response = "OK"; 142 } 143 comms.response.setContentType("text/ascii"); 144 comms.response.setContentLength(response.length()); 145 comms.response.getOutputStream().println(response); 146 } 147 148 149 } 150 | Popular Tags |