private static < T > T attemptLoad ( final Class < T > ofClass , final String className ) { if ( LOG . isLoggable ( Level . FINEST ) ) { LOG . finest ( "Attempting service load: " + className ) ; } Level level ; Throwable thrown ; try { Class < ? > clazz = Class . forName ( className ) ; if ( ! ofClass . isAssignableFrom ( clazz ) ) { if ( LOG . isLoggable ( Level . WARNING ) ) { LOG . warning ( clazz . getName ( ) + " is not assignable to " + ofClass . getName ( ) ) ; } return null ; } return ofClass . cast ( clazz . newInstance ( ) ) ; } catch ( LinkageError ex ) { level = Level . FINEST ; thrown = ex ; } catch ( ClassNotFoundException ex ) { level = Level . FINEST ; thrown = ex ; } catch ( InstantiationException ex ) { level = Level . WARNING ; thrown = ex ; } catch ( IllegalAccessException ex ) { level = Level . WARNING ; thrown = ex ; } LOG . log ( level , "Could not load " + ofClass . getSimpleName ( ) + " instance: " + className , thrown ) ; return null ; }
Attempts to load the specified implementation class . Attempts will fail if - for example - the implementation depends on a class not found on the classpath .