public class WekaPackageClassLoaderManager extends Object
WekaPackageLibIsolatingClassLoaders - one
for each package. Utils.forName() and weka.Run use this
classloader to find/instantiate schemes exposed in top-level package jar
files. Client code in a package should do the same, unless directly referring
to classes in other packages, in which case the other packages should be
explicit dependencies. This classloader will not find classes in third-party
libraries inside a package's lib directory.WekaPackageLibIsolatingClassLoader| Modifier and Type | Method and Description |
|---|---|
ClassLoader |
addPackageToClassLoader(File packageDir)
Create a class loader for the given package directory
|
ClassLoader |
findClassloaderForResource(String name)
Get the classloader that covers the jar that contains the named resource.
|
URL |
findResource(String name)
Find a named resource.
|
Enumeration<URL> |
findResources(String name)
Find a named resource.
|
static Class<?> |
forName(String className)
Return the class object for the supplied class name.
|
static Class<?> |
forName(String className,
boolean initialize)
Return the class object for the supplied class name.
|
ClassLoader |
getLoaderForClass(String className)
Attempts to locate a classloader for the named class.
|
WekaPackageLibIsolatingClassLoader |
getPackageClassLoader(String packageName)
Get the classloader for the named package
|
Set<String> |
getPackageJarFileClasses()
Get a set of all classes contained in all top-level jar files from Weka
packages.
|
File |
getPathToWekaJarFile()
Return the path to the weka.jar file (if found) on the classpath.
|
URL[] |
getWekaClassloaderClasspathEntries()
Get the entries in the Weka class loader (i.e.
|
static WekaPackageClassLoaderManager |
getWekaPackageClassLoaderManager()
Gets the singleton instance of the WekaPackageClassLoaderManager
|
static Object |
objectForName(String className)
Return an instantiated instance of the supplied class name.
|
void |
removeClassLoaderForPackage(String packageName)
Removes the named package classloader from those managed by this class.
|
public static WekaPackageClassLoaderManager getWekaPackageClassLoaderManager()
public static Object objectForName(String className) throws Exception
className - the name of the class to get an instance ofException - if the class cannot be found, or a problem occurs during
instantiationpublic static Class<?> forName(String className) throws ClassNotFoundException
className - the name of hte class to get an instance ofClassNotFoundException - if the named class cannot be found.public static Class<?> forName(String className, boolean initialize) throws ClassNotFoundException
className - the name of hte class to get an instance ofinitialize - true if the class should be initializedClassNotFoundException - if the named class cannot be found.public File getPathToWekaJarFile()
public URL[] getWekaClassloaderClasspathEntries()
public Set<String> getPackageJarFileClasses()
public void removeClassLoaderForPackage(String packageName)
packageName - the name of the package to remove the classloader forpublic ClassLoader addPackageToClassLoader(File packageDir) throws Exception
packageDir - the directory of a Weka package to create a class loader
forException - if a problem occurspublic ClassLoader getLoaderForClass(String className)
className - the name of the class to locate a classloader forpublic WekaPackageLibIsolatingClassLoader getPackageClassLoader(String packageName)
packageName - the name of the package to get the classloader forpublic URL findResource(String name)
name - the name of the resource to findpublic ClassLoader findClassloaderForResource(String name)
name - the name of the resource to get the owning classloader forpublic Enumeration<URL> findResources(String name) throws IOException
name - the name of the resource to findIOExceptionCopyright © 2019 University of Waikato, Hamilton, NZ. All rights reserved.