/** * Delegates class loading of <code>extensionClassName</code> to * {@link ClassLoaderSearchUtilDelegator#findClassFromClassLoaders(String, Iterable)} passing the * <code>extensionClassName</code> and the instance's <code>classLoaders</code>. * * @param <T> * @param extensionClassName * @return */ @SuppressWarnings("unchecked") private <T extends Assignable> Class<T> loadExtensionClass(String extensionClassName) { try { return (Class<T>) ClassLoaderSearchUtilDelegator.findClassFromClassLoaders(extensionClassName, getClassLoaders()); } catch (final ClassNotFoundException e) { throw new RuntimeException("Could not load class " + extensionClassName, e); } }
/** * Delegates class loading of <code>extensionClassName</code> to * {@link ClassLoaderSearchUtilDelegator#findClassFromClassLoaders(String, Iterable)} passing the * <code>extensionClassName</code> and the instance's <code>classLoaders</code>. * * @param <T> * @param extensionClassName * @return */ @SuppressWarnings("unchecked") private <T extends Assignable> Class<T> loadExtensionClass(String extensionClassName) { try { return (Class<T>) ClassLoaderSearchUtilDelegator.findClassFromClassLoaders(extensionClassName, getClassLoaders()); } catch (final ClassNotFoundException e) { throw new RuntimeException("Could not load class " + extensionClassName, e); } }
/** * Iterates through the classloaders to load the provider-configuration file for <code>extensionClass</code> in * META-INF/services/ using its binary name. * * @param <T> * @param extensionClass * SPI type for which the configuration file is looked for * @return An {@link InputStream} representing <code>extensionClass</code>'s configuration file * @throws RuntimeException * if it doesn't find a provider-configuration file for <code>extensionClass</code> * @throws UnknownExtensionTypeExceptionDelegator */ private <T extends Assignable> InputStream findExtensionImpl(final Class<T> extensionClass) { try { // Add all extension impls found in all CLs for (final ClassLoader cl : this.getClassLoaders()) { final InputStream stream = cl.getResourceAsStream("META-INF/services/" + extensionClass.getName()); if (stream != null) { return stream; } } // None found throw new RuntimeException("No extension implementation found for " + extensionClass.getName() + ", please verify classpath or add a extensionOverride"); } catch (Exception e) { throw UnknownExtensionTypeExceptionDelegator.newExceptionInstance(extensionClass); } }
/** * Iterates through the classloaders to load the provider-configuration file for <code>extensionClass</code> in * META-INF/services/ using its binary name. * * @param <T> * @param extensionClass * SPI type for which the configuration file is looked for * @return An {@link InputStream} representing <code>extensionClass</code>'s configuration file * @throws RuntimeException * if it doesn't find a provider-configuration file for <code>extensionClass</code> * @throws UnknownExtensionTypeExceptionDelegator */ private <T extends Assignable> InputStream findExtensionImpl(final Class<T> extensionClass) { try { // Add all extension impls found in all CLs for (final ClassLoader cl : this.getClassLoaders()) { final InputStream stream = cl.getResourceAsStream("META-INF/services/" + extensionClass.getName()); if (stream != null) { return stream; } } // None found throw new RuntimeException("No extension implementation found for " + extensionClass.getName() + ", please verify classpath or add a extensionOverride"); } catch (Exception e) { throw UnknownExtensionTypeExceptionDelegator.newExceptionInstance(extensionClass); } }