From: erik Date: Tue, 22 Jun 2010 19:35:52 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.3~161 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=2e7fbe1e64c571003cd859d520dea1286c3b21e3;p=utils --- diff --git a/support/general/src/main/java/org/wamblee/cache/Cache.java b/support/general/src/main/java/org/wamblee/cache/Cache.java index 6e0f1b3c..62af5943 100644 --- a/support/general/src/main/java/org/wamblee/cache/Cache.java +++ b/support/general/src/main/java/org/wamblee/cache/Cache.java @@ -12,16 +12,17 @@ * 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.wamblee.cache; import java.io.Serializable; /** - * The Cache interface represents... a cache. In some circumstances - * it is more optimal to implement caching directly in the code instead of - * relying on Hibernate caching methods. This interface abstracts from the used - * cache implementation. Cache implementations must be thread-safe. + * The Cache interface represents a cache intended for + * application-level caching. In some circumstances it is more optimal to + * implement caching directly in the code instead of relying on Hibernate + * caching methods. This interface abstracts from the used cache implementation. + * Cache implementations must be thread-safe. */ public interface Cache { /** @@ -40,7 +41,7 @@ public interface Cache { - private static final Logger LOGGER = Logger.getLogger(CachedObject.class); + private static final Logger LOGGER = Logger.getLogger(CachedObject.class + .getName()); /** * Cache to use. @@ -40,6 +41,16 @@ public class CachedObject { /** * Gets the object. Called when the object is not in the cache. + * In case computation fails, an exception should be thrown to ensure that the last + * known value will be used. * * @param aObjectKey * Id of the object in the cache. * * @return Object, must be non-null. */ - Value getObject(Key aObjectKey); + Value getObject(Key aObjectKey) throws Exception; } } diff --git a/support/general/src/main/java/org/wamblee/cache/EhCache.java b/support/general/src/main/java/org/wamblee/cache/EhCache.java index 6c262bf9..9c32dda8 100644 --- a/support/general/src/main/java/org/wamblee/cache/EhCache.java +++ b/support/general/src/main/java/org/wamblee/cache/EhCache.java @@ -20,13 +20,13 @@ import net.sf.ehcache.CacheException; import net.sf.ehcache.CacheManager; import net.sf.ehcache.Element; -import org.apache.log4j.Logger; import org.wamblee.io.InputResource; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; +import java.util.logging.Logger; /** * Cache implemented on top of EhCache. @@ -36,7 +36,7 @@ import java.io.Serializable; */ public class EhCache implements org.wamblee.cache.Cache { - private static final Logger LOGGER = Logger.getLogger(EhCache.class); + private static final Logger LOGGER = Logger.getLogger(EhCache.class.getName()); /** * EH Cache manager. @@ -68,7 +68,7 @@ public class EhCache + *
  • {@link Cache}: An interface representing an application-level cache with objects in the + * cache identified by keys. + *
  • + *
  • {@link CachedObject}: An object representing an object in a cache identified through a + * key. Upon expiry the cached object invokes a callback to recompute (and cache) the object + * again. + *
  • + *
  • {@link ComputedValue}: An object caching a computed value with a computation interface + * determining whether the object is out of date and allowing recomputation of the value. + *
  • + * + */ +package org.wamblee.cache; \ No newline at end of file diff --git a/support/general/src/main/java/org/wamblee/cache/package.html b/support/general/src/main/java/org/wamblee/cache/package.html deleted file mode 100644 index 17bde142..00000000 --- a/support/general/src/main/java/org/wamblee/cache/package.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - wamblee.org - - - -This package provides an interface for a cache together with several -implementations. - - - -@since - - - -