在jeecms v5中采用缓存管理回话的方式,这里采用最简单的ehcache实现回话的管理。
具体实现如下:
Ehcache的配置:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
<!--<diskStore path="java.io.tmpdir/jeecms/hibernate"/>-->
<defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120"
overflowToDisk="true" diskSpoolBufferSizeMB="30" maxElementsOnDisk="10000000"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120"/>
<cache name="com.jeecms.common.web.session.Session" maxElementsInMemory="500" eternal="false" timeToIdleSeconds="1200" overflowToDisk="true" diskPersistent="true"/>
<cache name="com.jeecms.cms.front.ContentCount" maxElementsInMemory="500" eternal="true" overflowToDisk="true" diskPersistent="false"/>
</ehcache>
Spring的配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-lazy-init="true">
<!--缓存-->
<bean id="cacheManager" class="com.jeecms.common.web.WebEhCacheManagerFacotryBean">
<property name="configLocation">
<value>/WEB-INF/config/ehcache-application.xml</value>
</property>
<property name="diskStoreLocation">
<value>/WEB-INF/cache/application</value>
</property>
</bean>
<!--SESSION缓存-->
<bean id="ehSessionCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="cacheManager">
<ref local="cacheManager"/>
</property>
<property name="cacheName">
<value>com.jeecms.common.web.Session</value>
</property>
<qualifier value="session"/>
</bean>
<!--内容计数缓存-->
<bean id="ehContentCountCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="cacheManager">
<ref local="cacheManager"/>
</property>
<property name="cacheName">
<value>com.jeecms.cms.front.ContentCount</value>
</property>
<qualifier value="contentCount"/>
</bean>
<!--站点流量缓存-->
<bean id="ehCmsSiteFlowCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="cacheManager">
<ref local="cacheManager"/>
</property>
<property name="cacheName">
<value>com.jeecms.cms.front.CmsSiteFlow</value>
</property>
<qualifier value="cmsSiteFlow"/>
</bean>
</beans>
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<CacheManager>,
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".
* <p>
* 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配置文件中不要配置<diskStore path=""/>,否则本设置无效。
*
* @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();
}
}
<!--EndFragment-->
相关推荐
JEECMS内容管理系统是国内java开源CMS行业知名度最高、用户量最大的站群管理系统。 · SpringMVC3+Spring3+Hibernate3+Freemarker技术架构 · 基于java技术开发,继承其强大、稳定、安全、高效、跨平台等多方面的...
jeecms开发文档,jeecms v5 版开发文档
jeecmsv5
jeecms v6 复制和移动栏目报错修改,直接覆盖这个页面就可以了
jeecms源码,spring+springmvc框架,jeecms资源,超好用。
JEECMS一直秉承用户体验、系统性能和实际应用为第一的研发思路,让jeecms的功能不断丰富的同时,更让jeecms适合更多的应用人群。 根据用户反馈新增和完善的功能还有很多,诸如:支持百度编辑器ueditor、用户模型...
jeecms9.2源代码文件 环境软件可以从以下网址中获得 Jdk 7.0 下载址: http://java.sun.com/javase/downloads/index.jsp Tomcat7 下载地址:https://tomcat.apache.org/download-70.cgi MySQL 5.0.22 下载地址:...
JEECMS
五、面向未来的过渡,JEECMS v2.3.2 Final版是JEECMS面世以来发布的第一个正式版本,具有更大的灵活性和稳定性;-一、系统内核完全开源,为用户提供透明的管理平台,为java初学者提供良好的学习平台; 二、核心模板...
JEECMS使用目前java主流技术架构:hibernate3+struts2+spring2+freemarker。AJAX使用jquery和json实现。视图层并没有使用传统的JSP技术,而是使用更为专业、灵活、高效freemarker。 数据库使用MYSQL,并可支持orcale...
jeecms 标签使用说明 jeecms 标签使用说明 jeecms 标签使用说明
JEECMSv8.1是一款支持微信小程序、栏目模型、内容模型交叉自定义、以及具备支付和财务结算的内容电商为一体内容管理系统:通过后台的简单设置即可自定义出集新闻管理、图库管理、视频管理、下载系统、文库管理、政务...
JEECMS是JavaEE版网站管理系统(Java Enterprise Edition Content Manage System)的简称。 · 基于java技术开发,继承其强大、稳定、安全、高效、跨平台等多方面的优点 · 采用hibernate3+spring mvc+spring2+...
jeecms标签列表和示例 jeecms数据表 jeecms模板标签说明 比较全哦!
欢迎使用JEECMS v9.2版,请按照以下步骤进行软件安装: 一、安装运行环境(JDK7+TOMCAT7+MYSQL5及以上,具体安装过程请参考本下载包中的相关说明文档); 二、将程序解压后的ROOT文件夹拷贝到tomcat安装目录下的...
摘要:JSP源码,CMS系统,JeeCMS jeecms v2012版是一款集新闻管理、图库管理、视频管理、下载系统、作品管理、产品发布及留言板于一体的综合性CMS系统。 jeecms v2012版新增功能如下: 1、新增统计功能 1.1...
JEECMS是国内Java版开源网站内容管理系统 1.基于java技术开发,继承其强大、稳定、安全、高效、跨平台等多方面的优点 2.采用SpringMVC3+Spring3+Hibernate3+Freemarker主流技术架构 3.懂html就能建站,提供最便利、...
jeecms完整全功能版——源代码,压缩包3,去掉后最gz,配合压缩包1解压。
JEECMS是JavaEE版网站管理系统 (Java Enterprise Edition Content Manage System)的简称。 · 基于java技术开发,继承其强大、稳定、安全、高效、跨平台等多方面的优点 · 采用SpringMVC3+Spring3+Hibernate3+...
JEECMS后台地址修改:JEECMS修改后台地址比较麻烦,按照文档上的步骤操作可以进行修改