1 17 package org.apache.geronimo.jetty.interceptor; 18 19 import javax.naming.Context ; 20 21 import org.apache.geronimo.naming.java.RootContext; 22 import org.mortbay.http.HttpRequest; 23 import org.mortbay.http.HttpResponse; 24 25 28 public class ComponentContextBeforeAfter implements BeforeAfter { 29 30 private final BeforeAfter next; 31 private final int index; 32 private final Context componentContext; 33 34 public ComponentContextBeforeAfter(BeforeAfter next, int index, Context componentContext) { 35 this.next = next; 36 this.index = index; 37 this.componentContext = componentContext; 38 } 39 40 public void before(Object [] context, HttpRequest httpRequest, HttpResponse httpResponse) { 41 context[index] = RootContext.getComponentContext(); 42 RootContext.setComponentContext(componentContext); 43 if (next != null) { 44 next.before(context, httpRequest, httpResponse); 45 } 46 } 47 48 public void after(Object [] context, HttpRequest httpRequest, HttpResponse httpResponse) { 49 if (next != null) { 50 next.after(context, httpRequest, httpResponse); 51 } 52 RootContext.setComponentContext((Context ) context[index]); 53 } 54 55 } 56 | Popular Tags |