|
Generated by JDiff |
||||||||
PREV PACKAGE NEXT PACKAGE FRAMES NO FRAMES |
This file contains all the changes in documentation in the packageorg.springframework.web
as colored differences. Deletions are shownlike this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.
Servlet 3.0 ServletContainerInitializer designed to support code-based configuration of the servlet container using Spring's WebApplicationInitializer SPI as opposed to (or possibly in combination with) the traditional {@code web.xml}-based approach.Class SpringServletContainerInitializer, void onStartup(Set<Class<?>>, ServletContext)Mechanism of Operation
This class will be loaded and instantiated and have its .onStartup method invoked by any Servlet 3.0-compliant container during container startup assuming that the {@code spring-web} module JAR is present on the classpath. This occurs through the JAR Services API ServiceLoader.load(Class) method detecting the {@code spring-web} module's {@code META-INF/services/javax.servlet.ServletContainerInitializer} service provider configuration file. See the JAR Services API documentation as well as section 8.2.4 of the Servlet 3.0 Final Draft specification for complete details.
when inIn combination with {@code web.xml}If a web application
does includeincludes a {@code WEB-INF/web.xml} file, it is important to understand that neither this nor any other {@code ServletContextInitializer} will be processed unless the {@code} element's {@code version} attribute is >= "3.0" and the {@code xsi:schemaLocation} for "http://java.sun.com/xml/ns/javaee" is set to "http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd". A web application can choose to limit the amount of classpath scanning the Servlet container does at startup either through the {@code metadata-complete} attribute in {@code web.xml}, which controls scanning for Servlet annotations or through an {@code
} element also in {@code web.xml}, which controls which web fragments (i.e. jars) are allowed to perform a {@code ServletContainerInitializer} scan. When using this feature, the SpringServletContainerInitializer can be enabled by adding "spring_web" to the list of named web fragments in {@code web.xml} as follows: {@code} some_web_fragment spring_web Relationship to Spring's {@code WebApplicationInitializer}
Spring's {@code WebApplicationInitializer} SPI consists of just one method: WebApplicationInitializer.onStartup(ServletContext). The signature is intentionally quite similar to ServletContainerInitializer.onStartup(Set, ServletContext): simply put, {@code SpringServletContainerInitializer} is responsible for instantiating and delegating the {@code ServletContext} to any user-defined {@code WebApplicationInitializer} implementations. It is then the responsibility of each {@code WebApplicationInitializer} to do the actual work of initializing the {@code ServletContext}. The exact process of delegation is described in detail in the onStartup documentation below.General Notes
In general, this class should be viewed as supporting infrastructure for the more important and user-facing {@code WebApplicationInitializer} SPI. Taking advantage of this container initializer is also completely optional: while it is true that this initializer will be loaded and invoked under all Servlet 3.0+ runtimes, it remains the user's choice whether to make any {@code WebApplicationInitializer} implementations available on the classpath. If no {@code WebApplicationInitializer} types are detected, this container initializer will have no effect.Note that use of this container initializer and of {@code WebApplicationInitializer} is not in any way "tied" to Spring MVC other than the fact that the types are shipped in the {@code spring-web} module JAR. Rather, they can be considered general-purpose in their ability to facilitate convenient code-based configuration of the {@code ServletContext}.
Said another wayIn other words, any servlet, listener, or filter may be registered within a {@code WebApplicationInitializer}, not just Spring MVC-specific components.This class is
notneither designed for extension nor intended to be extended. It should beconsideredconsidered an internal type, with {@code WebApplicationInitializer} being the public-facing SPI.See Also
See WebApplicationInitializer Javadoc for examples and detailed usage recommendations.@author Chris Beams @author Juergen Hoeller @author Rossen Stoyanchev @since 3.1 @see #onStartup(Set, ServletContext) @see WebApplicationInitializer
Delegate the {@code ServletContext} to any WebApplicationInitializer implementations present on the application classpath.Because this class declares @{@code HandlesTypes(WebApplicationInitializer.class)}, Servlet 3.0+ containers will automatically scan the classpath for implementations of Spring's {@code WebApplicationInitializer} interface and provide the set of all such types to the {@code webAppInitializerClasses} parameter of this method.
If no {@code WebApplicationInitializer} implementations are found on the classpath, this method is effectively a no-op. An INFO-level log message will be issued notifying the user that the {@code ServletContainerInitializer} has indeed been invoked
,but that no {@code WebApplicationInitializer} implementations were found.Assuming that one or more {@code WebApplicationInitializer} types are detected, they will be instantiated (and sorted if the @@Order annotation is present or the Ordered interface has been implemented). Then the WebApplicationInitializer.onStartup(ServletContext) method will be invoked on each instance, delegating the {@code ServletContext} such that each instance may register and configure servlets such as Spring's {@code DispatcherServlet}, listeners such as Spring's {@code ContextLoaderListener}, or any other Servlet API componentry such as filters. @param webAppInitializerClasses all implementations of WebApplicationInitializer found on the application classpath @param servletContext the servlet context to be initialized @see WebApplicationInitializer#onStartup(ServletContext) @see AnnotationAwareOrderComparator