2016-01-04 19:14 GMT+03:00 Mark Thomas <ma...@apache.org>: > Given that the Tomcat code doesn't contain any classes that implement > InstanceListener is looks to be unused internally. I'm wondering if > anyone else is using it. If not, there is a chunk of code we could > remove including a bunch of (admittedly simple/fast) calls made on every > request. > > Could we deprecate this in 8.0.x and remove it in 9.0.x?
The same discussion from 5 years ago (2011-01-07): http://tomcat.markmail.org/thread/fktuhl2ndeplpi6r "[PROPOSAL] Remove o.a.catlina.InstanceListener" Remy mentioned in that thread that JBoss class that I found (public class RunAsListener implements InstanceListener) is not relevant. A random copy (google'd) is here, http://stanford.edu/class/cs295/asgns/asgn6/src/org/jboss/web/tomcat/security/RunAsListener.java I think that nowadays there are better ways to inject behaviour / implement wrappers around init(), service() etc. - via AOP [1]. A Servlet and Filter are interfaces. We have instrumentation support in WebappClassLoader. Maybe AOP needs some hooks in other places. A working example is needed. But generally it would be better to use that rather than support this costly callback interface with a pair of events for each wrapped method. In other words, an alternative to InstanceListener can be to provide a hook that is called when a Filter / Servlet / Listener instance is created / added to a web application and to allow to wrap that instance. Implementation of that hook can create a proxy for the class on the fly as needed. Do we already have such a hook? A hook that allows to wrap a servlet at creation time is InstanceManager. I see no hook when adding a Servlet instance that is created by a web application (via ServletContext.addServlet(String, String, Servlet)), but in general one can implement a LifecycleListener and enumerate wrappers after a web application have started. The servlet instance can be obtained and replaced via StandardWrapper.getServlet()/setServlet(). I am OK with removal of InstanceListener. Best regards, Konstantin Kolinko [1] http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org