001/*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016package org.opengion.hayabusa.common;
017
018import javax.servlet.http.HttpSession ;
019import javax.servlet.http.HttpSessionListener;
020import javax.servlet.http.HttpSessionEvent;
021
022/**
023 * HttpSessionListener を実装した、セッション状態の監視リスナークラスです。
024 * これは、セッションの作成/破棄を監視できます。
025 * このリスナーは、WEB-INF/web.xml で、組み込みます。
026 *
027 * 【WEB-INF/web.xml】
028 *
029 *  <listener>
030 *      <listener-class>
031 *          org.opengion.hayabusa.common.HybsSessionListener
032 *      </listener-class>
033 *  </listener>
034 *
035 * @og.group ログイン制御
036 *
037 * @version  4.0
038 * @author   Kazuhiko Hasegawa
039 * @since    JDK5.0,
040 */
041public class HybsSessionListener implements HttpSessionListener {
042
043        /**
044         *  HttpSessionListener インターフェースの実装
045         *
046         * セッションが作成されたときにリスナーに通知される。
047         * 現段階では、なにもしない。
048         *
049         * @param event セッションイベント
050         */
051        @Override
052        public void sessionCreated( final HttpSessionEvent event ) {
053        // taglib\HeadTag.java に移動
054        //      HttpSession session = event.getSession();
055        //      SystemManager.addSession( session );
056        }
057
058        /**
059         *  HttpSessionListener インターフェースの実装
060         *
061         * セッションが破棄されたときにリスナーに通知される。
062         *
063         * @og.rev 5.5.9.1 (2012/12/07) SystemManager に渡すのは、sessionID ではなく、session オブジェクトとする。
064         *
065         * @param event セッションイベント
066         */
067        @Override
068        public void sessionDestroyed( final HttpSessionEvent event ) {
069                HttpSession session = event.getSession();
070//              String sessionID = session.getId();
071//              SystemManager.removeSession( sessionID );
072                SystemManager.removeSession( session );         // 5.5.9.1 (2012/12/07)
073        }
074}