org.springframework.cache.interceptor.CacheableOperation Java Examples

The following examples show how to use org.springframework.cache.interceptor.CacheableOperation. 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: 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 #2
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 #3
Source File: SpringCacheAnnotationParser.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
CacheableOperation parseCacheableAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, Cacheable cacheable) {
	CacheableOperation op = new CacheableOperation();

	op.setCacheNames(cacheable.cacheNames());
	op.setCondition(cacheable.condition());
	op.setUnless(cacheable.unless());
	op.setKey(cacheable.key());
	op.setKeyGenerator(cacheable.keyGenerator());
	op.setCacheManager(cacheable.cacheManager());
	op.setCacheResolver(cacheable.cacheResolver());
	op.setName(ae.toString());

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

	return op;
}
 
Example #4
Source File: SpringCacheAnnotationParser.java    From java-technology-stack with MIT License 6 votes vote down vote up
private CacheableOperation parseCacheableAnnotation(
		AnnotatedElement ae, DefaultCacheConfig defaultConfig, Cacheable cacheable) {

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

	builder.setName(ae.toString());
	builder.setCacheNames(cacheable.cacheNames());
	builder.setCondition(cacheable.condition());
	builder.setUnless(cacheable.unless());
	builder.setKey(cacheable.key());
	builder.setKeyGenerator(cacheable.keyGenerator());
	builder.setCacheManager(cacheable.cacheManager());
	builder.setCacheResolver(cacheable.cacheResolver());
	builder.setSync(cacheable.sync());

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

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

    builder.setName(ae.toString());
    builder.setCacheNames(cacheable.cacheNames());
    builder.setCondition(cacheable.condition());
    builder.setUnless(cacheable.unless());
    builder.setKey(cacheable.key());
    builder.setKeyGenerator(cacheable.keyGenerator());
    builder.setCacheManager(cacheable.cacheManager());
    builder.setCacheResolver(cacheable.cacheResolver());
    builder.setSync(cacheable.sync());

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

    return op;
}
 
Example #6
Source File: SpringCacheAnnotationParser.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
CacheableOperation parseCacheableAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, Cacheable cacheable) {
	CacheableOperation.Builder builder = new CacheableOperation.Builder();

	builder.setName(ae.toString());
	builder.setCacheNames(cacheable.cacheNames());
	builder.setCondition(cacheable.condition());
	builder.setUnless(cacheable.unless());
	builder.setKey(cacheable.key());
	builder.setKeyGenerator(cacheable.keyGenerator());
	builder.setCacheManager(cacheable.cacheManager());
	builder.setCacheResolver(cacheable.cacheResolver());
	builder.setSync(cacheable.sync());

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

	return op;
}
 
Example #7
Source File: SpringCacheAnnotationParser.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private CacheableOperation parseCacheableAnnotation(
		AnnotatedElement ae, DefaultCacheConfig defaultConfig, Cacheable cacheable) {

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

	builder.setName(ae.toString());
	builder.setCacheNames(cacheable.cacheNames());
	builder.setCondition(cacheable.condition());
	builder.setUnless(cacheable.unless());
	builder.setKey(cacheable.key());
	builder.setKeyGenerator(cacheable.keyGenerator());
	builder.setCacheManager(cacheable.cacheManager());
	builder.setCacheResolver(cacheable.cacheResolver());
	builder.setSync(cacheable.sync());

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

	return op;
}
 
Example #8
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 #9
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void singleComposedAnnotation() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singleComposed", 2);
	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"));
}
 
Example #10
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Ignore("Disabled until SPR-13475 is resolved")
@Test
public void singleComposedAnnotation() throws Exception {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singleComposed", 1);
	CacheOperation cacheOperation = ops.iterator().next();
	assertThat(cacheOperation, instanceOf(CacheableOperation.class));
	assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("composed")));
}
 
Example #11
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 #12
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 #13
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void cacheAnnotationOverride() {
	Collection<CacheOperation> ops = getOps(InterfaceCacheConfig.class, "interfaceCacheableOverride");
	assertSame(1, ops.size());
	CacheOperation cacheOperation = ops.iterator().next();
	assertTrue(cacheOperation instanceof CacheableOperation);
}
 
Example #14
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 #15
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 #16
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void cacheAnnotationOverride() {
	Collection<CacheOperation> ops = getOps(InterfaceCacheConfig.class, "interfaceCacheableOverride");
	assertSame(1, ops.size());
	CacheOperation cacheOperation = ops.iterator().next();
	assertTrue(cacheOperation instanceof CacheableOperation);
}
 
Example #17
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void singleComposedAnnotation() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singleComposed", 2);
	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"));
}
 
Example #18
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 #19
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 #20
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void singularAnnotation() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singular", 1);
	assertTrue(ops.iterator().next() instanceof CacheableOperation);
}
 
Example #21
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void singularAnnotation() throws Exception {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singular", 1);
	assertTrue(ops.iterator().next() instanceof CacheableOperation);
}
 
Example #22
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void singularAnnotation() {
	Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singular", 1);
	assertTrue(ops.iterator().next() instanceof CacheableOperation);
}