|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--bsh.BshClassManager
|
+--bsh.classpath.ClassManagerImpl
Manage all classloading in BeanShell.
Allows classpath extension and class file reloading.
This class holds the implementation of the BshClassManager so that it
can be separated from the core package.
This class currently relies on 1.2 for BshClassLoader and weak references.
Is there a workaround for weak refs? If so we could make this work
with 1.1 by supplying our own classloader code...
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.
Note: we may need some synchronization in here
Note on jdk1.2 dependency:
We are forced to use weak references here to accomodate all of the
fleeting namespace listeners. (NameSpaces must be informed if the class
space changes so that they can un-cache names). I had the interesting
thought that a way around this would be to implement BeanShell's own
garbage collector... Then I came to my senses and said - screw it,
class re-loading will require 1.2.
| Nested Class Summary |
| Nested classes inherited from class bsh.BshClassManager |
BshClassManager.Listener |
| Field Summary | |
private BshClassPath |
baseClassPath
The classpath of the base loader. |
private BshClassLoader |
baseLoader
This handles extension / modification of the base classpath The loader to use where no mapping of reloaded classes exists. |
private BshClassPath |
fullClassPath
This is the full blown classpath including baseClassPath (extensions), user path, and java bootstrap path (rt.jar) This is lazily constructed and further (and more importantly) lazily intialized in components because mapping the full path could be expensive. |
private java.util.Vector |
listeners
|
private java.util.Map |
loaderMap
Map by classname of loaders to use for reloaded classes |
private java.lang.ref.ReferenceQueue |
refQueue
|
| Fields inherited from class bsh.BshClassManager |
absoluteClassCache, absoluteNonClasses |
| Constructor Summary | |
ClassManagerImpl()
Used by BshClassManager singleton constructor |
|
| Method Summary | |
void |
addClassPath(java.net.URL path)
|
void |
addListener(BshClassManager.Listener l)
|
protected void |
classLoaderChanged()
Clear global class cache and notify namespaces to clear their class caches. |
void |
doSuperImport()
Support for "import *;" Hide details in here as opposed to NameSpace. |
void |
dump(java.io.PrintWriter i)
|
java.lang.ClassLoader |
getBaseLoader()
|
java.lang.Class |
getClassForName(java.lang.String name)
|
java.lang.String |
getClassNameByUnqName(java.lang.String name)
Return the name or null if none is found, Throw an ClassPathException containing detail if name is ambigous. |
BshClassPath |
getClassPath()
Get the full blown classpath. |
java.lang.ClassLoader |
getLoaderForClass(java.lang.String name)
|
java.lang.Class |
getPlainClassForName(java.lang.String name)
Delegate for bottom level implementation of Class.forName(). |
private void |
initBaseLoader()
init the baseLoader from the baseClassPath |
void |
reloadAllClasses()
Overlay the entire path with a new class loader. |
void |
reloadClasses(java.lang.String[] classNames)
Reloading classes means creating a new classloader and using it whenever we are asked for classes in the appropriate space. |
void |
reloadPackage(java.lang.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 |
setClassPath(java.net.URL[] cp)
Set a new base classpath and create a new base classloader. |
| Methods inherited from class bsh.BshClassManager |
addCMListener, cacheClassInfo, classExists, classForName, clearCaches, getClassManager, plainClassForName, setClassLoader |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private BshClassPath baseClassPath
private BshClassPath fullClassPath
private java.util.Vector listeners
private java.lang.ref.ReferenceQueue refQueue
private BshClassLoader baseLoader
private java.util.Map loaderMap
| Constructor Detail |
public ClassManagerImpl()
| Method Detail |
public java.lang.Class getClassForName(java.lang.String name)
getClassForName in class BshClassManagerBshClassManager.classForName( String )
public java.lang.Class getPlainClassForName(java.lang.String name)
throws java.lang.ClassNotFoundException
getPlainClassForName in class BshClassManagerjava.lang.ClassNotFoundExceptionBshClassManager.plainClassForName()public java.lang.ClassLoader getBaseLoader()
getBaseLoader in class BshClassManagerpublic java.lang.ClassLoader getLoaderForClass(java.lang.String name)
getLoaderForClass in class BshClassManager
public void addClassPath(java.net.URL path)
throws java.io.IOException
addClassPath in class BshClassManagerjava.io.IOExceptionpublic void reset()
reset in class BshClassManagerpublic void setClassPath(java.net.URL[] cp)
setClassPath in class BshClassManager
public void reloadAllClasses()
throws ClassPathException
reloadAllClasses in class BshClassManagerClassPathExceptionprivate void initBaseLoader()
public void reloadClasses(java.lang.String[] classNames)
throws ClassPathException
reloadClasses in class BshClassManagerClassPathException
public void reloadPackage(java.lang.String pack)
throws ClassPathException
reloadPackage in class BshClassManagerClassPathException
public BshClassPath getClassPath()
throws ClassPathException
ClassPathException
public void doSuperImport()
throws EvalError
doSuperImport in class BshClassManagerEvalError
public java.lang.String getClassNameByUnqName(java.lang.String name)
throws ClassPathException
getClassNameByUnqName in class BshClassManagerClassPathExceptionpublic void addListener(BshClassManager.Listener l)
addListener in class BshClassManagerpublic void removeListener(BshClassManager.Listener l)
removeListener in class BshClassManagerprotected void classLoaderChanged()
classLoaderChanged in class BshClassManagerpublic void dump(java.io.PrintWriter i)
dump in class BshClassManager
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||