public class WekaPackageLibIsolatingClassLoader
extends java.net.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,
java.io.File packageDir)
Constructor
|
Modifier and Type | Method and Description |
---|---|
static boolean |
checkForMissingFiles(Package toLoad,
java.io.File packageRoot,
java.io.PrintStream... progress)
Checks to see if there are any missing files/directories for a given
package.
|
java.util.List<WekaPackageLibIsolatingClassLoader> |
getPackageClassLoadersForDependencies()
Gets a list of class loaders for the packages that this one depends on
|
java.util.Set<java.lang.String> |
getPackageJarEntries()
Get a Set of the names of all classes contained within top-level jar files
in this package
|
java.lang.String |
getPackageName()
Return the name of the package that this classloader loads classes for
|
java.net.URL |
getResource(java.lang.String name)
Find a named resource.
|
java.util.Enumeration<java.net.URL> |
getResources(java.lang.String name)
Find an enumeration of resources matching the supplied name.
|
boolean |
hasThirdPartyClass(java.lang.String className)
Returns true if this classloader is covering the named third-party class
|
java.lang.String |
toString()
String representation of this classloader
|
close, findResource, findResources, getResourceAsStream, getURLs, newInstance, newInstance
public WekaPackageLibIsolatingClassLoader(WekaPackageClassLoaderManager repo, java.io.File packageDir) throws java.lang.Exception
repo
- a reference to the classloader managerpackageDir
- the package directory for the package covered by this
classloaderjava.lang.Exception
- if a problem occurspublic java.util.List<WekaPackageLibIsolatingClassLoader> getPackageClassLoadersForDependencies()
public java.net.URL getResource(java.lang.String name)
getResource
in class java.lang.ClassLoader
name
- the name of the resource to look forpublic java.util.Enumeration<java.net.URL> getResources(java.lang.String name) throws java.io.IOException
getResources
in class java.lang.ClassLoader
name
- the name to look forjava.io.IOException
- if a problem occurspublic boolean hasThirdPartyClass(java.lang.String className)
className
- the third-party classname to check forpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getPackageName()
public java.util.Set<java.lang.String> getPackageJarEntries()
public static boolean checkForMissingFiles(Package toLoad, java.io.File packageRoot, java.io.PrintStream... progress)
toLoad
- the package to checkpackageRoot
- the root directory of the packageprogress
- for printing progress/error info