static Object find(final String factoryId, final String fallbackClassName) throws ConfigurationError {

        // Figure out which ClassLoader to use for loading the provider
        // class. If there is a Context ClassLoader then use it.

        ClassLoader classLoader = ss.getContextClassLoader();

        if (classLoader == null) {
            // if we have no Context ClassLoader
            // so use the current ClassLoader
            classLoader = FactoryFinder.class.getClassLoader();
        }

        dPrint("find factoryId =" + factoryId);

        // Use the system property first
        try {
            final String systemProp = ss.getSystemProperty(factoryId);
            if (systemProp != null) {
                dPrint("found system property, value=" + systemProp);
                return newInstance(systemProp, classLoader, true);
            }
        } catch (final SecurityException se) {
            // if first option fails due to any reason we should try next option in the
            // look up algorithm.
        }

        // try to read from /propono.properties
        try {
            final String configFile = "/propono.properties";
            String factoryClassName = null;
            if (firstTime) {
                synchronized (cacheProps) {
                    if (firstTime) {
                        try {
                            final InputStream is = FactoryFinder.class.getResourceAsStream(configFile);
                            firstTime = false;
                            if (is != null) {
                                dPrint("Read properties file: " + configFile);
                                cacheProps.load(is);
                            }
                        } catch (final Exception intentionallyIgnored) {
                        }
                    }
                }
            }
            factoryClassName = cacheProps.getProperty(factoryId);

            if (factoryClassName != null) {
                dPrint("found in $java.home/propono.properties, value=" + factoryClassName);
                return newInstance(factoryClassName, classLoader, true);
            }
        } catch (final Exception ex) {
            if (debug) {
                ex.printStackTrace();
            }
        }

        // Try Jar Service Provider Mechanism
        final Object provider = findJarServiceProvider(factoryId);
        if (provider != null) {
            return provider;
        }
        if (fallbackClassName == null) {
            throw new ConfigurationError("Provider for " + factoryId + " cannot be found", null);
        }

        dPrint("loaded from fallback value: " + fallbackClassName);
        return newInstance(fallbackClassName, classLoader, true);
    }
static Object find ( final String factoryId , final String fallbackClassName ) throws ConfigurationError { ClassLoader classLoader = ss . getContextClassLoader ( ) ; if ( classLoader == null ) { classLoader = FactoryFinder . class . getClassLoader ( ) ; } dPrint ( "find factoryId =" + factoryId ) ; try { final String systemProp = ss . getSystemProperty ( factoryId ) ; if ( systemProp != null ) { dPrint ( "found system property, value=" + systemProp ) ; return newInstance ( systemProp , classLoader , true ) ; } } catch ( final SecurityException se ) { } try { final String configFile = "/propono.properties" ; String factoryClassName = null ; if ( firstTime ) { synchronized ( cacheProps ) { if ( firstTime ) { try { final InputStream is = FactoryFinder . class . getResourceAsStream ( configFile ) ; firstTime = false ; if ( is != null ) { dPrint ( "Read properties file: " + configFile ) ; cacheProps . load ( is ) ; } } catch ( final Exception intentionallyIgnored ) { } } } } factoryClassName = cacheProps . getProperty ( factoryId ) ; if ( factoryClassName != null ) { dPrint ( "found in $java.home/propono.properties, value=" + factoryClassName ) ; return newInstance ( factoryClassName , classLoader , true ) ; } } catch ( final Exception ex ) { if ( debug ) { ex . printStackTrace ( ) ; } } final Object provider = findJarServiceProvider ( factoryId ) ; if ( provider != null ) { return provider ; } if ( fallbackClassName == null ) { throw new ConfigurationError ( "Provider for " + factoryId + " cannot be found" , null ) ; } dPrint ( "loaded from fallback value: " + fallbackClassName ) ; return newInstance ( fallbackClassName , classLoader , true ) ; }
Finds the implementation Class object in the specified order. Main entry point.

@return Class object of factory, never null

@param factoryId Name of the factory to find, same as a property name
@param fallbackClassName Implementation class name, if nothing else is found. Use null to
mean no fallback.

Package private so this code can be shared.