git://wamblee.org
/
utils
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d76c1c5
)
(no commit message)
author
Erik Brakkee
<erik@brakkee.org>
Sat, 31 Jul 2010 17:32:56 +0000
(17:32 +0000)
committer
Erik Brakkee
<erik@brakkee.org>
Sat, 31 Jul 2010 17:32:56 +0000
(17:32 +0000)
support/general/src/main/java/org/wamblee/cache/CachedObject.java
patch
|
blob
|
history
support/general/src/main/java/org/wamblee/cache/ComputedValue.java
patch
|
blob
|
history
support/general/src/main/java/org/wamblee/cache/EhCache.java
patch
|
blob
|
history
support/general/src/main/java/org/wamblee/cache/ForeverCache.java
patch
|
blob
|
history
support/general/src/main/java/org/wamblee/cache/ZeroCache.java
patch
|
blob
|
history
support/general/src/main/java/org/wamblee/cache/package-info.java
patch
|
blob
|
history
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 7ec87534f08e521ec5c95bcccc6ec4b0479277a0..da86298d6598115f9f5b4a683a27053c8f08da73 100644
(file)
--- a/
support/general/src/main/java/org/wamblee/cache/CachedObject.java
+++ b/
support/general/src/main/java/org/wamblee/cache/CachedObject.java
@@
-79,10
+79,10
@@
public class CachedObject<KeyType extends Serializable, ValueType extends Serial
* method may return different objects.
*
* If the object is expired from the cache it is recomputed using the
* method may return different objects.
*
* If the object is expired from the cache it is recomputed using the
- * callback. In case the callback throws an exception the
- *
last known value is used. In case an exception is thrown, the problem is
- *
also logged. In case a recomputation is already being done by another
- *
thread, the last
known value is immediately returned.
+ * callback. In case the callback throws an exception the
last known value
+ *
is used. In case an exception is thrown, the problem is also logged. In
+ *
case a recomputation is already being done by another thread, the last
+ * known value is immediately returned.
*
* @return Object.
*/
*
* @return Object.
*/
@@
-112,7
+112,7
@@
public class CachedObject<KeyType extends Serializable, ValueType extends Serial
synchronized (this) {
value = object;
synchronized (this) {
value = object;
- }
+ }
} catch (Exception e) {
LOGGER.log(Level.INFO,
"Recomputation of cached item failed for key '" + objectKey +
} catch (Exception e) {
LOGGER.log(Level.INFO,
"Recomputation of cached item failed for key '" + objectKey +
@@
-122,8
+122,8
@@
public class CachedObject<KeyType extends Serializable, ValueType extends Serial
computing = false;
}
}
computing = false;
}
}
- synchronized
(this) {
- return value;
+ synchronized
(this) {
+ return value;
}
}
}
}
@@
-152,9
+152,9
@@
public class CachedObject<KeyType extends Serializable, ValueType extends Serial
*/
public static interface Computation<Key extends Serializable, Value extends Serializable> {
/**
*/
public static interface Computation<Key extends Serializable, Value extends Serializable> {
/**
- * 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.
+ * 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.
*
* @param aObjectKey
* Id of the object in the cache.
diff --git
a/support/general/src/main/java/org/wamblee/cache/ComputedValue.java
b/support/general/src/main/java/org/wamblee/cache/ComputedValue.java
index 24bbe5b0c159477bf053f34da32e3322ec3b2b31..4acafe6a432d8e3f224609148ecc4fd3579302c7 100644
(file)
--- a/
support/general/src/main/java/org/wamblee/cache/ComputedValue.java
+++ b/
support/general/src/main/java/org/wamblee/cache/ComputedValue.java
@@
-63,7
+63,7
@@
public class ComputedValue<T> {
private Computation<T> computedValue;
private Boolean busy;
private Computation<T> computedValue;
private Boolean busy;
- private T value;
+ private T value;
/**
* Constructs the compute guard
/**
* Constructs the compute guard
@@
-77,7
+77,7
@@
public class ComputedValue<T> {
lock = aLock;
computedValue = aComputation;
busy = false;
lock = aLock;
computedValue = aComputation;
busy = false;
- value = null;
+ value = null;
}
/**
}
/**
@@
-122,24
+122,27
@@
public class ComputedValue<T> {
return value;
}
}
return value;
}
}
-
+
/**
/**
- * Gets the currently cached value. No recomputation is performed.
- * @return Cached value.
+ * Gets the currently cached value. No recomputation is performed.
+ *
+ * @return Cached value.
*/
*/
- public T getCached() {
- synchronized
(lock) {
- return value;
+ public T getCached() {
+ synchronized
(lock) {
+ return value;
}
}
-
+
}
}
-
+
/**
/**
- * Sets the value explicitly.
- * @param aValue value to set.
+ * Sets the value explicitly.
+ *
+ * @param aValue
+ * value to set.
*/
*/
- public void set(T aValue) {
- synchronized
(lock) {
+ public void set(T aValue) {
+ synchronized
(lock) {
value = aValue;
}
}
value = aValue;
}
}
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 9c32dda8b932329271e63b1d8507e3ff5cd733db..795a95b4070c8e5d454346a05d27dcd04a2780a5 100644
(file)
--- a/
support/general/src/main/java/org/wamblee/cache/EhCache.java
+++ b/
support/general/src/main/java/org/wamblee/cache/EhCache.java
@@
-12,7
+12,7
@@
* 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.
* 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 net.sf.ehcache.Cache;
package org.wamblee.cache;
import net.sf.ehcache.Cache;
@@
-20,7
+20,6
@@
import net.sf.ehcache.CacheException;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
-
import org.wamblee.io.InputResource;
import java.io.IOException;
import org.wamblee.io.InputResource;
import java.io.IOException;
@@
-36,7
+35,8
@@
import java.util.logging.Logger;
*/
public class EhCache<KeyType extends Serializable, ValueType extends Serializable>
implements org.wamblee.cache.Cache<KeyType, ValueType> {
*/
public class EhCache<KeyType extends Serializable, ValueType extends Serializable>
implements org.wamblee.cache.Cache<KeyType, ValueType> {
- private static final Logger LOGGER = Logger.getLogger(EhCache.class.getName());
+ private static final Logger LOGGER = Logger.getLogger(EhCache.class
+ .getName());
/**
* EH Cache manager.
/**
* EH Cache manager.
diff --git
a/support/general/src/main/java/org/wamblee/cache/ForeverCache.java
b/support/general/src/main/java/org/wamblee/cache/ForeverCache.java
index aa2331fd45fd46147fc3a4ee3d58d2bcbaa0b64b..82b75f7f253a136340e1a10f2f59338d22914ee7 100644
(file)
--- a/
support/general/src/main/java/org/wamblee/cache/ForeverCache.java
+++ b/
support/general/src/main/java/org/wamblee/cache/ForeverCache.java
@@
-12,7
+12,7
@@
* 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.
* 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;
package org.wamblee.cache;
import java.io.Serializable;
diff --git
a/support/general/src/main/java/org/wamblee/cache/ZeroCache.java
b/support/general/src/main/java/org/wamblee/cache/ZeroCache.java
index d748e2a42c146093971129cc15b86dbc9598fb75..c2b3c678d6aa1ec0a349f551427a495dcbefb048 100644
(file)
--- a/
support/general/src/main/java/org/wamblee/cache/ZeroCache.java
+++ b/
support/general/src/main/java/org/wamblee/cache/ZeroCache.java
@@
-12,7
+12,7
@@
* 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.
* 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;
package org.wamblee.cache;
import java.io.Serializable;
diff --git
a/support/general/src/main/java/org/wamblee/cache/package-info.java
b/support/general/src/main/java/org/wamblee/cache/package-info.java
index 540a1c54ded493a630d9ce80cfbc4d12c4f15dae..bfec950d77d26325e7f9c5fe1b6a79f4a47a9db3 100644
(file)
--- a/
support/general/src/main/java/org/wamblee/cache/package-info.java
+++ b/
support/general/src/main/java/org/wamblee/cache/package-info.java
@@
-12,7
+12,7
@@
* 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.
* 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.
- */
+ */
/**
* This package provides an interface for a cache together with several implementations.
* The main interfaces and classes are:
/**
* This package provides an interface for a cache together with several implementations.
* The main interfaces and classes are: