/*
* Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* bstefanescu
*/
package org.eclipse.ecr.web.jaxrs.context;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.ecr.web.jaxrs.HttpFilter;
/**
* Manage the context of the current HTTP request and made it available through a thread local variable
* to web components that are invoked inside the request.
*
* @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
*
*/
public class RequestContextFilter extends HttpFilter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void run(HttpServletRequest request, HttpServletResponse response,
FilterChain chain) throws IOException, ServletException {
RequestContext ctx = new RequestContext(request, response);
try {
chain.doFilter(request, response);
} finally {
ctx.dispose();
}
}
@Override
public void destroy() {
}
}