You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ja...@apache.org on 2005/06/17 13:54:55 UTC
svn commit: r191133 -
/lenya/trunk/src/java/org/apache/lenya/util/SessionListener.java
Author: jann
Date: Fri Jun 17 04:54:54 2005
New Revision: 191133
URL: http://svn.apache.org/viewcvs?rev=191133&view=rev
Log:
Add SessionListener class
Added:
lenya/trunk/src/java/org/apache/lenya/util/SessionListener.java (with props)
Added: lenya/trunk/src/java/org/apache/lenya/util/SessionListener.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/util/SessionListener.java?rev=191133&view=auto
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/util/SessionListener.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/util/SessionListener.java Fri Jun 17 04:54:54 2005
@@ -0,0 +1,52 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.lenya.util;
+
+/**
+ * A Listener which store the session object in a HashMap on creation and
+ * remove it if the session is destroyed.
+ *
+ * @version $Id:$
+ */
+
+import javax.servlet.http.*;
+import java.util.WeakHashMap;
+
+public class SessionListener implements HttpSessionListener {
+
+ private static WeakHashMap allSessions = new WeakHashMap();
+
+ public void sessionCreated(HttpSessionEvent se) {
+
+ HttpSession session = se.getSession();
+ String sessionID = session.getId();
+ allSessions.put(sessionID,session);
+ }
+
+ public void sessionDestroyed(HttpSessionEvent se) {
+ HttpSession session = se.getSession();
+ String sessionID = session.getId();
+ if (allSessions.containsKey(sessionID)) {
+ allSessions.remove(sessionID);
+ }
+ }
+
+ public WeakHashMap getAllSessions() {
+ return allSessions;
+ }
+}
\ No newline at end of file
Propchange: lenya/trunk/src/java/org/apache/lenya/util/SessionListener.java
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org