static Object find ( String factoryId , String fallbackClassName ) throws ConfigurationError { ClassLoader classLoader = findClassLoader ( ) ; // Use the system property first String systemProp = System . getProperty ( factoryId ) ; if ( systemProp != null && systemProp . length ( ) > 0 ) { if ( debug ) debugPrintln ( "found " + systemProp + " in the system property " + factoryId ) ; return newInstance ( systemProp , classLoader ) ; } // try to read from $java.home/lib/jaxp.properties try { String factoryClassName = CacheHolder . cacheProps . getProperty ( factoryId ) ; if ( debug ) debugPrintln ( "found " + factoryClassName + " in $java.home/jaxp.properties" ) ; if ( factoryClassName != null ) { return newInstance ( factoryClassName , classLoader ) ; } } catch ( Exception ex ) { if ( debug ) { ex . printStackTrace ( ) ; } } // Try Jar Service Provider Mechanism Object provider = findJarServiceProvider ( factoryId ) ; if ( provider != null ) { return provider ; } if ( fallbackClassName == null ) { throw new ConfigurationError ( "Provider for " + factoryId + " cannot be found" , null ) ; } if ( debug ) debugPrintln ( "loaded from fallback value: " + fallbackClassName ) ; return newInstance ( fallbackClassName , classLoader ) ; }
Finds the implementation Class object in the specified order . Main entry point . Package private so this code can be shared .