Exemple #1
0
 /**
  * Provides request scope support for Spring IoC Container when
  * org.springframework.web.context.request.RequestContextListener has not been called.
  */
 public <T> T provideForRequest(RequestInfo request, Execution<T> execution) {
   if (springListenerAlreadyCalled()) {
     return execution.insideRequest(getContainer());
   }
   VRaptorRequestHolder.setRequestForCurrentThread(request);
   T result;
   try {
     ServletContext context = request.getServletContext();
     HttpServletRequest webRequest = request.getRequest();
     requestListener.requestInitialized(new ServletRequestEvent(context, webRequest));
     try {
       result = execution.insideRequest(getContainer());
     } finally {
       requestListener.requestDestroyed(new ServletRequestEvent(context, webRequest));
     }
   } finally {
     VRaptorRequestHolder.resetRequestForCurrentThread();
   }
   return result;
 }