public class WekaPackageLibIsolatingClassLoader extends URLClassLoader
A ClassLoader that loads/finds classes from one Weka plugin package. This includes the top-level jar file(s) and third-party libraries in the package's lib directory. First checks the parent classloader (typically application classloader) - covers general stuff and weka core classes. Next tries the package jar files and third-party libs covered by this classloader/package. Next tries packages this one depends on and their third-party libs - this is transitive. Finally tries all top-level package jar files over all packages.
The basic assumption for Weka packages is that classes present in top-level jar package jar files contain Weka-related code (schemes, filters, GUI panels, tools, etc.), that is visible to all other packages via Weka's dynamic class discovery mechanism. A top-level jar file should not contain any third-party library code. If package A needs to compile against (and explicitly reference) classes provided by package B (either top-level jar or third-party library), then it should declare a dependency on package B.
| Constructor and Description |
|---|
WekaPackageLibIsolatingClassLoader(WekaPackageClassLoaderManager repo,
File packageDir)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkForMissingFiles(Package toLoad,
File packageRoot,
PrintStream... progress)
Checks to see if there are any missing files/directories for a given
package.
|
List<WekaPackageLibIsolatingClassLoader> |
getPackageClassLoadersForDependencies()
Gets a list of class loaders for the packages that this one depends on
|
Set<String> |
getPackageJarEntries()
Get a Set of the names of all classes contained within top-level jar files
in this package
|
String |
getPackageName()
Return the name of the package that this classloader loads classes for
|
URL |
getResource(String name)
Find a named resource.
|
Enumeration<URL> |
getResources(String name)
Find an enumeration of resources matching the supplied name.
|
boolean |
hasThirdPartyClass(String className)
Returns true if this classloader is covering the named third-party class
|
String |
toString()
String representation of this classloader
|
close, findResource, findResources, getResourceAsStream, getURLs, newInstance, newInstanceclearAssertionStatus, getParent, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatuspublic WekaPackageLibIsolatingClassLoader(WekaPackageClassLoaderManager repo, File packageDir) throws Exception
repo - a reference to the classloader managerpackageDir - the package directory for the package covered by this
classloaderException - if a problem occurspublic List<WekaPackageLibIsolatingClassLoader> getPackageClassLoadersForDependencies()
public URL getResource(String name)
getResource in class ClassLoadername - the name of the resource to look forpublic Enumeration<URL> getResources(String name) throws IOException
getResources in class ClassLoadername - the name to look forIOException - if a problem occurspublic boolean hasThirdPartyClass(String className)
className - the third-party classname to check forpublic String toString()
public String getPackageName()
public Set<String> getPackageJarEntries()
public static boolean checkForMissingFiles(Package toLoad, File packageRoot, PrintStream... progress)
toLoad - the package to checkpackageRoot - the root directory of the packageprogress - for printing progress/error infoCopyright © 2020 University of Waikato, Hamilton, NZ. All rights reserved.