本文整理汇总了Java中net.sf.ehcache.config.ConfigurationFactory.parseConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationFactory.parseConfiguration方法的具体用法?Java ConfigurationFactory.parseConfiguration怎么用?Java ConfigurationFactory.parseConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.ehcache.config.ConfigurationFactory
的用法示例。
在下文中一共展示了ConfigurationFactory.parseConfiguration方法的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());
}
示例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));
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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( );
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
}