public static ResourceReader getResourceReaderProxy ( ResourceGenerator generator , ResourceReaderHandler rsReaderHandler , JawrConfig config ) { ResourceReader proxy = null ; // Defines the interfaces to be implemented by the ResourceReader int nbExtraInterface = 0 ; Class < ? > [ ] extraInterfaces = new Class < ? > [ 2 ] ; boolean isResourceGenerator = generator instanceof ResourceGenerator ; boolean isStreamResourceGenerator = generator instanceof StreamResourceGenerator ; if ( isResourceGenerator ) { extraInterfaces [ nbExtraInterface ++ ] = TextResourceReader . class ; } if ( isStreamResourceGenerator ) { extraInterfaces [ nbExtraInterface ++ ] = StreamResourceReader . class ; } Class < ? > [ ] generatorInterfaces = getGeneratorInterfaces ( generator ) ; Class < ? > [ ] implementedInterfaces = new Class [ generatorInterfaces . length + nbExtraInterface ] ; System . arraycopy ( generatorInterfaces , 0 , implementedInterfaces , 0 , generatorInterfaces . length ) ; System . arraycopy ( extraInterfaces , 0 , implementedInterfaces , generatorInterfaces . length , nbExtraInterface ) ; // Creates the proxy InvocationHandler handler = new ResourceGeneratorReaderWrapperInvocationHandler ( generator , rsReaderHandler , config ) ; proxy = ( ResourceReader ) Proxy . newProxyInstance ( ResourceGeneratorReaderProxyFactory . class . getClassLoader ( ) , implementedInterfaces , handler ) ; return proxy ; }
Creates a Resource reader from a resource generator .