简体   繁体   中英

intercepting session set attribute call

我们有一个第三方Java Web应用程序,它需要在集群中运行(我们需要在集群中复制会话),该应用程序中的会话属性不可序列化,并且我们不能访问源代码,它们是否干净,非侵入性的方法来拦截session.set属性调用并在将对象放入会话之前更改对象

Seeing HttpSessionAttributeListener is not a solution that is OK with you, there is the option of using a ServletFilter . Not sure is that is too intrusive for your requirements, though...

  1. Activate this ServletFilter first in the chain
  2. Wrap the HTTPServletRequest you're passing down the chain with your own implementation of HttpServletRequestWrapper , overriding getSession by returning a decorator implementation of the original container created Session implementation
  3. Your decorator is your gateway to intercepting the setAttribute methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM