protected ClassLoader initClassLoader ( String baseDirPath ) throws MalformedURLException { File webAppClasses = new File ( baseDirPath + WEB_INF_CLASSES_DIR_PATH ) ; File [ ] webAppLibs = new File ( baseDirPath + WEB_INF_LIB_DIR_PATH ) . listFiles ( new FilenameFilter ( ) { public boolean accept ( File dir , String name ) { return name . endsWith ( JAR_FILE_EXTENSION ) ; } } ) ; int length = webAppLibs != null ? webAppLibs . length + 1 : 1 ; URL [ ] urls = new URL [ length ] ; urls [ 0 ] = webAppClasses . toURI ( ) . toURL ( ) ; for ( int i = 1 ; i < length ; i ++ ) { urls [ i ] = webAppLibs [ i - 1 ] . toURI ( ) . toURL ( ) ; } ClassLoader webAppClassLoader = new JawrBundleProcessorCustomClassLoader ( urls , getClass ( ) . getClassLoader ( ) ) ; Thread . currentThread ( ) . setContextClassLoader ( webAppClassLoader ) ; return webAppClassLoader ; }
Initialize the classloader