/** * Returns the absolute path of the requested library. * @param name name of the library to load. * @return the absolute path of the requested library if found, <code>null</code> otheriwse. */ @Override protected String findLibrary(String name) { AbstractFile file; // Path of the requested library. // Tries to find the requested library. if((file = findResourceAsFile(name)) == null) return null; // Retrieves its absolute path. return file.getAbsolutePath(); }
/** * Tries to find the requested resource. * @param name name of the resource to locate. * @return the URL of the requested resource if found, <code>null</code> otherwise. */ @Override protected URL findResource(String name) { AbstractFile file; // Path to the requested resource. // Tries to find the resource. if((file = findResourceAsFile(name)) == null) return null; // Tries to retrieve an URL on the resource. try {return file.getJavaNetURL();} catch(Exception e) {return null;} }
/** * Tries to find and load the specified class. * @param name fully qualified name of the class to load. * @return the requested <code>Class</code> if found, <code>null</code> otherwise. * @throws ClassNotFoundException if the requested class was not found. */ @Override protected Class<?> findClass(String name) throws ClassNotFoundException { AbstractFile file; // File containing the class' bytecode. // Tries to locate the specified class and, if found, load it. if((file = findResourceAsFile(name.replace('.', '/') + ".class")) != null) { try {return loadClass(name, file);} catch(Exception e) {} } throw new ClassNotFoundException(name); } }
/** * Returns an input stream on the requested resource. * @param name name of the resource to open. * @return an input stream on the requested resource, <code>null</code> if not found. */ @Override public InputStream getResourceAsStream(String name) { AbstractFile file; // File representing the resource. InputStream in; // Input stream on the resource. // Tries the parent first, to respect the delegation model. if((in = getParent().getResourceAsStream(name)) != null) return in; // Tries to locate the resource in the extended classpath if it wasn't found // in the parent. if((file = findResourceAsFile(name)) != null) { try {return file.getInputStream();} catch(Exception e) {} } // Couldn't find the resource. return null; }