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 JetspeedStateManagerService.java SessionState.java StateManagerService.java
Date Tue, 14 May 2002 14:50:11 GMT
ggolden     02/05/14 07:50:11

  Modified:    src/java/org/apache/jetspeed/services/statemanager
                        JetspeedStateManagerService.java SessionState.java
                        StateManagerService.java
  Log:
  Changed getAttributeNames to return a String[] rather than an iterator.
  Made the JetspeedStateManagerService implementation use synchronized
  maps to be more thread safe.
  
  Revision  Changes    Path
  1.3       +36 -29    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JetspeedStateManagerService.java	3 May 2002 17:40:44 -0000	1.2
  +++ JetspeedStateManagerService.java	14 May 2002 14:50:11 -0000	1.3
  @@ -1,6 +1,6 @@
   /**********************************************************************************
   *
  -* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/JetspeedStateManagerService.java,v
1.2 2002/05/03 17:40:44 ggolden Exp $
  +* $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 $
   *
   * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -64,6 +64,8 @@
   import java.util.HashMap;
   import java.util.Map;
   import java.util.Set;
  +import java.util.Collections;
  +import java.util.Vector;
   import javax.servlet.ServletConfig;
   
   import org.apache.jetspeed.services.statemanager.StateManagerService;
  @@ -77,7 +79,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.2 $
  +* @version $Revision: 1.3 $
   * @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>
  @@ -89,7 +91,7 @@
   {
       /** Store each set of state parameters by state key
           (each is a HashMap keyed by parameter name) */
  -    private HashMap m_states = null;
  +    private Map m_states = null;
   
       /**
       * Performs early initialization.
  @@ -134,7 +136,9 @@
           throws InitializationException
       {
           super.init();
  -        m_states = new HashMap();
  +
  +        // create our states map synchronized
  +        m_states = Collections.synchronizedMap(new HashMap());
   
       }   // init
   
  @@ -161,9 +165,9 @@
       */
       public Object getAttribute ( String key, String name )
       {
  -        Map map = (Map) m_states.get(key);
  -        if (map == null) return null;
  -        return map.get(name);
  +        Map state = (Map) m_states.get(key);
  +        if (state == null) return null;
  +        return state.get(name);
   
       }   // getAttribute
   
  @@ -175,13 +179,15 @@
       */
       public void setAttribute( String key, String name, Object value )
       {
  -        Map map = (Map) m_states.get(key);
  -        if (map == null)
  +        Map state = (Map) m_states.get(key);
  +        if (state == null)
           {
  -            map = new HashMap();
  -            m_states.put(key, map);
  +            // create a synchronized map to store the state attributes
  +            state = Collections.synchronizedMap(new HashMap());
  +            m_states.put(key, state);
           }
  -        map.put(name, value);
  +
  +        state.put(name, value);
   
       }   // setAttribute
   
  @@ -192,9 +198,9 @@
       */
       public void removeAttribute( String key, String name )
       {
  -        Map map = (Map) m_states.get(key);
  -        if (map == null) return;
  -        map.remove(name);
  +        Map state = (Map) m_states.get(key);
  +        if (state == null) return;
  +        state.remove(name);
   
       }   // removeAttribute
   
  @@ -204,11 +210,11 @@
       */
       public void clear( String key )
       {
  -        Map map = (Map) m_states.get(key);
  -        if (map != null)
  +        Map state = (Map) m_states.get(key);
  +        if (state != null)
           {
               // remove all attributes
  -            map.clear();
  +            state.clear();
               
               // and forget about it
               m_states.remove(key);
  @@ -217,16 +223,17 @@
       }   // clear
   
       /**
  -    * Access an iterator on all names of attributes stored in the keyed state.
  +    * Access an array of all names of attributes stored in the keyed state.
       * @param key The state key.
  -    * @return An iterator on all names of attributes stored in the keyed state.
  +    * @return An array of all names of attributes stored in the keyed state.
       */
  -    public Iterator getAttributeNames( String key )
  +    public String[] getAttributeNames( String key )
       {
  -        Map map = (Map) m_states.get(key);
  -        if (map == null) return null;
  -        Set keys = map.keySet();
  -        return keys.iterator();
  +        Map state = (Map) m_states.get(key);
  +        if (state == null) return null;
  +
  +        // process all the current keys, synchronized
  +        return (String[]) state.keySet().toArray(new String[state.size()]);
   
       }   // getAttributeNames
   
  @@ -328,10 +335,10 @@
           }   // clear
   
           /**
  -        * Access an iterator on all names of attributes stored in the SessionState.
  -        * @return An iterator on all names of attribute stored in the SessionState.
  +        * Access an array of all names of attributes stored in the SessionState.
  +        * @return An array of all names of attribute stored in the SessionState.
           */
  -        public Iterator getAttributeNames()
  +        public String[] getAttributeNames()
           {
               return m_service.getAttributeNames(m_key);
   
  @@ -362,7 +369,7 @@
   
   /**********************************************************************************
   *
  -* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/JetspeedStateManagerService.java,v
1.2 2002/05/03 17:40:44 ggolden Exp $
  +* $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 $
   *
   **********************************************************************************/
   
  
  
  
  1.3       +6 -6      jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/SessionState.java
  
  Index: SessionState.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/SessionState.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SessionState.java	3 May 2002 17:40:44 -0000	1.2
  +++ SessionState.java	14 May 2002 14:50:11 -0000	1.3
  @@ -1,6 +1,6 @@
   /**********************************************************************************
   *
  -* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/SessionState.java,v
1.2 2002/05/03 17:40:44 ggolden Exp $
  +* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/SessionState.java,v
1.3 2002/05/14 14:50:11 ggolden Exp $
   *
   * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -66,7 +66,7 @@
   * <p>SessionState is an interface for objects that provide name - value information
sets
   * with a unique key that can be used in the StateManager service</p>
   * <p>See the proposal: jakarta-jetspeed/proposals/StateManager.txt for more details.</p>
  -* @version $Revision: 1.2 $
  +* @version $Revision: 1.3 $
   * @see org.apache.jetspeed.services.statemanager.StateManagerService
   * @author <a href="mailto:ggolden@apache.org">Glenn R. Golden</a>
   */
  @@ -98,10 +98,10 @@
       public void clear();
   
       /**
  -    * Access an iterator on all names of attributes stored in the SessionState.
  -    * @return An iterator on all names of attribute stored in the SessionState.
  +    * Access an array of all names of attributes stored in the SessionState.
  +    * @return An array of all names of attribute stored in the SessionState.
       */
  -    public Iterator getAttributeNames();
  +    public String[] getAttributeNames();
   
       /**
       * Access the unique StateManager key for the SessionState.
  @@ -118,7 +118,7 @@
   
   /**********************************************************************************
   *
  -* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/SessionState.java,v
1.2 2002/05/03 17:40:44 ggolden Exp $
  +* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/SessionState.java,v
1.3 2002/05/14 14:50:11 ggolden Exp $
   *
   **********************************************************************************/
   
  
  
  
  1.2       +6 -9      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StateManagerService.java	3 May 2002 15:04:38 -0000	1.1
  +++ StateManagerService.java	14 May 2002 14:50:11 -0000	1.2
  @@ -1,6 +1,6 @@
   /**********************************************************************************
   *
  -* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/StateManagerService.java,v
1.1 2002/05/03 15:04:38 ggolden Exp $
  +* $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 $
   *
   * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -59,15 +59,12 @@
   // package
   package org.apache.jetspeed.services.statemanager;
   
  -// imports
  -import java.util.Iterator;
  -
   /**
   * <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>
   * <p>See the proposal: jakarta-jetspeed/proposals/StateManager.txt for more details.</p>
  -* @version $Revision: 1.1 $
  +* @version $Revision: 1.2 $
   * @see org.apache.jetspeed.services.statemanager.SessionState
   * @author <a href="mailto:ggolden@apache.org">Glenn R. Golden</a>
   */
  @@ -106,11 +103,11 @@
       public void clear( String key );
   
       /**
  -    * Access an iterator on all names of attributes stored in the keyed state.
  +    * Access an array of all names of attributes stored in the keyed state.
       * @param key The state key.
  -    * @return An iterator on all names of attributes stored in the keyed state.
  +    * @return An array of all names of attributes stored in the keyed state.
       */
  -    public Iterator getAttributeNames( String key );
  +    public String[] getAttributeNames( String key );
   
       /**
       * Access an SessionState object with the given key.
  @@ -129,7 +126,7 @@
   
   /**********************************************************************************
   *
  -* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/StateManagerService.java,v
1.1 2002/05/03 15:04:38 ggolden Exp $
  +* $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 $
   *
   **********************************************************************************/
   
  
  
  

--
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