private Resolution createContextAndRedirect ( ExecutionContext executionContext , WaitPage annotation ) throws IOException { // Create context used to call the event in background. Context context = this . createContext ( executionContext ) ; context . actionBean = executionContext . getActionBean ( ) ; context . eventHandler = executionContext . getHandler ( ) ; context . annotation = annotation ; context . resolution = new ForwardResolution ( annotation . path ( ) ) ; context . bindingFlashScope = FlashScope . getCurrent ( context . actionBean . getContext ( ) . getRequest ( ) , false ) ; int id = context . hashCode ( ) ; // Id of context. String ids = Integer . toHexString ( id ) ; // Create background request to execute event. HttpServletRequest request = executionContext . getActionBeanContext ( ) . getRequest ( ) ; UrlBuilder urlBuilder = new UrlBuilder ( executionContext . getActionBeanContext ( ) . getLocale ( ) , THREAD_URL , false ) ; // Add parameters from the original request in case there were some parameters that weren't bound but are used @ SuppressWarnings ( { "cast" , "unchecked" } ) Set < Map . Entry < String , String [ ] > > paramSet = ( Set < Map . Entry < String , String [ ] > > ) request . getParameterMap ( ) . entrySet ( ) ; for ( Map . Entry < String , String [ ] > param : paramSet ) for ( String value : param . getValue ( ) ) urlBuilder . addParameter ( param . getKey ( ) , value ) ; urlBuilder . addParameter ( ID_PARAMETER , ids ) ; if ( context . bindingFlashScope != null ) { urlBuilder . addParameter ( StripesConstants . URL_KEY_FLASH_SCOPE_ID , String . valueOf ( context . bindingFlashScope . key ( ) ) ) ; } urlBuilder . addParameter ( StripesConstants . URL_KEY_SOURCE_PAGE , CryptoUtil . encrypt ( executionContext . getActionBeanContext ( ) . getSourcePage ( ) ) ) ; context . url = new URL ( request . getScheme ( ) , request . getServerName ( ) , request . getServerPort ( ) , request . getContextPath ( ) + urlBuilder . toString ( ) ) ; context . cookies = request . getHeader ( "Cookie" ) ; // Save context. contexts . put ( id , context ) ; // Execute background request. context . thread = new Thread ( context ) ; context . thread . start ( ) ; // Redirect user to wait page. return new RedirectResolution ( StripesFilter . getConfiguration ( ) . getActionResolver ( ) . getUrlBinding ( context . actionBean . getClass ( ) ) ) { @ Override public RedirectResolution addParameter ( String key , Object ... value ) { // Leave flash scope to background request. if ( ! StripesConstants . URL_KEY_FLASH_SCOPE_ID . equals ( key ) ) { return super . addParameter ( key , value ) ; } return this ; } } . addParameter ( ID_PARAMETER , ids ) ; }
Create a wait context to execute event in background .