org.springframework.cache.interceptor.CacheEvictOperation Java Examples

The following examples show how to use org.springframework.cache.interceptor.CacheEvictOperation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpringCacheAnnotationParser.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private CacheEvictOperation parseEvictAnnotation(
		AnnotatedElement ae, DefaultCacheConfig defaultConfig, CacheEvict cacheEvict) {

	CacheEvictOperation.Builder builder = new CacheEvictOperation.Builder();

	builder.setName(ae.toString());
	builder.setCacheNames(cacheEvict.cacheNames());
	builder.setCondition(cacheEvict.condition());
	builder.setKey(cacheEvict.key());
	builder.setKeyGenerator(cacheEvict.keyGenerator());
	builder.setCacheManager(cacheEvict.cacheManager());
	builder.setCacheResolver(cacheEvict.cacheResolver());
	builder.setCacheWide(cacheEvict.allEntries());
	builder.setBeforeInvocation(cacheEvict.beforeInvocation());

	defaultConfig.applyDefault(builder);
	CacheEvictOperation op = builder.build();
	validateCacheOperation(ae, op);

	return op;
}
 
Example #2
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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")));
}
 
Example #3
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void multipleComposedAnnotations() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multipleComposed", 4);
	Iterator<CacheOperation> it = ops.iterator();

	CacheOperation cacheOperation = it.next();
	assertThat(cacheOperation, instanceOf(CacheableOperation.class));
	assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("directly declared")));
	assertThat(cacheOperation.getKey(), equalTo(""));

	cacheOperation = it.next();
	assertThat(cacheOperation, instanceOf(CacheableOperation.class));
	assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("composedCache")));
	assertThat(cacheOperation.getKey(), equalTo("composedKey"));

	cacheOperation = it.next();
	assertThat(cacheOperation, instanceOf(CacheableOperation.class));
	assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("foo")));
	assertThat(cacheOperation.getKey(), equalTo(""));

	cacheOperation = it.next();
	assertThat(cacheOperation, instanceOf(CacheEvictOperation.class));
	assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("composedCacheEvict")));
	assertThat(cacheOperation.getKey(), equalTo("composedEvictionKey"));
}
 
Example #4
Source File: SpringCacheAnnotationParser.java    From java-technology-stack with MIT License 6 votes vote down vote up
private CacheEvictOperation parseEvictAnnotation(
		AnnotatedElement ae, DefaultCacheConfig defaultConfig, CacheEvict cacheEvict) {

	CacheEvictOperation.Builder builder = new CacheEvictOperation.Builder();

	builder.setName(ae.toString());
	builder.setCacheNames(cacheEvict.cacheNames());
	builder.setCondition(cacheEvict.condition());
	builder.setKey(cacheEvict.key());
	builder.setKeyGenerator(cacheEvict.keyGenerator());
	builder.setCacheManager(cacheEvict.cacheManager());
	builder.setCacheResolver(cacheEvict.cacheResolver());
	builder.setCacheWide(cacheEvict.allEntries());
	builder.setBeforeInvocation(cacheEvict.beforeInvocation());

	defaultConfig.applyDefault(builder);
	CacheEvictOperation op = builder.build();
	validateCacheOperation(ae, op);

	return op;
}
 
Example #5
Source File: SpringCacheAnnotationParser.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
CacheEvictOperation parseEvictAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, CacheEvict cacheEvict) {
	CacheEvictOperation op = new CacheEvictOperation();

	op.setCacheNames(cacheEvict.cacheNames());
	op.setCondition(cacheEvict.condition());
	op.setKey(cacheEvict.key());
	op.setKeyGenerator(cacheEvict.keyGenerator());
	op.setCacheManager(cacheEvict.cacheManager());
	op.setCacheResolver(cacheEvict.cacheResolver());
	op.setCacheWide(cacheEvict.allEntries());
	op.setBeforeInvocation(cacheEvict.beforeInvocation());
	op.setName(ae.toString());

	defaultConfig.applyDefault(op);
	validateCacheOperation(ae, op);

	return op;
}
 
Example #6
Source File: FixUseSupperClassAnnotationParser.java    From hsweb-framework with Apache License 2.0 6 votes vote down vote up
CacheEvictOperation parseEvictAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, CacheEvict cacheEvict) {
    CacheEvictOperation.Builder builder = new CacheEvictOperation.Builder();

    builder.setName(ae.toString());
    builder.setCacheNames(cacheEvict.cacheNames());
    builder.setCondition(cacheEvict.condition());
    builder.setKey(cacheEvict.key());
    builder.setKeyGenerator(cacheEvict.keyGenerator());
    builder.setCacheManager(cacheEvict.cacheManager());
    builder.setCacheResolver(cacheEvict.cacheResolver());
    builder.setCacheWide(cacheEvict.allEntries());
    builder.setBeforeInvocation(cacheEvict.beforeInvocation());

    defaultConfig.applyDefault(builder);
    CacheEvictOperation op = builder.build();
    validateCacheOperation(ae, op);

    return op;
}
 
Example #7
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void multipleComposedAnnotations() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multipleComposed", 4);
	Iterator<CacheOperation> it = ops.iterator();

	CacheOperation cacheOperation = it.next();
	assertThat(cacheOperation, instanceOf(CacheableOperation.class));
	assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("directly declared")));
	assertThat(cacheOperation.getKey(), equalTo(""));

	cacheOperation = it.next();
	assertThat(cacheOperation, instanceOf(CacheableOperation.class));
	assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("composedCache")));
	assertThat(cacheOperation.getKey(), equalTo("composedKey"));

	cacheOperation = it.next();
	assertThat(cacheOperation, instanceOf(CacheableOperation.class));
	assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("foo")));
	assertThat(cacheOperation.getKey(), equalTo(""));

	cacheOperation = it.next();
	assertThat(cacheOperation, instanceOf(CacheEvictOperation.class));
	assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("composedCacheEvict")));
	assertThat(cacheOperation.getKey(), equalTo("composedEvictionKey"));
}
 
Example #8
Source File: SpringCacheAnnotationParser.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
CacheEvictOperation parseEvictAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, CacheEvict cacheEvict) {
	CacheEvictOperation.Builder builder = new CacheEvictOperation.Builder();

	builder.setName(ae.toString());
	builder.setCacheNames(cacheEvict.cacheNames());
	builder.setCondition(cacheEvict.condition());
	builder.setKey(cacheEvict.key());
	builder.setKeyGenerator(cacheEvict.keyGenerator());
	builder.setCacheManager(cacheEvict.cacheManager());
	builder.setCacheResolver(cacheEvict.cacheResolver());
	builder.setCacheWide(cacheEvict.allEntries());
	builder.setBeforeInvocation(cacheEvict.beforeInvocation());

	defaultConfig.applyDefault(builder);
	CacheEvictOperation op = builder.build();
	validateCacheOperation(ae, op);

	return op;
}
 
Example #9
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void multipleAnnotation() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multiple", 2);
	Iterator<CacheOperation> it = ops.iterator();
	assertTrue(it.next() instanceof CacheableOperation);
	assertTrue(it.next() instanceof CacheEvictOperation);
}
 
Example #10
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void caching() throws Exception {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "caching", 2);
	Iterator<CacheOperation> it = ops.iterator();
	assertTrue(it.next() instanceof CacheableOperation);
	assertTrue(it.next() instanceof CacheEvictOperation);
}
 
Example #11
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void multipleAnnotation() throws Exception {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multiple", 2);
	Iterator<CacheOperation> it = ops.iterator();
	assertTrue(it.next() instanceof CacheableOperation);
	assertTrue(it.next() instanceof CacheEvictOperation);
}
 
Example #12
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void caching() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "caching", 2);
	Iterator<CacheOperation> it = ops.iterator();
	assertTrue(it.next() instanceof CacheableOperation);
	assertTrue(it.next() instanceof CacheEvictOperation);
}
 
Example #13
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void multipleAnnotation() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multiple", 2);
	Iterator<CacheOperation> it = ops.iterator();
	assertTrue(it.next() instanceof CacheableOperation);
	assertTrue(it.next() instanceof CacheEvictOperation);
}
 
Example #14
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void caching() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "caching", 2);
	Iterator<CacheOperation> it = ops.iterator();
	assertTrue(it.next() instanceof CacheableOperation);
	assertTrue(it.next() instanceof CacheEvictOperation);
}
 
Example #15
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void singularStereotype() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singleStereotype", 1);
	assertTrue(ops.iterator().next() instanceof CacheEvictOperation);
}
 
Example #16
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void singularStereotype() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singleStereotype", 1);
	assertTrue(ops.iterator().next() instanceof CacheEvictOperation);
}
 
Example #17
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void singularStereotype() throws Exception {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singleStereotype", 1);
	assertTrue(ops.iterator().next() instanceof CacheEvictOperation);
}