X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fcache%2FCachedObject.java;h=7ec87534f08e521ec5c95bcccc6ec4b0479277a0;hb=02f5f47eb96320baf55a6cb2e5141360e304b504;hp=f8eb8b0fad49c6c900f351ba6c6325c7168f503c;hpb=8de36ff0206c996baf3ee4adc3e2293b12ff5f39;p=utils diff --git a/support/general/src/main/java/org/wamblee/cache/CachedObject.java b/support/general/src/main/java/org/wamblee/cache/CachedObject.java index f8eb8b0f..7ec87534 100644 --- a/support/general/src/main/java/org/wamblee/cache/CachedObject.java +++ b/support/general/src/main/java/org/wamblee/cache/CachedObject.java @@ -1,12 +1,12 @@ /* - * Copyright 2005 the original author or authors. - * + * Copyright 2005-2010 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. @@ -15,20 +15,21 @@ */ package org.wamblee.cache; -import org.apache.log4j.Logger; - import java.io.Serializable; +import java.util.logging.Level; +import java.util.logging.Logger; /** - * Represents a cached object. The object is either retrieved from the cache if - * the cache has it, or a call back is invoked to get the object (and put it in - * the cache). + * Represents a cached object identified by the key it has in a certain + * {@link Cache}. The object is either retrieved from the cache if the cache has + * it, or a call back is invoked to get the object (and put it in the cache). * * @author Erik Brakkee * */ public class CachedObject { - 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; } }