Example usage for org.springframework.web.context ContextLoaderListener setContextInitializers

List of usage examples for org.springframework.web.context ContextLoaderListener setContextInitializers

Introduction

In this page you can find the example usage for org.springframework.web.context ContextLoaderListener setContextInitializers.

Prototype

@SuppressWarnings("unchecked")
public void setContextInitializers(@Nullable ApplicationContextInitializer<?>... initializers) 

Source Link

Document

Specify which ApplicationContextInitializer instances should be used to initialize the application context used by this ContextLoader .

Usage

From source file:org.springframework.web.context.AbstractContextLoaderInitializer.java

/**
 * Register a {@link ContextLoaderListener} against the given servlet context. The
 * {@code ContextLoaderListener} is initialized with the application context returned
 * from the {@link #createRootApplicationContext()} template method.
 * @param servletContext the servlet context to register the listener against
 *//*from ww w  .  ja  va 2  s  . c  o m*/
protected void registerContextLoaderListener(ServletContext servletContext) {
    WebApplicationContext rootAppContext = createRootApplicationContext();
    if (rootAppContext != null) {
        ContextLoaderListener listener = new ContextLoaderListener(rootAppContext);
        listener.setContextInitializers(getRootApplicationContextInitializers());
        servletContext.addListener(listener);
    } else {
        logger.debug("No ContextLoaderListener registered, as "
                + "createRootApplicationContext() did not return an application context");
    }
}