1 17 package org.apache.geronimo.jetty.interceptor; 18 19 import org.mortbay.http.HttpRequest; 20 import org.mortbay.http.HttpResponse; 21 import org.mortbay.jetty.servlet.ServletHandler; 22 import org.mortbay.jetty.servlet.ServletHttpRequest; 23 import org.mortbay.jetty.servlet.ServletHttpResponse; 24 25 28 public class RequestWrappingBeforeAfter implements BeforeAfter { 29 private final BeforeAfter next; 30 private final ServletHandler handler; 31 32 public RequestWrappingBeforeAfter(BeforeAfter next, ServletHandler handler) { 33 this.next = next; 34 this.handler = handler; 35 } 36 37 public void before(Object [] context, HttpRequest httpRequest, HttpResponse httpResponse) { 38 if (httpRequest != null) { 39 ServletHttpRequest request = (ServletHttpRequest) httpRequest.getWrapper(); 40 if (request == null) 41 { 42 request = new ServletHttpRequest(handler, null, httpRequest); 44 ServletHttpResponse response = new ServletHttpResponse(request, httpResponse); 45 httpRequest.setWrapper(request); 46 httpResponse.setWrapper(response); 47 } 48 } 49 next.before(context, httpRequest, httpResponse); 50 } 51 52 public void after(Object [] context, HttpRequest httpRequest, HttpResponse httpResponse) { 53 next.after(context, httpRequest, httpResponse); 54 } 55 } 56 | Popular Tags |