|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.myarch.reloader.Reloader
Performs dynamic class loading (reloading).
Uses controller object to figure out what classes to load.
When reload()
is called, loads the class passed as the
parameter and, depending on the controller, called classes.
For every reload()
call creates the new class loader
to clear the cache of loaded classes.
Field Summary | |
static java.lang.String |
RELOAD_ENABLE_PROPERTY
System property to turn reloading on/off. |
Constructor Summary | |
Reloader()
Constructs a new Reloader with default settings.
|
|
Reloader(java.lang.ClassLoader parent)
Constructs a new Reloader and sets
parent class loader for URLClassLoader that will be
used for reload() call.
|
|
Reloader(LoadController ctl)
Constructs a new Reloader for the specified controller. |
|
Reloader(java.net.URL[] urls)
Constructs a new Reloader for the specified URLs and
default controller.
|
|
Reloader(java.net.URL[] urls,
java.lang.ClassLoader parent)
Constructs a new Reloader for the specified URLs, parent class loader and
default controller.
|
|
Reloader(java.net.URL[] urls,
LoadController ctl)
Constructs a new Reloader for the specified URLs and controller.
|
Method Summary | |
java.lang.ClassLoader |
getParent()
Returns currently set parent class loader. |
java.net.URL[] |
getURLs()
Returns the current array of URLs for class loader. |
java.lang.Class |
reload(java.lang.String name)
Loads the class and classes used by this class depending on the controller. |
static boolean |
reloadEnabled()
|
void |
setLoadController(LoadController ctl)
Sets the controller object for Reloader . |
void |
setLogger(LoadActionListener logger)
Sets custom logger. |
void |
setParent(java.lang.ClassLoader parent)
Sets parent class loader for URLClassLoader that will be
used for reload() call.
|
static void |
setReloadOff()
Turns reloading off for all instances of Reloader .
|
static void |
setReloadOn()
Turns reloading on for all instances of Reloader .
|
void |
setURLs(java.net.URL[] urls)
Sets URLs for Reloader .
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String RELOAD_ENABLE_PROPERTY
-Dreloader.reload=yes
(or any value other than "no")
-Dreloader.reload=no
Constructor Detail |
public Reloader()
Reloader
with default settings.
ReloadMainController
is the default, so only main class
(the class passed to reload()
as a parameter) will be reloaded.public Reloader(java.net.URL[] urls)
Reloader
for the specified URLs and
default controller.
Reloader
uses class loader inherited from URLClassLoader
,
so URLs are passed to the URLClassLoader
during reload()
call.
urls
- the URLs from which to load classespublic Reloader(java.net.URL[] urls, java.lang.ClassLoader parent)
Reloader
for the specified URLs, parent class loader and
default controller.
ClassLoader.getSystemClassLoader()
) is used
as the default parent.urls
- the URLs from which to load classesparent
- the parent class loader for delegationpublic Reloader(LoadController ctl)
Reloader
for the specified controller.ctl
- controller object. Controller provides Reloader
with the list
of classes for loading.public Reloader(java.net.URL[] urls, LoadController ctl)
Reloader
for the specified URLs and controller.
urls
- the URLs from which to load classesctl
- controller object. Controller provides Reloader
with the list
of classes for loading.public Reloader(java.lang.ClassLoader parent)
Reloader
and sets
parent class loader for URLClassLoader
that will be
used for reload()
call.
Normally, it should be the loader of the calling class, i.e.
reloader = new Reloader( this.getClass().getClassLoader() );
setURLs()
.parent
- the parent class loader for delegationMethod Detail |
public static void setReloadOn()
Reloader
.
setReloadOff()
.public static void setReloadOff()
Reloader
.
-Dreloader.reload=no
.
public static boolean reloadEnabled()
public void setLoadController(LoadController ctl)
Reloader
. Controller provides
Reloader
with the list of classes for loading.ctl
- controller object.public void setURLs(java.net.URL[] urls)
Reloader
.
Reloader
uses class loader inherited from URLClassLoader
,
so URLs are passed to the URLClassLoader
during reload()
call.
urls
- the URLs from which to load classespublic java.net.URL[] getURLs()
public void setParent(java.lang.ClassLoader parent)
URLClassLoader
that will be
used for reload()
call.
Normally, it should be the loader of the calling class, i.e.
reloader = new Reloader( this.getClass().getClassLoader() );
parent
- the parent class loader for delegationpublic java.lang.ClassLoader getParent()
parent
- the parent class loader for delegationpublic void setLogger(LoadActionListener logger)
ReloadLogger
.
To create custom logger, implement LoadActionListener
interface.logger
- custom loggerpublic java.lang.Class reload(java.lang.String name) throws java.lang.ClassNotFoundException
URLClassLoader
).
For each class that should be loaded, the class loader calls the controller.
If the controller permits to load the class, the class loader tries to load it.
If it can not load the class,
it calls its parent class loader.name
- class name to loadjava.lang.ClassNotFoundException
- if class loader or its parent did not find the class
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |