Examples of Ehcache


Examples of net.sf.ehcache.Ehcache

        } else {
            cacheManager = EHCacheManagerHolder.getCacheManager(bus, getDefaultConfigFileURL());
        }
        CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager);
       
        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);
    }
View Full Code Here

Examples of net.sf.ehcache.Ehcache

     CacheManager.getInstance().addCache(cacheName);
   }
   public <K, V> Cache<K, V> getCache(String cacheName) {
     Cache cache = null;
     Ehcache ehcache = null;
     ehcache = (Ehcache) CacheManager.getInstance().getCache(cacheName);
     if (ehcache == null) {
       addCache(cacheName);
       ehcache = (Ehcache) CacheManager.getInstance().getCache(cacheName);
     }
View Full Code Here

Examples of net.sf.ehcache.Ehcache

        }

        @Override
        public int size() {
            if(springCache.getNativeCache() instanceof Ehcache) {
                Ehcache ehcache = (Ehcache) springCache.getNativeCache();
                return ehcache.getSize();
            }
            throw new UnsupportedOperationException("invoke spring cache abstract size method not supported");
        }
View Full Code Here

Examples of net.sf.ehcache.Ehcache

        }

        @Override
        public Set keys() {
            if(springCache.getNativeCache() instanceof Ehcache) {
                Ehcache ehcache = (Ehcache) springCache.getNativeCache();
                return new HashSet(ehcache.getKeys());
            }
            throw new UnsupportedOperationException("invoke spring cache abstract keys method not supported");
        }
View Full Code Here

Examples of net.sf.ehcache.Ehcache

        }

        @Override
        public Collection values() {
            if(springCache.getNativeCache() instanceof Ehcache) {
                Ehcache ehcache = (Ehcache) springCache.getNativeCache();
                List keys = ehcache.getKeys();
                if (!CollectionUtils.isEmpty(keys)) {
                    List values = new ArrayList(keys.size());
                    for (Object key : keys) {
                        Object value = get(key);
                        if (value != null) {
View Full Code Here

Examples of net.sf.ehcache.Ehcache

        LOG.info("Creating EhCache cache instance");

        int maxCacheSize = getIntConfigurationValue(facesContext, CoreConfiguration.Items.resourcesCacheSize);
        boolean preconfiguredCache = false;

        Ehcache ehcache = cacheManager.getEhcache(cacheName);
        if (ehcache == null) {
            ehcache = new net.sf.ehcache.Cache(cacheName, maxCacheSize, false, true, 0, 0);
        } else {
            preconfiguredCache = true;

            if (ehcache.getCacheConfiguration().getMaxEntriesLocalHeap() <= 0) {
                LOG.info(MessageFormat.format("Maximum cache size hasn''t been set, resetting to {0} max items", maxCacheSize));

                ehcache.getCacheConfiguration().setMaxEntriesLocalHeap(maxCacheSize);
            }
        }
        ehcache.setCacheManager(cacheManager);

        return new EhCacheCache(ehcache, preconfiguredCache);
    }
View Full Code Here

Examples of net.sf.ehcache.Ehcache

        return new EhcacheTimestampsRegion( accessStrategyFactory, getCache( regionName ), properties );
    }

    private Ehcache getCache(String name) throws CacheException {
        try {
            Ehcache cache = manager.getEhcache( name );
            if ( cache == null ) {
                LOG.unableToFindEhCacheConfiguration( name );
                manager.addCache( name );
                cache = manager.getEhcache( name );
                LOG.debug( "started EHCache region: " + name );
View Full Code Here

Examples of net.sf.ehcache.Ehcache

  protected Ehcache getCache(CachingModel model) throws CacheNotFoundException,
      CacheAccessException {
    EhCacheCachingModel ehCacheCachingModel = (EhCacheCachingModel) model;
    String cacheName = ehCacheCachingModel.getCacheName();

    Ehcache cache = (Cache) caches.get(cacheName);
    if (cache == null) {
      cache = decorateCache(getCache(cacheName), ehCacheCachingModel);
    }
    return cache;
  }
View Full Code Here

Examples of net.sf.ehcache.Ehcache

   * @throws CacheAccessException   wrapping any unexpected exception thrown by the cache.
   * @see AbstractCacheProviderFacade#onGetFromCache(Serializable,CachingModel)
   */
  protected Object onGetFromCache(Serializable key, CachingModel model)
      throws CacheException {
    Ehcache cache = getCache(model);
    Object cachedObject = null;

    try {
      Element cacheElement = cache.get(key);
      if (cacheElement != null) {
        cachedObject = cacheElement.getValue();
      }

    } catch (Exception exception) {
View Full Code Here

Examples of net.sf.ehcache.Ehcache

   * @see AbstractCacheProviderFacade#onPutInCache(Serializable,CachingModel,
   *Object)
   */
  protected void onPutInCache(Serializable key, CachingModel model, Object obj)
      throws CacheException {
    Ehcache cache = getCache(model);
    Element newCacheElement = new Element(key, (Serializable) obj);

    try {
      cache.put(newCacheElement);

    } catch (Exception exception) {
      throw new CacheAccessException(exception);
    }
  }
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.