[jboss-cvs] JBossAS SVN: r78552 - in branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session: notification and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 15 16:47:34 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-09-15 16:47:34 -0400 (Mon, 15 Sep 2008)
New Revision: 78552

Added:
   branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/
   branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionManagementStatus.java
   branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCapability.java
   branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCause.java
   branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicy.java
   branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicyBase.java
   branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/IgnoreUndeployLegacyClusteredSessionNotificationPolicy.java
   branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/LegacyClusteredSessionNotificationPolicy.java
Log:
[JBAS-5778] Add pluggable policy for deciding whether to emit servlet spec notifications around events affecting clustered sessions

Added: branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionManagementStatus.java
===================================================================
--- branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionManagementStatus.java	                        (rev 0)
+++ branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionManagementStatus.java	2008-09-15 20:47:34 UTC (rev 78552)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * Encapsulates the status of how the local container is managing the
+ * given session.
+ * 
+ * @author Brian Stansberry
+ */
+public class ClusteredSessionManagementStatus 
+{
+   private final String  realId;
+   private final boolean locallyUsed;
+   private final Boolean locallyActive;
+   private final Boolean locallyOwned;
+   
+   public ClusteredSessionManagementStatus(String realId,
+                                           boolean locallyUsed, 
+                                           Boolean locallyActive, 
+                                           Boolean locallyOwned)
+   {
+      if (this.realId == null)
+         throw new IllegalArgumentException("realId is null");
+      
+      this.realId = realId;
+      this.locallyUsed = locallyUsed;
+      // If we haven't been locallyUsed, we can't be locallyActive
+      this.locallyActive = (locallyUsed ? locallyActive : Boolean.FALSE);
+      // If we are locallyActive, we are locally owned
+      this.locallyOwned = (Boolean.TRUE.equals(locallyActive) ? Boolean.TRUE : locallyOwned);
+   }
+
+   /**
+    * Gets whether an HttpSession object for the given session has been
+    * returned from the container to the application on this node.
+    * 
+    * @return <code>true</code> if the session has been used locally, 
+    *         <code>false</code> if not.
+    */
+   public boolean isLocallyUsed()
+   {
+      return locallyUsed;
+   }
+
+   /**
+    * Gets whether an HttpSession object for the given session has been
+    * returned from the container to the application on this node AND
+    * this node is the last one to handle a request for the session.
+    * 
+    * @return <code>true</code> if the above conditions are true and the 
+    *         container is sure of this, <code>false</code> if they are not
+    *         true and the container knows this, or <code>null</code> if the
+    *         container is unsure if this node is the last one to handle a 
+    *         request for the session.
+    *         
+    * @see ClusteredSessionNotificationCapability#isLocallyActiveAware()
+    */
+   public Boolean getLocallyActive()
+   {
+      return locallyActive;
+   }
+
+   /**
+    * Gets whether this node considers itself to be the "owner" of the session;
+    * i.e. the one primarily responsible for managing its lifecycle. Note that
+    * a node that is undeploying a war will always give up ownership of its
+    * sessions if it is aware of other nodes in the cluster that still have
+    * the war deployed.
+    * 
+    * @return <code>true</code> if the container knows it is the owner,
+    *         <code>false</code> if it knows it is not the owner, or 
+    *         <code>null</code> if the container is unsure about ownership
+    *         or does not recognize the concept of ownership.
+    *         
+    * @see ClusteredSessionNotificationCapability#isLocallyOwnedAware()
+    */
+   public Boolean getLocallyOwned()
+   {
+      return locallyOwned;
+   }   
+   
+}

Added: branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCapability.java
===================================================================
--- branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCapability.java	                        (rev 0)
+++ branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCapability.java	2008-09-15 20:47:34 UTC (rev 78552)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+
+/**
+ * Encapsulates information about the container's capability to issue
+ * servlet spec notifications under different condititions. Implementations of
+ * {@link ClusteredSessionNotificationPolicy} can use this 
+ * information to get a sense of the capabilities of the container.
+ * 
+ * @author Brian Stansberry
+ */
+public class ClusteredSessionNotificationCapability
+{
+
+   /**
+    * Does the container support invoking <code>HttpSessionListener</code>
+    * callbacks under the given conditions?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is supported, 
+    *         <code>false</code> if not
+    */
+   public boolean isHttpSessionListenerInvocationSupported(ClusteredSessionManagementStatus status, 
+                                                           ClusteredSessionNotificationCause cause, 
+                                                           boolean local)
+   {
+      return local && status.isLocallyUsed() && !ClusteredSessionNotificationCause.STATE_TRANSFER.equals(cause);
+   }
+
+   /**
+    * Under the given conditions, does the container support invoking 
+    * <code>HttpSessionAttributeListener</code> callbacks?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is supported, 
+    *         <code>false</code> if not
+    */
+   public boolean isHttpSessionAttributeListenerInvocationSupported(ClusteredSessionManagementStatus status, 
+                                                           ClusteredSessionNotificationCause cause, 
+                                                           boolean local)
+   {
+      return local && status.isLocallyUsed() && !ClusteredSessionNotificationCause.STATE_TRANSFER.equals(cause);
+   }
+
+   /**
+    * Under the given conditions, does the container support invoking 
+    * <code>HttpSessionBindingListener</code> callbacks?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is supported, 
+    *         <code>false</code> if not
+    */
+   public boolean isHttpSessionBindingListenerInvocationSupported(ClusteredSessionManagementStatus status, 
+                                                           ClusteredSessionNotificationCause cause, 
+                                                           boolean local)
+   {
+      return local && status.isLocallyUsed() && !ClusteredSessionNotificationCause.STATE_TRANSFER.equals(cause);
+   }
+   
+   /**
+    * Is the container able to distinguish whether a session that has been
+    * {@link ClusteredSessionManagementStatus#isLocallyUsed() locally used}
+    * is also {@link ClusteredSessionManagementStatus#getLocallyActive() locally active}?
+    * 
+    * @return <code>true</code> if the container is able to make this distinction;
+    *         <code>false</code> if not
+    */
+   public boolean isLocallyActiveAware()
+   {
+      return false;
+   }
+   
+   /**
+    * Is the container able to distinguish whether a session is
+    * {@link ClusteredSessionManagementStatus#getLocallyOwned() locally owned}?
+    * 
+    * @return <code>true</code> if the container is able to make this distinction;
+    *         <code>false</code> if not
+    */
+   public boolean isLocallyOwnedAware()
+   {
+      return false;
+   }
+   
+   /**
+    * Returns whether the local container is aware of events on remote nodes 
+    * that could give rise to notifications.
+    * 
+    * @param cause the cause
+    * @return <code>true</code> if the local container is aware of the
+    *         remote event, <code>false</code> if not.
+    */
+   public boolean isRemoteCauseAware(ClusteredSessionNotificationCause cause)
+   {
+      return ClusteredSessionNotificationCause.CREATE.equals(cause) 
+                || ClusteredSessionNotificationCause.MODIFY.equals(cause) 
+                || ClusteredSessionNotificationCause.INVALIDATE.equals(cause);
+   }
+}


Property changes on: branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCapability.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCause.java
===================================================================
--- branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCause.java	                        (rev 0)
+++ branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCause.java	2008-09-15 20:47:34 UTC (rev 78552)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * Reasons why a servlet spec notification for a clustered session is being 
+ * generated.
+ * 
+ * @author Brian Stansberry
+ */
+public enum ClusteredSessionNotificationCause 
+{ 
+   /**
+    * Session has been newly created.
+    */
+   CREATE, 
+   
+   /**
+    * Session has been modified by the application.
+    */
+   MODIFY, 
+   
+   /**
+    * Session has failed over and is now in use on the local node.
+    */
+   FAILOVER,
+   
+   /**
+    * Session has failed over and is no longer active on the local node.
+    */
+   FAILAWAY,
+   
+   /**
+    * Session is being invalidated by the application.
+    */
+   INVALIDATE, 
+   
+   /**
+    * Session is being expired by the container due to timeout.
+    */
+   TIMEOUT, 
+   
+   /**
+    * Session is being expired by the container due to undeploy of the
+    * web application.
+    */
+   UNDEPLOY,
+   
+   /** 
+    * Local node became aware of a session active on another node as
+    * a result of the local node receiving a bulk state transfer due to
+    * its being elected to provide backup for that other node's sessions. 
+    */
+   STATE_TRANSFER//, 
+   
+//   /**
+//    * Local node has taken "ownership" of a session for a reason other than
+//    * failover; i.e. the session hasn't become active on the local node. In this
+//    * case the local node would have become aware of the session earlier (i.e.
+//    * via {@link #CREATE} or {@link #STATE_TRANSFER}) and these notifications
+//    * would signal the local node taking greater responsibility for the session.
+//    * Typically a policy implementation would not allow notifications for a
+//    * remotely originated CREATE or for a STATE_TRANSFER if it allows 
+//    * notifications for TAKE_OWNERSHIP, and vice versa. Otherwise, multiple
+//    * notifications would be received for the same session.
+//    */
+//   TAKE_OWNERSHIP,
+//   
+//   /**
+//    * Local node has relinquised "ownership" of a session for a reason other than
+//    * {@link #FAILAWAY} {@link #INVALIDATE}, {@link #TIMEOUT} or {@link #UNDEPLOY}; 
+//    * i.e. some other node is taking over as the owner of session.
+//    * Typically a policy implementation would not allow notifications for a
+//    * remotely originated CREATE or for a STATE_TRANSFER if it allows 
+//    * notifications for TAKE_OWNERSHIP, and vice versa. Otherwise, multiple
+//    * notifications would be received for the same session.
+//    */
+//   RELINQUISH_OWNERSHIP
+   
+}
\ No newline at end of file


Property changes on: branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCause.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicy.java
===================================================================
--- branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicy.java	                        (rev 0)
+++ branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicy.java	2008-09-15 20:47:34 UTC (rev 78552)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * Policy for determining whether the servlet spec notifications related
+ * to expiring a session are allowed to be emitted on the local cluster node.
+ * <p>
+ * <strong>Note:</strong> The use of the word <strong>allowed</strong> above
+ * is intentional; if a given policy implementation returns <code>true</code>
+ * from one of the methods in this interface, that does not mean the listener
+ * will be invoked by the container, nor does the presence of a method in this 
+ * interface imply that it will be invoked by the container in all cases. The
+ * only contract this interface creates is that before invoking a listener
+ * method, the container will invoke an implementation of this policy to 
+ * get permission and will not invoke the listeners if this policy returns
+ * <code>false</code>. If the container does not support emitting notifications
+ * in certain cases, it may not bother checking if the notification is allowed,
+ * and even if it checks, it still will not emit the notification.
+ * </p>
+ * <p>
+ * An example of a case where the container may not support emitting a 
+ * notification is for a session that has never been used locally.
+ * </p>
+ * 
+ * @author Brian Stansberry
+ */
+public interface ClusteredSessionNotificationPolicy
+{
+   /**
+    * Are invocations of <code>HttpSessionListener</code> callbacks
+    * allowed under the given conditions?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is allowed, 
+    *         <code>false</code> if not
+    */
+   boolean isHttpSessionListenerInvocationAllowed(ClusteredSessionManagementStatus status, 
+                                                  ClusteredSessionNotificationCause cause, 
+                                                  boolean local);
+
+
+   /**
+    * Under the given conditions, are invocations of
+    * <code>HttpSessionAttributeListener</code> callbacks allowed?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param attributeName value that would be passed to the <code>name</code>
+    *                      param of the <code>HttpSessionBindingEvent</code> if
+    *                      the listener were invoked
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is allowed, 
+    *         <code>false</code> if not
+    */
+   boolean isHttpSessionAttributeListenerInvocationAllowed(ClusteredSessionManagementStatus status, 
+                                                           ClusteredSessionNotificationCause cause, 
+                                                           String attributeName,
+                                                           boolean local);
+   
+   /**
+    * Under the given conditions, are invocations of
+    * <code>HttpSessionBindingListener</code> callbacks allowed?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param attributeName value that would be passed to the <code>name</code>
+    *                      param of the <code>HttpSessionBindingEvent</code> if
+    *                      the listener were invoked
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is allowed, 
+    *         <code>false</code> if not
+    */
+   boolean isHttpSessionBindingListenerInvocationAllowed(ClusteredSessionManagementStatus status, 
+                                                         ClusteredSessionNotificationCause cause,  
+                                                         String attributeName,
+                                                         boolean local);
+   
+   /**
+    * Provides the policy information about the container's capabilities with
+    * respect to issuing notifications. Will be invoked by the container before
+    * the first invocation of any of the other methods in this interface.
+    * 
+    * @param capability the capability, Will not be <code>null</code>.
+    */
+   void setClusteredSessionExpriationNotificationCapability(ClusteredSessionNotificationCapability capability);
+}


Property changes on: branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicy.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicyBase.java
===================================================================
--- branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicyBase.java	                        (rev 0)
+++ branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicyBase.java	2008-09-15 20:47:34 UTC (rev 78552)
@@ -0,0 +1,29 @@
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * Base superclass for a {@link ClusteredSessionNotificationPolicy} implementation.
+ * 
+ * @author Brian Stansberry
+ *
+ */
+public class ClusteredSessionNotificationPolicyBase 
+{
+
+   private ClusteredSessionNotificationCapability capability;
+
+   public ClusteredSessionNotificationPolicyBase()
+   {
+      super();
+   }
+
+   public void setClusteredSessionExpriationNotificationCapability(ClusteredSessionNotificationCapability capability)
+   {
+      this.capability = capability;
+   }
+
+   public ClusteredSessionNotificationCapability getClusteredSessionExpriationNotificationCapability()
+   {
+      return this.capability;
+   }
+
+}
\ No newline at end of file

Added: branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/IgnoreUndeployLegacyClusteredSessionNotificationPolicy.java
===================================================================
--- branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/IgnoreUndeployLegacyClusteredSessionNotificationPolicy.java	                        (rev 0)
+++ branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/IgnoreUndeployLegacyClusteredSessionNotificationPolicy.java	2008-09-15 20:47:34 UTC (rev 78552)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * Does not allow invocation of HttpSessionListener or HttpSessionAttributeListener
+ * during session expiration due to undeploy.
+ * 
+ * @author Brian Stansberry
+ */
+public class IgnoreUndeployLegacyClusteredSessionNotificationPolicy 
+   extends LegacyClusteredSessionNotificationPolicy
+{
+   /**
+    * Overrides superclass to return <code>false</code> if the cause of the
+    * notification is {@link ClusteredSessionNotificationCause.UNDEPLOY}.
+    *  
+    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
+    *         is <code>true</code> and the cause of the notification is not
+    *         {@link ClusteredSessionNotificationCause.UNDEPLOY}.
+    */
+   public boolean isHttpSessionAttributeListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, String attributeName, boolean local)
+   {
+      return !ClusteredSessionNotificationCause.UNDEPLOY.equals(cause) 
+               && super.isHttpSessionAttributeListenerInvocationAllowed(status, cause, attributeName, local);
+   }
+
+   /**
+    * Overrides superclass to return <code>false</code> if the cause of the
+    * notification is {@link ClusteredSessionNotificationCause.UNDEPLOY}.
+    *  
+    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
+    *         is <code>true</code> and the cause of the notification is not
+    *         {@link ClusteredSessionNotificationCause.UNDEPLOY}.
+    */
+   public boolean isHttpSessionListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, boolean local)
+   {
+      return !ClusteredSessionNotificationCause.UNDEPLOY.equals(cause) 
+               && isHttpSessionListenerInvocationAllowed(status, cause, local);
+   }
+
+}

Added: branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/LegacyClusteredSessionNotificationPolicy.java
===================================================================
--- branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/LegacyClusteredSessionNotificationPolicy.java	                        (rev 0)
+++ branches/Branch_4_2/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/LegacyClusteredSessionNotificationPolicy.java	2008-09-15 20:47:34 UTC (rev 78552)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * {@link ClusteredSessionNotificationPolicy} implementation that
+ * describes the behavior of JBoss AS releases prior to 4.2.4.
+ * 
+ * @author Brian Stansberry
+ */
+public class LegacyClusteredSessionNotificationPolicy 
+   extends ClusteredSessionNotificationPolicyBase 
+   implements ClusteredSessionNotificationPolicy
+{
+   // -------------------------------------- ClusteredSessionNotificationPolicy
+   
+   /**
+    * {@inheritDoc}
+    * 
+    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
+    *         is <code>true</code>.
+    */
+   public boolean isHttpSessionAttributeListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, String attributeName, boolean local)
+   {
+      return status.isLocallyUsed();
+   }
+
+   /**
+    * {@inheritDoc}
+    * 
+    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
+    *         is <code>true</code>.
+    */
+   public boolean isHttpSessionBindingListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, String attributeName, boolean local)
+   {
+      return status.isLocallyUsed();
+   }
+
+   /**
+    * {@inheritDoc}
+    * 
+    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
+    *         is <code>true</code>.
+    */
+   public boolean isHttpSessionListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, boolean local)
+   {
+      return status.isLocallyUsed();
+   }
+
+}




More information about the jboss-cvs-commits mailing list