1
2
3
4
5
6
7
8
9
10
11 package org.weda.servlet;
12
13 import java.util.Enumeration;
14 import javax.servlet.http.HttpSessionEvent;
15 import javax.servlet.http.HttpSessionListener;
16 import org.apache.commons.logging.Log;
17 import org.apache.commons.logging.LogFactory;
18 import org.weda.cache.CacheService;
19
20 /**Цель: освобождение ресурсов занимаемых сервисом {@link tim.docarch.service.CacheService}
21 *
22 * @author tim
23 */
24 public class SessionListener implements HttpSessionListener{
25 private final static Log log = LogFactory.getLog(SessionListener.class);
26
27 public void sessionDestroyed(HttpSessionEvent event) {
28
29 Enumeration it = event.getSession().getAttributeNames();
30 while (it.hasMoreElements()){
31 String attr = (String)it.nextElement();
32 Object obj = event.getSession().getAttribute(attr);
33 if (obj instanceof CacheService) {
34 log.debug("Reliasing cache.");
35 ((CacheService)obj).releaseAll();
36 }
37 }
38 }
39
40 public void sessionCreated(HttpSessionEvent event) {
41 }
42
43 }