Changeset 1382 for trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitoringProxyServlet.java
- Timestamp:
- 02/13/14 11:28:18 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitoringProxyServlet.java
r1374 r1382 34 34 /** 35 35 * <p> 36 * TODO document37 * the servlet deployed in the web server that receives all client messages and returns the client38 * java script. The messages are parsed, validated, and forwarded to the provided message listener.39 * If a message is not valid, it is discarded. If an event in a message is not valid, it is40 * discarded. Messages are only received via the POST HTTP method. The GET HTTP method is only41 * implemented for returning the client java script.36 * the servlet deployed in the web server of the proxy that proxies all incoming messages and 37 * forwards a copy of recorded exchanges to the exchange listener manager. It is based on the 38 * proxy servlet provided by jetty. It extends the servlet and implements all hooks required to 39 * get access to the exchanged requests and responses. Each hook forwards the tracked data to the 40 * exchange listener. On exchange completion, the exchange listener ensures a logging of the 41 * recorded exchange. 42 42 * </p> 43 43 * … … 49 49 private static final long serialVersionUID = 1L; 50 50 51 /** */ 51 /** 52 * the proxied server 53 */ 52 54 private String proxiedServer; 53 55 54 /** */ 56 /** 57 * the port of the proxied server 58 */ 55 59 private int proxiedPort; 56 60 57 /** */ 61 /** 62 * the exchange listener to handle the different events happening when an exchange is proxied 63 */ 58 64 private ExchangeListenerManager exchangeListenerManager; 59 65 60 66 /** 61 67 * <p> 62 * initializes the servlet with the message listener to which all events shall be forwarded68 * initializes the servlet with the proxied server and the exchange listener 63 69 * </p> 64 70 * 65 * @param messageListener the message listener that shall receive all client events 71 * @param proxiedServer the proxied server 72 * @param proxiedPort the port of the proxied server 73 * @param exchangeListenerManager the exchange listener to handle the different events 74 * happening when an exchange is proxied 66 75 */ 67 76 HttpMonitoringProxyServlet(String proxiedServer, … … 75 84 76 85 /* (non-Javadoc) 77 * @see org.eclipse.jetty.proxy.ProxyServlet#rewriteURI( javax.servlet.http.HttpServletRequest)86 * @see org.eclipse.jetty.proxy.ProxyServlet#rewriteURI(HttpServletRequest) 78 87 */ 79 88 @Override … … 91 100 92 101 /* (non-Javadoc) 93 * @see org.eclipse.jetty.proxy.ProxyServlet#customizeProxyRequest( org.eclipse.jetty.client.api.Request, javax.servlet.http.HttpServletRequest)102 * @see org.eclipse.jetty.proxy.ProxyServlet#customizeProxyRequest(Request, HttpServletRequest) 94 103 */ 95 104 @Override … … 102 111 103 112 /* (non-Javadoc) 104 * @see org.eclipse.jetty.proxy.ProxyServlet#onResponseContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.eclipse.jetty.client.api.Response, byte[], int, int)113 * @see ProxyServlet#onResponseContent(HttpServletRequest, HttpServletResponse, Response, byte[], int, int) 105 114 */ 106 115 @Override … … 119 128 120 129 /* (non-Javadoc) 121 * @see org.eclipse.jetty.proxy.ProxyServlet#onResponseSuccess(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.eclipse.jetty.client.api.Response)130 * @see ProxyServlet#onResponseSuccess(HttpServletRequest, HttpServletResponse, Response) 122 131 */ 123 132 @Override … … 133 142 134 143 /* (non-Javadoc) 135 * @see org.eclipse.jetty.proxy.ProxyServlet#onResponseFailure(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.eclipse.jetty.client.api.Response, java.lang.Throwable)144 * @see ProxyServlet#onResponseFailure(HttpServletRequest, HttpServletResponse, Response, Throwable) 136 145 */ 137 146 @Override … … 148 157 149 158 /** 150 * 159 * This content provided is required to copy the content of a proxied request. It uses 160 * delegation to wrap the original content provided but to also copy the data and forward 161 * it to the exchange listener manager. 151 162 */ 152 163 private class DubbingContentProvider implements ContentProvider { 153 164 154 /** */ 165 /** 166 * the dubbed request 167 */ 155 168 private HttpServletRequest request; 156 169 157 /** */ 170 /** 171 * the original content provider of which the data is copied 172 */ 158 173 private ContentProvider delegate; 159 174 160 175 /** 161 * 176 * initializes this content provider with the copied request and the delegate. 162 177 */ 163 178 public DubbingContentProvider(HttpServletRequest request, ContentProvider delegate) { … … 185 200 186 201 /** 187 * 202 * This iterator is used to implement the {@link DubbingContentProvider}. It works in the 203 * same manner and uses delegation for wrapping the original iterator and forwards all copied 204 * data to the exchange listener manager. 188 205 */ 189 206 public class DubbingByteBufferIterator implements Iterator<ByteBuffer> { 190 207 191 /** */ 208 /** 209 * the dubbed request 210 */ 192 211 private HttpServletRequest request; 193 212 194 /** */ 213 /** 214 * the original iterator of which the data is copied 215 */ 195 216 private Iterator<ByteBuffer> delegate; 196 217 197 218 /** 198 * 219 * initializes this iterator with the copied request and the delegate. 199 220 */ 200 221 public DubbingByteBufferIterator(HttpServletRequest request, Iterator<ByteBuffer> delegate) {
Note: See TracChangeset
for help on using the changeset viewer.