/** * Tests if a class is available. */ private boolean findClass(final String className) { try { findClassLoader().loadClass(className); return true; } catch (final ClassNotFoundException e) { return false; } }
/** * Load a class from different class loaders. * * @throws ClassNotFoundException if last {@code loadClass} failed. * @see #findClassLoader() */ private Class<?> loadClass(final String className) throws ClassNotFoundException { try { return findClassLoader().loadClass(className); } catch (final ClassNotFoundException e) { return getClass().getClassLoader().loadClass(className); } }
/** * Resolve resources from different class loaders. * * @throws IOException if {@code getResource} failed. * @see #findClassLoader() */ private Enumeration<URL> loadResources(final String name) throws IOException { Enumeration<URL> res = findClassLoader().getResources(name); if (res == null || !res.hasMoreElements()) { res = getClass().getClassLoader().getResources(name); } return res; } }
/** * Load a class from different class loaders. * * @throws ClassNotFoundException if last {@code loadClass} failed. * @see #findClassLoader() */ private Class<?> loadClass(final String className) throws ClassNotFoundException { try { return findClassLoader().loadClass(className); } catch (final ClassNotFoundException e) { return getClass().getClassLoader().loadClass(className); } }
/** * Resolve resources from different class loaders. * * @throws IOException if {@code getResource} failed. * @see #findClassLoader() */ private Enumeration<URL> loadResources(final String name) throws IOException { Enumeration<URL> res = findClassLoader().getResources(name); if (res == null || !res.hasMoreElements()) { res = getClass().getClassLoader().getResources(name); } return res; } }
/** * Resolve resources from different class loaders. * * @throws IOException if {@code getResource} failed. * @see #findClassLoader() */ private Enumeration<URL> loadResources(final String name) throws IOException { Enumeration<URL> res = findClassLoader().getResources(name); if (res == null || !res.hasMoreElements()) { res = getValidClassLoader(getClass()).getResources(name); } return res; }
/** * Load a class from different class loaders. * * @throws ClassNotFoundException if last {@code loadClass} failed. * @see #findClassLoader() */ private Class<?> loadClass(final String className) throws ClassNotFoundException { try { return findClassLoader().loadClass(className); } catch (final ClassNotFoundException e) { return getValidClassLoader(getClass()).loadClass(className); } }
/** * Creates a provider. */ private Object createInstance(final String className) throws FileSystemException { try { final Class<?> clazz = findClassLoader().loadClass(className); return clazz.newInstance(); } catch (final Exception e) { throw new FileSystemException("vfs.impl/create-provider.error", className, e); } } }
/** * Scans the classpath to find any droped plugin. * <p> * The plugin-description has to be in {@code /META-INF/vfs-providers.xml}. * * @throws FileSystemException if an error occurs. */ protected void configurePlugins() throws FileSystemException { final ClassLoader cl = findClassLoader(); Enumeration<URL> enumResources; try { enumResources = cl.getResources(PLUGIN_CONFIG_RESOURCE); } catch (final IOException e) { throw new FileSystemException(e); } while (enumResources.hasMoreElements()) { final URL url = enumResources.nextElement(); configure(url); } }