Package org.springframework.cache.interceptor

Examples of org.springframework.cache.interceptor.CacheOperation


    for (Element opElement : cacheableCacheMethods) {
      String name = prop.merge(opElement, parserContext.getReaderContext());
      TypedStringValue nameHolder = new TypedStringValue(name);
      nameHolder.setSource(parserContext.extractSource(opElement));
      CacheOperation op = prop.merge(opElement, parserContext.getReaderContext(), new CacheableOperation());

      Collection<CacheOperation> col = cacheOpMap.get(nameHolder);
      if (col == null) {
        col = new ArrayList<CacheOperation>(2);
        cacheOpMap.put(nameHolder, col);
      }
      col.add(op);
    }

    List<Element> evictCacheMethods = DomUtils.getChildElementsByTagName(definition, CACHE_EVICT_ELEMENT);

    for (Element opElement : evictCacheMethods) {
      String name = prop.merge(opElement, parserContext.getReaderContext());
      TypedStringValue nameHolder = new TypedStringValue(name);
      nameHolder.setSource(parserContext.extractSource(opElement));
      CacheEvictOperation op = prop.merge(opElement, parserContext.getReaderContext(), new CacheEvictOperation());

      String wide = opElement.getAttribute("all-entries");
      if (StringUtils.hasText(wide)) {
        op.setCacheWide(Boolean.valueOf(wide.trim()));
      }

      String after = opElement.getAttribute("before-invocation");
      if (StringUtils.hasText(after)) {
        op.setBeforeInvocation(Boolean.valueOf(after.trim()));
      }

      Collection<CacheOperation> col = cacheOpMap.get(nameHolder);
      if (col == null) {
        col = new ArrayList<CacheOperation>(2);
        cacheOpMap.put(nameHolder, col);
      }
      col.add(op);
    }

    List<Element> putCacheMethods = DomUtils.getChildElementsByTagName(definition, CACHE_PUT_ELEMENT);

    for (Element opElement : putCacheMethods) {
      String name = prop.merge(opElement, parserContext.getReaderContext());
      TypedStringValue nameHolder = new TypedStringValue(name);
      nameHolder.setSource(parserContext.extractSource(opElement));
      CacheOperation op = prop.merge(opElement, parserContext.getReaderContext(), new CachePutOperation());

      Collection<CacheOperation> col = cacheOpMap.get(nameHolder);
      if (col == null) {
        col = new ArrayList<CacheOperation>(2);
        cacheOpMap.put(nameHolder, col);
View Full Code Here


  }

  @Test
  public void fullClassLevelWithCustomKeyManager() {
    Collection<CacheOperation> ops = getOps(AnnotatedClassWithFullDefault.class, "methodLevelKeyGenerator", 1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertSharedConfig(cacheOperation, "custom", "", "classCacheResolver" , "classCacheName");
  }
View Full Code Here

  }

  @Test
  public void fullClassLevelWithCustomCacheManager() {
    Collection<CacheOperation> ops = getOps(AnnotatedClassWithFullDefault.class, "methodLevelCacheManager", 1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertSharedConfig(cacheOperation, "classKeyGenerator", "custom", "", "classCacheName");
  }
View Full Code Here

  }

  @Test
  public void fullClassLevelWithCustomCacheResolver() {
    Collection<CacheOperation> ops = getOps(AnnotatedClassWithFullDefault.class, "methodLevelCacheResolver", 1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertSharedConfig(cacheOperation, "classKeyGenerator", "", "custom" , "classCacheName");
  }
View Full Code Here

  }

  @Test
  public void customClassLevelWithCustomCacheName() {
    Collection<CacheOperation> ops = getOps(AnnotatedClassWithCustomDefault.class, "methodLevelCacheName", 1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertSharedConfig(cacheOperation, "classKeyGenerator", "", "classCacheResolver", "custom");
  }
View Full Code Here

  }

  @Test
  public void severalCacheConfigUseClosest() {
    Collection<CacheOperation> ops = getOps(MultipleCacheConfig.class, "multipleCacheConfig");
    CacheOperation cacheOperation = ops.iterator().next();
    assertSharedConfig(cacheOperation, "", "", "", "myCache");
  }
View Full Code Here

  }

  @Test
  public void partialClassLevelWithCustomCacheManager() {
    Collection<CacheOperation> ops = getOps(AnnotatedClassWithSomeDefault.class, "methodLevelCacheManager", 1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertSharedConfig(cacheOperation, "classKeyGenerator", "custom", "", "classCacheName");
  }
View Full Code Here

  }

  @Test
  public void partialClassLevelWithCustomCacheResolver() {
    Collection<CacheOperation> ops = getOps(AnnotatedClassWithSomeDefault.class, "methodLevelCacheResolver", 1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertSharedConfig(cacheOperation, "classKeyGenerator", "", "custom", "classCacheName");
  }
View Full Code Here

  }

  @Test
  public void partialClassLevelWithNoCustomization() {
    Collection<CacheOperation> ops = getOps(AnnotatedClassWithSomeDefault.class, "noCustomization", 1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertSharedConfig(cacheOperation, "classKeyGenerator", "classCacheManager", "", "classCacheName");
  }
View Full Code Here

  @Test
  public void testMultipleStereotypes() throws Exception {
    Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multipleStereotype", 3);
    Iterator<CacheOperation> it = ops.iterator();
    assertTrue(it.next() instanceof CacheableOperation);
    CacheOperation next = it.next();
    assertTrue(next instanceof CacheEvictOperation);
    assertTrue(next.getCacheNames().contains("foo"));
    next = it.next();
    assertTrue(next instanceof CacheEvictOperation);
    assertTrue(next.getCacheNames().contains("bar"));
  }
View Full Code Here

TOP

Related Classes of org.springframework.cache.interceptor.CacheOperation

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.