1 28 29 package com.caucho.server.dispatch; 30 31 import com.caucho.soa.servlet.ProtocolServlet; 32 33 import javax.servlet.FilterChain ; 34 import javax.servlet.ServletException ; 35 import javax.servlet.ServletRequest ; 36 import javax.servlet.ServletResponse ; 37 import javax.servlet.UnavailableException ; 38 import java.io.IOException ; 39 import java.util.HashMap ; 40 41 44 public class WebServiceFilterChain implements FilterChain { 45 public static final String SERVLET_NAME 46 = "javax.servlet.error.servlet_name"; 47 48 private ServletConfigImpl _config; 50 51 private ProtocolServlet _skeleton; 53 54 59 public WebServiceFilterChain(ServletConfigImpl config) 60 { 61 if (config == null) 62 throw new NullPointerException (); 63 64 _config = config; 65 } 66 67 70 public String getServletName() 71 { 72 return _config.getServletName(); 73 } 74 75 78 public HashMap <String ,String > getRoleMap() 79 { 80 return _config.getRoleMap(); 81 } 82 83 91 public void doFilter(ServletRequest request, 92 ServletResponse response) 93 throws ServletException , IOException 94 { 95 if (_skeleton == null) { 96 try { 97 _skeleton = _config.createWebServiceSkeleton(); 98 } catch (ServletException e) { 99 throw e; 100 } catch (RuntimeException e) { 101 throw e; 102 } catch (Exception e) { 103 throw new ServletException (e); 104 } 105 } 106 107 try { 108 _skeleton.service(request, response); 109 } catch (UnavailableException e) { 110 _skeleton = null; 111 _config.setInitException(e); 112 _config.killServlet(); 113 request.setAttribute(SERVLET_NAME, _config.getServletName()); 114 throw e; 115 } catch (ServletException e) { 116 request.setAttribute(SERVLET_NAME, _config.getServletName()); 117 throw e; 118 } catch (IOException e) { 119 request.setAttribute(SERVLET_NAME, _config.getServletName()); 120 throw e; 121 } catch (RuntimeException e) { 122 request.setAttribute(SERVLET_NAME, _config.getServletName()); 123 throw e; 124 } catch (Throwable e) { 125 request.setAttribute(SERVLET_NAME, _config.getServletName()); 126 throw new ServletException (e); 127 } 128 } 129 } 130 | Popular Tags |