Examples of CacheInterceptor


Examples of org.springframework.cache.interceptor.CacheInterceptor

  @Test
  public void onlyOneInterceptorIsAvailable() {
    Map<String, CacheInterceptor> interceptors = ctx.getBeansOfType(CacheInterceptor.class);
    assertEquals("Only one interceptor should be defined", 1, interceptors.size());
    CacheInterceptor interceptor = interceptors.values().iterator().next();
    assertEquals("Custom interceptor not defined", TestCacheInterceptor.class, interceptor.getClass());
  }
View Full Code Here

Examples of org.springframework.cache.interceptor.CacheInterceptor

      return new DefaultCacheableService();
    }

    @Bean
    public CacheInterceptor cacheInterceptor(CacheOperationSource cacheOperationSource) {
      CacheInterceptor cacheInterceptor = new TestCacheInterceptor();
      cacheInterceptor.setCacheManager(cacheManager());
      cacheInterceptor.setCacheOperationSources(cacheOperationSource);
      return cacheInterceptor;
    }
View Full Code Here

Examples of org.springframework.cache.interceptor.CacheInterceptor

        "/org/springframework/cache/config/cache-advice.xml");
  }

  @Test
  public void testKeyStrategy() throws Exception {
    CacheInterceptor bean = ctx.getBean("cacheAdviceClass", CacheInterceptor.class);
    Assert.assertSame(ctx.getBean("keyGenerator"), bean.getKeyGenerator());
  }
View Full Code Here

Examples of org.springframework.cache.interceptor.CacheInterceptor

    return new AnnotationConfigApplicationContext(EnableCachingConfig.class);
  }

  @Test
  public void testKeyStrategy() {
    CacheInterceptor ci = ctx.getBean(CacheInterceptor.class);
    assertSame(ctx.getBean("keyGenerator", KeyGenerator.class), ci.getKeyGenerator());
  }
View Full Code Here

Examples of org.springframework.cache.interceptor.CacheInterceptor

    assertSame(ctx.getBean("keyGenerator", KeyGenerator.class), ci.getKeyGenerator());
  }

  @Test
  public void testCacheErrorHandler() {
    CacheInterceptor ci = ctx.getBean(CacheInterceptor.class);
    assertSame(ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
  }
View Full Code Here

Examples of org.springframework.cache.interceptor.CacheInterceptor

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

    CacheInterceptor ci = context.getBean(CacheInterceptor.class);
    assertNotNull(ci.getCacheResolver());
    assertEquals(SimpleCacheResolver.class, ci.getCacheResolver().getClass());
    assertSame(context.getBean(CacheManager.class),
        ((SimpleCacheResolver)ci.getCacheResolver()).getCacheManager());
    context.close();
  }
View Full Code Here

Examples of org.springframework.cache.interceptor.CacheInterceptor

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

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

Examples of org.springframework.cache.interceptor.CacheInterceptor

  }

  @Bean
  @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
  public CacheInterceptor cacheInterceptor() {
    CacheInterceptor interceptor = new CacheInterceptor();
    interceptor.setCacheOperationSources(cacheOperationSource());
    if (this.cacheResolver != null) {
      interceptor.setCacheResolver(this.cacheResolver);
    }
    else if (this.cacheManager != null) {
      interceptor.setCacheManager(this.cacheManager);
    }
    if (this.keyGenerator != null) {
      interceptor.setKeyGenerator(this.keyGenerator);
    }
    if (this.errorHandler != null) {
      interceptor.setErrorHandler(this.errorHandler);
    }
    return interceptor;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.