當前位置: 首頁>>代碼示例>>Java>>正文


Java Configuration類代碼示例

本文整理匯總了Java中net.sf.ehcache.config.Configuration的典型用法代碼示例。如果您正苦於以下問題:Java Configuration類的具體用法?Java Configuration怎麽用?Java Configuration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Configuration類屬於net.sf.ehcache.config包,在下文中一共展示了Configuration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testEHCacheCompatiblity

import net.sf.ehcache.config.Configuration; //導入依賴的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: ServletCache

import net.sf.ehcache.config.Configuration; //導入依賴的package包/類
private ServletCache(String name, int type) {
	this.type = type;
	Configuration managerConfig = new Configuration();
	CacheConfiguration mqCf = new CacheConfiguration(name, CacheConfig
			.getConfig().getMaxElementsInMemory());
	mqCf.setEternal(true);
	DiskStoreConfiguration dsCf = new DiskStoreConfiguration();
	dsCf.setPath(CacheConfig.getConfig().getDiskStorePath());
	managerConfig.addDiskStore(dsCf);
	mqCf.setMaxElementsOnDisk(0);
	mqCf.setMaxEntriesLocalHeap(CacheConfig.getConfig()
			.getMaxElementsInMemory());
	mqCf.persistence(new PersistenceConfiguration()
			.strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP));
	mqCf.setTransactionalMode("OFF");
	mqCf.setMemoryStoreEvictionPolicy(CacheConfig.getConfig()
			.getMemoryStoreEvictionPolicy());
	managerConfig.addCache(mqCf);
	cacheManager = new CacheManager(managerConfig);
	cache = cacheManager.getCache(name);
}
 
開發者ID:jbeetle,項目名稱:BJAF3.x,代碼行數:22,代碼來源:ServletCache.java

示例3: internalCreateCacheManager

import net.sf.ehcache.config.Configuration; //導入依賴的package包/類
/**
 * Actual creation of the singleton.
 *
 * @param config
 *            the parsed EhCache configuration
 * @return the cache manager
 * @throws CacheException
 *             in case the creation failed
 */
private static synchronized CacheManager internalCreateCacheManager(Configuration config)
        throws CacheException {
    if (SINGLETON != null) {
        extendEhCacheWithCustomConfig(SINGLETON, config);
    } else {
        // for better control over the files created by the application override the diskstore
        // path
        // for flushing cached data to disk
        overrideDiskStorePath(config);
        // disable the update check
        config.setUpdateCheck(false);
        SINGLETON = new CacheManager(config);
    }
    return SINGLETON;
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:25,代碼來源:SingletonEhCacheManagerFactory.java

示例4: getInstance

import net.sf.ehcache.config.Configuration; //導入依賴的package包/類
public synchronized CacheManager getInstance() {
    if (cacheManager == null) {
        cacheManager = createCacheManagerInstance();

        // always turn off ET phone-home
        LOG.debug("Turning off EHCache update checker ...");
        Configuration config = cacheManager.getConfiguration();
        try {
            // need to set both the system property and bypass the setUpdateCheck method as that can be changed dynamically
            System.setProperty("net.sf.ehcache.skipUpdateCheck", "true");
            ReflectionHelper.setField(config.getClass().getDeclaredField("updateCheck"), config, false);

            LOG.info("Turned off EHCache update checker. updateCheck={}", config.getUpdateCheck());
        } catch (Throwable e) {
            // ignore
            LOG.warn("Error turning off EHCache update checker. Beware information sent over the internet!", e);
        }
    }

    return cacheManager;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:22,代碼來源:CacheManagerFactory.java

示例5: testCreateCacheManagers

import net.sf.ehcache.config.Configuration; //導入依賴的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

示例6: createTestCacheManager

import net.sf.ehcache.config.Configuration; //導入依賴的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

示例7: getEhCacheConfig

import net.sf.ehcache.config.Configuration; //導入依賴的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

示例8: setupCacheSource

import net.sf.ehcache.config.Configuration; //導入依賴的package包/類
private void setupCacheSource(final boolean lazyReads, final int cacheSize, final int flushDelay) {
  InMemoryViewComputationCacheSource cache = new InMemoryViewComputationCacheSource(s_fudgeContext);
  ViewComputationCacheServer server = new ViewComputationCacheServer(cache);
  _serverSocket = new ServerSocketFudgeConnectionReceiver(cache.getFudgeContext(), server, Executors
      .newCachedThreadPool());
  _serverSocket.setLazyFudgeMsgReads(lazyReads);
  _serverSocket.start();
  _socket = new SocketFudgeConnection(cache.getFudgeContext());
  _socket.setFlushDelay(flushDelay);
  try {
    _socket.setInetAddress(InetAddress.getLocalHost());
  } catch (UnknownHostException e) {
    throw new OpenGammaRuntimeException("", e);
  }
  _socket.setPortNumber(_serverSocket.getPortNumber());

  RemoteCacheClient client = new RemoteCacheClient(_socket);
  Configuration configuration = new Configuration();
  CacheConfiguration cacheConfig = new CacheConfiguration();
  cacheConfig.setMaxElementsInMemory(cacheSize);
  configuration.setDefaultCacheConfiguration(cacheConfig);
  _cacheSource = new RemoteViewComputationCacheSource(client, new DefaultFudgeMessageStoreFactory(
      new InMemoryBinaryDataStoreFactory(), s_fudgeContext), _cacheManager);
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:25,代碼來源:ServerSocketRemoteViewComputationCacheTest.java

示例9: getCacheManager

import net.sf.ehcache.config.Configuration; //導入依賴的package包/類
private CacheManager getCacheManager() {
	if (manager == null) {
		Configuration config = new Configuration();
		CacheConfiguration cacheconfig = new CacheConfiguration(getName(), maxElementsInMemory);
		cacheconfig.setDiskExpiryThreadIntervalSeconds(diskExpiryThreadIntervalSeconds);
		cacheconfig.setDiskPersistent(diskPersistent);
		cacheconfig.setEternal(eternal);
		cacheconfig.setMaxElementsOnDisk(maxElementsOnDisk);
		cacheconfig.setMemoryStoreEvictionPolicyFromObject(memoryStoreEvictionPolicy);
		cacheconfig.setOverflowToDisk(overflowToDisk);
		cacheconfig.setTimeToIdleSeconds(timeToIdleSeconds);
		cacheconfig.setTimeToLiveSeconds(timeToLiveSeconds);

		DiskStoreConfiguration diskStoreConfigurationParameter = new DiskStoreConfiguration();
		diskStoreConfigurationParameter.setPath(getPath().getAbsolutePath());
		config.addDiskStore(diskStoreConfigurationParameter);
		config.setDefaultCacheConfiguration(cacheconfig);
		manager = new CacheManager(config);
	}
	return manager;
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:22,代碼來源:EhcacheMap.java

示例10: main

import net.sf.ehcache.config.Configuration; //導入依賴的package包/類
public static void main(String[] args) throws IllegalAccessException {
    CacheManager manager = CacheManager.create();
    Configuration configuration = manager.getConfiguration();
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    Object object= poolConfig;
    Field[] fields = object.getClass().getDeclaredFields();
    String prefix="cache.ehcache.";
    for(Field field:fields){
       field.setAccessible(true);
        Method method = getSetMethod(object.getClass(),field);
        if(method!=null&& CacheConfig.checkIsBasicType(field.getType())){
            System.out.println("#默認值"+field.get(object));
            System.out.println(prefix+field.getName());
        }
    }
}
 
開發者ID:dubboclub,項目名稱:dubbo-plus,代碼行數:17,代碼來源:GenerateEhCacheDefaultConfig.java

示例11: afterPropertiesSet

import net.sf.ehcache.config.Configuration; //導入依賴的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

示例12: getProperties

import net.sf.ehcache.config.Configuration; //導入依賴的package包/類
@Override
public Properties getProperties() {
    Configuration ec = cacheManager.getConfiguration();
    Properties p = new Properties();
    p.put("name", ec.getName());
    p.put("source", ec.getConfigurationSource().toString());
    p.put("timeoutSeconds", ec.getDefaultTransactionTimeoutInSeconds());
    p.put("maxBytesDisk", ec.getMaxBytesLocalDisk());
    p.put("maxBytesHeap", ec.getMaxBytesLocalHeap());
    p.put("maxDepth", ec.getSizeOfPolicyConfiguration().getMaxDepth());
    p.put("defaultCacheMaxEntries", ec.getDefaultCacheConfiguration().getMaxEntriesLocalHeap());
    p.put("defaultCacheTimeToIdleSecs", ec.getDefaultCacheConfiguration().getTimeToIdleSeconds());
    p.put("defaultCacheTimeToLiveSecs", ec.getDefaultCacheConfiguration().getTimeToLiveSeconds());
    p.put("defaultCacheEternal", ec.getDefaultCacheConfiguration().isEternal());
    return p;
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:17,代碼來源:EhcacheMemoryService.java

示例13: init

import net.sf.ehcache.config.Configuration; //導入依賴的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

示例14: BigMemoryGoStore

import net.sf.ehcache.config.Configuration; //導入依賴的package包/類
public BigMemoryGoStore() {
    Configuration managerConfiguration = new Configuration()
            .name("benchmark")
            .cache(new CacheConfiguration()
                    .name("store")
                    .maxBytesLocalHeap(50, MemoryUnit.MEGABYTES)
                    .maxBytesLocalOffHeap(500, MemoryUnit.MEGABYTES)
                    .eternal(true)
            );

    cacheManager = CacheManager.create(managerConfiguration);
    cache = cacheManager.getCache("store");

    // get notified when cache is not big enough
    CacheEventListener evictionListener = new CacheEventListenerAdapter() {
        @Override
        public void notifyElementEvicted(Ehcache ehcache, Element element) {
            cacheFull = true;
        }
    };
    cache.getCacheEventNotificationService().registerListener(evictionListener);
}
 
開發者ID:bgranvea,項目名稱:offheapstore-benchmark,代碼行數:23,代碼來源:BigMemoryGoStore.java

示例15: getInjector

import net.sf.ehcache.config.Configuration; //導入依賴的package包/類
private Injector getInjector(Properties customProperties) {
    Injector injector = Guice.createInjector(new JoynrPropertiesModule(customProperties), new AbstractModule() {

        @Override
        protected void configure() {
            bind(DomainAccessControlProvisioning.class).to(StaticDomainAccessControlProvisioning.class);
            bind(DomainAccessControlStore.class).to(DomainAccessControlStoreEhCache.class);
        }

        @Provides
        CacheManager provideCacheManager() {
            Configuration configuration = new Configuration();
            configuration.setName("GDACEhCacheManager");
            return CacheManager.create(configuration);
        }
    });
    return injector;
}
 
開發者ID:bmwcarit,項目名稱:joynr,代碼行數:19,代碼來源:ProvisionedDomainAccessControlStoreTest.java


注:本文中的net.sf.ehcache.config.Configuration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。