org.springframework.web.util
Class IntrospectorCleanupListener
java.lang.Object
org.springframework.web.util.IntrospectorCleanupListener
- All Implemented Interfaces:
- EventListener, ServletContextListener
public class IntrospectorCleanupListener
- extends Object
- implements ServletContextListener
Listener that flushes the JavaBeans Introspector cache on web app shutdown.
Register this listener in your web.xml to guarantee proper release of
the web app class loader and the classes that it holds.
If the JavaBeans Introspector has been used to analyze application classes,
the Introspector cache will hold a hard reference to those classes.
Consequently, those classes and the web app class loader will not be
garbage collected on web app shutdown!
Unfortunately, the only way to clean up the Introspector is to flush
the entire cache, as there is no way to specifically determine the
application's classes referenced there. This will remove cached
introspection results for all other applications in the server too.
Note that this listener is not necessary when using Spring's
beans infrastructure, as Spring's own introspection results cache will
immediately flush an analyzed class from the JavaBeans Introspector cache.
Application classes hardly ever need to use the JavaBeans Introspector
directly, so are normally not the cause of Introspector resource leaks.
Rather, many libraries and frameworks do not clean up the Introspector,
for example Struts and Quartz.
Note that a single such Introspector leak will cause the entire web
app class loader to not get garbage collected! This has the consequence that
you will see all the application's static class resources (like singletons)
around after web app shutdown, which is not the fault of those classes!
- Since:
- 1.1
- Author:
- Juergen Hoeller
- See Also:
Introspector.flushCaches()
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IntrospectorCleanupListener
public IntrospectorCleanupListener()
contextInitialized
public void contextInitialized(ServletContextEvent event)
- Specified by:
contextInitialized
in interface ServletContextListener
contextDestroyed
public void contextDestroyed(ServletContextEvent event)
- Specified by:
contextDestroyed
in interface ServletContextListener
Copyright (c) 2002-2005 The Spring Framework Project.