|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbsh.BshClassManager
BshClassManager manages all classloading in BeanShell. It also supports a dynamically loaded extension (bsh.classpath package) which allows classpath extension and class file reloading. Currently the extension relies on 1.2 for BshClassLoader and weak references. See http://www.beanshell.org/manual/classloading.html for details on the bsh classloader architecture.
Bsh has a multi-tiered class loading architecture. No class loader is used unless/until the classpath is modified or a class is reloaded.
Nested Class Summary | |
static interface |
BshClassManager.Listener
|
Field Summary | |
protected Hashtable |
absoluteClassCache
Global cache for things we know are classes. |
protected Hashtable |
absoluteNonClasses
Global cache for things we know are *not* classes. |
protected Hashtable |
definingClasses
|
protected Hashtable |
definingClassesBaseNames
|
protected Hashtable |
resolvedObjectMethods
Caches for resolved object and static methods. |
protected Hashtable |
resolvedStaticMethods
|
Constructor Summary | |
BshClassManager()
|
Method Summary | |
void |
addClassPath(URL path)
|
void |
addListener(BshClassManager.Listener l)
|
void |
cacheClassInfo(String name,
Class value)
Cache info about whether name is a class or not. |
void |
cacheResolvedMethod(Class clas,
Class[] types,
Method method)
Cache a resolved (possibly overloaded) method based on the argument types used to invoke it, subject to classloader change. |
boolean |
classExists(String name)
|
Class |
classForName(String name)
Load the specified class by name, taking into account added classpath and reloaded classes, etc. |
protected void |
classLoaderChanged()
|
protected void |
clearCaches()
Clear the caches in BshClassManager |
protected static UtilEvalError |
cmUnavailable()
|
static BshClassManager |
createClassManager(Interpreter interpreter)
Create a new instance of the class manager. |
Class |
defineClass(String name,
byte[] code)
|
protected void |
definingClass(String className)
Flag the class name as being in the process of being defined. |
protected void |
doneDefiningClass(String className)
Indicate that the specified class name has been defined and may be loaded normally. |
protected void |
doSuperImport()
Support for "import *;" Hide details in here as opposed to NameSpace. |
void |
dump(PrintWriter pw)
|
protected String |
getClassBeingDefined(String className)
This method is a temporary workaround used with definingClass. |
protected String |
getClassNameByUnqName(String name)
Return the name or null if none is found, Throw an ClassPathException containing detail if name is ambigous. |
protected Method |
getResolvedMethod(Class clas,
String methodName,
Class[] types,
boolean onlyStatic)
Return a previously cached resolved method. |
URL |
getResource(String path)
Get a resource URL using the BeanShell classpath |
InputStream |
getResourceAsStream(String path)
Get a resource stream using the BeanShell classpath |
protected boolean |
hasSuperImport()
A "super import" ("import *") operation has been performed. |
protected boolean |
isClassBeingDefined(String className)
|
protected Class |
loadSourceClass(String name)
|
protected static Error |
noClassDefFound(String className,
Error e)
Annotate the NoClassDefFoundError with some info about the class we were trying to load. |
Class |
plainClassForName(String name)
Perform a plain Class.forName() or call the externally provided classloader. |
void |
reloadAllClasses()
Overlay the entire path with a new class loader. |
void |
reloadClasses(String[] classNames)
Reloading classes means creating a new classloader and using it whenever we are asked for classes in the appropriate space. |
void |
reloadPackage(String pack)
Reload all classes in the specified package: e.g. |
void |
removeListener(BshClassManager.Listener l)
|
void |
reset()
Clear all loaders and start over. |
void |
setClassLoader(ClassLoader externalCL)
Set an external class loader. |
void |
setClassPath(URL[] cp)
Set a new base classpath and create a new base classloader. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected transient Hashtable absoluteClassCache
protected transient Hashtable absoluteNonClasses
protected transient Hashtable resolvedObjectMethods
protected transient Hashtable resolvedStaticMethods
protected transient Hashtable definingClasses
protected transient Hashtable definingClassesBaseNames
Constructor Detail |
public BshClassManager()
Method Detail |
public static BshClassManager createClassManager(Interpreter interpreter)
bsh.Interpreter.getClassManager()
,
bsh.Interpreter.setClassLoader( ClassLoader )
public boolean classExists(String name)
public Class classForName(String name)
protected Class loadSourceClass(String name)
public Class plainClassForName(String name) throws ClassNotFoundException
ClassNotFoundException
classForName( String )
public URL getResource(String path)
path
- should be an absolute pathpublic InputStream getResourceAsStream(String path)
path
- should be an absolute pathpublic void cacheClassInfo(String name, Class value)
value
- if value is non-null, cache the class
if value is null, set the flag that it is *not* a class to
speed later resolutionpublic void cacheResolvedMethod(Class clas, Class[] types, Method method)
protected Method getResolvedMethod(Class clas, String methodName, Class[] types, boolean onlyStatic)
onlyStatic
- specifies that only a static method may be returned.
protected void clearCaches()
void #reset() for external usage
public void setClassLoader(ClassLoader externalCL)
public void addClassPath(URL path) throws IOException
IOException
public void reset()
public void setClassPath(URL[] cp) throws UtilEvalError
UtilEvalError
public void reloadAllClasses() throws UtilEvalError
UtilEvalError
public void reloadClasses(String[] classNames) throws UtilEvalError
UtilEvalError
public void reloadPackage(String pack) throws UtilEvalError
UtilEvalError
protected void doSuperImport() throws UtilEvalError
UtilEvalError
protected boolean hasSuperImport()
protected String getClassNameByUnqName(String name) throws UtilEvalError
UtilEvalError
public void addListener(BshClassManager.Listener l)
public void removeListener(BshClassManager.Listener l)
public void dump(PrintWriter pw)
protected void definingClass(String className)
protected boolean isClassBeingDefined(String className)
protected String getClassBeingDefined(String className)
protected void doneDefiningClass(String className)
public Class defineClass(String name, byte[] code)
protected void classLoaderChanged()
protected static Error noClassDefFound(String className, Error e)
protected static UtilEvalError cmUnavailable()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |