Package org.springframework.cache.jcache.interceptor

Examples of org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource


  @Test
  public void cacheResolver() {
    ConfigurableApplicationContext context = new GenericXmlApplicationContext(
        "/org/springframework/cache/jcache/config/jCacheNamespaceDriven-resolver.xml");

    DefaultJCacheOperationSource ci = context.getBean(DefaultJCacheOperationSource.class);
    assertSame(context.getBean("cacheResolver"), ci.getCacheResolver());
    context.close();
  }
View Full Code Here


  @Test
  public void fullCachingConfig() throws Exception {
    AnnotationConfigApplicationContext context =
        new AnnotationConfigApplicationContext(FullCachingConfig.class);
    DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
    assertSame(context.getBean(KeyGenerator.class), cos.getKeyGenerator());
    assertSame(context.getBean("cacheResolver", CacheResolver.class),
        cos.getCacheResolver());
    assertSame(context.getBean("exceptionCacheResolver", CacheResolver.class),
        cos.getExceptionCacheResolver());
    JCacheInterceptor interceptor = context.getBean(JCacheInterceptor.class);
    assertSame(context.getBean("errorHandler", CacheErrorHandler.class), interceptor.getErrorHandler());
  }
View Full Code Here

  @Test
  public void emptyConfigSupport() {
    ConfigurableApplicationContext context =
        new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);

    DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
    assertNotNull(cos.getCacheResolver());
    assertEquals(SimpleCacheResolver.class, cos.getCacheResolver().getClass());
    assertSame(context.getBean(CacheManager.class),
        ((SimpleCacheResolver) cos.getCacheResolver()).getCacheManager());
    assertNotNull(cos.getExceptionCacheResolver());
    assertEquals(SimpleExceptionCacheResolver.class, cos.getExceptionCacheResolver().getClass());
    assertSame(context.getBean(CacheManager.class),
        ((SimpleExceptionCacheResolver) cos.getExceptionCacheResolver()).getCacheManager());
    context.close();
  }
View Full Code Here

  @Test
  public void bothSetOnlyResolverIsUsed() {
    ConfigurableApplicationContext context =
        new AnnotationConfigApplicationContext(FullCachingConfigSupport.class);

    DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
    assertSame(context.getBean("cacheResolver"), cos.getCacheResolver());
    assertSame(context.getBean("keyGenerator"), cos.getKeyGenerator());
    assertSame(context.getBean("exceptionCacheResolver"), cos.getExceptionCacheResolver());
    context.close();
  }
View Full Code Here

  }

  @Bean(name = "jCacheOperationSource")
  @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
  public JCacheOperationSource cacheOperationSource() {
    DefaultJCacheOperationSource source = new DefaultJCacheOperationSource();
    if (this.cacheManager != null) {
      source.setCacheManager(this.cacheManager);
    }
    if (this.keyGenerator != null) {
      source.setKeyGenerator(this.keyGenerator);
    }
    if (this.cacheResolver != null) {
      source.setCacheResolver(this.cacheResolver);
    }
    if (this.exceptionCacheResolver != null) {
      source.setExceptionCacheResolver(this.exceptionCacheResolver);
    }
    return source;
  }
View Full Code Here

TOP

Related Classes of org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.