public class CdiAwareHandlerWrapper extends HandlerWrapper
{
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
try
{
cdiContainer.getContextControl().startContext(RequestScoped.class);
super.handle(target, baseRequest, request, response);
}
finally
{
cdiContainer.getContextControl().stopContext(RequestScoped.class);
}
}
}