Example usage for org.springframework.web.util WebUtils removeWebAppRootSystemProperty

List of usage examples for org.springframework.web.util WebUtils removeWebAppRootSystemProperty

Introduction

In this page you can find the example usage for org.springframework.web.util WebUtils removeWebAppRootSystemProperty.

Prototype

public static void removeWebAppRootSystemProperty(ServletContext servletContext) 

Source Link

Document

Remove the system property that points to the web app root directory.

Usage

From source file:com.shengpay.commons.bp.logback.LogbackWebConfigurer.java

/**
 * Shut down logback, properly releasing all file locks and resetting the web app root system property.
 * //  w ww  .  j a v a2s .  co m
 * @param servletContext
 *            the current ServletContext
 * @see WebUtils#removeWebAppRootSystemProperty
 */
public static void shutdownLogging(ServletContext servletContext) {
    servletContext.log("Shutting down logback");
    try {
        LogbackConfigurer.shutdownLogging();
    } finally {
        // Remove the web app root system property.
        if (exposeWebAppRoot(servletContext)) {
            WebUtils.removeWebAppRootSystemProperty(servletContext);
        }
    }
}

From source file:ch.qos.logback.ext.spring.web.WebLogbackConfigurer.java

/**
 * Shut down Logback, properly releasing all file locks
 * and resetting the web app root system property.
 *
 * @param servletContext the current ServletContext
 * @see WebUtils#removeWebAppRootSystemProperty
 *//*  ww  w .j  a  v a2s  .  c  o  m*/
public static void shutdownLogging(ServletContext servletContext) {
    //Uninstall the SLF4J java.util.logging bridge *before* shutting down the Logback framework.
    try {
        Class<?> julBridge = ClassUtils.forName("org.slf4j.bridge.SLF4JBridgeHandler",
                ClassUtils.getDefaultClassLoader());
        Method uninstall = ReflectionUtils.findMethod(julBridge, "uninstall");
        if (uninstall != null) {
            servletContext.log("Uninstalling JUL to SLF4J bridge");
            ReflectionUtils.invokeMethod(uninstall, null);
        }
    } catch (ClassNotFoundException ignored) {
        //No need to shutdown the java.util.logging bridge. If it's not on the classpath, it wasn't started either.
    }

    try {
        servletContext.log("Shutting down Logback");
        LogbackConfigurer.shutdownLogging();
    } finally {
        // Remove the web app root system property.
        if (exposeWebAppRoot(servletContext)) {
            WebUtils.removeWebAppRootSystemProperty(servletContext);
        }
    }
}