Package net.sf.ehcache.config

Examples of net.sf.ehcache.config.CacheConfiguration


        if (bus != null) {
            confName = bus.getId();
        }
        cacheManager = EHCacheManagerHolder.getCacheManager(confName, configFileURL);
        // Cannot overflow to disk as SecurityToken Elements can't be serialized
        @SuppressWarnings("deprecation")
        CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager)
            .overflowToDisk(false); //tokens not writable
       
        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);
       
        // Set the TimeToLive value from the CacheConfiguration
        ttl = cc.getTimeToLiveSeconds();
    }
View Full Code Here


public class Ehcache implements ICache {
    private Cache cache;

    public Ehcache(long offHeap) {
        CacheConfiguration config = new CacheConfiguration("sample-offheap-cache", 0).
                overflowToOffHeap(true).maxBytesLocalOffHeap(offHeap, MemoryUnit.BYTES);
        CacheManager manager = CacheManager.create();
        manager.addCache(new Cache(config));
        this.cache = manager.getCache("sample-offheap-cache");
    }
View Full Code Here

    private EHCacheUtil() {
        //
    }
   
    public static CacheConfiguration getCacheConfiguration(String key, CacheManager cacheManager) {
        CacheConfiguration cc = cacheManager.getConfiguration().getCacheConfigurations().get(key);
        if (cc == null && key.contains("-")) {
            cc = cacheManager.getConfiguration().getCacheConfigurations().get(
                    key.substring(0, key.lastIndexOf('-')));
        }
        if (cc == null) {
            cc = cacheManager.getConfiguration().getDefaultCacheConfiguration();
        }
        if (cc == null) {
            cc = new CacheConfiguration();
        } else {
            cc = (CacheConfiguration)cc.clone();
        }
        cc.setName(key);
        return cc;
    }
View Full Code Here

        } else {
            Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
            cacheManager = CacheManager.create(conf);
        }
       
        CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(key, cacheManager);
       
        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);

        // Set the TimeToLive value from the CacheConfiguration
        ttl = cc.getTimeToLiveSeconds();
    }
View Full Code Here

    /**
     * Validates that the supplied Ehcache instance is valid for use as a Hibernate cache.
     */
    public static void validateEhcache(Ehcache cache) throws CacheException {
        CacheConfiguration cacheConfig = cache.getCacheConfiguration();

        if ( cacheConfig.isTerracottaClustered() ) {
            TerracottaConfiguration tcConfig = cacheConfig.getTerracottaConfiguration();
            switch ( tcConfig.getValueMode() ) {
                case IDENTITY:
                    throw new CacheException(
                            "The clustered Hibernate cache " + cache.getName() + " is using IDENTITY value mode.\n"
                                    + "Identity value mode cannot be used with Hibernate cache regions."
View Full Code Here

        final Ehcache cache = createMock(Ehcache.class);
        final ResourcesElementsProvider elementsProvider = createMock(ResourcesElementsProvider.class);
       
        expect(elementsProvider.getDefaultIncludedType()).andReturn(Included.AGGREGATED);
        expect(cache.getInternalContext()).andReturn(null).anyTimes();
        expect(cache.getCacheConfiguration()).andReturn(new CacheConfiguration());
        expect(cache.get(doc1Resouce)).andReturn(null);
        expect(cache.getQuiet(doc1Resouce)).andReturn(null);
        cache.put(anyObject(Element.class));
        expectLastCall();
       
View Full Code Here

        final Ehcache cache = createMock(Ehcache.class);
        final ResourcesElementsProvider elementsProvider = createMock(ResourcesElementsProvider.class);
       
        expect(elementsProvider.getDefaultIncludedType()).andReturn(Included.AGGREGATED);
        expect(cache.getInternalContext()).andReturn(null).anyTimes();
        expect(cache.getCacheConfiguration()).andReturn(new CacheConfiguration());
        expect(cache.get(doc1Resouce)).andReturn(null);
        expect(cache.getQuiet(doc1Resouce)).andReturn(null);
        cache.put(anyObject(Element.class));
        expectLastCall();
       
View Full Code Here

        final CachedResource<?> cachedResource = createMock(CachedResource.class);
        final ResourcesElementsProvider elementsProvider = createMock(ResourcesElementsProvider.class);
       
        expect(elementsProvider.getDefaultIncludedType()).andReturn(Included.AGGREGATED);
        expect(cache.getInternalContext()).andReturn(null).anyTimes();
        expect(cache.getCacheConfiguration()).andReturn(new CacheConfiguration());
        expect(cache.get(doc1Resouce))
            .andReturn(new Element(doc1Resouce, cachedResource));
       
        final long lastModified = doc1.lastModified();
       
View Full Code Here

        final CachedResource<?> cachedResource = createMock(CachedResource.class);
        final ResourcesElementsProvider elementsProvider = createMock(ResourcesElementsProvider.class);
       
        expect(elementsProvider.getDefaultIncludedType()).andReturn(Included.AGGREGATED);
        expect(cache.getInternalContext()).andReturn(null).anyTimes();
        expect(cache.getCacheConfiguration()).andReturn(new CacheConfiguration());
        final Element element = new Element("class path resource [CachingResourceLoaderImplTest_doc1.txt]", cachedResource);
        expect(cache.get(doc1Resouce)).andReturn(element);
       
        final long lastModified = doc1.lastModified();
       
View Full Code Here

        final CachedResource<?> cachedResource = createMock(CachedResource.class);
        final ResourcesElementsProvider elementsProvider = createMock(ResourcesElementsProvider.class);
       
        expect(elementsProvider.getDefaultIncludedType()).andReturn(Included.AGGREGATED);
        expect(cache.getInternalContext()).andReturn(null).anyTimes();
        expect(cache.getCacheConfiguration()).andReturn(new CacheConfiguration());
        expect(cache.get(doc1Resouce))
            .andReturn(new Element(doc1Resouce, cachedResource));
       
        expect(cachedResource.getLastCheckTime()).andReturn(System.currentTimeMillis());
       
View Full Code Here

TOP

Related Classes of net.sf.ehcache.config.CacheConfiguration

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.