Package net.sf.ehcache

Examples of net.sf.ehcache.CacheManager


    bind(CacheManager.class).annotatedWith(ListingCacheAware.class).toProvider(new Provider<CacheManager>() {

      @Override
      public CacheManager get() {
        final URL url = Thread.currentThread().getContextClassLoader().getResource("ehcache.xml");
        return new CacheManager(url);
      }
    }).in(Scopes.SINGLETON);

    // IRowListHandlerProvider
    bind(IRowListHandlerProvider.class).to(TestRowListHandlerProvider.class).in(Scopes.SINGLETON);
View Full Code Here


      }
    }
    else {
      // Independent CacheManager instance (the default).
      if (this.configLocation != null) {
        this.cacheManager = new CacheManager(this.configLocation.getInputStream());
      }
      else {
        this.cacheManager = new CacheManager();
      }
    }
  }
View Full Code Here

      }
    }
    else {
      // Independent CacheManager instance (the default).
      if (this.configLocation != null) {
        this.cacheManager = new CacheManager(this.configLocation.getInputStream());
      }
      else {
        this.cacheManager = new CacheManager();
      }
    }
    if (this.cacheManagerName != null) {
      this.cacheManager.setName(this.cacheManagerName);
    }
View Full Code Here

      }
    }
    else {
      // Independent CacheManager instance (the default).
      if (this.configLocation != null) {
        this.cacheManager = new CacheManager(this.configLocation.getInputStream());
      }
      else {
        this.cacheManager = new CacheManager();
      }
    }
    if (this.cacheManagerName != null) {
      this.cacheManager.setName(this.cacheManagerName);
    }
View Full Code Here

    EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
    assertEquals(CacheManager.class, cacheManagerFb.getObjectType());
    assertTrue("Singleton property", cacheManagerFb.isSingleton());
    cacheManagerFb.afterPropertiesSet();
    try {
      CacheManager cm = (CacheManager) cacheManagerFb.getObject();
      assertTrue("Loaded CacheManager with no caches", cm.getCacheNames().length == 0);
      Cache myCache1 = cm.getCache("myCache1");
      assertTrue("No myCache1 defined", myCache1 == null);
    }
    finally {
      cacheManagerFb.destroy();
    }
View Full Code Here

    EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
    cacheManagerFb.setConfigLocation(new ClassPathResource("testEhcache.xml", getClass()));
    cacheManagerFb.setCacheManagerName("myCacheManager");
    cacheManagerFb.afterPropertiesSet();
    try {
      CacheManager cm = (CacheManager) cacheManagerFb.getObject();
      assertTrue("Correct number of caches loaded", cm.getCacheNames().length == 1);
      Cache myCache1 = cm.getCache("myCache1");
      assertFalse("myCache1 is not eternal", myCache1.isEternal());
      assertTrue("myCache1.maxElements == 300", myCache1.getMaxElementsInMemory() == 300);
    }
    finally {
      cacheManagerFb.destroy();
View Full Code Here

  public void testEhCacheFactoryBeanWithBlockingCache() throws Exception {
    EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
    cacheManagerFb.afterPropertiesSet();
    try {
      CacheManager cm = (CacheManager) cacheManagerFb.getObject();
      EhCacheFactoryBean cacheFb = new EhCacheFactoryBean();
      cacheFb.setCacheManager(cm);
      cacheFb.setCacheName("myCache1");
      cacheFb.setBlocking(true);
      cacheFb.afterPropertiesSet();
      Ehcache myCache1 = cm.getEhcache("myCache1");
      assertTrue(myCache1 instanceof BlockingCache);
    }
    finally {
      cacheManagerFb.destroy();
    }
View Full Code Here

  public void testEhCacheFactoryBeanWithSelfPopulatingCache() throws Exception {
    EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
    cacheManagerFb.afterPropertiesSet();
    try {
      CacheManager cm = (CacheManager) cacheManagerFb.getObject();
      EhCacheFactoryBean cacheFb = new EhCacheFactoryBean();
      cacheFb.setCacheManager(cm);
      cacheFb.setCacheName("myCache1");
      cacheFb.setCacheEntryFactory(new CacheEntryFactory() {
        public Object createEntry(Object key) throws Exception {
          return key;
        }
      });
      cacheFb.afterPropertiesSet();
      Ehcache myCache1 = cm.getEhcache("myCache1");
      assertTrue(myCache1 instanceof SelfPopulatingCache);
      assertEquals("myKey1", myCache1.get("myKey1").getValue());
    }
    finally {
      cacheManagerFb.destroy();
View Full Code Here

  public void testEhCacheFactoryBeanWithUpdatingSelfPopulatingCache() throws Exception {
    EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
    cacheManagerFb.afterPropertiesSet();
    try {
      CacheManager cm = (CacheManager) cacheManagerFb.getObject();
      EhCacheFactoryBean cacheFb = new EhCacheFactoryBean();
      cacheFb.setCacheManager(cm);
      cacheFb.setCacheName("myCache1");
      cacheFb.setCacheEntryFactory(new UpdatingCacheEntryFactory() {
        public Object createEntry(Object key) throws Exception {
          return key;
        }
        public void updateEntryValue(Object key, Object value) throws Exception {
        }
      });
      cacheFb.afterPropertiesSet();
      Ehcache myCache1 = cm.getEhcache("myCache1");
      assertTrue(myCache1 instanceof UpdatingSelfPopulatingCache);
      assertEquals("myKey1", myCache1.get("myKey1").getValue());
    }
    finally {
      cacheManagerFb.destroy();
View Full Code Here

          getLogger().warn("Locationmap cache configuration is deprecated through cocoon.xconf.  "
             + "Please use ehcache.xml instead.");
        }
       
        if(m_cacheAll == true) {
            m_cacheManager = new CacheManager();
            m_cache = m_cacheManager.getCache("lm_Cache");
            debug("LM caching enabled and configured.");
        }
    }
View Full Code Here

TOP

Related Classes of net.sf.ehcache.CacheManager

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.