public class ClassLoaderLeakPreventorFactory extends Object
logger may need to be thread safe.| Modifier and Type | Field and Description |
|---|---|
protected Map<String,ClassLoaderPreMortemCleanUp> |
cleanUps
Map from name to
ClassLoaderPreMortemCleanUps with all the actions to invoke to make a
ClassLoader ready for Garbage Collection. |
protected ClassLoader |
leakSafeClassLoader
ClassLoader to be used when invoking the PreClassLoaderInitiators. |
protected Logger |
logger
The
Logger that will be passed on to the different PreClassLoaderInitiators and
ClassLoaderPreMortemCleanUps |
protected Map<String,PreClassLoaderInitiator> |
preInitiators
Map from name to
PreClassLoaderInitiators with all the actions to invoke in the
leakSafeClassLoader. |
| Constructor and Description |
|---|
ClassLoaderLeakPreventorFactory()
Create new
ClassLoaderLeakPreventorFactory with ClassLoader.getSystemClassLoader() as the
leakSafeClassLoader and default PreClassLoaderInitiators and ClassLoaderPreMortemCleanUps. |
ClassLoaderLeakPreventorFactory(ClassLoader leakSafeClassLoader)
Create new
ClassLoaderLeakPreventorFactory with supplied ClassLoader as the
leakSafeClassLoader and default PreClassLoaderInitiators and ClassLoaderPreMortemCleanUps. |
protected final ClassLoader leakSafeClassLoader
ClassLoader to be used when invoking the PreClassLoaderInitiators.
Defaults to ClassLoader.getSystemClassLoader(), but could be any other framework or
app server classloader.protected Logger logger
Logger that will be passed on to the different PreClassLoaderInitiators and
ClassLoaderPreMortemCleanUpsprotected final Map<String,PreClassLoaderInitiator> preInitiators
PreClassLoaderInitiators with all the actions to invoke in the
leakSafeClassLoader. Maintains insertion order. Thread safe.protected final Map<String,ClassLoaderPreMortemCleanUp> cleanUps
ClassLoaderPreMortemCleanUps with all the actions to invoke to make a
ClassLoader ready for Garbage Collection. Maintains insertion order. Thread safe.public ClassLoaderLeakPreventorFactory()
ClassLoaderLeakPreventorFactory with ClassLoader.getSystemClassLoader() as the
leakSafeClassLoader and default PreClassLoaderInitiators and ClassLoaderPreMortemCleanUps.public ClassLoaderLeakPreventorFactory(ClassLoader leakSafeClassLoader)
ClassLoaderLeakPreventorFactory with supplied ClassLoader as the
leakSafeClassLoader and default PreClassLoaderInitiators and ClassLoaderPreMortemCleanUps.public void configureDefaults()
PreClassLoaderInitiators and ClassLoaderPreMortemCleanUpspublic ClassLoaderLeakPreventor newLeakPreventor()
ClassLoaderLeakPreventor used to prevent the provided Thread.contextClassLoader of the
Thread.currentThread() from leaking.
Please be aware that ClassLoaderLeakPreventors created by the same factory share the same
PreClassLoaderInitiator and ClassLoaderPreMortemCleanUp instances, in case their config is changed.public ClassLoaderLeakPreventor newLeakPreventor(ClassLoader classLoader)
ClassLoaderLeakPreventor used to prevent the provided ClassLoader from leakingpublic void setLogger(Logger logger)
public void addPreInitiator(PreClassLoaderInitiator preClassLoaderInitiator)
PreClassLoaderInitiator, using the class name as namepublic void addCleanUp(ClassLoaderPreMortemCleanUp classLoaderPreMortemCleanUp)
ClassLoaderPreMortemCleanUp, using the class name as namepublic void addCleanUp(String name, ClassLoaderPreMortemCleanUp classLoaderPreMortemCleanUp)
ClassLoaderPreMortemCleanUppublic void clearPreInitiators()
PreClassLoaderInitiatorspublic void clearCleanUps()
ClassLoaderPreMortemCleanUpspublic <C extends PreClassLoaderInitiator> C getPreInitiator(Class<C> clazz)
PreClassLoaderInitiator for further configuring.
Please be aware that ClassLoaderLeakPreventors created by the same factory share the same
PreClassLoaderInitiator and ClassLoaderPreMortemCleanUp instances, in case their config is changed.public <C extends ClassLoaderPreMortemCleanUp> C getCleanUp(Class<C> clazz)
ClassLoaderPreMortemCleanUp for further configuring.
Please be aware that ClassLoaderLeakPreventors created by the same factory share the same
PreClassLoaderInitiator and ClassLoaderPreMortemCleanUp instances, in case their config is changed.public <C extends PreClassLoaderInitiator> void removePreInitiator(Class<C> clazz)
PreClassLoaderInitiator for further configuringpublic <C extends ClassLoaderPreMortemCleanUp> void removeCleanUp(Class<C> clazz)
ClassLoaderPreMortemCleanUp for further configuringCopyright © 2019. All rights reserved.