001/*
002 *
003 * (C) Copyright 2006-2009 Nuxeo SAS (http://nuxeo.com/) and contributors.
004 *
005 * All rights reserved. This program and the accompanying materials
006 * are made available under the terms of the GNU Lesser General Public License
007 * (LGPL) version 2.1 which accompanies this distribution, and is available at
008 * http://www.gnu.org/licenses/lgpl.html
009 *
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013 * Lesser General Public License for more details.
014 *
015 * Contributors:
016 *     Nuxeo - initial API and implementation
017 *
018 * $Id$
019 */
020
021package org.nuxeo.ecm.platform.web.common.session;
022
023import javax.servlet.http.HttpSessionEvent;
024import javax.servlet.http.HttpSessionListener;
025
026/**
027 * Listen to HttpSession events to update the {@link NuxeoHttpSessionMonitor}.
028 *
029 * @author Tiry (tdelprat@nuxeo.com)
030 * @since 5.4.2
031 */
032public class NuxeoSessionListener implements HttpSessionListener {
033
034    @Override
035    public void sessionCreated(HttpSessionEvent se) {
036        NuxeoHttpSessionMonitor.instance().addEntry(se.getSession());
037    }
038
039    @Override
040    public void sessionDestroyed(HttpSessionEvent se) {
041        NuxeoHttpSessionMonitor.instance().removeEntry(se.getSession().getId());
042    }
043
044}