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


Java Configuration.setName方法代碼示例

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


在下文中一共展示了Configuration.setName方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: 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

示例4: afterPropertiesSet

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void afterPropertiesSet() throws Exception {
    Cache.ID = key + "." + Dates.newDateStringOfFormatDateTimeSSSNoneSpace();
    Cache.HOST = Utils.getLocalHostIP();
    Cache.CACHE_STORE = key + spliter + "cache" + spliter + "store";
    Cache.CACHE_STORE_SYNC = Cache.CACHE_STORE + spliter + "sync";
    if (this.localEnabled) {
        Configuration configuration = new Configuration();
        configuration.setName(Cache.ID);
        configuration.setMaxBytesLocalHeap(localMaxBytesLocalHeap);
        configuration.setMaxBytesLocalDisk(localMaxBytesLocalDisk);
        // DiskStore
        // 每次啟動設置新的文件地址,以避免重啟期間一級緩存未同步,以及單機多應用啟動造成EhcacheManager重複的問題.
        DiskStoreConfiguration dsc = new DiskStoreConfiguration();
        dsc.setPath(localStoreLocation + Cache.ID);
        configuration.diskStore(dsc);
        // DefaultCache
        CacheConfiguration defaultCacheConfiguration = new CacheConfiguration();
        defaultCacheConfiguration.setEternal(false);
        defaultCacheConfiguration.setOverflowToDisk(true);
        defaultCacheConfiguration.setDiskPersistent(false);
        defaultCacheConfiguration.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU);
        defaultCacheConfiguration.setDiskExpiryThreadIntervalSeconds(localDiskExpiryThreadIntervalSeconds);
        // 默認false,使用引用.設置為true,避免外部代碼修改了緩存對象.造成EhCache的緩存對象也隨之改變
        // 但是設置為true後,將引起element的tti不自動刷新.如果直接新建element去覆蓋原值.則本地ttl和遠程ttl會產生一定的誤差.
        // 因此,使用時放棄手動覆蓋方式刷新本地tti,當本地tti過期後,自動從Redis中再獲取即可.
        defaultCacheConfiguration.copyOnRead(true);
        defaultCacheConfiguration.copyOnWrite(true);
        defaultCacheConfiguration.setTimeToIdleSeconds(localTimeToIdleSeconds);
        defaultCacheConfiguration.setTimeToLiveSeconds(localTimeToLiveSeconds);
        configuration.setDefaultCacheConfiguration(defaultCacheConfiguration);
        configuration.setDynamicConfig(false);
        configuration.setUpdateCheck(false);
        this.cacheManager = new CacheManager(configuration);
        this.cacheSync = new RedisPubSubSync(this);// 使用Redis Topic發送訂閱緩存變更消息
    }
}
 
開發者ID:yrain,項目名稱:smart-cache,代碼行數:39,代碼來源:CacheTemplate.java

示例5: load

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
public static void load() {

        Configuration config = new Configuration();
        config.setName("stallionFilterCache");
        CacheManager.create(config);
        manager = CacheManager.create();
    }
 
開發者ID:StallionCMS,項目名稱:stallion-core,代碼行數:8,代碼來源:FilterCache.java

示例6: afterPropertiesSet

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

示例7: CacheQueue

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
/**
 * 構造函數
 * 
 * @param block
 *            --是否為阻塞隊列,true是阻塞隊列,false是非阻塞隊列
 * @param cacheLength
 *            --內存中隊列長度,值>0;
 * @param persistDirPath
 *            --數據落地目錄(<b>注意:一個隊列對應一個目錄路徑,多個隊列共享一個目錄路徑,是不允許的,會出現數據不一致的情況! <
 *            /b>)
 */
public CacheQueue(final boolean block, final int cacheLength,
		final String persistDirPath) {
	if (cacheLength < 0) {
		throw new AppRuntimeException("cacheLength must >0!");
	}
	if (block) {
		this.tmpQueue = new BlockQueue();
	} else {
		this.tmpQueue = new NoBlockConcurrentQueue();
	}
	psKeys = new ConcurrentLinkedQueue<Long>();
	hcName = "cq-" + persistDirPath.hashCode();
	Configuration managerConfig = new Configuration();
	CacheConfiguration mqCf = new CacheConfiguration(hcName, cacheLength);
	mqCf.setEternal(true);
	// mqCf.setDiskStorePath(persistDirPath);
	mqCf.setMaxElementsOnDisk(0);
	mqCf.setTransactionalMode("OFF");
	mqCf.setMemoryStoreEvictionPolicy("LFU");
	// mqCf.setDiskPersistent(true);
	// mqCf.setMaxElementsInMemory(cacheLength);
	mqCf.setMaxEntriesLocalHeap(cacheLength);
	// mqCf.setOverflowToDisk(true);
	mqCf.persistence(new PersistenceConfiguration()
			.strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP));
	managerConfig.addCache(mqCf);
	DiskStoreConfiguration dsCf = new DiskStoreConfiguration();
	dsCf.setPath(persistDirPath);
	managerConfig.addDiskStore(dsCf);
	managerConfig.setName(hcName);
	// cacheManager = new CacheManager(managerConfig);
	cacheManager = CacheManager.newInstance(managerConfig);
	cache = cacheManager.getCache(hcName);
	count = new AtomicLong(0);
}
 
開發者ID:jbeetle,項目名稱:BJAF3.x,代碼行數:47,代碼來源:CacheQueue.java

示例8: afterPropertiesSet

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

示例9: provideCacheManager

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
@Provides
@Singleton
CacheManager provideCacheManager() {
    Configuration configuration = new Configuration();
    configuration.setName("GDACEhCacheManager");
    return CacheManager.create(configuration);
}
 
開發者ID:bmwcarit,項目名稱:joynr,代碼行數:8,代碼來源:GlobalDomainAccessControllerModule.java

示例10: provideCacheManager

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
@Provides
@Singleton
public CacheManager provideCacheManager() {
    Configuration configuration = new Configuration();
    configuration.setName("LDACEhCacheManager");
    configuration.setUpdateCheck(false);
    return CacheManager.create(configuration);
}
 
開發者ID:bmwcarit,項目名稱:joynr,代碼行數:9,代碼來源:AccessControlClientModule.java

示例11: afterPropertiesSet

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
@Override
public void afterPropertiesSet() throws IOException, CacheException {
	logger.info("Initializing EhCache CacheManager");
	InputStream is = (this.configLocation != null ? this.configLocation.getInputStream() : null);
	try {
		Configuration configuration = (is != null ?
				ConfigurationFactory.parseConfiguration(is) : 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);
		}
	}
	finally {
		if (is != null) {
			is.close();
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:42,代碼來源:EhCacheManagerFactoryBean.java

示例12: load

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
public static void load() {

        Configuration config = new Configuration();
        config.setName("stallionLocalMemoryCache");
        manager = CacheManager.create();
    }
 
開發者ID:StallionCMS,項目名稱:stallion-core,代碼行數:7,代碼來源:LocalMemoryCache.java

示例13: init

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
@PostConstruct
@SuppressWarnings("unused")
private void init() throws Exception {

    // Init Cache
    Configuration c = new Configuration();
    c.setName("sessionManager");
    manager = CacheManager.create(c);
    CacheConfiguration config = new CacheConfiguration();
    config.eternal(false).name(CACHE_NAME).maxEntriesLocalHeap(maxEntries).memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU).timeToIdleSeconds(timeToIdle).timeToLiveSeconds(timeToLive);
    if (!manager.cacheExists(CACHE_NAME)) {
        manager.addCache(new Cache(config));
    }
    sessions = manager.getCache(CACHE_NAME);

    // Init JMS replication
    ConnectionFactory factory = new ActiveMQConnectionFactory(this.url);
    Connection conn = factory.createConnection();
    conn.start();
    jmsSession = (TopicSession) conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    final Topic topic = jmsSession.createTopic(TOPIC_NAME);
    tp = jmsSession.createPublisher(topic);

    listener = new Thread() { // Thread created once upon container startup
        @Override
        public void run() {
            try {
                MessageConsumer consumer = jmsSession.createConsumer(topic);
                while (live) {

                    ObjectMessage msg = (ObjectMessage) consumer.receive();

                    LOG.debug("Received replication message: {}", msg);

                    if (PUT.equals(msg.getStringProperty(ACTION_KEY))) {
                        sessions.put(new Element(msg.getStringProperty(TOKEN_KEY), msg.getObject()));
                    } else if (REMOVE.equals(msg.getStringProperty(ACTION_KEY))) {
                        sessions.remove(msg.getStringProperty(TOKEN_KEY));
                    }

                }
            } catch (JMSException e) {
                LOG.error("Error reading replication message", e);
            }
        }
    };

    listener.start();
}
 
開發者ID:inbloom,項目名稱:secure-data-service,代碼行數:50,代碼來源:SessionCache.java

示例14: buildCacheManager

import net.sf.ehcache.config.Configuration; //導入方法依賴的package包/類
/**
 * Build an EhCache {@link CacheManager} from the default configuration.
 * <p>The CacheManager will be configured from "ehcache.xml" in the root of the class path
 * (that is, default EhCache initialization - as defined in the EhCache docs - will apply).
 * If no configuration file can be found, a fail-safe fallback configuration will be used.
 * @param name the desired name of the cache manager
 * @return the new EhCache CacheManager
 * @throws CacheException in case of configuration parsing failure
 */
public static CacheManager buildCacheManager(String name) throws CacheException {
	Configuration configuration = ConfigurationFactory.parseConfiguration();
	configuration.setName(name);
	return new CacheManager(configuration);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:15,代碼來源:EhCacheManagerUtils.java


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