001 /**
002 *
003 * $Revision: 15200 $ $Date: 2009-05-15 16:47:58 +0200 (Fri, 15 May 2009) $
004 *
005 * This file is part of ** M y C o R e **
006 * Visit our homepage at http://www.mycore.de/ for details.
007 *
008 * This program is free software; you can use it, redistribute it
009 * and / or modify it under the terms of the GNU General Public License
010 * (GPL) as published by the Free Software Foundation; either version 2
011 * of the License or (at your option) any later version.
012 *
013 * This program is distributed in the hope that it will be useful, but
014 * WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program, normally in the file license.txt.
020 * If not, write to the Free Software Foundation Inc.,
021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
022 *
023 **/
024 package org.mycore.common.events;
025
026 import org.mycore.common.MCRSession;
027
028 /**
029 *
030 * @author Thomas Scheffler (yagee)
031 *
032 * @version $Revision: 15200 $ $Date: 2009-05-15 16:47:58 +0200 (Fri, 15 May 2009) $
033 * @since 2.0
034 */
035 public class MCRSessionEvent {
036
037 public static enum Type {
038 activated, created, destroyed, passivated;
039 }
040
041 private Type type;
042
043 private MCRSession session;
044
045 private int concurrentAccessors;
046
047 public MCRSessionEvent(MCRSession session, Type type, int concurrentAccessors) {
048 this.session = session;
049 this.type = type;
050 this.concurrentAccessors = concurrentAccessors;
051 }
052
053 /**
054 * Return how many threads accessed the session at time the event occured.
055 */
056 public int getConcurrentAccessors() {
057 return concurrentAccessors;
058 }
059
060 /**
061 * Return the MCRSession on which this event occured.
062 */
063 public MCRSession getSession() {
064 return session;
065 }
066
067 /**
068 * Return the event type of this event.
069 */
070 public Type getType() {
071 return type;
072 }
073
074 public String toString() {
075 StringBuilder sb=new StringBuilder();
076 sb.append("MCRSessionEvent['");
077 sb.append(getSession());
078 sb.append("',");
079 sb.append(getType());
080 sb.append(",");
081 sb.append(getConcurrentAccessors());
082 sb.append("]'");
083 return sb.toString();
084 }
085
086 }