當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。