1 17 18 19 package org.apache.geronimo.jetty6.handler; 20 21 import java.io.IOException ; 22 23 import javax.naming.Context ; 24 import javax.servlet.ServletException ; 25 import javax.servlet.http.HttpServletRequest ; 26 import javax.servlet.http.HttpServletResponse ; 27 28 import org.apache.geronimo.naming.java.RootContext; 29 import org.mortbay.jetty.handler.AbstractHandler; 30 31 34 public class ComponentContextHandler extends AbstractImmutableHandler { 35 36 private final Context componentContext; 37 38 public ComponentContextHandler(AbstractHandler next, Context componentContext) { 39 super(next); 40 this.componentContext = componentContext; 41 } 42 43 public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException , ServletException { 44 Context oldContext = RootContext.getComponentContext(); 45 try { 46 RootContext.setComponentContext(componentContext); 47 next.handle(target, request, response, dispatch); 48 } finally { 49 RootContext.setComponentContext(oldContext); 50 } 51 } 52 53 public void lifecycleCommand(LifecycleCommand lifecycleCommand) throws Exception { 54 Context oldContext = RootContext.getComponentContext(); 55 try { 56 RootContext.setComponentContext(componentContext); 57 super.lifecycleCommand(lifecycleCommand); 58 } finally { 59 RootContext.setComponentContext(oldContext); 60 } 61 } 62 } 63 | Popular Tags |