geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r498245 - in /geronimo/server/trunk/modules: geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/ geronimo-clustering/src/main/java/org/apache/geronimo/clustering/ geronimo-jetty6-clustering-wadi/src/main/java/org/apa...
Date Sun, 21 Jan 2007 05:07:30 GMT
Author: gdamour
Date: Sat Jan 20 21:07:29 2007
New Revision: 498245

URL: http://svn.apache.org/viewvc?view=rev&rev=498245
Log:
* Add SessionListener.notifySessionDestruction: clients can now receive
callbacks when a Session is destroyed, e.g. when they expire.

* ClusteredSessionManager uses this callback to properly remove the 
destroyed session from its internal storage.

* Sync code with the new WADI API.

This fixes GERONIMO-2764 - Clustered HttpSessions are not properly destroyed 
during eviction.

Modified:
    geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
    geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionListener.java
    geronimo/server/trunk/modules/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/WADIClusteredPreHandler.java
    geronimo/server/trunk/modules/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/WADIClusteredPreHandlerFactory.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/ClusteredSessionManager.java

Modified: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java?view=diff&rev=498245&r1=498244&r2=498245
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
(original)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
Sat Jan 20 21:07:29 2007
@@ -37,7 +37,7 @@
 import org.codehaus.wadi.InvocationException;
 import org.codehaus.wadi.Motable;
 import org.codehaus.wadi.PoolableInvocationWrapperPool;
-import org.codehaus.wadi.SessionPool;
+import org.codehaus.wadi.SessionMonitor;
 import org.codehaus.wadi.core.ConcurrentMotableMap;
 import org.codehaus.wadi.group.Dispatcher;
 import org.codehaus.wadi.impl.ClusteredManager;
@@ -49,6 +49,7 @@
 import org.codehaus.wadi.servicespace.ServiceSpace;
 import org.codehaus.wadi.servicespace.ServiceSpaceName;
 import org.codehaus.wadi.web.WebSession;
+import org.codehaus.wadi.web.WebSessionFactory;
 
 import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList;
 
@@ -67,6 +68,7 @@
     private final CopyOnWriteArrayList listeners;
 
     private ClusteredManager manager;
+    private SessionMonitor sessionMonitor;
     private ServiceSpace serviceSpace;
 
     public BasicWADISessionManager(WADISessionManagerConfigInfo configInfo,
@@ -100,7 +102,7 @@
                     ConcurrentMotableMap mmap,
                     Evicter mevicter,
                     PoolableInvocationWrapperPool requestPool) {
-                return new MotionTracker(next, mevicter, mmap, contextPool, requestPool);
+                return new MotionTracker(next, mevicter, mmap, sessionFactory, requestPool);
             }
         };
         stackContext.build();
@@ -108,6 +110,9 @@
         serviceSpace = stackContext.getServiceSpace();
         manager = stackContext.getManager();
 
+        sessionMonitor = stackContext.getSessionMonitor();
+        sessionMonitor.addSessionListener(new SessionListenerAdapter());
+        
         serviceSpace.start();
     }
 
@@ -164,6 +169,14 @@
         return webSession;
     }
 
+    private WebSession notifySessionDestruction(WebSession webSession) {
+        for (Iterator iter = listeners.iterator(); iter.hasNext();) {
+            SessionListener listener = (SessionListener) iter.next();
+            listener.notifySessionDestruction(new WADISessionAdaptor(webSession));
+        }
+        return webSession;
+    }
+
     private class MotionTracker extends MemoryContextualiser {
         private final Immoter immoter;
         private final Emoter emoter;
@@ -171,9 +184,9 @@
         public MotionTracker(Contextualiser next,
                 Evicter evicter,
                 ConcurrentMotableMap map,
-                SessionPool pool,
+                WebSessionFactory sessionFactory,
                 PoolableInvocationWrapperPool requestPool) {
-            super(next, evicter, map, pool, requestPool);
+            super(next, evicter, map, sessionFactory, requestPool);
 
             Immoter immoterDelegate = super.getImmoter();
             immoter = new InboundSessionTracker(immoterDelegate);
@@ -237,6 +250,17 @@
         public Motable newMotable() {
             return delegate.newMotable();
         }
+    }
+    
+    private class SessionListenerAdapter implements org.codehaus.wadi.SessionListener {
+
+        public void onSessionCreation(org.codehaus.wadi.Session session) {
+        }
+
+        public void onSessionDestruction(org.codehaus.wadi.Session session) {
+            notifySessionDestruction((WebSession) session);
+        }
+        
     }
 
     public static final GBeanInfo GBEAN_INFO;

Modified: geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionListener.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionListener.java?view=diff&rev=498245&r1=498244&r2=498245
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionListener.java
(original)
+++ geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionListener.java
Sat Jan 20 21:07:29 2007
@@ -48,4 +48,10 @@
      */
     void notifyOutboundSessionMigration(Session session);
     
+    /**
+     * Calls when a Session is destroyed.
+     * 
+     * @param session Destroyed session.
+     */
+    void notifySessionDestruction(Session session);
 }

Modified: geronimo/server/trunk/modules/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/WADIClusteredPreHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/WADIClusteredPreHandler.java?view=diff&rev=498245&r1=498244&r2=498245
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/WADIClusteredPreHandler.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/WADIClusteredPreHandler.java
Sat Jan 20 21:07:29 2007
@@ -29,7 +29,6 @@
 import org.apache.geronimo.clustering.ClusteredInvocationException;
 import org.apache.geronimo.jetty6.cluster.AbstractClusteredPreHandler;
 import org.codehaus.wadi.InvocationException;
-import org.codehaus.wadi.InvocationProxy;
 import org.codehaus.wadi.impl.ClusteredManager;
 import org.codehaus.wadi.web.impl.WebInvocation;
 
@@ -68,8 +67,7 @@
                     }
                 }
             };
-            InvocationProxy invocationProxy = wadiManager.getInvocationProxy();
-            invocation.init(request, response, chainAdapter, invocationProxy);
+            invocation.init(request, response, chainAdapter);
             try {
                 wadiManager.contextualise(invocation);
             } catch (InvocationException e) {

Modified: geronimo/server/trunk/modules/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/WADIClusteredPreHandlerFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/WADIClusteredPreHandlerFactory.java?view=diff&rev=498245&r1=498244&r2=498245
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/WADIClusteredPreHandlerFactory.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/WADIClusteredPreHandlerFactory.java
Sat Jan 20 21:07:29 2007
@@ -36,6 +36,9 @@
     private ClusteredManager wadiManager;
 
     public WADIClusteredPreHandlerFactory(WADISessionManager sessionManager) {
+        if (null == sessionManager) {
+            throw new IllegalArgumentException("sessionManager is required");
+        }
         this.sessionManager = sessionManager;
     }
     

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/ClusteredSessionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/ClusteredSessionManager.java?view=diff&rev=498245&r1=498244&r2=498245
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/ClusteredSessionManager.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/ClusteredSessionManager.java
Sat Jan 20 21:07:29 2007
@@ -47,9 +47,6 @@
         setIdManager(sessionIdManager);
 
         sessionManager.registerListener(new MigrationListener());
-
-        // sessions are not removed by this manager. They are invalidated via a callback
mechanism
-        setMaxInactiveInterval(-1);
     }
 
     @Override
@@ -111,6 +108,16 @@
         }
 
         public void notifyOutboundSessionMigration(org.apache.geronimo.clustering.Session
session) {
+            ClusteredSession clusteredSession = getClusteredSession(session);
+            removeSession(clusteredSession, false);
+        }
+
+        public void notifySessionDestruction(org.apache.geronimo.clustering.Session session)
{
+            ClusteredSession clusteredSession = getClusteredSession(session);
+            removeSession(clusteredSession, true);
+        }
+        
+        private ClusteredSession getClusteredSession(org.apache.geronimo.clustering.Session
session) throws AssertionError {
             ClusteredSession clusteredSession;
             synchronized (idToSession) {
                 clusteredSession = idToSession.remove(session.getSessionId());
@@ -118,8 +125,10 @@
             if (null == clusteredSession) {
                 throw new AssertionError("Session [" + session + "] is undefined");
             }
-            removeSession(clusteredSession, false);
+            return clusteredSession;
         }
+        
+        
     }
 
     public class ClusteredSession extends Session {



Mime
View raw message