当前位置: 首页>>代码示例>>Java>>正文


Java Configuration.addDefaultCache方法代码示例

本文整理汇总了Java中net.sf.ehcache.config.Configuration.addDefaultCache方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.addDefaultCache方法的具体用法?Java Configuration.addDefaultCache怎么用?Java Configuration.addDefaultCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.ehcache.config.Configuration的用法示例。


在下文中一共展示了Configuration.addDefaultCache方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpGlobal

import net.sf.ehcache.config.Configuration; //导入方法依赖的package包/类
@BeforeClass
public static void setUpGlobal() {
    final Configuration config = new Configuration();
    config.addDefaultCache(
            new CacheConfiguration("default", Integer.MAX_VALUE)
                .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU)
                .overflowToDisk(false));
    CACHE_MANAGER = CacheManager.create(config);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:10,代码来源:TestEhcacheProtocolRequirements.java

示例2: BlockingCacheFactory

import net.sf.ehcache.config.Configuration; //导入方法依赖的package包/类
public BlockingCacheFactory(int timeToLiveSeconds, int maxEntriesLocalHeap) {
    Configuration cfg = new Configuration();
    CacheConfiguration.CacheDecoratorFactoryConfiguration cdfc =
            new CacheConfiguration.CacheDecoratorFactoryConfiguration();
    cdfc.setClass(BlockingCacheDecoratorFactory.class.getName());
    CacheConfiguration defaultCacheCfg = new CacheConfiguration();
    defaultCacheCfg.addCacheDecoratorFactory(cdfc);
    defaultCacheCfg.setTimeToLiveSeconds(timeToLiveSeconds);
    defaultCacheCfg.setMaxEntriesLocalHeap(maxEntriesLocalHeap);
    cfg.addDefaultCache(defaultCacheCfg);

    manager = CacheManager.create(cfg);

}
 
开发者ID:telefonicaid,项目名称:fiware-keypass,代码行数:15,代码来源:BlockingCacheFactory.java

示例3: IbisCacheManager

import net.sf.ehcache.config.Configuration; //导入方法依赖的package包/类
private IbisCacheManager() {
	Configuration cacheManagerConfig = new Configuration();
	String cacheDir = AppConstants.getInstance().getResolvedProperty(CACHE_DIR_KEY);
	if (StringUtils.isNotEmpty(cacheDir)) {
		log.debug("setting cache directory to ["+cacheDir+"]");
		DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
		diskStoreConfiguration.setPath(cacheDir);
		cacheManagerConfig.addDiskStore(diskStoreConfiguration);
	} 
	CacheConfiguration defaultCacheConfig = new CacheConfiguration();
	cacheManagerConfig.addDefaultCache(defaultCacheConfig);
	cacheManager= new CacheManager(cacheManagerConfig);
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:14,代码来源:IbisCacheManager.java

示例4: init

import net.sf.ehcache.config.Configuration; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void init(String name) throws Exception {
    if ((directoryService != null) && directoryService.isStarted()) {
        return;
    }

    directoryService.setInstanceId(name);

    // instance layout
    InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name);
    if (instanceLayout.getInstanceDirectory().exists()) {
        try {
            FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory());
        } catch (IOException e) {
            LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e);
        }
    }
    directoryService.setInstanceLayout(instanceLayout);

    // EhCache in disabled-like-mode
    Configuration ehCacheConfig = new Configuration();
    CacheConfiguration defaultCache = new CacheConfiguration("default", 1).eternal(false).timeToIdleSeconds(30)
            .timeToLiveSeconds(30).overflowToDisk(false);
    ehCacheConfig.addDefaultCache(defaultCache);
    CacheService cacheService = new CacheService(new CacheManager(ehCacheConfig));
    directoryService.setCacheService(cacheService);

    // Init the schema
    // SchemaLoader loader = new SingleLdifSchemaLoader();
    SchemaLoader loader = new JarLdifSchemaLoader();
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    schemaManager.loadAllEnabled();
    ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry();
    for (LdapComparator<?> comparator : comparatorRegistry) {
        if (comparator instanceof NormalizingComparator) {
            ((NormalizingComparator) comparator).setOnServer();
        }
    }
    directoryService.setSchemaManager(schemaManager);
    InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager);

    SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
    schemaPartition.setWrappedPartition(inMemorySchemaPartition);
    directoryService.setSchemaPartition(schemaPartition);
    List<Throwable> errors = schemaManager.getErrors();
    if (errors.size() != 0) {
        throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
    }

    // Init system partition
    Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(),
            directoryService.getDnFactory(), "system", ServerDNConstants.SYSTEM_DN, 500,
            new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system"));
    systemPartition.setSchemaManager(directoryService.getSchemaManager());
    partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100);
    directoryService.setSystemPartition(systemPartition);

    directoryService.startup();
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:62,代码来源:InMemoryDirectoryServiceFactory.java

示例5: init

import net.sf.ehcache.config.Configuration; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "unused" })
public void init() {
	log.info("Loading ehcache");
	// log.debug("Appcontext: " + applicationContext.toString());
	try {
		// instance the manager
		CacheManager cm = CacheManager.getInstance();
		// Use the Configuration to create our caches
		Configuration configuration = new Configuration();
		//set initial default cache name
		String defaultCacheName = Cache.DEFAULT_CACHE_NAME;
		//add the configs to a configuration
		for (CacheConfiguration conf : configs) {
			//set disk expiry
			conf.setDiskExpiryThreadIntervalSeconds(diskExpiryThreadIntervalSeconds);
			//set eviction policy
			conf.setMemoryStoreEvictionPolicy(memoryStoreEvictionPolicy);
			if (null == cache) {
				//get first cache name and use as default
				defaultCacheName = conf.getName();
				configuration.addDefaultCache(conf);
			} else {
				configuration.addCache(conf);
			}
		}
		//instance the helper
		ConfigurationHelper helper = new ConfigurationHelper(cm, configuration);
		//create the default cache
		cache = helper.createDefaultCache();
		//init the default
		cache.initialise();
		cache.bootstrap();
		//create the un-init'd caches
		Set<Cache> caches = helper.createCaches();
		if (log.isDebugEnabled()) {
			log.debug("Number of caches: " + caches.size() + " Default cache: " + (cache != null ? 1 : 0));
		}
		for (Cache nonDefaultCache : caches) {
			nonDefaultCache.initialise();
			nonDefaultCache.bootstrap();
			//set first cache to be main local member
			if (null == nonDefaultCache) {
				log.debug("Default cache name: {}", defaultCacheName);
				nonDefaultCache = cm.getCache(defaultCacheName);
			}
		}
	} catch (Exception e) {
		log.warn("Error on cache init", e);
	}
	if (log.isDebugEnabled()) {
		log.debug("Cache is null? {}", (null == cache));
	}
}
 
开发者ID:Kyunghwa-Yoo,项目名称:StitchRTSP,代码行数:54,代码来源:EhCacheImpl.java

示例6: init

import net.sf.ehcache.config.Configuration; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void init(String name) throws Exception {
   if ((directoryService == null) || directoryService.isStarted()) {
      return;
   }

   directoryService.setInstanceId(name);

   // instance layout
   InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name);
   if (instanceLayout.getInstanceDirectory().exists()) {
      try {
         FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory());
      } catch (IOException e) {
         LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e);
      }
   }
   directoryService.setInstanceLayout(instanceLayout);

   // EhCache in disabled-like-mode
   Configuration ehCacheConfig = new Configuration();
   CacheConfiguration defaultCache = new CacheConfiguration("default", 1).eternal(false).timeToIdleSeconds(30).timeToLiveSeconds(30).overflowToDisk(false);
   ehCacheConfig.addDefaultCache(defaultCache);
   CacheService cacheService = new CacheService(new CacheManager(ehCacheConfig));
   directoryService.setCacheService(cacheService);

   // Init the schema
   // SchemaLoader loader = new SingleLdifSchemaLoader();
   SchemaLoader loader = new JarLdifSchemaLoader();
   SchemaManager schemaManager = new DefaultSchemaManager(loader);
   schemaManager.loadAllEnabled();
   ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry();
   for (LdapComparator<?> comparator : comparatorRegistry) {
      if (comparator instanceof NormalizingComparator) {
         ((NormalizingComparator) comparator).setOnServer();
      }
   }
   directoryService.setSchemaManager(schemaManager);
   InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager);

   SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
   schemaPartition.setWrappedPartition(inMemorySchemaPartition);
   directoryService.setSchemaPartition(schemaPartition);
   List<Throwable> errors = schemaManager.getErrors();
   if (errors.size() != 0) {
      throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
   }

   // Init system partition
   Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), directoryService.getDnFactory(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system"));
   systemPartition.setSchemaManager(directoryService.getSchemaManager());
   partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100);
   directoryService.setSystemPartition(systemPartition);

   directoryService.startup();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:60,代码来源:InMemoryDirectoryServiceFactory.java

示例7: init

import net.sf.ehcache.config.Configuration; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void init(String name) throws Exception {
    if ((directoryService != null) && directoryService.isStarted()) {
        return;
    }

    directoryService.setInstanceId(name);

    // instance layout
    InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name);
    if (instanceLayout.getInstanceDirectory().exists()) {
        try {
            FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory());
        } catch (IOException e) {
            LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e);
        }
    }
    directoryService.setInstanceLayout(instanceLayout);

    // EhCache in disabled-like-mode
    Configuration ehCacheConfig = new Configuration();
    CacheConfiguration defaultCache = new CacheConfiguration("ApacheDSTestCache", 1).eternal(false).timeToIdleSeconds(30)
            .timeToLiveSeconds(30).overflowToDisk(false);
    ehCacheConfig.addDefaultCache(defaultCache);
    cacheManager = new CacheManager(ehCacheConfig);
    CacheService cacheService = new CacheService(cacheManager);
    directoryService.setCacheService(cacheService);

    // Init the schema
    // SchemaLoader loader = new SingleLdifSchemaLoader();
    SchemaLoader loader = new JarLdifSchemaLoader();
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    schemaManager.loadAllEnabled();
    ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry();
    for (LdapComparator<?> comparator : comparatorRegistry) {
        if (comparator instanceof NormalizingComparator) {
            ((NormalizingComparator) comparator).setOnServer();
        }
    }
    directoryService.setSchemaManager(schemaManager);
    InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager);

    SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
    schemaPartition.setWrappedPartition(inMemorySchemaPartition);
    directoryService.setSchemaPartition(schemaPartition);
    List<Throwable> errors = schemaManager.getErrors();
    if (errors.size() != 0) {
        throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
    }

    // Init system partition
    Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), "system",
            ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(),
                    "system"));
    systemPartition.setSchemaManager(directoryService.getSchemaManager());
    partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100);
    directoryService.setSystemPartition(systemPartition);

    directoryService.startup();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:64,代码来源:InMemoryDirectoryServiceFactory.java

示例8: init

import net.sf.ehcache.config.Configuration; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "unused" })
public void init() {
    log.info("Loading ehcache");
    // log.debug("Appcontext: " + applicationContext.toString());
    try {
        // instance the manager
        CacheManager cm = CacheManager.getInstance();
        // Use the Configuration to create our caches
        Configuration configuration = new Configuration();
        //set initial default cache name
        String defaultCacheName = Cache.DEFAULT_CACHE_NAME;
        //add the configs to a configuration
        for (CacheConfiguration conf : configs) {
            //set disk expiry
            conf.setDiskExpiryThreadIntervalSeconds(diskExpiryThreadIntervalSeconds);
            //set eviction policy
            conf.setMemoryStoreEvictionPolicy(memoryStoreEvictionPolicy);
            if (null == cache) {
                //get first cache name and use as default
                defaultCacheName = conf.getName();
                configuration.addDefaultCache(conf);
            } else {
                configuration.addCache(conf);
            }
        }
        //instance the helper
        ConfigurationHelper helper = new ConfigurationHelper(cm, configuration);
        //create the default cache
        cache = helper.createDefaultCache();
        //init the default
        cache.initialise();
        cache.bootstrap();
        //create the un-init'd caches
        Set<Cache> caches = helper.createCaches();
        if (log.isDebugEnabled()) {
            log.debug("Number of caches: " + caches.size() + " Default cache: " + (cache != null ? 1 : 0));
        }
        for (Cache nonDefaultCache : caches) {
            nonDefaultCache.initialise();
            nonDefaultCache.bootstrap();
            //set first cache to be main local member
            if (null == nonDefaultCache) {
                log.debug("Default cache name: {}", defaultCacheName);
                nonDefaultCache = cm.getCache(defaultCacheName);
            }
        }
    } catch (Exception e) {
        log.warn("Error on cache init", e);
    }
    if (log.isDebugEnabled()) {
        log.debug("Cache is null? {}", (null == cache));
    }
}
 
开发者ID:Red5,项目名称:red5-io,代码行数:54,代码来源:EhCacheImpl.java


注:本文中的net.sf.ehcache.config.Configuration.addDefaultCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。