RequestContextFilter.java :  » Portal » stringbeans-3.5 » com » nabhinc » ws » server » Java Open Source

Java Open Source » Portal » stringbeans 3.5 
stringbeans 3.5 » com » nabhinc » ws » server » RequestContextFilter.java
package com.nabhinc.ws.server;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RequestContextFilter implements Filter {

  public void init(FilterConfig arg0) throws ServletException {
    // No initialization needed

  }

  public void doFilter(ServletRequest req, ServletResponse res,
      FilterChain arg2) throws IOException, ServletException {
    // Attach request context to this thread
    try {
      RequestContext reqContext = new RequestContext((HttpServletRequest) req, (HttpServletResponse) res);
      Current.attachRequestContext(reqContext);
      arg2.doFilter(req, res);
    } finally {
      Current.detachRequestContext();
    }
  }

  public void destroy() {
    // Nothing special needs to be done here

  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.