1 17 package org.apache.servicemix.http; 18 19 import java.io.IOException ; 20 21 import javax.servlet.ServletConfig ; 22 import javax.servlet.ServletException ; 23 import javax.servlet.http.HttpServlet ; 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.http.HttpServletResponse ; 26 27 public class HttpBridgeServlet extends HttpServlet { 28 29 32 private static final long serialVersionUID = -7995806514300732777L; 33 34 private HttpProcessor processor; 35 36 public HttpProcessor getProcessor() { 37 return processor; 38 } 39 40 public void setProcessor(HttpProcessor processor) { 41 this.processor = processor; 42 } 43 44 public void init(ServletConfig config) throws ServletException { 45 super.init(config); 46 if (processor == null) { 47 processor = (HttpProcessor) getServletContext().getAttribute("processor"); 48 if (processor == null) { 49 throw new ServletException ("No binding property available on the servlet context"); 50 } 51 } 52 } 53 54 55 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException , IOException { 56 try { 57 getProcessor().process(request, response); 58 } catch (IOException e) { 59 throw e; 60 } catch (ServletException e) { 61 throw e; 62 } catch (RuntimeException e) { 63 throw e; 64 } catch (Exception e) { 65 throw new ServletException ("Failed to process request: " + e, e); 66 } 67 } 68 69 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException , IOException { 70 try { 71 getProcessor().process(request, response); 72 } catch (IOException e) { 73 throw e; 74 } catch (ServletException e) { 75 throw e; 76 } catch (RuntimeException e) { 77 throw e; 78 } catch (Exception e) { 79 throw new ServletException ("Failed to process request: " + e, e); 80 } 81 } 82 83 } 84 | Popular Tags |