From 54f82cd5400568764e78a31788232cad4900ff03 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 28 May 2012 00:09:46 +0200 Subject: [PATCH] Polish caching components --- .../cache/annotation/package-info.java | 6 ++---- .../cache/concurrent/ConcurrentMapCache.java | 7 ++++--- .../cache/concurrent/package-info.java | 4 +--- .../cache/ehcache/EhCacheCache.java | 10 +++++----- .../cache/ehcache/EhCacheCacheManager.java | 16 ++++++++-------- .../cache/ehcache/package-info.java | 8 ++------ 6 files changed, 22 insertions(+), 29 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/package-info.java b/spring-context/src/main/java/org/springframework/cache/annotation/package-info.java index 6c230a8eaa..52bd2a3586 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/package-info.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/package-info.java @@ -1,8 +1,6 @@ - /** * Annotations and supporting classes for declarative cache management. - * Hooked into Spring's caching interception infrastructure - * via {@link org.springframework.cache.interceptor.CacheOperationSource - * CacheOperationSource} implementation. + * Hooked into Spring's cache interception infrastructure via + * {@link org.springframework.cache.interceptor.CacheOperationSource}. */ package org.springframework.cache.annotation; diff --git a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java index 5c78b30920..270435f301 100644 --- a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java +++ b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java @@ -16,13 +16,13 @@ package org.springframework.cache.concurrent; +import org.springframework.cache.Cache; +import org.springframework.cache.support.SimpleValueWrapper; + import java.io.Serializable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import org.springframework.cache.Cache; -import org.springframework.cache.support.SimpleValueWrapper; - /** * Simple {@link Cache} implementation based on the core JDK * {@code java.util.concurrent} package. @@ -62,6 +62,7 @@ public class ConcurrentMapCache implements Cache { /** * Create a new ConcurrentMapCache with the specified name. * @param name the name of the cache + * @param allowNullValues whether to accept and convert null values for this cache */ public ConcurrentMapCache(String name, boolean allowNullValues) { this(name, new ConcurrentHashMap(), allowNullValues); diff --git a/spring-context/src/main/java/org/springframework/cache/concurrent/package-info.java b/spring-context/src/main/java/org/springframework/cache/concurrent/package-info.java index c322897233..40cf65d313 100644 --- a/spring-context/src/main/java/org/springframework/cache/concurrent/package-info.java +++ b/spring-context/src/main/java/org/springframework/cache/concurrent/package-info.java @@ -1,9 +1,7 @@ - /** * Implementation package for {@code java.util.concurrent} based caches. * Provides a {@link org.springframework.cache.CacheManager CacheManager} * and {@link org.springframework.cache.Cache Cache} implementation for - * use in a Spring context. + * use in a Spring context, using a JDK based thread pool at runtime. */ package org.springframework.cache.concurrent; - diff --git a/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java b/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java index 9258d76895..eb02a84e2a 100644 --- a/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java +++ b/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -57,10 +57,6 @@ public class EhCacheCache implements Cache { return this.cache; } - public void clear() { - this.cache.removeAll(); - } - public ValueWrapper get(Object key) { Element element = this.cache.get(key); return (element != null ? new SimpleValueWrapper(element.getObjectValue()) : null); @@ -74,4 +70,8 @@ public class EhCacheCache implements Cache { this.cache.remove(key); } + public void clear() { + this.cache.removeAll(); + } + } diff --git a/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java b/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java index a1588ac7df..edfa43bfa5 100644 --- a/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java @@ -39,18 +39,17 @@ public class EhCacheCacheManager extends AbstractCacheManager { /** - * Returns the backing EhCache {@link net.sf.ehcache.CacheManager}. - * @return the backing EhCache {@link net.sf.ehcache.CacheManager}. + * Set the backing EhCache {@link net.sf.ehcache.CacheManager}. */ - public net.sf.ehcache.CacheManager getCacheManager() { - return cacheManager; + public void setCacheManager(net.sf.ehcache.CacheManager cacheManager) { + this.cacheManager = cacheManager; } /** - * Sets the backing EhCache {@link net.sf.ehcache.CacheManager}. + * Return the backing EhCache {@link net.sf.ehcache.CacheManager}. */ - public void setCacheManager(net.sf.ehcache.CacheManager cacheManager) { - this.cacheManager = cacheManager; + public net.sf.ehcache.CacheManager getCacheManager() { + return this.cacheManager; } @@ -83,4 +82,5 @@ public class EhCacheCacheManager extends AbstractCacheManager { } return cache; } -} \ No newline at end of file + +} diff --git a/spring-context/src/main/java/org/springframework/cache/ehcache/package-info.java b/spring-context/src/main/java/org/springframework/cache/ehcache/package-info.java index 101caa7de7..3263df5a36 100644 --- a/spring-context/src/main/java/org/springframework/cache/ehcache/package-info.java +++ b/spring-context/src/main/java/org/springframework/cache/ehcache/package-info.java @@ -1,11 +1,7 @@ - /** - * * Support classes for the open source cache - * Ehcache, - * allowing to set up an EHCache CacheManager and Caches + * EhCache, + * allowing to set up an EhCache CacheManager and Caches * as beans in a Spring context. - * */ package org.springframework.cache.ehcache; -