portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggol...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager SessionStateBindingListener.java JetspeedStateManagerService.java StateManagerService.java
Date Fri, 17 May 2002 18:37:47 GMT
ggolden     02/05/17 11:37:47

  Modified:    src/java/org/apache/jetspeed/services/statemanager
                        JetspeedStateManagerService.java
                        StateManagerService.java
  Added:       src/java/org/apache/jetspeed/services/statemanager
                        SessionStateBindingListener.java
  Log:
  Introducing the SessionStateBindingListener interface, loosely based on
  the HttpSessionBindingListener interface.
  Objects that act as attribute values placed into the StateManager's
  SessionStates that implement this interface will be notified when they are
  added to and removed from the SessionState.
  
  Revision  Changes    Path
  1.4       +26 -3     jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/JetspeedStateManagerService.java
  
  Index: JetspeedStateManagerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/JetspeedStateManagerService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JetspeedStateManagerService.java	14 May 2002 14:50:11 -0000	1.3
  +++ JetspeedStateManagerService.java	17 May 2002 18:37:46 -0000	1.4
  @@ -1,6 +1,6 @@
   /**********************************************************************************
   *
  -* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/JetspeedStateManagerService.java,v
1.3 2002/05/14 14:50:11 ggolden Exp $
  +* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/JetspeedStateManagerService.java,v
1.4 2002/05/17 18:37:46 ggolden Exp $
   *
   * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -69,9 +69,11 @@
   import javax.servlet.ServletConfig;
   
   import org.apache.jetspeed.services.statemanager.StateManagerService;
  +import org.apache.jetspeed.services.statemanager.SessionStateBindingListener;
   import org.apache.turbine.services.TurbineBaseService;
   import org.apache.turbine.services.InitializationException;
   import org.apache.turbine.util.RunData;
  +import org.apache.turbine.util.Log;
   
   /**
   * <p>JetspeedStateManagerService is a Turbine Service implementation of the
  @@ -79,7 +81,7 @@
   * <p>SessionState is stored in a HashMap, keyed by state key.  In the HashMap, each
   * SessionState has another HashMap, storing the names and values of the state info. </p>
   * <p>See the proposal: jakarta-jetspeed/proposals/StateManager.txt for more details.</p>
  -* @version $Revision: 1.3 $
  +* @version $Revision: 1.4 $
   * @see org.apache.jetspeed.services.statemanager.StateManagerService
   * @see org.apache.jetspeed.services.statemanager.SessionState
   * @author <a href="mailto:ggolden@apache.org">Glenn R. Golden</a>
  @@ -213,6 +215,27 @@
           Map state = (Map) m_states.get(key);
           if (state != null)
           {
  +            Set attributes = state.entrySet();
  +            synchronized (state)
  +            {
  +                Iterator i = attributes.iterator();
  +                while (i.hasNext())
  +                {
  +                    Map.Entry attribute = (Map.Entry) i.next();
  +
  +                    // if this object wants session binding notification
  +                    if (attribute.getValue() instanceof SessionStateBindingListener)
  +                    {
  +                        try
  +                        {
  +                            ((SessionStateBindingListener)attribute.getValue())
  +                                .valueUnbound(key, (String)attribute.getKey());
  +                        }
  +                        catch (Throwable e) {Log.warn("JetspeedStateManagerService.clear:
unbinding exception: ", e);}
  +                    }
  +                }
  +            }
  +
               // remove all attributes
               state.clear();
               
  @@ -369,7 +392,7 @@
   
   /**********************************************************************************
   *
  -* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/JetspeedStateManagerService.java,v
1.3 2002/05/14 14:50:11 ggolden Exp $
  +* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/JetspeedStateManagerService.java,v
1.4 2002/05/17 18:37:46 ggolden Exp $
   *
   **********************************************************************************/
   
  
  
  
  1.3       +10 -4     jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/StateManagerService.java
  
  Index: StateManagerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/StateManagerService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StateManagerService.java	14 May 2002 14:50:11 -0000	1.2
  +++ StateManagerService.java	17 May 2002 18:37:46 -0000	1.3
  @@ -1,6 +1,6 @@
   /**********************************************************************************
   *
  -* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/StateManagerService.java,v
1.2 2002/05/14 14:50:11 ggolden Exp $
  +* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/StateManagerService.java,v
1.3 2002/05/17 18:37:46 ggolden Exp $
   *
   * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -62,10 +62,16 @@
   /**
   * <p>The StateManagerService is a service that manages SessionState information.
   * Each SessionState is identified by a unique key in this service.  The SessionState
  -* is composed of name - value sets of information, stored under the key by the service.</p>
  +* is composed of name - value sets of attributes, stored under the key by the service.</p>
   * <p>See the proposal: jakarta-jetspeed/proposals/StateManager.txt for more details.</p>
  -* @version $Revision: 1.2 $
  +* <p>Attribute values placed into SessionStates may be automatically removed, for
example when
  +* a SessionState expires in some way, or by means of some other automatic service.  These
value
  +* objects can be notified of their placement into and out of the SessionState.  Objects
that wish
  +* to receive this notification implement the SessionStateBindingListener interface.  This
is based
  +* on and similar to the HttpSessionBindingListener mechanism.</p>
  +* @version $Revision: 1.3 $
   * @see org.apache.jetspeed.services.statemanager.SessionState
  +* @see org.apache.jetspeed.services.statemanager.SessionStateBindingListener
   * @author <a href="mailto:ggolden@apache.org">Glenn R. Golden</a>
   */
   public interface StateManagerService
  @@ -126,7 +132,7 @@
   
   /**********************************************************************************
   *
  -* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/StateManagerService.java,v
1.2 2002/05/14 14:50:11 ggolden Exp $
  +* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/StateManagerService.java,v
1.3 2002/05/17 18:37:46 ggolden Exp $
   *
   **********************************************************************************/
   
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/SessionStateBindingListener.java
  
  Index: SessionStateBindingListener.java
  ===================================================================
  /**********************************************************************************
  *
  * $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/SessionStateBindingListener.java,v
1.1 2002/05/17 18:37:46 ggolden Exp $
  *
  * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  // package
  package org.apache.jetspeed.services.statemanager;
  
  // imports
  
  
  /**
  * <p>SessionStateBindingListener is an interface for objects that wish to be
  * notified when they are bound to and unbound from a SessionState managed by the
  * Jetspeed SessionManagerService.</p>
  * <p>This is loosely modeled on the HttpSessionBindingListener.</p>
  * @version $Revision: 1.1 $
  * @see org.apache.jetspeed.services.statemanager.StateManagerService
  * @author <a href="mailto:ggolden@apache.org">Glenn R. Golden</a>
  */
  public interface SessionStateBindingListener
  {
      /**
      * Accept notification that this object has been bound as a SessionState attribute.
      * @param sessionStateKey The id of the session state which holds the attribute.
      * @param attributeName The id of the attribute to which this object is now the value.
      */
      public void valueBound(String sessionStateKey, String attributeName);
  
      /**
      * Accept notification that this object has been removed from a SessionState attribute.
      * @param sessionStateKey The id of the session state which held the attribute.
      * @param attributeName The id of the attribute to which this object was the value.
      */
      public void valueUnbound(String sessionStateKey, String attributeName);
  
  }   // interface SessionStateBindingListener
  
  /**********************************************************************************
  *
  * $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/SessionStateBindingListener.java,v
1.1 2002/05/17 18:37:46 ggolden Exp $
  *
  **********************************************************************************/
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:jetspeed-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@jakarta.apache.org>


Mime
View raw message