+ update default key generator strategy to improve compatibility for implicit declaration on one arg method
+ updated docs
This commit is contained in:
Costin Leau
2011-03-06 17:13:24 +00:00
parent a4aca64007
commit c3a635196b
8 changed files with 91 additions and 6 deletions

View File

@@ -20,7 +20,7 @@ import java.lang.reflect.Method;
/**
* Cache 'key' extractor. Used for creating a key based on the given method
* (used as context) and its parameter.
* (used as context) and its parameters.
*
* @author Costin Leau
*/

View File

@@ -21,14 +21,22 @@ import java.lang.reflect.Method;
import org.springframework.cache.KeyGenerator;
/**
* Default key generator. Computes a resulting key based on the hashcode of the
* given parameters.
* Default key generator. Returns 0 if no param is given, the param itself if only one is given or a hash code computed
* from all given params hash code.
*
* @author Costin Leau
*/
public class DefaultKeyGenerator implements KeyGenerator<Object> {
public Object extract(Method method, Object... params) {
if (params.length == 1) {
return params[0];
}
if (params.length == 0) {
return 0;
}
int hashCode = 17;
for (Object object : params) {