天天看点

webwork结合memcached实现sna架构

实现思路,使用一个拦截器实现session的处理:

  1. 获取sessionId,查找sessionAttribute(自定义hashmap)
  2. 设置session attribute到webwork
  3. 监控session attribute,一旦发现修改,则持久化到cache中

使用方法:

1、配置拦截器

<interceptor class="com.comwave.sna.interceptor.SNAInterceptor" name="snaInterceptor"></interceptor>

<interceptor-ref name="snaInterceptor"></interceptor-ref>

2、配置spring

<bean class="com.comwave.sna.cache.provider.MemcachedCacheManager" id="cacheManager" destroy-method="close"></bean>

  <constructor-arg value="127.0.0.1:11212"></constructor-arg>

如果使用struct2,则需要修改相应的接口,并增加setCacheManager方法

继续阅读