Ignore:
Timestamp:
07/08/15 09:03:46 (9 years ago)
Author:
pharms
Message:
  • added ordering id for requests and responses
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/ExchangeListener.java

    r1561 r1991  
    2727 
    2828import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorExchangeHandler; 
     29import de.ugoe.cs.autoquest.httpmonitor.IdGenerator; 
    2930import de.ugoe.cs.autoquest.plugin.http.logdata.Address; 
    3031import de.ugoe.cs.autoquest.plugin.http.logdata.Content; 
     
    4647 * recording an exchange can not be done in one step. This is due to the fact, that the proxy 
    4748 * 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. 
    5053 * </p> 
    5154 *  
     
    6366    /** 
    6467     * <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> 
    6575     * the request of compiled exchange 
    6676     * </p> 
    6777     */ 
    6878    private HttpServletRequest request; 
     79     
     80    /** 
     81     * <p> 
     82     * the ordering id for the request 
     83     * </p> 
     84     */ 
     85    private long requestOrderingId; 
    6986 
    7087    /** 
     
    8198     */ 
    8299    private HttpServletResponse response; 
     100     
     101    /** 
     102     * <p> 
     103     * the ordering id for the response 
     104     * </p> 
     105     */ 
     106    private long responseOrderingId; 
    83107 
    84108    /** 
     
    99123     * <p> 
    100124     * 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 
    101126     * </p> 
    102127     *  
    103128     * @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) { 
    106132        this.exchangeHandler = exchangeHandler; 
     133        this.idGenerator = idGenerator; 
    107134    } 
    108135 
     
    123150        lastUpdate = System.currentTimeMillis(); 
    124151        this.request = request; 
     152        this.requestOrderingId = idGenerator.getNextId(); 
    125153    } 
    126154 
     
    159187        lastUpdate = System.currentTimeMillis(); 
    160188        this.response = response; 
     189        this.responseOrderingId = idGenerator.getNextId(); 
    161190    } 
    162191     
     
    239268        exchange.setReceiver(address); 
    240269         
    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)); 
    243272         
    244273        exchangeHandler.handleHttpExchange(exchange); 
     
    250279     * </p> 
    251280     */ 
    252     private HttpRequest map(HttpServletRequest request, ObjectFactory eventObjectFactory) { 
     281    private HttpRequest map(HttpServletRequest request, 
     282                            long               requestOrderingId, 
     283                            ObjectFactory      eventObjectFactory) 
     284    { 
    253285        HttpRequest eventRequest = eventObjectFactory.createHttpRequest(); 
     286        eventRequest.setOrderingId(requestOrderingId); 
    254287        eventRequest.setMethod(Method.fromValue(request.getMethod())); 
    255288        eventRequest.setProtocol(Protocol.fromValue(request.getProtocol())); 
     
    311344     * </p> 
    312345     */ 
    313     private HttpResponse map(HttpServletResponse response, ObjectFactory eventObjectFactory) { 
     346    private HttpResponse map(HttpServletResponse response, 
     347                             long                responseOrderingId, 
     348                             ObjectFactory       eventObjectFactory) 
     349    { 
    314350        HttpResponse eventResponse = eventObjectFactory.createHttpResponse(); 
    315351         
    316352        eventResponse.setStatus(BigInteger.valueOf(response.getStatus())); 
     353        eventResponse.setOrderingId(responseOrderingId); 
    317354 
    318355        Headers headers = eventObjectFactory.createHeaders(); 
Note: See TracChangeset for help on using the changeset viewer.