package com.ibatis.sqlmap.engine.cache;
import java.net.URL;
import java.util.Properties;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
import com.ibatis.sqlmap.engine.cache.CacheController;
import com.ibatis.sqlmap.engine.cache.CacheModel;
public class EhCacheController implements CacheController {
/** The EhCache CacheManager. */
private CacheManager cacheManager;
/**
* Flush a cache model.
*
* @param cacheModel
* - the model to flush.
*/
public void flush(CacheModel cacheModel) {
getCache(cacheModel).removeAll();
}
/**
* Get an object from a cache model.
*
* @param cacheModel
* - the model.
* @param key
* - the key to the object.
* @return the object if in the cache, or null(?).
*/
public Object getObject(CacheModel cacheModel, Object key) {
Object result = null;
Element element = getCache(cacheModel).get(key);
if (element != null) {
result = element.getObjectValue();
}
return result;
}
/**
* Put an object into a cache model.
*
* @param cacheModel
* - the model to add the object to.
* @param key
* - the key to the object.
* @param object
* - the object to add.
*/
public void putObject(CacheModel cacheModel, Object key, Object object) {
getCache(cacheModel).put(new Element(key, object));
}
/**
* Remove an object from a cache model.
*
* @param cacheModel
* - the model to remove the object from.
* @param key
* - the key to the object.
* @return the removed object(?).
*/
public Object removeObject(CacheModel cacheModel, Object key) {
Object result = this.getObject(cacheModel, key);
getCache(cacheModel).remove(key);
return result;
}
/**
* Configure a cache controller. Initialize the EH Cache Manager as a
* singleton.
*
* @param props
* - the properties object continaing configuration information.
*/
public void setProperties(Properties props) {
URL url = getClass().getResource(props.getProperty("configFile"));
cacheManager = CacheManager.create(url);
}
/**
* Gets an EH Cache based on an iBatis cache Model.
*
* @param cacheModel
* - the cache model.
* @return the EH Cache.
*/
private Cache getCache(CacheModel cacheModel) {
String cacheName = cacheModel.getId();
Cache cache = cacheManager.getCache(cacheName);
return cache;
}
/**
* Shut down the EH Cache CacheManager.
*/
public void finalize() {
if (cacheManager != null) {
cacheManager.shutdown();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
spring+ibatis+ehcache整合例子
共47个文件
jar:15个
xml:10个
java:7个
5星 · 超过95%的资源 需积分: 10 274 下载量 8 浏览量
2011-04-28
11:59:07
上传
评论 2
收藏 6.35MB RAR 举报
温馨提示
spring+ibatis+ehcache整合完整例子,数据库MySQL
资源推荐
资源详情
资源评论
收起资源包目录
IbatisTest.rar (47个子文件)
IbatisTest
.project 386B
bin
log4j.properties 3KB
junitTest
SimpleExample.class 3KB
AccountServiceImplTest.class 3KB
com
ibatis
dao
BaseDao.class 321B
sqlmap
engine
cache
EhCacheController.class 3KB
domain
Account.class 2KB
Account.xml 2KB
Account-bak.xml 2KB
service
AccountService.class 510B
impl
AccountServiceImpl.class 2KB
SqlMapConfig.xml 917B
jdbc.properties 143B
ehcache.xml 729B
beans.xml 2KB
.settings
org.eclipse.core.resources.prefs 126B
org.eclipse.jdt.core.prefs 629B
src
log4j.properties 3KB
junitTest
SimpleExample.java 2KB
AccountServiceImplTest.java 2KB
com
ibatis
dao
BaseDao.java 170B
sqlmap
engine
cache
EhCacheController.java 3KB
domain
Account.xml 2KB
Account-bak.xml 2KB
Account.java 895B
service
AccountService.java 490B
impl
AccountServiceImpl.java 1KB
SqlMapConfig.xml 917B
jdbc.properties 143B
ehcache.xml 729B
beans.xml 2KB
.classpath 1KB
lib
commons-dbcp.jar 119KB
commons-logging.jar 59KB
spring-webmvc-struts.jar 36KB
backport-util-concurrent.jar 320KB
cglib-nodep-2.1_3.jar 317KB
mysql.jar 484KB
log4j-1.2.15.jar 383KB
aspectjrt.jar 112KB
log4j.jar 359KB
ibatis-2.3.4.726.jar 375KB
common-annotations.jar 6KB
ehcache-1.5.0.jar 258KB
commons-pool.jar 61KB
spring.jar 2.81MB
aspectjweaver.jar 1.47MB
共 47 条
- 1
sky_sa
- 粉丝: 9
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 记录了贪心,动态规划等算法基本思想与设计.zip
- 基于菲阿里基本模型,以及MACD RSI BooL 等技术指标 构建一套基于贪心算法策略的智能投顾模型.zip
- oj算法代码-贪心算法.zip
- 基于yolov8行人检测源码+模型.zip
- 公开整理-地级市-绿色专利申请、授权数据集(2000-2022年).xlsx
- 基于Transformer模型的图像质量评分模型实现源码+详细说明文档.zip
- CST电磁场仿真+线性螺旋电感+建模步骤细节和RLC端口配置+CST高级建模操作
- 大数据库实验的报告材料材料(word文档良心出品).doc
- AIS2024 valid
- 最入门的爬虫代码 python.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页