private static Object newInstance()

in src/main/java/org/apache/servicemix/executors/impl/FactoryFinder.java [108:141]


    private static Object newInstance(String className,
                                      ClassLoader classLoader)
            throws ConfigurationError {

        final ClassLoader iClassLoader = classLoader;
        final String iClassName = className;

        // REVIEW This doPriv block may be unnecessary because this method is private and
        // the caller already has a doPriv.  I added the doPriv in case someone changes the
        // visibility of this method to non-private.
        Object obj =
            doPrivileged( new PrivilegedAction() {
                public Object run() {
                    try {
                        if (iClassLoader != null) {
                            try {
                                return iClassLoader.loadClass(iClassName).newInstance();
                            } catch (ClassNotFoundException x) {
                                // try again
                            }
                        }
                        return Class.forName(iClassName).newInstance();
                    } catch (ClassNotFoundException x) {
                        throw new ConfigurationError(
                                "Provider " + iClassName + " not found", x);
                    } catch (Exception x) {
                        throw new ConfigurationError(
                                "Provider " + iClassName + " could not be instantiated: " + x,
                                x);
                    }
                }
            });
        return obj;
    }