private synchronized URLClassLoader getClassLoader ( ) { if ( modelClassLoader == null ) { List < File > jars = res . filterFiles ( "jar" ) ; // jars as defined in List < File > cli_jars = getExtraResources ( ) ; // cli extra jars List < File > dirs = res . filterDirectories ( ) ; // testing List < URL > urls = new ArrayList < URL > ( ) ; try { for ( int i = 0 ; i < jars . size ( ) ; i ++ ) { urls . add ( jars . get ( i ) . toURI ( ) . toURL ( ) ) ; if ( log . isLoggable ( Level . CONFIG ) ) { log . config ( "classpath entry from simulation: " + jars . get ( i ) ) ; } } for ( int i = 0 ; i < dirs . size ( ) ; i ++ ) { urls . add ( dirs . get ( i ) . toURI ( ) . toURL ( ) ) ; if ( log . isLoggable ( Level . CONFIG ) ) { log . config ( "dir entry: " + dirs . get ( i ) ) ; } } for ( int i = 0 ; i < cli_jars . size ( ) ; i ++ ) { urls . add ( cli_jars . get ( i ) . toURI ( ) . toURL ( ) ) ; if ( log . isLoggable ( Level . CONFIG ) ) { log . config ( "classpath entry from CLI: " + cli_jars . get ( i ) ) ; } } urls . add ( new URL ( "file:" + System . getProperty ( "oms.prj" ) + "/dist/" ) ) ; if ( log . isLoggable ( Level . CONFIG ) ) { log . config ( "Sim loading classpath : " + "file:" + System . getProperty ( "oms.prj" ) + "/dist/" ) ; } } catch ( MalformedURLException ex ) { throw new ComponentException ( "Illegal resource:" + ex . getMessage ( ) ) ; } modelClassLoader = new URLClassLoader ( urls . toArray ( new URL [ 0 ] ) , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; } return modelClassLoader ; }
get the URL class loader for all the resources ( just for jar files