Package net.sf.ehcache

Examples of net.sf.ehcache.Ehcache


       
       
        cacheMock.expects(once()).method("removeQuiet").with(eq(WINDOW_ID)).will(returnValue(true));
       
       
        Ehcache cache = (Ehcache) cacheMock.proxy();       
        PortletWindowCache windowCache = new EhPortletWindowCache(cache)
        windowCache.putPortletWindow(window);
       
        windowCache.removePortletWindow(WINDOW_ID);
        assertNull(windowCache.getPortletWindowByEntityId(ENTITY_ID));
View Full Code Here


       
       
        cacheMock.expects(atLeastOnce()).method("removeQuiet").with(eq(WINDOW_ID)).will(returnValue(true));
       
       
        Ehcache cache = (Ehcache) cacheMock.proxy();       
        PortletWindowCache windowCache = new EhPortletWindowCache(cache)
        windowCache.putPortletWindow(window);
       
        windowCache.removePortletWindowByPortletEntityId(ENTITY_ID);
        assertNull(windowCache.getPortletWindow(WINDOW_ID));
View Full Code Here

    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

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

     *
     * @return {@link Cache}
     */
    public Ehcache initializeCache() {
        CacheManager cacheManager = getCacheManagerFactory().getInstance();
        Ehcache cache;
        if (cacheManager.cacheExists(config.getCacheName())) {
            if (LOG.isTraceEnabled()) {
                LOG.trace("Found an existing cache: {}", config.getCacheName());
                LOG.trace("Cache {} currently contains {} elements",
                        config.getCacheName(),
                        cacheManager.getEhcache(config.getCacheName()).getSize());
            }
            cache = cacheManager.getEhcache(config.getCacheName());
        } else {
            cache = new Cache(config.getCacheName(),
                    config.getMaxElementsInMemory(),
                    config.getMemoryStoreEvictionPolicy(),
                    config.isOverflowToDisk(),
                    config.getDiskStorePath(),
                    config.isEternal(),
                    config.getTimeToLiveSeconds(),
                    config.getTimeToIdleSeconds(),
                    config.isDiskPersistent(),
                    config.getDiskExpiryThreadIntervalSeconds(),
                    null);

            for (CacheEventListener listener : config.getEventListenerRegistry().getEventListeners()) {
                cache.getCacheEventNotificationService().registerListener(listener);
            }

            for (CacheLoaderWrapper loader : config.getCacheLoaderRegistry().getCacheLoaders()) {
                loader.init(cache);
                cache.registerCacheLoader(loader);
            }

            cacheManager.addCache(cache);

            if (LOG.isDebugEnabled()) {
                LOG.debug("Added a new cache: " + cache.getName());
            }
        }

        return cache;
    }
View Full Code Here

   
    public EHCacheTokenStore(String key, URL configFileURL) {
        cacheManager = EHCacheManagerHolder.getCacheManager(configFileURL);

        // Cannot overflow to disk as SecurityToken Elements can't be serialized
        Ehcache newCache = new Cache(key, MAX_ELEMENTS, false, false, DEFAULT_TTL, DEFAULT_TTL);
        cache = cacheManager.addCacheIfAbsent(newCache);
    }
View Full Code Here

    private long ttl = DEFAULT_TTL;
   
    public EHCacheReplayCache(String key, URL configFileURL) {
        cacheManager = EHCacheManagerHolder.getCacheManager(configFileURL);
       
        Ehcache newCache = new Cache(key, 50000, true, false, DEFAULT_TTL, DEFAULT_TTL);
        cache = cacheManager.addCacheIfAbsent(newCache);
    }
View Full Code Here

            cacheManager = CacheManager.create();
        } else {
            cacheManager = CacheManager.create(configFileURL);
        }
       
        Ehcache newCache = new Cache(REQUEST_CACHE_KEY, 50000, true, false, DEFAULT_TTL, DEFAULT_TTL);
        requestCache = cacheManager.addCacheIfAbsent(newCache);
       
        newCache = new Cache(RESPONSE_CACHE_KEY, 50000, true, false, DEFAULT_TTL, DEFAULT_TTL);
        responseCache = cacheManager.addCacheIfAbsent(newCache);
    }
View Full Code Here

     * @return the queue of messages, or if none existed, a new queue
     * @throws AsynchronousCommandException
     */
    synchronized Queue getQueue() throws AsynchronousCommandException {
        Queue queue;
        Ehcache cache = getMessageCache();
        Element element;
        try {
            element = cache.get(QUEUE_KEY);
        } catch (CacheException e) {
            throw new AsynchronousCommandException("Unable to retrieve queue.", e);
        }
        if (element == null) {
            queue = new ConcurrentLinkedQueue();
            Element queueElement = new Element(QUEUE_KEY, queue);
            cache.put(queueElement);
        } else {
            queue = (Queue) element.getValue();
        }
        return queue;
    }
View Full Code Here

     *
     * @return the {@link #MESSAGE_CACHE} cache
     * @throws AsynchronousCommandException if the {@link #MESSAGE_CACHE} is null
     */
    public Ehcache getMessageCache() throws AsynchronousCommandException {
        Ehcache cache = cacheManager.getEhcache(MESSAGE_CACHE);
        if (cache == null) {
            throw new AsynchronousCommandException(
                    "ehcache.xml with a configuration entry for " +
                            MESSAGE_CACHE + " was not found in the classpath.");
        }
View Full Code Here

TOP

Related Classes of net.sf.ehcache.Ehcache

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.