private void doProcess ( final String requestUri , final Reader reader , final Writer writer ) throws IOException { Reader input = reader ; Writer output = null ; LOG . debug ( "processing resource: {}" , requestUri ) ; try { final StopWatch stopWatch = new StopWatch ( ) ; final Injector injector = InjectorBuilder . create ( new BaseWroManagerFactory ( ) ) . build ( ) ; final List < ResourcePreProcessor > processors = getProcessorsList ( ) ; if ( processors == null || processors . isEmpty ( ) ) { IOUtils . copy ( reader , writer ) ; } else { for ( final ResourcePreProcessor processor : processors ) { stopWatch . start ( "Using " + processor . getClass ( ) . getSimpleName ( ) ) ; // inject all required properties injector . inject ( processor ) ; output = new StringWriter ( ) ; LOG . debug ( "Using {} processor" , processor ) ; processor . process ( createResource ( requestUri ) , input , output ) ; input = new StringReader ( output . toString ( ) ) ; stopWatch . stop ( ) ; } LOG . debug ( stopWatch . prettyPrint ( ) ) ; if ( output != null ) { writer . write ( output . toString ( ) ) ; } } } finally { reader . close ( ) ; writer . close ( ) ; } }
Applies configured processor on the intercepted stream .