Package org.zeroturnaround.javarebel
Interface Reloader
-
public interface ReloaderProvides control and notification over/on class loading and reloading. To use acquire an instance from the
ReloaderFactory.ReloaderFactory.getInstance() .addClassReloadListener(new ClassEventListener() { public void onClassEvent(int eventType, Class klass) { System.out.println( "Class '" + klass.getName() + "' was reloaded!"); } });- Author:
- Jevgeni Kabanov (ekabanov@zeroturnaround.com)
- See Also:
ReloaderFactory,Integration,Configuration,Logger,Plugin
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidaddBeforeReloadCheck(Runnable beforeReloadCheck)Register aRunnableto receive notifications before we start reloading all the changed classes.voidaddClassLoadListener(ClassEventListener listener)Register aClassEventListenerto receive notifications when managed classes are loaded.voidaddClassReloadListener(Class<?>[] classes, ClassEventListener listener)Register aClassEventListenerto receive notifications when one of the given managed classes is reloaded.voidaddClassReloadListener(Class<?> klass, ClassEventListener listener)Register aClassEventListenerto receive notifications when the given managed class is reloaded.voidaddClassReloadListener(Reference<? extends ClassEventListener> listener)Register aClassEventListenerto receive notifications when managed classes are reloaded.voidaddClassReloadListener(ClassEventListener listener)Register aClassEventListenerto receive notifications when managed classes are reloaded.voidaddDependencyReloadListener(Class<?> klass, Class<?>[] dependencies, ClassEventListener listener)Register aClassEventListenerto receive notifications when one of the given managed dependent classes is reloaded.voidaddHierarchyReloadListener(Class<?> klass, ClassEventListener listener)Register aClassEventListenerto receive notifications when the given managed class, it's super class or any of it's interfaces is reloaded.voidaddReloadCheckListener(Class<?> klass, ReloadCheckListener listener)Deprecated.voidblockReloadListeners(int priority)Block reloads with priority lower than given from executing before current reload listener has completed.booleancheckAndReload(Class<?> klass)Causes a class to be reloaded if (and only if) the underlying ".class" file has been updated.voidforceCheck()Ensure that classes are checked for changes even when previous check was just performed.booleanisReloadableClass(Class<?> klass)Returns whether this particular class is managed by JRebel and will be reloaded when it's updated.booleanisReloadEnabled()Returns whether reloading is enabled generally.booleanisReloadingClass(Class<?> klass)Returns whether this particular class is currently being reloaded.voidreinitClass(Class<?> klass)voidreinitOnReload(Class<?> klass)voidreinitOnReload(String className)voidremoveClassLoadListener(ClassEventListener listener)Deregister aClassEventListener.voidremoveClassReloadListener(Reference<? extends ClassEventListener> listener)Deregister aClassEventListener.voidremoveClassReloadListener(ClassEventListener listener)Deregister aClassEventListener.voidtriggerClassReload()Notify that some class has been reloaded or that it will be reloaded.voidwaitForReload()In case change detection is performed in a background thread wait for change detection and reload to complete.
-
-
-
Method Detail
-
isReloadEnabled
boolean isReloadEnabled()
Returns whether reloading is enabled generally.- Returns:
- Whether reloading is enabled generally.
-
isReloadableClass
boolean isReloadableClass(Class<?> klass)
Returns whether this particular class is managed by JRebel and will be reloaded when it's updated.- Parameters:
klass- Any class.- Returns:
- Whether this particular class is managed by JRebel and will be reloaded when it's updated.
-
isReloadingClass
boolean isReloadingClass(Class<?> klass)
Returns whether this particular class is currently being reloaded. This istruewhile theClassEventListener-s receive the events.- Parameters:
klass- Class managed by JRebel.- Returns:
- whether this particular class is currently being reloaded.
- Since:
- 3.0
-
checkAndReload
boolean checkAndReload(Class<?> klass)
Causes a class to be reloaded if (and only if) the underlying ".class" file has been updated. Returns true if reloaded, false otherwise.
Note, that as JRebel is lazy, such checks may be necessary if you want to be sure that your metadata is up-to-date. The
ClassEventListenerwill only fire after JRebel has reloaded the class, which by default occurs on method calls to the class in question (and some reflection methods).- Parameters:
klass- The class to check.- Returns:
- true if reloaded, false otherwise.
- See Also:
ClassEventListener
-
forceCheck
void forceCheck()
Ensure that classes are checked for changes even when previous check was just performed. This method should be used with classes that are generated by application server or some framework to make sure they get reloaded immediately, otherwise if a reload check has been just done next check may be delayed.
-
triggerClassReload
void triggerClassReload()
Notify that some class has been reloaded or that it will be reloaded.
-
waitForReload
void waitForReload()
In case change detection is performed in a background thread wait for change detection and reload to complete.
-
addReloadCheckListener
void addReloadCheckListener(Class<?> klass, ReloadCheckListener listener)
Deprecated.Register aReloadCheckListenerto receive notifications when last modified time is being checked.- Parameters:
klass- The class being checked.- Since:
- 3.0
-
addClassLoadListener
void addClassLoadListener(ClassEventListener listener)
Register aClassEventListenerto receive notifications when managed classes are loaded.
-
removeClassLoadListener
void removeClassLoadListener(ClassEventListener listener)
Deregister aClassEventListener.
-
addClassReloadListener
void addClassReloadListener(ClassEventListener listener)
Register aClassEventListenerto receive notifications when managed classes are reloaded.
-
addClassReloadListener
void addClassReloadListener(Reference<? extends ClassEventListener> listener)
Register aClassEventListenerto receive notifications when managed classes are reloaded. This method accepts Weak/Soft references.
-
addClassReloadListener
void addClassReloadListener(Class<?> klass, ClassEventListener listener)
Register aClassEventListenerto receive notifications when the given managed class is reloaded.
-
addClassReloadListener
void addClassReloadListener(Class<?>[] classes, ClassEventListener listener)
Register aClassEventListenerto receive notifications when one of the given managed classes is reloaded.
-
addDependencyReloadListener
void addDependencyReloadListener(Class<?> klass, Class<?>[] dependencies, ClassEventListener listener)
Register aClassEventListenerto receive notifications when one of the given managed dependent classes is reloaded. When the given class is being checked the dependencies are automatically checked, The registered listener will be provided with the registered class (not a dependency just reloaded).
-
addHierarchyReloadListener
void addHierarchyReloadListener(Class<?> klass, ClassEventListener listener)
Register aClassEventListenerto receive notifications when the given managed class, it's super class or any of it's interfaces is reloaded. When the given class is being checked the dependencies are automatically checked, The registered listener will be provided with the registered class (not a dependency just reloaded).
-
addBeforeReloadCheck
void addBeforeReloadCheck(Runnable beforeReloadCheck)
Register aRunnableto receive notifications before we start reloading all the changed classes. Sometimes we need to re-create some state before class reloads, because some classes need to be transformed at load time based on the state- Since:
- 18.2.3
-
removeClassReloadListener
void removeClassReloadListener(ClassEventListener listener)
Deregister aClassEventListener.
-
removeClassReloadListener
void removeClassReloadListener(Reference<? extends ClassEventListener> listener)
Deregister aClassEventListener. This method accepts Weak/Soft references.
-
reinitClass
void reinitClass(Class<?> klass)
-
reinitOnReload
void reinitOnReload(Class<?> klass)
-
reinitOnReload
void reinitOnReload(String className)
-
blockReloadListeners
void blockReloadListeners(int priority)
Block reloads with priority lower than given from executing before current reload listener has completed.- Parameters:
priority-
-
-