From 9ba05c1e6b69b10dcb9f20bf4ac7471c9da88cdc Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 28 Mar 2018 14:04:13 -0500 Subject: [PATCH] HHH-12441 - Deprecate hibernate-ehcache --- .../internal/log/DeprecationLogger.java | 4 +- .../ehcache/internal/DeprecationLogger.java | 44 +++++++++++++++++++ .../internal/EhCacheMessageLogger.java | 4 +- .../internal/EhcacheRegionFactory.java | 1 + 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/DeprecationLogger.java diff --git a/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java index 77dd1de4e6..455b09d244 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java @@ -24,9 +24,11 @@ import static org.jboss.logging.Logger.Level.WARN; @MessageLogger( projectCode = "HHH" ) @ValidIdRange( min = 90000001, max = 90001000 ) public interface DeprecationLogger extends BasicLogger { + String CATEGORY = "org.hibernate.orm.deprecation"; + DeprecationLogger DEPRECATION_LOGGER = Logger.getMessageLogger( DeprecationLogger.class, - "org.hibernate.orm.deprecation" + CATEGORY ); /** diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/DeprecationLogger.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/DeprecationLogger.java new file mode 100644 index 0000000000..09fe0e6dd2 --- /dev/null +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/DeprecationLogger.java @@ -0,0 +1,44 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.cache.ehcache.internal; + +import org.jboss.logging.BasicLogger; +import org.jboss.logging.Logger; +import org.jboss.logging.annotations.LogMessage; +import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.MessageLogger; +import org.jboss.logging.annotations.ValidIdRange; + +import static org.hibernate.internal.log.DeprecationLogger.CATEGORY; +import static org.jboss.logging.Logger.Level.WARN; + +/** + * @author Steve Ebersole + */ +@MessageLogger(projectCode = "HHH") +@ValidIdRange( min = 20100, max = 20100) +public interface DeprecationLogger extends BasicLogger { + /** + * Singleton access + */ + DeprecationLogger INSTANCE = Logger.getMessageLogger( + DeprecationLogger.class, + CATEGORY + ); + + /** + * Log a message (WARN) about this provider being deprecated + */ + @LogMessage(level = WARN) + @Message( + value = "The Ehcache second-level cache provider for Hibernate is deprecated. " + + "See https://hibernate.atlassian.net/browse/HHH-12441 for details.", + id = 20100 + ) + void logDeprecation(); + +} diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/EhCacheMessageLogger.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/EhCacheMessageLogger.java index c07dd74b67..5972f55e29 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/EhCacheMessageLogger.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/EhCacheMessageLogger.java @@ -13,16 +13,18 @@ import org.jboss.logging.Logger; import org.jboss.logging.annotations.LogMessage; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageLogger; +import org.jboss.logging.annotations.ValidIdRange; import static org.jboss.logging.Logger.Level.WARN; /** * The jboss-logging {@link MessageLogger} for the hibernate-ehcache module. It reserves message ids ranging from - * 20001 to 25000 inclusively. + * 20099 to 20099 (allow 20100 for our DeprecationLogger) inclusively. *

* New messages must be added after the last message defined to ensure message codes are unique. */ @MessageLogger(projectCode = "HHH") +@ValidIdRange( min = 20001, max = 20099) public interface EhCacheMessageLogger extends CoreMessageLogger { EhCacheMessageLogger INSTANCE = Logger.getMessageLogger( EhCacheMessageLogger.class, diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/EhcacheRegionFactory.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/EhcacheRegionFactory.java index 361f21dff5..8e21a4a030 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/EhcacheRegionFactory.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/EhcacheRegionFactory.java @@ -50,6 +50,7 @@ public class EhcacheRegionFactory extends RegionFactoryTemplate { public EhcacheRegionFactory(CacheKeysFactory cacheKeysFactory) { this.cacheKeysFactory = cacheKeysFactory; + DeprecationLogger.INSTANCE.logDeprecation(); } public CacheManager getCacheManager() {