-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a mechanism for adding ApplicationContextInitializers to DispatcherServlet's ApplicationContext [SPR-11314] #15938
Comments
Glyn Normington commented For anyone who didn't dig into the reference URL, the goal of this feature is to support auto-reconfiguration for servlet 3 applications. |
Juergen Hoeller commented I've implemented this as a "globalInitializerClasses" init-param now, basically like the existing "contextInitializerClasses" but applying to FrameworkServlets as well. They are applied right at the end of context initialization but still before locally specified "contextInitializerClasses", if any, to preserve a remaining chance for overriding. Since this implementation is rather straightforward, I'm backporting it to 3.2.7 as well. Can't remember whether you ever asked for it, but here you go :-) Juergen |
Juergen Hoeller commented Guys, please test this over the next few days against the latest snapshots. Would be great to have it verified to work with both 4.0.1 and 3.2.7 before that pair gets released on Jan 23... Juergen |
nebhale commented Juergen Hoeller, is this a replacement for the |
Juergen Hoeller commented This is in addition to the regular contextInitializerClasses value; both settings are evaluated. However, I wouldn't expect much mixing-and-matching there. Juergen |
nebhale commented Juergen Hoeller I've tried the latest snapshot ( ctx.setInitParameter(ContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM,
AutoReconfigurationApplicationContextInitializer.class.getCanonicalName());
ctx.setInitParameter(ContextLoader.GLOBAL_INITIALIZER_CLASSES_PARAM,
AutoReconfigurationApplicationContextInitializer.class.getCanonicalName()); I still see the root context doing the right thing, but no change to the |
Juergen Hoeller commented Hmm, just the "globalInitializerClasses" init-param should be sufficient for all application contexts. So there's no need to set "contextInitializerClasses" in addition. Does "globalInitializerClasses" alone apply to the root context correctly, at least? This is how we test the FrameworkServlet effect at the moment:
So I'm not sure what's not working there :-( Juergen |
nebhale commented Looks like an issue on my end (I don't think IDEA replaced my original code in the Tomcat container), but it appears to work. This should be exactly what we need. Thanks for the work. |
Juergen Hoeller commented Cool, good to hear :-) |
nebhale opened SPR-11314 and commented
Currently, there is no way to add an
ApplicationContextInitializer
to theDispatcherServlet
'sApplicationContext
at runtime (i.e. without explicit configuration on the application's part). This is possible to do on the rootApplicationContext
using thecontextInitializerClasses
Servlet init-param.Some mechanism (accessible from a
ServletContainerInitializer
) should be exposed in order to influence theDispatcherServlet
'sApplicationContext
and allow anApplicationContextInitializer
to be added.Affects: 3.2.6, 4.0 GA
Reference URL: https://github.com/nebhale/spring-servlet3-autoreconfig-poc
Referenced from: commits 444b372, 5fb2665, 91881ff
Backported to: 3.2.7
The text was updated successfully, but these errors were encountered: