Package net.sf.ehcache.config

Examples of net.sf.ehcache.config.CacheConfiguration$CacheExtensionFactoryConfiguration


            }
           
            cacheManager = EHCacheUtil.createCacheManager(conf);
        }
       
        CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(CACHE_KEY, cacheManager);
       
        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);
    }
View Full Code Here


  public static ISCCache<?> createDefaultSCCache(SCCacheConfiguration scCacheConfiguration, SC_CACHE_TYPE cacheType) {
    // sets up the configuration needed for the EHCache
    String diskPath = scCacheConfiguration.getDiskPath();

    // Configuration for EHCache cache
    CacheConfiguration ehCacheConfiguration = new CacheConfiguration();
    ehCacheConfiguration.setEternal(true); // elements stay in cache until app removes them
    ehCacheConfiguration.setOverflowToDisk(true);
    ehCacheConfiguration.setMaxElementsInMemory(scCacheConfiguration.getMaxElementsInMemory());
    ehCacheConfiguration.setMaxElementsOnDisk(scCacheConfiguration.getMaxElementsOnDisk());
    ehCacheConfiguration.setDiskPersistent(SCCacheFactory.DEFAULT_CACHE_DISK_PERSISTENT);
    ehCacheConfiguration.setDiskStorePath(diskPath);
    ehCacheConfiguration.setName(cacheType.name());
    ehCacheConfiguration.setCopyOnRead(true);
    ehCacheConfiguration.setCopyOnWrite(true);
    ehCacheConfiguration.setDiskExpiryThreadIntervalSeconds(scCacheConfiguration.getExpirationCheckIntervalSeconds());
   
    // create cache
    EHCacheImpl<?> cacheData = null;
    switch (cacheType) {
    case META_DATA_CACHE:
      cacheData = new EHCacheImpl<SCCacheMetaEntry>(ehCacheConfiguration);
      break;
    case DATA_CACHE:
      cacheData = new EHCacheImpl<SCMPMessage>(ehCacheConfiguration);
      break;
    }

    if (manager == null) {
      // following code adds EHCache monitor by JOT
      // FactoryConfiguration<FactoryConfiguration> factory = new FactoryConfiguration<FactoryConfiguration>();
      // factory.className("org.terracotta.ehcachedx.monitor.probe.ProbePeerListenerFactory");
      // factory.setProperties("monitorAddress=localhost, monitorPort=9889, memoryMeasurement=true");
      // factory.setPropertySeparator(",");
      // configuration.addCacheManagerPeerListenerFactory(factory);

      // Configuration is required for EHCache CacheManager
      Configuration ehCacheManagerConfiguration = new Configuration();
      DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
      if (diskPath != null) {
        diskStoreConfiguration.setPath(diskPath);
      }
      // use the ehCacheConfiguration as default but change the name
      ehCacheConfiguration.setName(SCCacheFactory.DEFAULT_CACHE_NAME);
      ehCacheManagerConfiguration.addDiskStore(diskStoreConfiguration);
      ehCacheManagerConfiguration.setName(SCCacheFactory.DEFAULT_CACHE_NAME);
      ehCacheManagerConfiguration.setDefaultCacheConfiguration(ehCacheConfiguration);
      ehCacheManagerConfiguration.setUpdateCheck(false); // disable update checker (checks EHCache version)
      manager = new CacheManager(ehCacheManagerConfiguration);
View Full Code Here

  public static ISCCacheModule<?> createDefaultSCCache(SCCacheConfiguration scCacheConfiguration, SC_CACHE_MODULE_TYPE cacheType) {
    // sets up the configuration needed for the EHCache
    String diskPath = scCacheConfiguration.getDiskPath();

    // Configuration for EHCache cache
    CacheConfiguration ehCacheConfiguration = new CacheConfiguration();
    ehCacheConfiguration.setEternal(true); // elements stay in cache until app removes them
    ehCacheConfiguration.setOverflowToDisk(true);
    ehCacheConfiguration.setMaxElementsInMemory(scCacheConfiguration.getMaxElementsInMemory());
    ehCacheConfiguration.setMaxElementsOnDisk(scCacheConfiguration.getMaxElementsOnDisk());
    ehCacheConfiguration.setDiskPersistent(SCCacheFactory.DEFAULT_CACHE_DISK_PERSISTENT);
    ehCacheConfiguration.setDiskStorePath(diskPath);
    ehCacheConfiguration.setName(cacheType.name());
    ehCacheConfiguration.setCopyOnRead(false);
    ehCacheConfiguration.setCopyOnWrite(false);
    ehCacheConfiguration.setDiskExpiryThreadIntervalSeconds(scCacheConfiguration.getExpirationCheckIntervalSeconds());
   
    // create cache
    EHCacheImpl<?> cacheData = null;
    switch (cacheType) {
    case META_DATA_CACHE_MODULE:
      cacheData = new EHCacheImpl<SCCacheMetaEntry>(ehCacheConfiguration);
      break;
    case DATA_CACHE_MODULE:
      cacheData = new EHCacheImpl<SCMPMessage>(ehCacheConfiguration);
      break;
    }

    if (ehManager == null) {
      // following code adds EHCache monitor by JOT
      // FactoryConfiguration<FactoryConfiguration> factory = new FactoryConfiguration<FactoryConfiguration>();
      // factory.className("org.terracotta.ehcachedx.monitor.probe.ProbePeerListenerFactory");
      // factory.setProperties("monitorAddress=localhost, monitorPort=9889, memoryMeasurement=true");
      // factory.setPropertySeparator(",");
      // configuration.addCacheManagerPeerListenerFactory(factory);

      // Configuration is required for EHCache CacheManager
      Configuration ehCacheManagerConfiguration = new Configuration();
      DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
      if (diskPath != null) {
        diskStoreConfiguration.setPath(diskPath);
      }
      // use the ehCacheConfiguration as default but change the name
      ehCacheConfiguration.setName(SCCacheFactory.DEFAULT_CACHE_NAME);
      ehCacheManagerConfiguration.addDiskStore(diskStoreConfiguration);
      ehCacheManagerConfiguration.setName(SCCacheFactory.DEFAULT_CACHE_NAME);
      ehCacheManagerConfiguration.setDefaultCacheConfiguration(ehCacheConfiguration);
      ehCacheManagerConfiguration.setUpdateCheck(false); // disable update checker (checks EHCache version)
      ehManager = new CacheManager(ehCacheManagerConfiguration);
View Full Code Here

            b.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(this);
        }

        cacheManager = EHCacheManagerHolder.getCacheManager(bus, configFileURL);
        // Cannot overflow to disk as SecurityToken Elements can't be serialized
        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

    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('-') - 1));
        }
        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

        }
        return cacheManager;
    }
   
    protected static Ehcache createCache(CacheManager cacheManager, String cacheKey) {
        CacheConfiguration clientCC = EHCacheUtil.getCacheConfiguration(cacheKey, cacheManager);
        return cacheManager.addCacheIfAbsent(new Cache(clientCC));
    }
View Full Code Here

        return (Cache<T>) cache;
    }

    private <T> EhCacheImpl<T> createNewCache( String cacheId, Class<T> valueType )
    {
        CacheConfiguration cc = createCacheConfiguration( cacheId );

        // TODO: We also need all the other Configurations that are possible, like cacheLoaderFactoryConfiguration
        net.sf.ehcache.Cache cache = new net.sf.ehcache.Cache( cc );
        cacheManager.addCache( cache );
View Full Code Here

    public void activateService()
        throws Exception
    {
        net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration();
        configureEhCache( configuration );
        CacheConfiguration cc = createCacheConfiguration( "qi4j.ehcache.config.default" );
        configuration.setDefaultCacheConfiguration( cc );
        cacheManager = CacheManager.newInstance( configuration );
    }
View Full Code Here

        Integer maxElementsInMemory = conf.maxElementsInMemory().get();
        if( maxElementsInMemory <= 0 )
        {
            maxElementsInMemory = 10000;
        }
        CacheConfiguration cacheConfig = new CacheConfiguration( cacheId, maxElementsInMemory );
        String transactionalMode = conf.transactionalMode().get();
        if( transactionalMode.length() > 0 )
        {
            cacheConfig.transactionalMode( transactionalMode );
        }

        Long timeToLiveSeconds = conf.timeToLiveSeconds().get();
        if( timeToLiveSeconds > 0 )
        {
            cacheConfig.timeToLiveSeconds( timeToLiveSeconds );
        }

        Long timeToIdleSeconds = conf.timeToIdleSeconds().get();
        if( timeToIdleSeconds > 0 )
        {
            cacheConfig.timeToIdleSeconds( timeToIdleSeconds );
        }

        String name = conf.name().get();
        if( name.length() > 0 )
        {
            cacheConfig.name( name );
        }

        String memoryStoreEvictionPolicy = conf.memoryStoreEvictionPolicy().get();
        if( memoryStoreEvictionPolicy.length() > 0 )
        {
            cacheConfig.memoryStoreEvictionPolicy( memoryStoreEvictionPolicy );
        }

        Integer maxElementsOnDisk = conf.maxElementsOnDisk().get();
        if( maxElementsOnDisk > 0 )
        {
            cacheConfig.maxElementsOnDisk( maxElementsOnDisk );
        }

        Boolean loggingEnabled = conf.loggingEnabled().get();
        if( loggingEnabled != null )
        {
            cacheConfig.logging( loggingEnabled );
        }

        Boolean eternal = conf.eternal().get();
        cacheConfig.eternal( eternal );

        Integer diskSpoolBufferSizeMB = conf.diskSpoolBufferSizeMB().get();
        if( diskSpoolBufferSizeMB > 0 )
        {
            cacheConfig.diskSpoolBufferSizeMB( diskSpoolBufferSizeMB );
        }

        Long diskExpiryThreadIntervalSeconds = conf.diskExpiryThreadIntervalSeconds().get();
        if( diskExpiryThreadIntervalSeconds > 0 )
        {
            cacheConfig.diskExpiryThreadIntervalSeconds( diskExpiryThreadIntervalSeconds );
        }

        Integer diskAccessStripes = conf.diskAccessStripes().get();
        if( diskAccessStripes > 0 )
        {
            cacheConfig.diskAccessStripes( diskAccessStripes );
        }
        Boolean clearOnFlush = conf.clearOnFlush().get();
        if( clearOnFlush != null )
        {
            cacheConfig.clearOnFlush( clearOnFlush );
        }

        // Persistence Configuration
        PersistenceConfiguration persistenceConfig = new PersistenceConfiguration();
        Strategy strategy = conf.persistenceStrategy().get();
        if( strategy == null )
        {
            persistenceConfig.strategy( Strategy.NONE );
        }
        else
        {
            persistenceConfig.strategy( strategy );
        }
        cacheConfig.persistence( persistenceConfig );

        return cacheConfig;
    }
View Full Code Here

    }
   
    public EHCacheReplayCache(String key, CacheManager cacheManager) {
        this.cacheManager = cacheManager;
       
        CacheConfiguration cc = EHCacheManagerHolder.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

TOP

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

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.