portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r446804 - in /portals/jetspeed-2/trunk: commons/src/java/org/apache/jetspeed/container/ commons/src/java/org/apache/jetspeed/container/session/ components/portal/src/java/org/apache/jetspeed/container/session/ components/portal/src/java/org...
Date Sat, 16 Sep 2006 01:39:20 GMT
Author: ate
Date: Fri Sep 15 18:39:17 2006
New Revision: 446804

URL: http://svn.apache.org/viewvc?view=rev&rev=446804
Log:
Fixing JIRA issue JS2-282: Portlet sessions are not invalidated when the portal session is
destroyed with emptySessionPath="true"
See: http://issues.apache.org/jira/browse/JS2-582

Added:
    portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/session/
    portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitorImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/session/
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/session/PortalSessionMonitorImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/session/PortalSessionsManagerImpl.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortalSessionMonitor.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortalSessionsManager.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitor.java
Modified:
    portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedServlet.java
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml

Modified: portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java?view=diff&rev=446804&r1=446803&r2=446804
==============================================================================
--- portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
(original)
+++ portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
Fri Sep 15 18:39:17 2006
@@ -38,6 +38,8 @@
 import javax.servlet.http.HttpServletRequestWrapper;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.jetspeed.container.session.PortalSessionsManager;
+import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.services.JetspeedPortletServices;
 import org.apache.jetspeed.services.PortletServices;
 import org.apache.jetspeed.tools.pamanager.PortletApplicationManagement;
@@ -54,6 +56,7 @@
     private String  contextName;
     private boolean started = false;
     private Timer   startTimer = null;
+    private PortalSessionsManager psm;
 
     // -------------------------------------------------------------------
     // I N I T I A L I Z A T I O N
@@ -167,6 +170,8 @@
                     DirectoryHelper paDirHelper = new DirectoryHelper(new File(paDir));
                     pam.startPortletApplication(contextPath, paDirHelper, paClassLoader);
                     started = true;
+                    psm = (PortalSessionsManager)services.getService(PortalSessionsManager.SERVICE_NAME);
+
                     context.log(STARTED_MSG + contextPath);
                     return true;
                 }
@@ -309,6 +314,11 @@
                     // never mind, it won't be used anymore.                 
                 }
             }
+            if (psm != null)
+            {
+                RequestContext rc = (RequestContext)request.getAttribute(RequestContext.REQUEST_PORTALENV);
+                psm.checkMonitorSession(contextName,rc.getRequest().getSession(),request.getSession(false));
+            }
         }
     }
 
@@ -382,6 +392,7 @@
                 }
             }
             contextName = null;
+            psm = null;
             }
         }
         }

Added: portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitorImpl.java?view=auto&rev=446804
==============================================================================
--- portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitorImpl.java
(added)
+++ portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitorImpl.java
Fri Sep 15 18:39:17 2006
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2000-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.jetspeed.container.session;
+
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionEvent;
+
+import org.apache.jetspeed.container.session.PortalSessionsManager;
+import org.apache.jetspeed.container.session.PortletApplicationSessionMonitor;
+import org.apache.jetspeed.services.JetspeedPortletServices;
+import org.apache.jetspeed.services.PortletServices;
+
+/**
+ * PortletApplicationSessionMonitorImpl
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: $
+ */
+public class PortletApplicationSessionMonitorImpl implements PortletApplicationSessionMonitor

+{
+    private static final long serialVersionUID = -6729032046828426324L;
+    
+    private String contextPath;    
+    private String portalSessionId;
+    private long portalSessionKey;
+    private transient HttpSession session;
+
+    public PortletApplicationSessionMonitorImpl(String contextPath, String portalSessionId,
long portalSessionKey)
+    {
+        this.contextPath = contextPath;
+        this.portalSessionId = portalSessionId;
+        this.portalSessionKey = portalSessionKey;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortletApplicationSessionMonitor#getPortalSessionKey()
+     */
+    public long getPortalSessionKey()
+    {
+        return portalSessionKey;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortletApplicationSessionMonitor#getPortalSessionId()
+     */
+    public String getPortalSessionId()
+    {
+        return portalSessionId;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortletApplicationSessionMonitor#getContextPath()
+     */
+    public String getContextPath()
+    {
+        return contextPath;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortletApplicationSessionMonitor#invalidateSession()
+     */
+    public void invalidateSession()
+    {
+        if ( session != null )
+        {
+            HttpSession thisSession = session;
+            session = null;
+            try
+            {
+                thisSession.invalidate();
+            }
+            catch (Exception ise)
+            {
+                // ignore
+            }
+        }        
+    }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
+     */
+    public void valueBound(HttpSessionBindingEvent event)
+    {
+        this.session = event.getSession();
+    }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)
+     */
+    public void valueUnbound(HttpSessionBindingEvent event)
+    {
+        if ( session != null )
+        {
+            PortalSessionsManager manager = getManager(); 
+            if ( manager != null )
+            {
+                manager.sessionDestroyed(this);
+            }
+            session = null;
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.http.HttpSessionActivationListener#sessionDidActivate(javax.servlet.http.HttpSessionEvent)
+     */
+    public void sessionDidActivate(HttpSessionEvent event)
+    {
+        this.session = event.getSession();
+        PortalSessionsManager manager = getManager(); 
+        if ( manager != null )
+        {
+            manager.sessionDidActivate(this);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.http.HttpSessionActivationListener#sessionWillPassivate(javax.servlet.http.HttpSessionEvent)
+     */
+    public void sessionWillPassivate(HttpSessionEvent event)
+    {
+        PortalSessionsManager manager = getManager(); 
+        if ( manager != null )
+        {
+            manager.sessionWillPassivate(this);
+        }
+        session = null;
+    }
+    
+    private PortalSessionsManager getManager()
+    {
+        PortletServices services = JetspeedPortletServices.getSingleton();
+        if (services != null)
+        {
+            return (PortalSessionsManager)services.getService(PortalSessionsManager.SERVICE_NAME);
+        }
+        return null;
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/session/PortalSessionMonitorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/session/PortalSessionMonitorImpl.java?view=auto&rev=446804
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/session/PortalSessionMonitorImpl.java
(added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/session/PortalSessionMonitorImpl.java
Fri Sep 15 18:39:17 2006
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2000-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.jetspeed.container.session;
+
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionEvent;
+
+import org.apache.jetspeed.services.JetspeedPortletServices;
+import org.apache.jetspeed.services.PortletServices;
+
+/**
+ * PortalSessionMonitorImpl
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: $
+ */
+public class PortalSessionMonitorImpl implements PortalSessionMonitor
+{
+    private static final long serialVersionUID = 1239564779524373742L;
+
+    private long sessionKey;
+    private transient HttpSession session;
+    
+    public PortalSessionMonitorImpl(long sessionKey)
+    {
+        this.sessionKey = sessionKey;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortalSessionMonitor#getSessionId()
+     */
+    public String getSessionId()
+    {
+        HttpSession thisSession = session;
+        return thisSession != null ? thisSession.getId() : null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortalSessionMonitor#getSessionKey()
+     */
+    public long getSessionKey()
+    {
+        return sessionKey;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortalSessionMonitor#invalidateSession()
+     */
+    public void invalidateSession()
+    {
+        HttpSession thisSession = session;
+        if ( thisSession != null )
+        {
+            session = null;
+            try
+            {
+                thisSession.invalidate();
+            }
+            catch (Exception ise)
+            {
+                // ignore
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
+     */
+    public void valueBound(HttpSessionBindingEvent event)
+    {
+        this.session = event.getSession();
+    }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)
+     */
+    public void valueUnbound(HttpSessionBindingEvent event)
+    {
+        if ( session != null )
+        {
+            PortalSessionsManager manager = getManager();
+            if (manager != null)
+            {
+                manager.portalSessionDestroyed(this);
+            }
+            session = null;
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.http.HttpSessionActivationListener#sessionDidActivate(javax.servlet.http.HttpSessionEvent)
+     */
+    public void sessionDidActivate(HttpSessionEvent event)
+    {
+        this.session = event.getSession();
+        PortalSessionsManager manager = getManager();
+        if (manager != null)
+        {
+            manager.portalSessionDestroyed(this);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.http.HttpSessionActivationListener#sessionWillPassivate(javax.servlet.http.HttpSessionEvent)
+     */
+    public void sessionWillPassivate(HttpSessionEvent event)
+    {
+        PortalSessionsManager manager = getManager();
+        if (manager != null)
+        {
+            manager.portalSessionWillPassivate(this);
+        }
+        session = null;
+    }
+
+    private PortalSessionsManager getManager()
+    {
+        PortletServices services = JetspeedPortletServices.getSingleton();
+        if (services != null)
+        {
+            return (PortalSessionsManager)services.getService(PortalSessionsManager.SERVICE_NAME);
+        }
+        return null;
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/session/PortalSessionsManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/session/PortalSessionsManagerImpl.java?view=auto&rev=446804
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/session/PortalSessionsManagerImpl.java
(added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/session/PortalSessionsManagerImpl.java
Fri Sep 15 18:39:17 2006
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2000-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.jetspeed.container.session;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.servlet.http.HttpSession;
+
+/**
+ * PortalSessionsManagerImpl
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: $
+ */
+public class PortalSessionsManagerImpl implements PortalSessionsManager
+{
+    private static final class PortalSessionRegistry
+    {
+        long portalSessionKey;
+        PortalSessionMonitor psm;
+        HashMap sessionMonitors;
+        
+        PortalSessionRegistry()
+        {
+            sessionMonitors = new HashMap();
+        }
+    }
+    
+    private long       portalSessionKeySequence;
+    private HashMap portalSessionsRegistry;
+    
+    public PortalSessionsManagerImpl()
+    {
+        portalSessionKeySequence = System.currentTimeMillis();
+        portalSessionsRegistry = new HashMap();
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortalSessionsManager#portalSessionCreated(javax.servlet.http.HttpSession)
+     */
+    public synchronized void portalSessionCreated(HttpSession portalSession)
+    {
+        PortalSessionMonitor psm = new PortalSessionMonitorImpl(++portalSessionKeySequence);
+        portalSession.setAttribute(PortalSessionMonitor.SESSION_KEY, psm);
+        // register it as if activated
+        portalSessionDidActivate(psm);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortalSessionsManager#portalSessionWillPassivate(org.apache.jetspeed.container.session.PortalSessionMonitor)
+     */
+    public synchronized void portalSessionWillPassivate(PortalSessionMonitor psm)
+    {
+        portalSessionsRegistry.remove(psm.getSessionId());
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortalSessionsManager#portalSessionDidActivate(org.apache.jetspeed.container.session.PortalSessionMonitor)
+     */
+    public synchronized void portalSessionDidActivate(PortalSessionMonitor restoredPsm)
+    {
+        PortalSessionRegistry psr = (PortalSessionRegistry)portalSessionsRegistry.get(restoredPsm.getSessionId());
+        if ( psr != null && psr.portalSessionKey != -1 && psr.portalSessionKey
!= restoredPsm.getSessionKey() )
+        {
+            // looks like Client didn't join the previous portal session while the sessionId
is reused (cookies disabled?)
+            // destroy the "old" portal Session and any (probably also not-joined) registered
paSessions
+            portalSessionDestroyed(psr.psm);
+            psr = null;
+        }
+        if ( psr == null )
+        {
+            psr = new PortalSessionRegistry();
+            portalSessionsRegistry.put(restoredPsm.getSessionId(), psr);
+        }
+        // save the restored instance
+        psr.psm = restoredPsm;
+        psr.portalSessionKey = restoredPsm.getSessionKey();
+        // validate registered paSessions are in sync
+        Iterator iter = psr.sessionMonitors.values().iterator();
+        PortletApplicationSessionMonitor pasm;
+        while (iter.hasNext())
+        {
+            pasm = (PortletApplicationSessionMonitor)iter.next();
+            if ( pasm.getPortalSessionKey() != psr.portalSessionKey )
+            {
+                pasm.invalidateSession();
+                iter.remove();
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortalSessionsManager#portalSessionDestroyed(org.apache.jetspeed.container.session.PortalSessionMonitor)
+     */
+    public synchronized void portalSessionDestroyed(PortalSessionMonitor psm)
+    {
+        PortalSessionRegistry psr = (PortalSessionRegistry)portalSessionsRegistry.remove(psm.getSessionId());
+        if ( psr != null )
+        {
+            Iterator iter = psr.sessionMonitors.values().iterator();
+            while (iter.hasNext())
+            {
+                ((PortletApplicationSessionMonitor)iter.next()).invalidateSession();
+            }
+            // To make sure its gone.
+            // You better not remove the psm from the portal session yourself ;)
+            psm.invalidateSession();
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortalSessionsManager#checkMonitorSession(java.lang.String,
javax.servlet.http.HttpSession, javax.servlet.http.HttpSession)
+     */
+    public synchronized void checkMonitorSession(String contextPath, HttpSession portalSession,
HttpSession paSession)
+    {
+        if ( portalSession != null && paSession != null )
+        {
+            PortalSessionRegistry psr = (PortalSessionRegistry)portalSessionsRegistry.get(portalSession.getId());
+            PortletApplicationSessionMonitor pasm = (PortletApplicationSessionMonitor)psr.sessionMonitors.get(contextPath);
+            if ( pasm != null )
+            {
+                try
+                {
+                    if ( paSession.getAttribute(PortletApplicationSessionMonitor.SESSION_KEY)
== null )
+                    {
+                        // looks like Client didn't join the previous pa session
+                        // destroy the "old" paSession
+                        pasm.invalidateSession();                    
+                        pasm = null;
+                        // no need to remove the "old" pasm from the sessionMonitors as it
will be replaced right below
+                    }
+                }
+                catch (IllegalStateException ise)
+                {
+                    // paSession already invalid, ignore
+                }
+            }
+            if ( pasm == null )
+            {
+                pasm = new PortletApplicationSessionMonitorImpl(contextPath,portalSession.getId(),psr.portalSessionKey);
+                try
+                {
+                    paSession.setAttribute(PortletApplicationSessionMonitor.SESSION_KEY,
pasm);
+                    psr.sessionMonitors.put(contextPath, pasm);
+                }
+                catch (IllegalStateException ise)
+                {
+                    // paSession already invalid, ignore
+                }
+            }
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortalSessionsManager#sessionWillPassivate(org.apache.jetspeed.container.session.PortletApplicationSessionMonitor)
+     */
+    public void sessionWillPassivate(PortletApplicationSessionMonitor pasm)
+    {
+        PortalSessionRegistry psr = (PortalSessionRegistry)portalSessionsRegistry.get(pasm.getPortalSessionId());
+        if (psr != null )
+        {
+            psr.sessionMonitors.remove(pasm.getContextPath());
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortalSessionsManager#sessionDidActivate(org.apache.jetspeed.container.session.PortletApplicationSessionMonitor)
+     */
+    public synchronized void sessionDidActivate(PortletApplicationSessionMonitor restoredPasm)
+    {
+        PortalSessionRegistry psr = (PortalSessionRegistry)portalSessionsRegistry.get(restoredPasm.getPortalSessionId());
+        if ( psr == null )
+        {
+            // looks like the portalSession was passivated or the paSession was replicated
to another JVM while its related portalSession wasn't (yet)
+            // so, we're gonna anticipate future activation of the portalSession:
+            // create a temporary psr with an "empty" psm for now (portalSessionKey == -1)
+            // once the portalSession is replicated/Activated, it will validate registered
paSessions having the correct portalSessionKey
+            psr = new PortalSessionRegistry();
+            psr.psm = new PortalSessionMonitorImpl(-1);
+            portalSessionsRegistry.put(restoredPasm.getPortalSessionId(), psr);
+        }
+        // save the restored instance
+        psr.sessionMonitors.put(restoredPasm.getContextPath(), restoredPasm);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.container.session.PortalSessionsManager#sessionDestroyed(org.apache.jetspeed.container.session.PortletApplicationSessionMonitor)
+     */
+    public synchronized void sessionDestroyed(PortletApplicationSessionMonitor pasm)
+    {
+        PortalSessionRegistry psr = (PortalSessionRegistry)portalSessionsRegistry.get(pasm.getPortalSessionId());
+        if ( psr != null )
+        {
+            psr.sessionMonitors.remove(pasm.getContextPath());
+            // To make sure its gone.
+            // You better not remove the pasm from the session yourself ;)
+            pasm.invalidateSession();
+        }
+    }
+}

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedServlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedServlet.java?view=diff&rev=446804&r1=446803&r2=446804
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedServlet.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedServlet.java
Fri Sep 15 18:39:17 2006
@@ -39,6 +39,7 @@
 import org.apache.jetspeed.components.ComponentManager;
 import org.apache.jetspeed.components.SpringComponentManager;
 import org.apache.jetspeed.components.factorybeans.ServletConfigFactoryBean;
+import org.apache.jetspeed.container.session.PortalSessionsManager;
 import org.apache.jetspeed.engine.servlet.ServletHelper;
 import org.apache.jetspeed.exception.JetspeedException;
 import org.apache.jetspeed.pipeline.valve.SecurityValve;
@@ -46,6 +47,8 @@
 import org.apache.jetspeed.request.RequestContextComponent;
 import org.apache.jetspeed.security.SecurityHelper;
 import org.apache.jetspeed.security.UserPrincipal;
+import org.apache.jetspeed.services.JetspeedPortletServices;
+import org.apache.jetspeed.services.PortletServices;
 import org.apache.jetspeed.statistics.PortalStatistics;
 
 /**
@@ -324,6 +327,15 @@
     
     public void sessionCreated(HttpSessionEvent se)
     {
+        PortletServices services = JetspeedPortletServices.getSingleton();
+        if (services != null)
+        {
+            PortalSessionsManager psm = (PortalSessionsManager)services.getService(PortalSessionsManager.SERVICE_NAME);
+            if (psm != null)
+            {
+                psm.portalSessionCreated(se.getSession());
+            }
+        }
     }
     
     public void sessionDestroyed(HttpSessionEvent se)

Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortalSessionMonitor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortalSessionMonitor.java?view=auto&rev=446804
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortalSessionMonitor.java
(added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortalSessionMonitor.java
Fri Sep 15 18:39:17 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-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.jetspeed.container.session;
+
+import java.io.Serializable;
+
+import javax.servlet.http.HttpSessionActivationListener;
+import javax.servlet.http.HttpSessionBindingListener;
+
+/**
+ * PortalSessionMonitor
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: $
+ */
+public interface PortalSessionMonitor extends HttpSessionBindingListener, HttpSessionActivationListener,
Serializable
+{
+    String SESSION_KEY = PortalSessionMonitor.class.getName();
+    
+    long getSessionKey();
+    String getSessionId();
+    void invalidateSession();
+}

Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortalSessionsManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortalSessionsManager.java?view=auto&rev=446804
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortalSessionsManager.java
(added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortalSessionsManager.java
Fri Sep 15 18:39:17 2006
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-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.jetspeed.container.session;
+
+import javax.servlet.http.HttpSession;
+
+/**
+ * PortalSessionsMonitor
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: $
+ */
+public interface PortalSessionsManager
+{
+    String SERVICE_NAME = PortalSessionsManager.class.getName();
+    
+    void portalSessionCreated(HttpSession portalSession);
+    void portalSessionWillPassivate(PortalSessionMonitor psm);
+    void portalSessionDidActivate(PortalSessionMonitor psm);
+    void portalSessionDestroyed(PortalSessionMonitor psm);
+    void checkMonitorSession(String contextPath, HttpSession portalSession, HttpSession paSession);
   
+    void sessionWillPassivate(PortletApplicationSessionMonitor pasm);    
+    void sessionDidActivate(PortletApplicationSessionMonitor pasm);    
+    void sessionDestroyed(PortletApplicationSessionMonitor pasm);    
+}

Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitor.java?view=auto&rev=446804
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitor.java
(added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitor.java
Fri Sep 15 18:39:17 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-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.jetspeed.container.session;
+
+import java.io.Serializable;
+
+import javax.servlet.http.HttpSessionActivationListener;
+import javax.servlet.http.HttpSessionBindingListener;
+
+/**
+ * PortletApplicationSessionMonitor
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: $
+ */
+public interface PortletApplicationSessionMonitor extends HttpSessionBindingListener, HttpSessionActivationListener,
Serializable
+{
+    String SESSION_KEY = PortletApplicationSessionMonitor.class.getName();    
+    long getPortalSessionKey();
+    String getPortalSessionId();
+    String getContextPath();
+    void invalidateSession();
+}
\ No newline at end of file

Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml?view=diff&rev=446804&r1=446803&r2=446804
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml Fri Sep 15
18:39:17 2006
@@ -95,6 +95,10 @@
           <entry key="PreferencesProvider">
             <ref bean="org.apache.jetspeed.prefs.PreferencesProvider"/>
           </entry>
+          <entry key="org.apache.jetspeed.container.session.PortalSessionsManager">
+            <bean class="org.apache.jetspeed.container.session.PortalSessionsManagerImpl"/>
+          </entry>
+          
 <!-- first uncomment the below service bean in security-spi-atn.xml
          <entry key="PasswordEncodingService">
            <ref bean="org.apache.jetspeed.security.PasswordEncodingService" />



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message