⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treecachepool.java

📁 羽量级数据持久层开发框架
💻 JAVA
字号:
package org.speedframework.cache;

import org.jboss.cache.TreeCache;
import org.speedframework.exception.SpeedFrameworkException;

/**
 * JBoss Cache Pool
 * 
 * @author lizf
 * 
 */
public class TreeCachePool implements CachePool {

	/**
	 * 
	 */
	private static final String SPEED_CACHE = "CACHE";

	private static TreeCache cache = null;

	public TreeCachePool() {
		try {
			if (cache == null) {
				cache = new TreeCache();
				cache.setClusterProperties("treecache.xml");
				cache.createService();
				cache.startService();
			}
		} catch (Exception e) {
			// TODO 自动生成 catch 块
			throw new SpeedFrameworkException(e);
		}

	}

	public synchronized void put(Object name, Object value)
			throws SpeedFrameworkException {
		try {
			cache.put(SPEED_CACHE, name, value);
		} catch (org.jboss.cache.CacheException e) {
			throw new SpeedFrameworkException(e);
		}
	}

	public synchronized Object get(Object name) throws SpeedFrameworkException {
		Object value = null;
		try {
			value = cache.get(SPEED_CACHE, name);
		} catch (org.jboss.cache.CacheException e) {
			// throw new CacheException(e);
			throw new SpeedFrameworkException(e);
		}
		return value;

	}

	public String getStats() {
		// return ( (TreeCache) cachePool.get(key))
		return null;
	}

	public void dispose() {
		cache.destroy();
	}

	public synchronized void remove(Object name) throws SpeedFrameworkException {
		try {
			cache.remove(SPEED_CACHE, name);
		} catch (org.jboss.cache.CacheException e) {
			throw new SpeedFrameworkException(e);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -