private static void handleResourceLoader ( final Object resourceLoader , final ClassLoader classLoader , final ClasspathOrder classpathOrderOut , final ScanSpec scanSpec , final LogNode log ) { if ( resourceLoader == null ) { return ; } // PathResourceLoader has root field, which is a Path object final Object root = ReflectionUtils . getFieldVal ( resourceLoader , "root" , false ) ; // type VirtualFile final File physicalFile = ( File ) ReflectionUtils . invokeMethod ( root , "getPhysicalFile" , false ) ; String path = null ; if ( physicalFile != null ) { final String name = ( String ) ReflectionUtils . invokeMethod ( root , "getName" , false ) ; if ( name != null ) { // getParentFile() removes "contents" directory final File file = new File ( physicalFile . getParentFile ( ) , name ) ; if ( FileUtils . canRead ( file ) ) { path = file . getAbsolutePath ( ) ; } else { // This is an exploded jar or classpath directory path = physicalFile . getAbsolutePath ( ) ; } } else { path = physicalFile . getAbsolutePath ( ) ; } } else { path = ( String ) ReflectionUtils . invokeMethod ( root , "getPathName" , false ) ; if ( path == null ) { // Try Path or File final File file = root instanceof Path ? ( ( Path ) root ) . toFile ( ) : root instanceof File ? ( File ) root : null ; if ( file != null ) { path = file . getAbsolutePath ( ) ; } } } if ( path == null ) { final File file = ( File ) ReflectionUtils . getFieldVal ( resourceLoader , "fileOfJar" , false ) ; if ( file != null ) { path = file . getAbsolutePath ( ) ; } } if ( path != null ) { classpathOrderOut . addClasspathEntry ( path , classLoader , scanSpec , log ) ; } else { if ( log != null ) { log . log ( "Could not determine classpath for ResourceLoader: " + resourceLoader ) ; } } }
Handle a resource loader .