KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > jcr > launcher > SessionListener


1 package org.exoplatform.jcr.launcher;
2
3 import javax.servlet.ServletContext JavaDoc;
4 import javax.servlet.http.HttpSession JavaDoc;
5 import javax.servlet.http.HttpSessionEvent JavaDoc;
6
7 import org.exoplatform.container.PortalContainer;
8 import org.exoplatform.container.RootContainer;
9 import org.exoplatform.container.SessionContainer;
10
11 public class SessionListener {
12   
13   public void sessionCreated(HttpSessionEvent JavaDoc event) {
14   }
15
16   public void sessionDestroyed(HttpSessionEvent JavaDoc event) {
17     HttpSession JavaDoc session = event.getSession() ;
18     ServletContext JavaDoc context = session.getServletContext() ;
19     PortalContainer pcontainer =
20       RootContainer.getInstance().getPortalContainer(context.getServletContextName()) ;
21     SessionContainer scontainer = (SessionContainer)pcontainer.getComponentInstance(session.getId()) ;
22     if(scontainer != null) {
23       PortalContainer.setInstance(pcontainer) ;
24       pcontainer.unregisterComponent(session.getId()) ;
25       scontainer.stop() ;
26       PortalContainer.setInstance(null) ;
27     }
28   }
29   
30 }
31
Popular Tags