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.http.HttpContext; 22 import org.apache.geronimo.jetty.JettyWebAppContext; 23 24 27 public class WebApplicationContextBeforeAfter implements BeforeAfter { 28 29 private final BeforeAfter next; 30 private final int index; 31 private final JettyWebAppContext webAppContext; 32 33 public WebApplicationContextBeforeAfter(BeforeAfter next, int index, JettyWebAppContext webAppContext) { 34 this.next = next; 35 this.index = index; 36 this.webAppContext = webAppContext; 37 } 38 39 public void before(Object [] context, HttpRequest httpRequest, HttpResponse httpResponse) { 40 if (httpResponse != null) { 41 context[index] = httpResponse.getHttpContext(); 42 httpResponse.setHttpContext(webAppContext); 43 } 44 if (next != null) { 45 next.before(context, httpRequest, httpResponse); 46 } 47 } 48 49 public void after(Object [] context, HttpRequest httpRequest, HttpResponse httpResponse) { 50 if (next != null) { 51 next.after(context, httpRequest, httpResponse); 52 } 53 if (httpResponse != null) { 54 httpResponse.setHttpContext((HttpContext) context[index]); 55 } 56 } 57 } 58 | Popular Tags |