Polishing

This commit is contained in:
Juergen Hoeller
2019-02-15 17:06:11 +01:00
parent c2bd229d4c
commit e307dd58db
8 changed files with 87 additions and 81 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -62,12 +62,15 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
this.allParameterDetails = initializeAllParameterDetails(methodDetails.getMethod());
}
/**
* Return the {@link ExceptionTypeFilter} to use to filter exceptions thrown while
* invoking the method.
*/
public abstract ExceptionTypeFilter getExceptionTypeFilter();
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
int parameterCount = method.getParameterCount();
List<CacheParameterDetail> result = new ArrayList<>(parameterCount);
for (int i = 0; i < parameterCount; i++) {
CacheParameterDetail detail = new CacheParameterDetail(method, i);
result.add(detail);
}
return result;
}
@Override
@@ -113,12 +116,25 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
return result.toArray(new CacheInvocationParameter[0]);
}
/**
* Return the {@link ExceptionTypeFilter} to use to filter exceptions thrown while
* invoking the method.
* @see #createExceptionTypeFilter
*/
public abstract ExceptionTypeFilter getExceptionTypeFilter();
/**
* Convenience method for subclasses to create a specific {@code ExceptionTypeFilter}.
* @see #getExceptionTypeFilter()
*/
protected ExceptionTypeFilter createExceptionTypeFilter(
Class<? extends Throwable>[] includes, Class<? extends Throwable>[] excludes) {
return new ExceptionTypeFilter(Arrays.asList(includes), Arrays.asList(excludes), true);
}
@Override
public String toString() {
return getOperationDescription().append("]").toString();
@@ -137,16 +153,6 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
}
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
List<CacheParameterDetail> result = new ArrayList<>();
for (int i = 0; i < method.getParameterCount(); i++) {
CacheParameterDetail detail = new CacheParameterDetail(method, i);
result.add(detail);
}
return result;
}
/**
* Details for a single cache parameter.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -24,9 +24,10 @@ import org.springframework.cache.interceptor.BasicOperation;
import org.springframework.cache.interceptor.CacheResolver;
/**
* Model the base of JSR-107 cache operation.
* <p>A cache operation can be statically cached as it does not contain
* any runtime operation of a specific cache invocation.
* Model the base of JSR-107 cache operation through an interface contract.
*
* <p>A cache operation can be statically cached as it does not contain any
* runtime operation of a specific cache invocation.
*
* @author Stephane Nicoll
* @since 4.1