static Object find(String factoryId,String fallbackClassName) throws ConfigurationError {
  ClassLoader classLoader=findClassLoader();
  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 {
    String javah=System.getProperty("java.home");
    String configFile=javah + File.separator + "lib"+ File.separator+ "jaxp.properties";
    String factoryClassName=null;
    if (firstTime) {
synchronized (cacheProps) {
        if (firstTime) {
          File f=new File(configFile);
          firstTime=false;
          if (f.exists()) {
            if (debug)             debugPrintln("Read properties file " + f);
            cacheProps.load(new FileInputStream(f));
          }
        }
      }
    }
    factoryClassName=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();
    }
  }
  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);
}

static Object find ( String factoryId , String fallbackClassName ) throws ConfigurationError { ClassLoader classLoader = findClassLoader ( ) ; 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 { String javah = System . getProperty ( "java.home" ) ; String configFile = javah + File . separator + "lib" + File . separator + "jaxp.properties" ; String factoryClassName = null ; if ( firstTime ) { synchronized ( cacheProps ) { if ( firstTime ) { File f = new File ( configFile ) ; firstTime = false ; if ( f . exists ( ) ) { if ( debug ) debugPrintln ( "Read properties file " + f ) ; cacheProps . load ( new FileInputStream ( f ) ) ; } } } } factoryClassName = 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 ( ) ; } } 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 .
