01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.completex.objective.components.ocache;
10:
11: /**
12: * Plugin to caches to transform the retrieved value.
13: * Can be used if the object is stored in the cache in packed form, for instance
14: *
15: * @author Gennady Krizhevsky
16: */
17: public interface ValueTransformer {
18:
19: public static final NullValueTransformer NULL_VALUE_TRANSFORMER = new NullValueTransformer();
20:
21: /**
22: * Method that is called by the cache before caching the value
23: *
24: * @param key key
25: * @param value value being cached
26: * @return transformed value
27: */
28: Object beforePut(Object key, Object value);
29:
30: /**
31: * Method that is called by the cache after retrieving the value from the cache
32: *
33: * @param key key
34: * @param value cached value
35: * @return transformed value
36: */
37: Object afterGet(Object key, Object value);
38:
39: /**
40: * Null implementation
41: */
42: public static class NullValueTransformer implements
43: ValueTransformer {
44: public Object beforePut(Object key, Object value) {
45: return value;
46: }
47:
48: public Object afterGet(Object key, Object value) {
49: return value;
50: }
51: }
52: }
|