class ExtensionObjectFactory {

    public <T> T newInstance(SpiExtensionFactory extensionFactory, Class<T> type) throws ExtensionLoadingException {
        try {
            Class<?> extensionClass = loadClass(extensionFactory);
            Object instance = extensionClass.newInstance();
            return type.cast(instance);
        } catch (ExtensionLoadingException e) {
            throw e;
        } catch (Exception e) {
            throw new ExtensionLoadingException("error instantiating class=" + extensionFactory.factoryClass(), e);
        }
    }

    private  ExtensionObjectFactory();
    @VisibleForTesting  ExtensionObjectFactory(Function<SpiExtensionFactory, ClassSource> extensionLocator);

}