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


Java ConfigurationFactory类代码示例

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


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

示例1: testEHCacheCompatiblity

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
@Test
public void testEHCacheCompatiblity() throws Exception {
    // get the default cache manager
    CacheManagerFactory factory = new DefaultCacheManagerFactory();
    CacheManager manager = factory.getInstance();
    assertEquals(Status.STATUS_ALIVE, manager.getStatus());
    
    // create another unrelated cache manager
    Configuration conf = 
        ConfigurationFactory.parseConfiguration(DefaultCacheManagerFactory.class.getResource("/test-ehcache.xml"));
    assertNotNull(conf);
    conf.setName("otherCache");
    CacheManager other = CacheManager.create(conf);
    assertEquals(Status.STATUS_ALIVE, other.getStatus());
    
    // shutdown this unrelated cache manager 
    other.shutdown();
    assertEquals(Status.STATUS_SHUTDOWN, other.getStatus());
    
    // the default cache manager should be still running
    assertEquals(Status.STATUS_ALIVE, manager.getStatus());
    
    factory.doStop();
    // the default cache manger is shutdown
    assertEquals(Status.STATUS_SHUTDOWN, manager.getStatus());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:DefaultCacheManagerFactoryTest.java

示例2: testCreateCacheManagers

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
@Test
public void testCreateCacheManagers() throws Exception {
    // no arg
    assertNotNull("create with no arg", EHCacheUtil.createCacheManager());
    
    URL configURL = EHCacheUtil.class.getResource("/test-ehcache.xml");
    assertNotNull(configURL);
    
    // string
    assertNotNull("create with string", EHCacheUtil.createCacheManager(configURL.getPath()));
    
    // url
    assertNotNull("create with url", EHCacheUtil.createCacheManager(configURL));
    
    // inputstream
    assertNotNull("create with inputstream", EHCacheUtil.createCacheManager(configURL.openStream()));
    
    // config
    Configuration conf = ConfigurationFactory.parseConfiguration(configURL);
    assertNotNull(conf);
    assertNotNull("create with configuration", EHCacheUtil.createCacheManager(conf));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:EHCacheUtilTest.java

示例3: createTestCacheManager

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
/**
 * Creates a unique cache manager.
 *
 * @param uniqueName  the unique name, typically a test case class name
 * @return the unique cache manager, not null
 */
public static CacheManager createTestCacheManager(String uniqueName) {
  ArgumentChecker.notNull(uniqueName, "uniqueName");
  if (UNIQUE_TEST_NAMES.putIfAbsent(uniqueName, uniqueName) != null) {
    throw new OpenGammaRuntimeException("CacheManager has already been created with unique name: " + uniqueName);
  }
  try {
    InputStream configStream = getTestEhCacheConfig();
    Configuration config = ConfigurationFactory.parseConfiguration(configStream);
    config.setName(uniqueName);
    config.setUpdateCheck(false);
    return CacheManager.newInstance(config);
  } catch (CacheException ex) {
    throw new OpenGammaRuntimeException("Unable to create CacheManager", ex);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:EHCacheUtils.java

示例4: getEhCacheConfig

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
private static synchronized Configuration getEhCacheConfig() {
  String ehcacheConfigFile = DEFAULT_EHCACHE_CONFIG_FILE;
  String overrideEhcacheConfigFile = System.getProperty("ehcache.config"); // passed in by Ant
  if (overrideEhcacheConfigFile != null) {
    ehcacheConfigFile = overrideEhcacheConfigFile;
    System.err.println("Using ehcache.config from system property: " + ehcacheConfigFile);
  } else {
    System.err.println("Using default ehcache.config file name: " + ehcacheConfigFile);
  }
  try (InputStream resource = EHCacheUtils.class.getResourceAsStream(ehcacheConfigFile)) {
    Configuration config = ConfigurationFactory.parseConfiguration(resource);
    config.setUpdateCheck(false);
    return config;
  } catch (IOException ex) {
    throw new OpenGammaRuntimeException("Unable to read ehcache file", ex);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:18,代码来源:EHCacheUtils.java

示例5: afterPropertiesSet

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
public void afterPropertiesSet() throws IOException, CacheException {
	log.info("Initializing EHCache CacheManager");
	Configuration config = null;
	if (this.configLocation != null) {
		config = ConfigurationFactory
				.parseConfiguration(this.configLocation.getInputStream());
		if (this.diskStoreLocation != null) {
			DiskStoreConfiguration dc = new DiskStoreConfiguration();
			dc.setPath(this.diskStoreLocation.getFile().getAbsolutePath());
			try {
				config.addDiskStore(dc);
			} catch (ObjectExistsException e) {
				log.warn("if you want to config distStore in spring,"
						+ " please remove diskStore in config file!", e);
			}
		}
	}
	if (config != null) {
		this.cacheManager = new CacheManager(config);
	} else {
		this.cacheManager = new CacheManager();
	}
	if (this.cacheManagerName != null) {
		this.cacheManager.setName(this.cacheManagerName);
	}
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:27,代码来源:WebEhCacheManagerFacotryBean.java

示例6: init

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
/**
 * Itializes the service by creating a manager object with a given configuration file.
 */
private void init( )
{
    Configuration configuration = ConfigurationFactory.parseConfiguration( );
    configuration.setName( LUTECE_CACHEMANAGER_NAME );
    _manager = CacheManager.create( configuration );
    loadDefaults( );
    loadCachesConfig( );

    boolean bJmxMonitoring = AppPropertiesService.getProperty( PROPERTY_JMX_MONITORING, FALSE ).equals( TRUE );

    if ( bJmxMonitoring )
    {
        initJmxMonitoring( );
    }
}
 
开发者ID:lutece-platform,项目名称:lutece-core,代码行数:19,代码来源:CacheService.java

示例7: afterPropertiesSet

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
    Configuration configuration = ConfigurationFactory.parseConfiguration();

    // Override configuration to make sure cache is stored in Airsonic home dir.
    File cacheDir = new File(SettingsService.getAirsonicHome(), "cache");
    configuration.getDiskStoreConfiguration().setPath(cacheDir.getPath());

    cacheManager = CacheManager.create(configuration);
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:10,代码来源:CacheFactory.java

示例8: afterPropertiesSet

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws CacheException {
	logger.info("Initializing EhCache CacheManager");
	Configuration configuration = (this.configLocation != null ?
			EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration());
	if (this.cacheManagerName != null) {
		configuration.setName(this.cacheManagerName);
	}
	if (this.shared) {
		// Old-school EhCache singleton sharing...
		// No way to find out whether we actually created a new CacheManager
		// or just received an existing singleton reference.
		this.cacheManager = CacheManager.create(configuration);
	}
	else if (this.acceptExisting) {
		// EhCache 2.5+: Reusing an existing CacheManager of the same name.
		// Basically the same code as in CacheManager.getInstance(String),
		// just storing whether we're dealing with an existing instance.
		synchronized (CacheManager.class) {
			this.cacheManager = CacheManager.getCacheManager(this.cacheManagerName);
			if (this.cacheManager == null) {
				this.cacheManager = new CacheManager(configuration);
			}
			else {
				this.locallyManaged = false;
			}
		}
	}
	else {
		// Throwing an exception if a CacheManager of the same name exists already...
		this.cacheManager = new CacheManager(configuration);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:34,代码来源:EhCacheManagerFactoryBean.java

示例9: IndexedCollectionAdapter

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
public IndexedCollectionAdapter(BananaRama parent){
    //This must be configurable in the future
    final Configuration conf = ConfigurationFactory
            .parseConfiguration();
    
    conf.getDefaultCacheConfiguration()
            .getPersistenceConfiguration()
            .strategy(PersistenceConfiguration.Strategy.NONE);
    
    cacheManager =  CacheManager.newInstance(conf);
    cache = cacheManager.addCacheIfAbsent(CACHE_NAME);
    this.parent = parent;
}
 
开发者ID:cr0wbar,项目名称:Bananarama,代码行数:14,代码来源:IndexedCollectionAdapter.java

示例10: afterPropertiesSet

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
    Configuration configuration = ConfigurationFactory.parseConfiguration();

    // Override configuration to make sure cache is stored in Subsonic home dir.
    File cacheDir = new File(SettingsService.getSubsonicHome(), "cache");
    configuration.getDiskStoreConfiguration().setPath(cacheDir.getPath());

    cacheManager = CacheManager.create(configuration);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:10,代码来源:CacheFactory.java

示例11: getConfiguration

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Configuration getConfiguration(Properties properties) throws CacheException {
    Configuration config = ConfigurationFactory.parseConfiguration(resolveEhcacheConfigFile());
    postProcessConfiguration(config, properties);
    return config;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:10,代码来源:DefaultEhCacheConfigurer.java

示例12: produce

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
@Produces @Singleton
public CacheManager produce(Configuration configuration) {
	InputStream cacheConfigurationStream = EhServiceCacheManager.class.getResourceAsStream("cache.xml");
	
	net.sf.ehcache.config.Configuration cacheConfiguration = ConfigurationFactory.parseConfiguration(cacheConfigurationStream);
	
	String cacheLocation = configuration.getCacheLocation();
	if (cacheLocation!=null && !cacheLocation.isEmpty()) {
		log.info("Setting cache location to {}", cacheLocation);
		cacheConfiguration.getDiskStoreConfiguration().setPath(cacheLocation);
	} else log.trace("cache location {}", cacheConfiguration.getDiskStoreConfiguration().getPath());
	
	return CacheManager.newInstance(cacheConfiguration);
}
 
开发者ID:openfigis,项目名称:sharks,代码行数:15,代码来源:EhCacheManagerProducer.java

示例13: initializeEhcacheDiskStore

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
private void initializeEhcacheDiskStore(Environment environment) {
    DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
    diskStoreConfiguration.setPath(environment.getProperty(HmpProperties.EHCACHE_DATA_DIR));

    Configuration configuration = ConfigurationFactory.parseConfiguration();
    configuration.addDiskStore(diskStoreConfiguration);

    CacheManager.newInstance(configuration);
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:10,代码来源:Bootstrap.java

示例14: afterPropertiesSet

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
    Configuration configuration = ConfigurationFactory.parseConfiguration();

    // Override configuration to make sure cache is stored in Madsonic home dir.
    File cacheDir = new File(SettingsService.getMadsonicHome(), "cache");
    configuration.getDiskStoreConfiguration().setPath(cacheDir.getPath());

    cacheManager = CacheManager.create(configuration);
}
 
开发者ID:MadMarty,项目名称:madsonic-server-5.1,代码行数:10,代码来源:CacheFactory.java

示例15: afterPropertiesSet

import net.sf.ehcache.config.ConfigurationFactory; //导入依赖的package包/类
public void afterPropertiesSet() throws IOException, CacheException {
	logger.info("Initializing EhCache CacheManager");
	InputStream is = (this.configLocation != null ? this.configLocation.getInputStream() : null);
	try {
		// A bit convoluted for EhCache 1.x/2.0 compatibility.
		// To be much simpler once we require EhCache 2.1+
		if (this.cacheManagerName != null) {
			if (this.shared && createWithConfiguration == null) {
				// No CacheManager.create(Configuration) method available before EhCache 2.1;
				// can only set CacheManager name after creation.
				this.cacheManager = (is != null ? CacheManager.create(is) : CacheManager.create());
				this.cacheManager.setName(this.cacheManagerName);
			}
			else {
				Configuration configuration = (is != null ? ConfigurationFactory.parseConfiguration(is) :
						ConfigurationFactory.parseConfiguration());
				configuration.setName(this.cacheManagerName);
				if (this.shared) {
					this.cacheManager = (CacheManager) ReflectionUtils.invokeMethod(createWithConfiguration, null, configuration);
				}
				else {
					this.cacheManager = new CacheManager(configuration);
				}
			}
		}
		// For strict backwards compatibility: use simplest possible constructors...
		else if (this.shared) {
			this.cacheManager = (is != null ? CacheManager.create(is) : CacheManager.create());
		}
		else {
			this.cacheManager = (is != null ? new CacheManager(is) : new CacheManager());
		}
	}
	finally {
		if (is != null) {
			is.close();
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:40,代码来源:EhCacheManagerFactoryBean.java


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