From 8bfba6a07a6a6f3f11e8395b4afe2969654dd7c1 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 4 Apr 2016 14:56:08 +0200 Subject: [PATCH] EhCacheManagerFactoryBean logs cache manager name Issue: SPR-14110 --- .../cache/ehcache/EhCacheManagerFactoryBean.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java index 06c5a5e8560..2287995b666 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-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. @@ -81,7 +81,7 @@ public class EhCacheManagerFactoryBean implements FactoryBean, Ini /** * Set the name of the EhCache CacheManager (if a specific name is desired). - * @see net.sf.ehcache.CacheManager#setName(String) + * @see net.sf.ehcache.config.Configuration#setName(String) */ public void setCacheManagerName(String cacheManagerName) { this.cacheManagerName = cacheManagerName; @@ -126,12 +126,17 @@ public class EhCacheManagerFactoryBean implements FactoryBean, Ini @Override public void afterPropertiesSet() throws CacheException { - logger.info("Initializing EhCache CacheManager"); + if (logger.isInfoEnabled()) { + logger.info("Initializing EhCache CacheManager" + + (this.cacheManagerName != null ? " '" + this.cacheManagerName + "'" : "")); + } + Configuration configuration = (this.configLocation != null ? EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration()); if (this.cacheManagerName != null) { configuration.setName(this.cacheManagerName); } + if (this.shared) { // Old-school EhCache singleton sharing... // No way to find out whether we actually created a new CacheManager @@ -178,7 +183,10 @@ public class EhCacheManagerFactoryBean implements FactoryBean, Ini @Override public void destroy() { if (this.locallyManaged) { - logger.info("Shutting down EhCache CacheManager"); + if (logger.isInfoEnabled()) { + logger.info("Shutting down EhCache CacheManager" + + (this.cacheManagerName != null ? " '" + this.cacheManagerName + "'" : "")); + } this.cacheManager.shutdown(); } }