com.myarch.reloader
Interface LoadController
- All Known Implementing Classes:
- ClassCollectionController, ReloadAllController, ReloadMainController, ReloadPackageController
- public interface LoadController
After Reloader.reload()
was called and the main class was loaded, JVM uses the main class' class loader
for all classes that the main class uses (calls, extends or refers to). Therefore, it is
important to be able to load these classes selectively to avoid ClassCastException
.
Reloader
always uses an instance of LoadController
to figure out what classes to load.
Reloader
or, more precisely, the class loader created by Reloader
,
calls LoadController
every time it needs to load a class. It only loads classes for which
isReloadAllowed
returns true.
- Author:
- Alexander Ananiev
Method Summary |
boolean |
isLoadByParentAllowed(java.lang.String className,
java.lang.String mainClassName,
java.lang.ClassLoader loader)
If the class loader used by Reloader fails to load a loadable class
(isReloadAllowed(...)==true)
it may delegate to its parent loader.
|
boolean |
isReloadAllowed(java.lang.String className,
java.lang.String mainClassName,
java.lang.ClassLoader loader)
Class loader will try to load a class only if this method returns true . |
isReloadAllowed
public boolean isReloadAllowed(java.lang.String className,
java.lang.String mainClassName,
java.lang.ClassLoader loader)
- Class loader will try to load a class only if this method returns
true
.
- Parameters:
className
- class name to loadmainClassName
- name of the "main" class.
Main class is a class passed as a parameter to Reloader.reload()
method.loader
- the actual class loader used to load a class.- Returns:
true
if class className
is allowed to be loaded.
isLoadByParentAllowed
public boolean isLoadByParentAllowed(java.lang.String className,
java.lang.String mainClassName,
java.lang.ClassLoader loader)
- If the class loader used by
Reloader
fails to load a loadable class
(isReloadAllowed(...)==true)
it may delegate to its parent loader.
Most controllers should not allow for using parent loader. Parent loader (which is usually system loader)
will cache class files so
there is no guarantee that the class will actually be reloaded.
Note that this method is called only if isReloadAllowed()
previously
returned true
for this class. For all other classes (non-reloadable classes)
parent loader will be called regardless.
Returning false
from this method ensures that class either reloaded or
ClassNotFoundException
is thrown.
- Parameters:
className
- class name to loadmainClassName
- name of the "main" class.
Main class is a class passed as a parameter to Reloader.reload()
method.loader
- the actual class loader used to load a class (parent loader).- Returns:
true
if class className
is allowed to be loaded by the parent loader.
Copyright © 2001 Alexander Ananiev & MyArch.com. All Rights Reserved.