Example usage for org.springframework.web.context.support XmlWebApplicationContext getClass

List of usage examples for org.springframework.web.context.support XmlWebApplicationContext getClass

Introduction

In this page you can find the example usage for org.springframework.web.context.support XmlWebApplicationContext getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.openmrs.module.web.WebModuleUtil.java

/**
 * Stops, closes, and refreshes the Spring context for the given <code>servletContext</code>
 *
 * @param servletContext//from  w ww. j  a  v a 2 s  . c o m
 * @param isOpenmrsStartup if this refresh is being done at application startup
 * @param startedModule the module that was just started and waiting on the context refresh
 * @return The newly refreshed webApplicationContext
 */
public static XmlWebApplicationContext refreshWAC(ServletContext servletContext, boolean isOpenmrsStartup,
        Module startedModule) {
    XmlWebApplicationContext wac = (XmlWebApplicationContext) WebApplicationContextUtils
            .getWebApplicationContext(servletContext);
    if (log.isDebugEnabled()) {
        log.debug("Refreshing web applciation Context of class: " + wac.getClass().getName());
    }

    if (dispatcherServlet != null) {
        dispatcherServlet.stopAndCloseApplicationContext();
    }

    if (staticDispatcherServlet != null) {
        staticDispatcherServlet.stopAndCloseApplicationContext();
    }

    XmlWebApplicationContext newAppContext = (XmlWebApplicationContext) ModuleUtil
            .refreshApplicationContext(wac, isOpenmrsStartup, startedModule);

    try {
        // must "refresh" the spring dispatcherservlet as well to add in
        //the new handlerMappings
        if (dispatcherServlet != null) {
            dispatcherServlet.reInitFrameworkServlet();
        }

        if (staticDispatcherServlet != null) {
            staticDispatcherServlet.refreshApplicationContext();
        }
    } catch (ServletException se) {
        log.warn("Caught a servlet exception while refreshing the dispatcher servlet", se);
    }

    try {
        if (dwrServlet != null) {
            dwrServlet.reInitServlet();
        }
    } catch (ServletException se) {
        log.warn("Cause a servlet exception while refreshing the dwr servlet", se);
    }

    return newAppContext;
}