在jeecms v5中采用缓存管理回话的方式,这里采用最简单的ehcache实现回话的管理。

具体实现如下:

Ehcache的配置:

overflowToDisk="true"diskSpoolBufferSizeMB="30"maxElementsOnDisk="10000000"

diskPersistent="false"diskExpiryThreadIntervalSeconds="120"/>

Spring的配置

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"

default-lazy-init="true">

/WEB-INF/config/ehcache-application.xml

/WEB-INF/cache/application

com.jeecms.common.web.Session

com.jeecms.cms.front.ContentCount

com.jeecms.cms.front.CmsSiteFlow

package com.jeecms.common.web;

import java.io.IOException;

import net.sf.ehcache.CacheException;

import net.sf.ehcache.CacheManager;

import net.sf.ehcache.ObjectExistsException;

import net.sf.ehcache.config.Configuration;

import net.sf.ehcache.config.ConfigurationFactory;

import net.sf.ehcache.config.DiskStoreConfiguration;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.DisposableBean;

import org.springframework.beans.factory.FactoryBean;

import org.springframework.beans.factory.InitializingBean;

import org.springframework.core.io.Resource;

/**

* 用于Web的EhCacheManagerFacotryBean。可以基于Web根目录指定diskStore地址。

*/

public class WebEhCacheManagerFacotryBean implements FactoryBean,

InitializingBean, DisposableBean {

private final Logger log = LoggerFactory

.getLogger(WebEhCacheManagerFacotryBean.class);

private Resource configLocation;

private Resource diskStoreLocation;

private String cacheManagerName;

private CacheManager cacheManager;

/**

* Set the location of the EHCache config file. A typical value is

* "/WEB-INF/ehcache.xml".

*

* Default is "ehcache.xml" in the root of the class path, or if not found,

* "ehcache-failsafe.xml" in the EHCache jar (default EHCache

* initialization).

*

* @see net.sf.ehcache.CacheManager#create(java.io.InputStream)

* @see net.sf.ehcache.CacheManager#CacheManager(java.io.InputStream)

*/

public void setConfigLocation(Resource configLocation) {

this.configLocation = configLocation;

}

/**

* 设置ehcahce的diskStore path,例如:/WEB-INF/cache

*

* 如设置了此项,则在ehcache配置文件中不要配置,否则本设置无效。

*

* @param diskStoreLocation

*/

public void setdiskStoreLocation(Resource diskStoreLocation) {

this.diskStoreLocation = diskStoreLocation;

}

/**

* Set the name of the EHCache CacheManager (if a specific name is desired).

*

* @see net.sf.ehcache.CacheManager#setName(String)

*/

public void setCacheManagerName(String cacheManagerName) {

this.cacheManagerName = cacheManagerName;

}

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);

}

}

public CacheManager getObject() {

return this.cacheManager;

}

public Class extends CacheManager> getObjectType() {

return (this.cacheManager != null ? this.cacheManager.getClass()

: CacheManager.class);

}

public boolean isSingleton() {

return true;

}

public void destroy() {

log.info("Shutting down EHCache CacheManager");

this.cacheManager.shutdown();

}

}

jeecms oracle v5_jeecms v5 spring和ehcache的整合相关推荐

  1. 缓存插件 Spring支持EHCache缓存

    Spring仅仅是提供了对缓存的支持,但它并没有任何的缓存功能的实现,spring使用的是第三方的缓存框架来实现缓存的功能.其中,spring对EHCache提供了很好的支持. 在介绍Spring的缓 ...

  2. 转Spring+Hibernate+EHcache配置(二)

    Spring AOP+EHCache简单缓存系统解决方案 需要使用Spring来实现一个Cache简单的解决方案,具体需求如下:使用任意一个现有开源Cache Framework,要求可以Cache系 ...

  3. 关于spring与EHcache的集成

    ehcache.xml配置如下: <?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns: ...

  4. Spring和Ehcache整合详解

    Spring和Ehcache整合详解 一.官方主页 Spring Cache 二.概述 EhCache 是一个纯Java的进程内缓存框架,具有快速.精干等特点. Spring 提供了对缓存功能的抽象: ...

  5. SSM框架Spring+SpringMVC+MyBatis——详细整合教程

    2019独角兽企业重金招聘Python工程师标准>>> 摘要: 包括SQL Maps和Data Access Objects(DAO)MyBatis 消除了几乎所有的JDBC代码和参 ...

  6. Spring系列(七)、Spring与MyBatis框架整合

    7 搭建Spring与MyBatis的集成环境 要实现Spring与MyBatis的整合,很明显需要这两个框架各自的jar包,以及整合两个框架的中间包mybatis-spring.jar: 我们使用m ...

  7. Spring Boot 2.x整合Quartz

    宣传官网 xb.exrick.cn 在线Demo xboot.exrick.cn 开源版Github地址 github.com/Exrick/x-bo- 开发文档 www.kancloud.cn/ex ...

  8. velocity mybatis spring 在maven的整合开发(二)

    2019独角兽企业重金招聘Python工程师标准>>> 对于一个web项目,位于WEB-INFO下的web.xml永远是该项目的总配置. 我的web.xml <?xml ver ...

  9. Struts2与Spring、Hibernate三者整合的过程示例

    转载地址:http://www.360doc.com/content/09/0416/09/61497_3148602.shtml# 原来spring配置文件自动生成数据源和整合先后有关系,留着做个提 ...

  10. Spring与Quartz的整合实现定时任务调度

    Spring与Quartz的整合实现定时任务调度 摘自: http://kevin19900306.iteye.com/blog/1397744 最近在研究Spring中的定时任务功能,最好的办法当然 ...

最新文章

  1. linux支持表情的字体,让应用程序支持emoji字符
  2. 概率论面试系列第一弹: 贝叶斯公式
  3. C#并行编程(5):需要知道的异步
  4. P4313-文理分科【最小割】
  5. android node
  6. Go语言学习Day04
  7. 基于JAVA+SpringMVC+Mybatis+MYSQL的学生公寓管理系统
  8. php html script,html script标签怎么用
  9. Express 常用中间件 body-parser 实现解析
  10. java web服务器cpu占用过高的处理 (2014-07-21 17:17:36)
  11. Ubuntu好用的软件推荐
  12. A very hard mathematic problem(二分)
  13. unity3D 插件plugins
  14. 输入法只能打拼音不能打汉字
  15. 锐文科技发布基于国产FPGA的智能网卡芯片
  16. 一篇文章教会你用Python爬取淘宝评论数据(写在记事本)
  17. 长城汽车召回上万辆欧拉IQ:电池存在安全隐患,曾因自燃被拉黑
  18. GCC中-O1 -O2 -O3 优化的原理是什么?
  19. 20160829-你拥有的最宝贵的财富是什么?
  20. pandas获得指定行_pandas实现选取特定索引的行

热门文章

  1. android bugly 错误分析,# app 3.6.1 Bugly中崩溃分析
  2. dest是什么意思(dest是什么意思车上的)
  3. db_recovery_file_dest与log_archive_dest、log_archive_dest_n
  4. python支持向量机 股票_测 python 利用SVM预测股票涨跌
  5. 用 线性回归 预测股票的涨跌
  6. halcon 缺陷检测 表面凸点检测
  7. 从罗京、张艺谋看CCTV的知识管理
  8. 云片网实现短信验证码
  9. ADB Interface 找不到驱动程序 怎么破
  10. 获取汉字拼音首字母方法