开发:在web.xml中注册Intros

开发:在l中注册Intros

增加方式以下:l中加入rospectorCleanupListener/listener-class/rospectorCleanupListener源代码中对其的解释以下:在Web应用程序关闭时IntrospectorCleanupListener将会刷新JDK的JavaBeans的Introspector缓存。在你的l中注册这个listener来确保Web应用程序的类加载器以及其加载的类正确的释放资源。如果JavaBeans的Introspector已被用来分析应用程序类,系统级的Introspector缓存将持有这些类的一个硬援用。因此,这些类和Web应用程序的类加载器在Web应用程序关闭时将不会被垃圾搜集器回收!而IntrospectorCleanupListener则会对其进行适当的清算,已使其能够被垃圾搜集器回收。不幸的是,唯一能够清算Introspector的方法是刷新全部Introspector缓存,没有其他办法来确切指定应用程序所援用的类。这将删除所有其他应用程序在服务器的缓存的Introspector结果。请注意,在使用Spring内部的bean机制时,不需要使用此监听器,由于Spring自己的introspectionresultscache将会立即刷新被分析过的JavaBeansIntrospectorcache,而仅仅会在应用程序自己的ClassLoader里面持有一个cache。虽然Spring本身不产生泄漏,注意,即便在Spring框架的类本身驻留在一个“共同”类加载器(如系统的ClassLoader)的情况下,也依然应当使用使用IntrospectorCleanupListener。在这种情况下,这个IntrospectorCleanupListener将会妥善清算Spring的introspectioncache。应用程序类,几近不需要直接使用JavaBeansIntrospector,所以,通常都不是Introspectorresource造成内存泄漏。相反,许多库和框架,不清算Introspector,例如:Struts和Quartz。需要注意的是一个简单Introspector泄漏将会致使全部Web应用程序的类加载器不会被回收!这样做的结果,将会是在web应用程序关闭时,该应用程序所有的静态类资源(比如:单实例对象)都没有得到释放。而致使内存泄漏的根本原因其实并不是这些未被回收的类!IntrospectorCleanupListener应当注册为l中的第一个Listener,在任何其他Listener之前注册,比如在SpringsContextLoaderListener注册之前,才能确保IntrospectorCleanupListener在Web运用的生命周期适当时机生效。下面是源码/**Copyright-theoriginalauthororauthors.**LicensedundertheApacheLicense,Version2.0(theLicense);*youmaynotusethisfileexceptin
































北京治白癜风的医院哪家最好
怎么样治好白癜风



转载请注明:http://www.guyukameng.com/php/701.html