本文整理汇总了Java中org.springframework.cache.interceptor.CacheOperation类的典型用法代码示例。如果您正苦于以下问题:Java CacheOperation类的具体用法?Java CacheOperation怎么用?Java CacheOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CacheOperation类属于org.springframework.cache.interceptor包,在下文中一共展示了CacheOperation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: merge
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
<T extends CacheOperation> T merge(Element element, ReaderContext readerCtx, T op) {
String cache = element.getAttribute("cache");
// sanity check
String[] localCaches = caches;
if (StringUtils.hasText(cache)) {
localCaches = StringUtils.commaDelimitedListToStringArray(cache.trim());
} else {
if (caches == null) {
readerCtx.error("No cache specified specified for " + element.getNodeName(), element);
}
}
op.setCacheNames(localCaches);
op.setKey(getAttributeValue(element, "key", this.key));
op.setCondition(getAttributeValue(element, "condition", this.condition));
return op;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:CacheAdviceParser.java
示例2: parsePutAnnotation
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
CacheOperation parsePutAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, CachePut cachePut) {
CachePutOperation.Builder builder = new CachePutOperation.Builder();
builder.setName(ae.toString());
builder.setCacheNames(cachePut.cacheNames());
builder.setCondition(cachePut.condition());
builder.setUnless(cachePut.unless());
builder.setKey(cachePut.key());
builder.setKeyGenerator(cachePut.keyGenerator());
builder.setCacheManager(cachePut.cacheManager());
builder.setCacheResolver(cachePut.cacheResolver());
defaultConfig.applyDefault(builder);
CachePutOperation op = builder.build();
validateCacheOperation(ae, op);
return op;
}
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:19,代码来源:FixUseSupperClassAnnotationParser.java
示例3: validateCacheOperation
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
/**
* Validates the specified {@link CacheOperation}.
* <p>Throws an {@link IllegalStateException} if the state of the operation is
* invalid. As there might be multiple sources for default values, this ensure
* that the operation is in a proper state before being returned.
*
* @param ae the annotated element of the cache operation
* @param operation the {@link CacheOperation} to validate
*/
private void validateCacheOperation(AnnotatedElement ae, CacheOperation operation) {
if (StringUtils.hasText(operation.getKey()) && StringUtils.hasText(operation.getKeyGenerator())) {
throw new IllegalStateException("Invalid cache annotation configuration on '" +
ae.toString() + "'. Both 'key' and 'keyGenerator' attributes have been set. " +
"These attributes are mutually exclusive: either set the SpEL expression used to" +
"compute the key at runtime or set the name of the KeyGenerator bean to use.");
}
if (StringUtils.hasText(operation.getCacheManager()) && StringUtils.hasText(operation.getCacheResolver())) {
throw new IllegalStateException("Invalid cache annotation configuration on '" +
ae.toString() + "'. Both 'cacheManager' and 'cacheResolver' attributes have been set. " +
"These attributes are mutually exclusive: the cache manager is used to configure a" +
"default cache resolver if none is set. If a cache resolver is set, the cache manager" +
"won't be used.");
}
}
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:25,代码来源:FixUseSupperClassAnnotationParser.java
示例4: applyDefault
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
/**
* Apply the defaults to the specified {@link CacheOperation.Builder}.
*
* @param builder the operation builder to update
*/
public void applyDefault(CacheOperation.Builder builder) {
if (builder.getCacheNames().isEmpty() && this.cacheNames != null) {
builder.setCacheNames(this.cacheNames);
}
if (!StringUtils.hasText(builder.getKey()) && !StringUtils.hasText(builder.getKeyGenerator()) &&
StringUtils.hasText(this.keyGenerator)) {
builder.setKeyGenerator(this.keyGenerator);
}
if (StringUtils.hasText(builder.getCacheManager()) || StringUtils.hasText(builder.getCacheResolver())) {
// One of these is set so we should not inherit anything
} else if (StringUtils.hasText(this.cacheResolver)) {
builder.setCacheResolver(this.cacheResolver);
} else if (StringUtils.hasText(this.cacheManager)) {
builder.setCacheManager(this.cacheManager);
}
}
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:23,代码来源:FixUseSupperClassAnnotationParser.java
示例5: getCacheOperations
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
/**
* Determine the caching attribute for this method invocation.
* <p>Defaults to the class's caching attribute if no method attribute is found.
*
* @param method the method for the current invocation (never {@code null})
* @param targetClass the target class for this invocation (may be {@code null})
* @return {@link CacheOperation} for this method, or {@code null} if the method
* is not cacheable
*/
@Override
public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) {
if (method.getDeclaringClass() == Object.class) {
return null;
}
Object cacheKey = getCacheKey(method, targetClass);
Collection<CacheOperation> cached = this.attributeCache.get(cacheKey);
if (cached != null) {
return (cached != NULL_CACHING_ATTRIBUTE ? cached : null);
} else {
Collection<CacheOperation> cacheOps = computeCacheOperations(method, targetClass);
if (cacheOps != null) {
if (logger.isDebugEnabled()) {
logger.debug("Adding cacheable method '" + method.getName() + "' with attribute: " + cacheOps);
}
this.attributeCache.put(cacheKey, cacheOps);
} else {
this.attributeCache.put(cacheKey, NULL_CACHING_ATTRIBUTE);
}
return cacheOps;
}
}
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:34,代码来源:FixUseSupperClassFallbackCacheOperationSource.java
示例6: parsePutAnnotation
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
CacheOperation parsePutAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, CachePut cachePut) {
CachePutOperation op = new CachePutOperation();
op.setCacheNames(cachePut.cacheNames());
op.setCondition(cachePut.condition());
op.setUnless(cachePut.unless());
op.setKey(cachePut.key());
op.setKeyGenerator(cachePut.keyGenerator());
op.setCacheManager(cachePut.cacheManager());
op.setCacheResolver(cachePut.cacheResolver());
op.setName(ae.toString());
defaultConfig.applyDefault(op);
validateCacheOperation(ae, op);
return op;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:SpringCacheAnnotationParser.java
示例7: validateCacheOperation
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
/**
* Validates the specified {@link CacheOperation}.
* <p>Throws an {@link IllegalStateException} if the state of the operation is
* invalid. As there might be multiple sources for default values, this ensure
* that the operation is in a proper state before being returned.
* @param ae the annotated element of the cache operation
* @param operation the {@link CacheOperation} to validate
*/
private void validateCacheOperation(AnnotatedElement ae, CacheOperation operation) {
if (StringUtils.hasText(operation.getKey()) && StringUtils.hasText(operation.getKeyGenerator())) {
throw new IllegalStateException("Invalid cache annotation configuration on '" +
ae.toString() + "'. Both 'key' and 'keyGenerator' attributes have been set. " +
"These attributes are mutually exclusive: either set the SpEL expression used to" +
"compute the key at runtime or set the name of the KeyGenerator bean to use.");
}
if (StringUtils.hasText(operation.getCacheManager()) && StringUtils.hasText(operation.getCacheResolver())) {
throw new IllegalStateException("Invalid cache annotation configuration on '" +
ae.toString() + "'. Both 'cacheManager' and 'cacheResolver' attributes have been set. " +
"These attributes are mutually exclusive: the cache manager is used to configure a" +
"default cache resolver if none is set. If a cache resolver is set, the cache manager" +
"won't be used.");
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:SpringCacheAnnotationParser.java
示例8: applyDefault
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
/**
* Apply the defaults to the specified {@link CacheOperation}.
* @param operation the operation to update
*/
public void applyDefault(CacheOperation operation) {
if (operation.getCacheNames().isEmpty() && this.cacheNames != null) {
operation.setCacheNames(this.cacheNames);
}
if (!StringUtils.hasText(operation.getKey()) && !StringUtils.hasText(operation.getKeyGenerator()) &&
StringUtils.hasText(this.keyGenerator)) {
operation.setKeyGenerator(this.keyGenerator);
}
if (StringUtils.hasText(operation.getCacheManager()) || StringUtils.hasText(operation.getCacheResolver())) {
// One of these is set so we should not inherit anything
}
else if (StringUtils.hasText(this.cacheResolver)) {
operation.setCacheResolver(this.cacheResolver);
}
else if (StringUtils.hasText(this.cacheManager)) {
operation.setCacheManager(this.cacheManager);
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:SpringCacheAnnotationParser.java
示例9: multipleComposedAnnotations
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
@Ignore("Disabled until SPR-13475 is resolved")
@Test
public void multipleComposedAnnotations() throws Exception {
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multipleComposed", 3);
Iterator<CacheOperation> it = ops.iterator();
CacheOperation cacheOperation = it.next();
assertThat(cacheOperation, instanceOf(CacheableOperation.class));
assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("composedCache")));
cacheOperation = it.next();
assertThat(cacheOperation, instanceOf(CacheableOperation.class));
assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("foo")));
cacheOperation = it.next();
assertThat(cacheOperation, instanceOf(CacheEvictOperation.class));
assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("composedCache")));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:AnnotationCacheOperationSourceTests.java
示例10: parsePutAnnotation
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
CacheOperation parsePutAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, CachePut cachePut) {
CachePutOperation.Builder builder = new CachePutOperation.Builder();
builder.setName(ae.toString());
builder.setCacheNames(cachePut.cacheNames());
builder.setCondition(cachePut.condition());
builder.setUnless(cachePut.unless());
builder.setKey(cachePut.key());
builder.setKeyGenerator(cachePut.keyGenerator());
builder.setCacheManager(cachePut.cacheManager());
builder.setCacheResolver(cachePut.cacheResolver());
defaultConfig.applyDefault(builder);
CachePutOperation op = builder.build();
validateCacheOperation(ae, op);
return op;
}
开发者ID:txazo,项目名称:spring,代码行数:19,代码来源:SpringCacheAnnotationParser.java
示例11: applyDefault
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
/**
* Apply the defaults to the specified {@link CacheOperation.Builder}.
* @param builder the operation builder to update
*/
public void applyDefault(CacheOperation.Builder builder) {
if (builder.getCacheNames().isEmpty() && this.cacheNames != null) {
builder.setCacheNames(this.cacheNames);
}
if (!StringUtils.hasText(builder.getKey()) && !StringUtils.hasText(builder.getKeyGenerator()) &&
StringUtils.hasText(this.keyGenerator)) {
builder.setKeyGenerator(this.keyGenerator);
}
if (StringUtils.hasText(builder.getCacheManager()) || StringUtils.hasText(builder.getCacheResolver())) {
// One of these is set so we should not inherit anything
}
else if (StringUtils.hasText(this.cacheResolver)) {
builder.setCacheResolver(this.cacheResolver);
}
else if (StringUtils.hasText(this.cacheManager)) {
builder.setCacheManager(this.cacheManager);
}
}
开发者ID:txazo,项目名称:spring,代码行数:24,代码来源:SpringCacheAnnotationParser.java
示例12: determineCacheOperations
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
/**
* Determine the cache operation(s) for the given method or class.
* <p>This implementation delegates to configured
* {@link CacheAnnotationParser}s for parsing known annotations into
* Spring's metadata attribute class.
* <p>Can be overridden to support custom annotations that carry
* caching metadata.
* @param ae the annotated method or class
* @return the configured caching operations, or {@code null} if none found
*/
protected Collection<CacheOperation> determineCacheOperations(AnnotatedElement ae) {
Collection<CacheOperation> ops = null;
for (CacheAnnotationParser annotationParser : this.annotationParsers) {
Collection<CacheOperation> annOps = annotationParser.parseCacheAnnotations(ae);
if (annOps != null) {
if (ops == null) {
ops = new ArrayList<CacheOperation>();
}
ops.addAll(annOps);
}
}
return ops;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:AnnotationCacheOperationSource.java
示例13: parseCacheAnnotations
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
@Override
public Collection<CacheOperation> parseCacheAnnotations(AnnotatedElement ae) {
Collection<CacheOperation> ops = null;
Collection<Cacheable> cacheables = getAnnotations(ae, Cacheable.class);
if (cacheables != null) {
ops = lazyInit(ops);
for (Cacheable cacheable : cacheables) {
ops.add(parseCacheableAnnotation(ae, cacheable));
}
}
Collection<CacheEvict> evicts = getAnnotations(ae, CacheEvict.class);
if (evicts != null) {
ops = lazyInit(ops);
for (CacheEvict e : evicts) {
ops.add(parseEvictAnnotation(ae, e));
}
}
Collection<CachePut> updates = getAnnotations(ae, CachePut.class);
if (updates != null) {
ops = lazyInit(ops);
for (CachePut p : updates) {
ops.add(parseUpdateAnnotation(ae, p));
}
}
Collection<Caching> caching = getAnnotations(ae, Caching.class);
if (caching != null) {
ops = lazyInit(ops);
for (Caching c : caching) {
ops.addAll(parseCachingAnnotation(ae, c));
}
}
return ops;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:SpringCacheAnnotationParser.java
示例14: parseUpdateAnnotation
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
CacheOperation parseUpdateAnnotation(AnnotatedElement ae, CachePut caching) {
CachePutOperation cuo = new CachePutOperation();
cuo.setCacheNames(caching.value());
cuo.setCondition(caching.condition());
cuo.setUnless(caching.unless());
cuo.setKey(caching.key());
cuo.setName(ae.toString());
return cuo;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:SpringCacheAnnotationParser.java
示例15: parseCacheAnnotations
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
protected Collection<CacheOperation> parseCacheAnnotations(DefaultCacheConfig cachingConfig, AnnotatedElement ae) {
Collection<CacheOperation> ops = null;
Collection<Cacheable> cacheables = AnnotatedElementUtils.getAllMergedAnnotations(ae, Cacheable.class);
if (!cacheables.isEmpty()) {
ops = lazyInit(ops);
for (Cacheable cacheable : cacheables) {
ops.add(parseCacheableAnnotation(ae, cachingConfig, cacheable));
}
}
Collection<CacheEvict> evicts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CacheEvict.class);
if (!evicts.isEmpty()) {
ops = lazyInit(ops);
for (CacheEvict evict : evicts) {
ops.add(parseEvictAnnotation(ae, cachingConfig, evict));
}
}
Collection<CachePut> puts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CachePut.class);
if (!puts.isEmpty()) {
ops = lazyInit(ops);
for (CachePut put : puts) {
ops.add(parsePutAnnotation(ae, cachingConfig, put));
}
}
Collection<Caching> cachings = AnnotatedElementUtils.getAllMergedAnnotations(ae, Caching.class);
if (!cachings.isEmpty()) {
ops = lazyInit(ops);
for (Caching caching : cachings) {
Collection<CacheOperation> cachingOps = parseCachingAnnotation(ae, cachingConfig, caching);
if (cachingOps != null) {
ops.addAll(cachingOps);
}
}
}
return ops;
}
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:38,代码来源:FixUseSupperClassAnnotationParser.java
示例16: determineCacheOperations
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
/**
* Determine the cache operation(s) for the given {@link CacheOperationProvider}.
* <p>This implementation delegates to configured
* {@link CacheAnnotationParser}s for parsing known annotations into
* Spring's metadata attribute class.
* <p>Can be overridden to support custom annotations that carry
* caching metadata.
*
* @param provider the cache operation provider to use
* @return the configured caching operations, or {@code null} if none found
*/
protected Collection<CacheOperation> determineCacheOperations(CacheOperationProvider provider) {
Collection<CacheOperation> ops = null;
for (FixUseSupperClassCacheAnnotationParser annotationParser : this.annotationParsers) {
Collection<CacheOperation> annOps = provider.getCacheOperations(annotationParser);
if (annOps != null) {
if (ops == null) {
ops = new ArrayList<>();
}
ops.addAll(annOps);
}
}
return ops;
}
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:25,代码来源:FixUseSupperClassCacheOperationSource.java
示例17: findCacheOperations
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
@Override
protected Collection<CacheOperation> findCacheOperations(final Class<?> clazz) {
return determineCacheOperations(new CacheOperationProvider() {
@Override
public Collection<CacheOperation> getCacheOperations(CacheAnnotationParser parser) {
return parser.parseCacheAnnotations(clazz);
}
});
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:AnnotationCacheOperationSource.java
示例18: determineCacheOperations
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
/**
* Determine the cache operation(s) for the given {@link CacheOperationProvider}.
* <p>This implementation delegates to configured
* {@link CacheAnnotationParser}s for parsing known annotations into
* Spring's metadata attribute class.
* <p>Can be overridden to support custom annotations that carry
* caching metadata.
* @param provider the cache operation provider to use
* @return the configured caching operations, or {@code null} if none found
*/
protected Collection<CacheOperation> determineCacheOperations(CacheOperationProvider provider) {
Collection<CacheOperation> ops = null;
for (CacheAnnotationParser annotationParser : this.annotationParsers) {
Collection<CacheOperation> annOps = provider.getCacheOperations(annotationParser);
if (annOps != null) {
if (ops == null) {
ops = new ArrayList<CacheOperation>();
}
ops.addAll(annOps);
}
}
return ops;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:AnnotationCacheOperationSource.java
示例19: parseCacheAnnotations
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
protected Collection<CacheOperation> parseCacheAnnotations(DefaultCacheConfig cachingConfig, AnnotatedElement ae) {
Collection<CacheOperation> ops = null;
Collection<Cacheable> cacheables = getAnnotations(ae, Cacheable.class);
if (cacheables != null) {
ops = lazyInit(ops);
for (Cacheable cacheable : cacheables) {
ops.add(parseCacheableAnnotation(ae, cachingConfig, cacheable));
}
}
Collection<CacheEvict> evicts = getAnnotations(ae, CacheEvict.class);
if (evicts != null) {
ops = lazyInit(ops);
for (CacheEvict evict : evicts) {
ops.add(parseEvictAnnotation(ae, cachingConfig, evict));
}
}
Collection<CachePut> puts = getAnnotations(ae, CachePut.class);
if (puts != null) {
ops = lazyInit(ops);
for (CachePut put : puts) {
ops.add(parsePutAnnotation(ae, cachingConfig, put));
}
}
Collection<Caching> cachings = getAnnotations(ae, Caching.class);
if (cachings != null) {
ops = lazyInit(ops);
for (Caching caching : cachings) {
ops.addAll(parseCachingAnnotation(ae, cachingConfig, caching));
}
}
return ops;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:35,代码来源:SpringCacheAnnotationParser.java
示例20: merge
import org.springframework.cache.interceptor.CacheOperation; //导入依赖的package包/类
<T extends CacheOperation> T merge(Element element, ReaderContext readerCtx, T op) {
String cache = element.getAttribute("cache");
// sanity check
String[] localCaches = caches;
if (StringUtils.hasText(cache)) {
localCaches = StringUtils.commaDelimitedListToStringArray(cache.trim());
}
else {
if (caches == null) {
readerCtx.error("No cache specified specified for " + element.getNodeName(), element);
}
}
op.setCacheNames(localCaches);
op.setKey(getAttributeValue(element, "key", this.key));
op.setKeyGenerator(getAttributeValue(element, "key-generator", this.keyGenerator));
op.setCacheManager(getAttributeValue(element, "cache-manager", this.cacheManager));
op.setCondition(getAttributeValue(element, "condition", this.condition));
if (StringUtils.hasText(op.getKey()) && StringUtils.hasText(op.getKeyGenerator())) {
throw new IllegalStateException("Invalid cache advice configuration on '"
+ element.toString() + "'. Both 'key' and 'keyGenerator' attributes have been set. " +
"These attributes are mutually exclusive: either set the SpEL expression used to" +
"compute the key at runtime or set the name of the KeyGenerator bean to use.");
}
return op;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:CacheAdviceParser.java
注:本文中的org.springframework.cache.interceptor.CacheOperation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论