Changeset 1991 for trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/ExchangeListener.java
- Timestamp:
- 07/08/15 09:03:46 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/ExchangeListener.java
r1561 r1991 27 27 28 28 import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorExchangeHandler; 29 import de.ugoe.cs.autoquest.httpmonitor.IdGenerator; 29 30 import de.ugoe.cs.autoquest.plugin.http.logdata.Address; 30 31 import de.ugoe.cs.autoquest.plugin.http.logdata.Content; … … 46 47 * recording an exchange can not be done in one step. This is due to the fact, that the proxy 47 48 * servlet notifies different processing states for requests and response. An exchange listener 48 * records all these event. On the occurrence of the final event, it compiles an 49 * {@link HttpExchange} and forwards it to the exchange handler. 49 * records all these events. On the occurrence of the final event, it compiles an 50 * {@link HttpExchange} and forwards it to the exchange handler. When receiving the first event 51 * of the request, it also determines a respective ordering id. The same applies for the response. 52 * The ordering ids are retrieved from a provided id generator. 50 53 * </p> 51 54 * … … 63 66 /** 64 67 * <p> 68 * the id generator used to generate ordering ids for requests and responses 69 * </p> 70 */ 71 private IdGenerator idGenerator; 72 73 /** 74 * <p> 65 75 * the request of compiled exchange 66 76 * </p> 67 77 */ 68 78 private HttpServletRequest request; 79 80 /** 81 * <p> 82 * the ordering id for the request 83 * </p> 84 */ 85 private long requestOrderingId; 69 86 70 87 /** … … 81 98 */ 82 99 private HttpServletResponse response; 100 101 /** 102 * <p> 103 * the ordering id for the response 104 * </p> 105 */ 106 private long responseOrderingId; 83 107 84 108 /** … … 99 123 * <p> 100 124 * initialized the exchange listener with the exchange handler to forward compiled exchanges to 125 * and the id generator to be used for generating ordering ids for requests and responses 101 126 * </p> 102 127 * 103 128 * @param exchangeHandler the exchange handler to forward compiled exchanges to 104 */ 105 ExchangeListener(HttpMonitorExchangeHandler exchangeHandler) { 129 * @param idGenerator the id generator to used for generating ordering ids 130 */ 131 ExchangeListener(HttpMonitorExchangeHandler exchangeHandler, IdGenerator idGenerator) { 106 132 this.exchangeHandler = exchangeHandler; 133 this.idGenerator = idGenerator; 107 134 } 108 135 … … 123 150 lastUpdate = System.currentTimeMillis(); 124 151 this.request = request; 152 this.requestOrderingId = idGenerator.getNextId(); 125 153 } 126 154 … … 159 187 lastUpdate = System.currentTimeMillis(); 160 188 this.response = response; 189 this.responseOrderingId = idGenerator.getNextId(); 161 190 } 162 191 … … 239 268 exchange.setReceiver(address); 240 269 241 exchange.setRequest(map(request, eventObjectFactory));242 exchange.setResponse(map(response, eventObjectFactory));270 exchange.setRequest(map(request, requestOrderingId, eventObjectFactory)); 271 exchange.setResponse(map(response, responseOrderingId, eventObjectFactory)); 243 272 244 273 exchangeHandler.handleHttpExchange(exchange); … … 250 279 * </p> 251 280 */ 252 private HttpRequest map(HttpServletRequest request, ObjectFactory eventObjectFactory) { 281 private HttpRequest map(HttpServletRequest request, 282 long requestOrderingId, 283 ObjectFactory eventObjectFactory) 284 { 253 285 HttpRequest eventRequest = eventObjectFactory.createHttpRequest(); 286 eventRequest.setOrderingId(requestOrderingId); 254 287 eventRequest.setMethod(Method.fromValue(request.getMethod())); 255 288 eventRequest.setProtocol(Protocol.fromValue(request.getProtocol())); … … 311 344 * </p> 312 345 */ 313 private HttpResponse map(HttpServletResponse response, ObjectFactory eventObjectFactory) { 346 private HttpResponse map(HttpServletResponse response, 347 long responseOrderingId, 348 ObjectFactory eventObjectFactory) 349 { 314 350 HttpResponse eventResponse = eventObjectFactory.createHttpResponse(); 315 351 316 352 eventResponse.setStatus(BigInteger.valueOf(response.getStatus())); 353 eventResponse.setOrderingId(responseOrderingId); 317 354 318 355 Headers headers = eventObjectFactory.createHeaders();
Note: See TracChangeset
for help on using the changeset viewer.