-
Andy Wilkinson authored
Previously, @WebListeners were discovered via custom component scanning and then registered programmatically via the ServletContext. The servlet spec requires any ServletContextListener registered in this manner to be prohibited from programatically configuring servlets, filters, and listeners. This left us not strictly complying with the servlet spec as a ServletContextListener registered via a @WebListener annotation should be able to programatically configure other components. This commit updates WebListenerHandler to register each @WebListener component directly with Jetty, Tomcat, or Undertow rather than via the ServletContext API. This ensure that any @WebListener-annoated ServletContextListener registered via servlet component scanning is able to programatically register servlets, filters, and listeners. There is a small chance that this will be a breaking change for some users: 1. The ServletListenerRegistrationBeans that were previously defined for each @WebListener will now be WebListenerHandler.WebListenerRegistrars 2. Each @WebListener-annotated class will now be instantiated by Jetty, Tomcat, or Undertow. Jetty and Tomcat both require the class to be public and have a public default constructor. Previously, a package-private class or default constructor could be used as the instantiation was performed by Spring Framework. Undertow is not affected as it can instantiate a package-private type. Fixes gh-18303
fafc0a91