mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:15:50 +00:00
Merge cc7b4106d7
into 05f7cf4e3f
This commit is contained in:
commit
8733f9dff5
4 changed files with 167 additions and 119 deletions
1
pom.xml
1
pom.xml
|
@ -163,7 +163,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Date and Time -->
|
<!-- Date and Time -->
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2016 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.samples.petclinic.util;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContextEvent;
|
||||||
|
import javax.servlet.ServletContextListener;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.LoggerContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the web application stops, various resources need to be cleaned up to
|
||||||
|
* prevent memory leaks.
|
||||||
|
*/
|
||||||
|
public class CleanUp implements ServletContextListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void contextInitialized(ServletContextEvent arg0) {
|
||||||
|
// NO-OP
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void contextDestroyed(ServletContextEvent arg0) {
|
||||||
|
// Logback is configured to use JMX so make sure that all objects are
|
||||||
|
// deregistered from JMX else there will be a memory leak
|
||||||
|
// http://logback.qos.ch/manual/jmxConfig.html
|
||||||
|
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||||
|
lc.stop();
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,10 @@
|
||||||
</contextListener>
|
</contextListener>
|
||||||
|
|
||||||
<!-- To enable JMX Management -->
|
<!-- To enable JMX Management -->
|
||||||
|
|
||||||
<jmxConfigurator/>
|
<jmxConfigurator/>
|
||||||
|
<!-- Avoid conflicts with other web applications using logback and JMX -->
|
||||||
|
<contextName>PetClinic</contextName>
|
||||||
|
|
||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder>
|
<encoder>
|
||||||
|
|
|
@ -42,6 +42,9 @@
|
||||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||||
</listener>
|
</listener>
|
||||||
|
|
||||||
|
<listener>
|
||||||
|
<listener-class>org.springframework.samples.petclinic.util.CleanUp</listener-class>
|
||||||
|
</listener>
|
||||||
<!--
|
<!--
|
||||||
- Servlet that dispatches request to registered handlers (Controller implementations).
|
- Servlet that dispatches request to registered handlers (Controller implementations).
|
||||||
-->
|
-->
|
||||||
|
|
Loading…
Reference in a new issue