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 jakarta.servlet.http.HttpSession ;
019import jakarta.servlet.http.HttpSessionListener;
020import jakarta.servlet.http.HttpSessionEvent;
021
022import jakarta.servlet.annotation.WebListener;                          // 6.3.4.0 (2015/08/01)
023
024/**
025 * HttpSessionListener を実装した、セッション状態の監視リスナークラスです。
026 * これは、セッションの作成/破棄を監視できます。
027 * このリスナーは、WEB-INF/web.xml で、組み込みます。
028 *
029 * 【WEB-INF/web.xml】
030 *
031 *  <listener>
032 *      <listener-class>
033 *          org.opengion.hayabusa.common.HybsSessionListener
034 *      </listener-class>
035 *  </listener>
036 *
037 * @og.group ログイン制御
038 *
039 * @version  4.0
040 * @author   Kazuhiko Hasegawa
041 * @since    JDK5.0,
042 */
043@WebListener
044public class HybsSessionListener implements HttpSessionListener {
045
046        /**
047         * デフォルトコンストラクター
048         *
049         * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor.
050         */
051        public HybsSessionListener() { super(); }               // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。
052
053        /**
054         *  HttpSessionListener インターフェースの実装
055         *
056         * セッションが作成されたときにリスナーに通知される。
057         * 現段階では、なにもしない。
058         *
059         * @param event セッションイベント
060         */
061        @Override
062        public void sessionCreated( final HttpSessionEvent event ) {
063        // taglib\HeadTag.java に移動
064        //      HttpSession session = event.getSession();
065        //      SystemManager.addSession( session );
066        }
067
068        /**
069         *  HttpSessionListener インターフェースの実装
070         *
071         * セッションが破棄されたときにリスナーに通知される。
072         *
073         * @og.rev 5.5.9.1 (2012/12/07) SystemManager に渡すのは、sessionID ではなく、session オブジェクトとする。
074         *
075         * @param event セッションイベント
076         */
077        @Override
078        public void sessionDestroyed( final HttpSessionEvent event ) {
079                final HttpSession session = event.getSession();
080                SystemManager.removeSession( session );         // 5.5.9.1 (2012/12/07)
081        }
082}