public class WekaPackageClassLoaderManager
extends java.lang.Object
WekaPackageLibIsolatingClassLoader
s - 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 |
---|---|
java.lang.ClassLoader |
addPackageToClassLoader(java.io.File packageDir)
Create a class loader for the given package directory
|
java.lang.ClassLoader |
findClassloaderForResource(java.lang.String name)
Get the classloader that covers the jar that contains the named resource.
|
java.net.URL |
findResource(java.lang.String name)
Find a named resource.
|
java.util.Enumeration<java.net.URL> |
findResources(java.lang.String name)
Find a named resource.
|
static java.lang.Class<?> |
forName(java.lang.String className)
Return the class object for the supplied class name.
|
static java.lang.Class<?> |
forName(java.lang.String className,
boolean initialize)
Return the class object for the supplied class name.
|
java.lang.ClassLoader |
getLoaderForClass(java.lang.String className)
Attempts to locate a classloader for the named class.
|
WekaPackageLibIsolatingClassLoader |
getPackageClassLoader(java.lang.String packageName)
Get the classloader for the named package
|
java.util.Set<java.lang.String> |
getPackageJarFileClasses()
Get a set of all classes contained in all top-level jar files from Weka
packages.
|
java.io.File |
getPathToWekaJarFile()
Return the path to the weka.jar file (if found) on the classpath.
|
java.net.URL[] |
getWekaClassloaderClasspathEntries()
Get the entries in the Weka class loader (i.e.
|
static WekaPackageClassLoaderManager |
getWekaPackageClassLoaderManager()
Gets the singleton instance of the WekaPackageClassLoaderManager
|
static java.lang.Object |
objectForName(java.lang.String className)
Return an instantiated instance of the supplied class name.
|
void |
removeClassLoaderForPackage(java.lang.String packageName)
Removes the named package classloader from those managed by this class.
|
public static WekaPackageClassLoaderManager getWekaPackageClassLoaderManager()
public static java.lang.Object objectForName(java.lang.String className) throws java.lang.Exception
className
- the name of the class to get an instance ofjava.lang.Exception
- if the class cannot be found, or a problem occurs during
instantiationpublic static java.lang.Class<?> forName(java.lang.String className) throws java.lang.ClassNotFoundException
className
- the name of hte class to get an instance ofjava.lang.ClassNotFoundException
- if the named class cannot be found.public static java.lang.Class<?> forName(java.lang.String className, boolean initialize) throws java.lang.ClassNotFoundException
className
- the name of hte class to get an instance ofinitialize
- true if the class should be initializedjava.lang.ClassNotFoundException
- if the named class cannot be found.public java.io.File getPathToWekaJarFile()
public java.net.URL[] getWekaClassloaderClasspathEntries()
public java.util.Set<java.lang.String> getPackageJarFileClasses()
public void removeClassLoaderForPackage(java.lang.String packageName)
packageName
- the name of the package to remove the classloader forpublic java.lang.ClassLoader addPackageToClassLoader(java.io.File packageDir) throws java.lang.Exception
packageDir
- the directory of a Weka package to create a class loader
forjava.lang.Exception
- if a problem occurspublic java.lang.ClassLoader getLoaderForClass(java.lang.String className)
className
- the name of the class to locate a classloader forpublic WekaPackageLibIsolatingClassLoader getPackageClassLoader(java.lang.String packageName)
packageName
- the name of the package to get the classloader forpublic java.net.URL findResource(java.lang.String name)
name
- the name of the resource to findpublic java.lang.ClassLoader findClassloaderForResource(java.lang.String name)
name
- the name of the resource to get the owning classloader forpublic java.util.Enumeration<java.net.URL> findResources(java.lang.String name) throws java.io.IOException
name
- the name of the resource to findjava.io.IOException