1 17 18 package org.apache.geronimo.jetty6; 19 20 import java.io.IOException ; 21 22 import javax.servlet.ServletException ; 23 import javax.servlet.http.HttpServletRequest ; 24 import javax.servlet.http.HttpServletResponse ; 25 26 import org.mortbay.jetty.servlet.ServletHandler; 27 28 31 public class JettyServletHandler extends ServletHandler { 32 33 private final PreHandler chainedHandler; 34 35 public JettyServletHandler(PreHandler chainedHandler) { 36 if (null == chainedHandler) { 37 chainedHandler = new NoOpChainedHandler(); 38 } 39 this.chainedHandler = chainedHandler; 40 chainedHandler.setNextHandler(new ActualJettyServletHandler()); 41 } 42 43 @Override 44 public void handle(String target, HttpServletRequest request,HttpServletResponse response, int type) 45 throws IOException { 46 try { 47 chainedHandler.handle(target, request, response, type); 48 } catch (ServletException e) { 49 throw (IOException ) new IOException ().initCause(e); 50 } 51 } 52 53 protected void doHandle(String target, HttpServletRequest request, HttpServletResponse response, int type) 54 throws IOException , ServletException { 55 super.handle(target, request, response, type); 56 } 57 58 private class ActualJettyServletHandler extends AbstractPreHandler { 59 60 public void handle(String target, HttpServletRequest request, HttpServletResponse response, int type) 61 throws IOException , ServletException { 62 doHandle(target, request, response, type); 63 } 64 } 65 66 private static class NoOpChainedHandler extends AbstractPreHandler { 67 68 public void handle(String target, HttpServletRequest request, HttpServletResponse response, int type) 69 throws IOException , ServletException { 70 next.handle(target, request, response, type); 71 } 72 } 73 74 } 75 | Popular Tags |