try
{
//logger.info("***PATH: " + request.getRequestURL());
// classloader/deployment aware RestasyProviderFactory. Used to have request specific
// ResteasyProviderFactory.getInstance()
ResteasyProviderFactory defaultInstance = ResteasyProviderFactory.getInstance();
if (defaultInstance instanceof ThreadLocalResteasyProviderFactory)
{
ThreadLocalResteasyProviderFactory.push(providerFactory);
}
HttpHeaders headers = null;
UriInfoImpl uriInfo = null;
try
{
headers = ServletUtil.extractHttpHeaders(request);
uriInfo = ServletUtil.extractUriInfo(request, servletMappingPrefix);
}
catch (Exception e)
{
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
// made it warn so that people can filter this.
logger.warn("Failed to parse request.", e);
return;
}
HttpResponse theResponse = responseFactory.createResteasyHttpResponse(response);
HttpRequest in = requestFactory.createResteasyHttpRequest(httpMethod, request, headers, uriInfo, theResponse, response);
try
{
ResteasyProviderFactory.pushContext(HttpServletRequest.class, request);
ResteasyProviderFactory.pushContext(HttpServletResponse.class, response);
ResteasyProviderFactory.pushContext(SecurityContext.class, new ServletSecurityContext(request));
if (handleNotFound)
{
dispatcher.invoke(in, theResponse);
}
else
{
((SynchronousDispatcher) dispatcher).invokePropagateNotFound(in, theResponse);
}
}
finally
{
ResteasyProviderFactory.clearContextData();
}
}
finally
{
ResteasyProviderFactory defaultInstance = ResteasyProviderFactory.getInstance();
if (defaultInstance instanceof ThreadLocalResteasyProviderFactory)
{
ThreadLocalResteasyProviderFactory.pop();
}