Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 public <T> T provideForRequest(RequestInfo request, Execution<T> execution) {
   PicoBasedContainer container = null;
   try {
     container = getComponentRegistry().provideRequestContainer(request);
     container.getContainer().start();
     return execution.insideRequest(container);
   } finally {
     if (container != null) {
       MutablePicoContainer picoContainer = container.getContainer();
       picoContainer.stop();
       picoContainer.dispose();
     }
   }
 }