{
try
{
// classloader/deployment aware RestasyProviderFactory. Used to have request specific
// ResteasyProviderFactory.getInstance()
ResteasyProviderFactory defaultInstance = ResteasyProviderFactory.getInstance();
if (defaultInstance instanceof ThreadLocalResteasyProviderFactory)
{
ThreadLocalResteasyProviderFactory.push(providerFactory);
}
HttpHeaders headers = ServletUtil.extractHttpHeaders(request);
UriInfoImpl uriInfo = ServletUtil.extractUriInfo(request, servletMappingPrefix);
HttpResponse theResponse = createServletResponse(response);
HttpRequest in = createHttpRequest(httpMethod, request, headers, uriInfo, theResponse);
try
{
ResteasyProviderFactory.pushContext(HttpServletRequest.class, request);
ResteasyProviderFactory.pushContext(HttpServletResponse.class, response);
try
{
// embedded TJWS and Jetty might not have these things initialized
ServletConfig config1 = getServletConfig();
ResteasyProviderFactory.pushContext(ServletConfig.class, config1);
}
catch (Exception ignored)
{
}
try
{
// embedded TJWS and Jetty might not have these things initialized
ServletContext servletContext = getServletContext();
ResteasyProviderFactory.pushContext(ServletContext.class, servletContext);
}
catch (Exception ignored)
{
}
ResteasyProviderFactory.pushContext(SecurityContext.class, new ServletSecurityContext(request));
dispatcher.invoke(in, theResponse);
}
finally
{
ResteasyProviderFactory.clearContextData();
}
}
finally
{
ResteasyProviderFactory defaultInstance = ResteasyProviderFactory.getInstance();
if (defaultInstance instanceof ThreadLocalResteasyProviderFactory)
{
ThreadLocalResteasyProviderFactory.pop();
}