1 28 29 package com.caucho.server.dispatch; 30 31 import javax.servlet.FilterChain ; 32 import javax.servlet.ServletException ; 33 import javax.servlet.ServletRequest ; 34 import javax.servlet.ServletResponse ; 35 import java.io.IOException ; 36 37 41 public class ClassLoaderFilterChain implements FilterChain { 42 private final ClassLoader _loader; 44 private final FilterChain _next; 45 46 52 public ClassLoaderFilterChain(FilterChain next, ClassLoader loader) 53 { 54 _next = next; 55 _loader = loader; 56 } 57 58 66 public void doFilter(ServletRequest request, 67 ServletResponse response) 68 throws ServletException , IOException 69 { 70 Thread thread = Thread.currentThread(); 71 ClassLoader oldLoader = thread.getContextClassLoader(); 72 73 try { 74 thread.setContextClassLoader(_loader); 75 76 _next.doFilter(request, response); 77 } finally { 78 thread.setContextClassLoader(oldLoader); 79 } 80 } 81 } 82 | Popular Tags |