@ Override public boolean preHandle ( HttpServletRequest request , HttpServletResponse response , Object handler ) throws Exception { final List < IRequestParameterProcessor > incompleteDynamicProcessors = new LinkedList < IRequestParameterProcessor > ( this . dynamicRequestParameterProcessors ) ; // Loop while there are still dynamic processors to execute int cycles = 0 ; while ( incompleteDynamicProcessors . size ( ) > 0 ) { // Run all dynamic processors that are not yet complete for ( final Iterator < IRequestParameterProcessor > processorItr = incompleteDynamicProcessors . iterator ( ) ; processorItr . hasNext ( ) ; ) { final IRequestParameterProcessor requestParameterProcessor = processorItr . next ( ) ; // If a dynamic processor completes remove it from the list. final boolean complete = requestParameterProcessor . processParameters ( request , response ) ; if ( complete ) { processorItr . remove ( ) ; } } cycles ++ ; // If the max cycle count is reached log a warning and break out of the dynamic // processing loop if ( cycles >= this . maxNumberOfProcessingCycles ) { this . logger . warn ( incompleteDynamicProcessors . size ( ) + " IDynamicRequestParameterProcessors did not complete processing after " + cycles + " attempts. Execution will continue but this situation should be reviewed. Incomplete Processors=" + incompleteDynamicProcessors , new Throwable ( "Stack Trace" ) ) ; break ; } } return true ; }
Process the request first with the dynamic processors until all are complete and then the static processors .