[Building Sakai] Add a session listener to sakai session

Navarro Sanchez, Maria Dolores mdolores.navarro at tecnocom.es
Tue Jan 11 02:56:17 PST 2011


Hi all,

I have a problem and I need a little help. I have developed a Sakai tool and I need to intercept the sakai session creation and sakai session destruction. I have developed the following SessionListener:


public final class SessionListener implements ServletContextListener, HttpSessionListener {

    private ServletContext context = null;
    private static Log log = LogFactory.getLog(SessionListener.class);

    public void contextDestroyed(ServletContextEvent event) {
      log.debug("contextDestroyed");
      this.context = null;
    }

    public void contextInitialized(ServletContextEvent event) {
      this.context = event.getServletContext();
      log.debug ("contextInitialized");
    }

    public void sessionCreated(HttpSessionEvent event) {
      log.debug ("sessionCreated('" + event.getSession().getId() + "')");
    }

    public void sessionDestroyed(HttpSessionEvent event) {
      log.debug ("sessionDestroyed('" + event.getSession().getId() + "')");
    }

}



I have added my Listener in the web.xml of my tool:



    <listener>
        <listener-class>org.sakaiproject.util.ToolListener</listener-class>
        <listener-class>listeners.SessionListener</listener-class>
    </listener>



The context events are intercepted normally but session events are not intercepted. How can I intercept these events? Is there any other listener interface I have to implement?
Do you know if there is any other way to do what I need?

Thanks in advance,
Dolores





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20110111/544b8ad5/attachment.html 


More information about the sakai-dev mailing list