1 16 17 package org.springframework.mock.web; 18 19 import java.io.IOException ; 20 21 import javax.servlet.Filter ; 22 import javax.servlet.FilterChain ; 23 import javax.servlet.Servlet ; 24 import javax.servlet.ServletException ; 25 import javax.servlet.ServletRequest ; 26 import javax.servlet.ServletResponse ; 27 28 import org.springframework.util.Assert; 29 30 42 public class PassThroughFilterChain implements FilterChain { 43 44 private Filter filter; 45 46 private FilterChain nextFilterChain; 47 48 private Servlet servlet; 49 50 51 57 public PassThroughFilterChain(Filter filter, FilterChain nextFilterChain) { 58 Assert.notNull(filter, "Filter must not be null"); 59 Assert.notNull(nextFilterChain, "'FilterChain must not be null"); 60 this.filter = filter; 61 this.nextFilterChain = nextFilterChain; 62 } 63 64 68 public PassThroughFilterChain(Servlet servlet) { 69 Assert.notNull(servlet, "Servlet must not be null"); 70 this.servlet = servlet; 71 } 72 73 74 77 public void doFilter(ServletRequest request, ServletResponse response) throws ServletException , IOException { 78 if (this.filter != null) { 79 this.filter.doFilter(request, response, this.nextFilterChain); 80 } 81 else { 82 this.servlet.service(request, response); 83 } 84 } 85 86 } 87 | Popular Tags |