Ignore:
Timestamp:
02/13/14 11:28:18 (10 years ago)
Author:
pharms
Message:
File:
1 edited

Legend:

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

    r1374 r1382  
    3434/** 
    3535 * <p> 
    36  * TODO document 
    37  * the servlet deployed in the web server that receives all client messages and returns the client 
    38  * 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 is 
    40  * discarded. Messages are only received via the POST HTTP method. The GET HTTP method is only 
    41  * 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. 
    4242 * </p> 
    4343 *  
     
    4949    private static final long serialVersionUID = 1L; 
    5050 
    51     /** */ 
     51    /** 
     52     * the proxied server 
     53     */ 
    5254    private String proxiedServer; 
    5355     
    54     /** */ 
     56    /** 
     57     * the port of the proxied server 
     58     */ 
    5559    private int proxiedPort; 
    5660 
    57     /** */ 
     61    /** 
     62     * the exchange listener to handle the different events happening when an exchange is proxied 
     63     */ 
    5864    private ExchangeListenerManager exchangeListenerManager; 
    5965     
    6066    /** 
    6167     * <p> 
    62      * initializes the servlet with the message listener to which all events shall be forwarded 
     68     * initializes the servlet with the proxied server and the exchange listener 
    6369     * </p> 
    6470     * 
    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 
    6675     */ 
    6776    HttpMonitoringProxyServlet(String                  proxiedServer, 
     
    7584 
    7685    /* (non-Javadoc) 
    77      * @see org.eclipse.jetty.proxy.ProxyServlet#rewriteURI(javax.servlet.http.HttpServletRequest) 
     86     * @see org.eclipse.jetty.proxy.ProxyServlet#rewriteURI(HttpServletRequest) 
    7887     */ 
    7988    @Override 
     
    91100 
    92101    /* (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) 
    94103     */ 
    95104    @Override 
     
    102111 
    103112    /* (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) 
    105114     */ 
    106115    @Override 
     
    119128 
    120129    /* (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) 
    122131     */ 
    123132    @Override 
     
    133142 
    134143    /* (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) 
    136145     */ 
    137146    @Override 
     
    148157 
    149158    /** 
    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. 
    151162     */ 
    152163    private class DubbingContentProvider implements ContentProvider { 
    153164 
    154         /** */ 
     165        /** 
     166         * the dubbed request 
     167         */ 
    155168        private HttpServletRequest request; 
    156169         
    157         /** */ 
     170        /** 
     171         * the original content provider of which the data is copied  
     172         */ 
    158173        private ContentProvider delegate; 
    159174 
    160175        /** 
    161          * 
     176         * initializes this content provider with the copied request and the delegate. 
    162177         */ 
    163178        public DubbingContentProvider(HttpServletRequest request, ContentProvider delegate) { 
     
    185200 
    186201    /** 
    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. 
    188205     */ 
    189206    public class DubbingByteBufferIterator implements Iterator<ByteBuffer> { 
    190207 
    191         /** */ 
     208        /** 
     209         * the dubbed request 
     210         */ 
    192211        private HttpServletRequest request; 
    193212         
    194         /** */ 
     213        /** 
     214         * the original iterator of which the data is copied  
     215         */ 
    195216        private Iterator<ByteBuffer> delegate; 
    196217         
    197218        /** 
    198          * 
     219         * initializes this iterator with the copied request and the delegate. 
    199220         */ 
    200221        public DubbingByteBufferIterator(HttpServletRequest request, Iterator<ByteBuffer> delegate) { 
Note: See TracChangeset for help on using the changeset viewer.