myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gcrawf...@apache.org
Subject svn commit: r1099931 - in /myfaces/trinidad/trunk: ./ trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/
Date Thu, 05 May 2011 19:26:52 GMT
Author: gcrawford
Date: Thu May  5 19:26:52 2011
New Revision: 1099931

URL: http://svn.apache.org/viewvc?rev=1099931&view=rev
Log:
TRINIDAD-2091 add mutable information to property key to support partial state saving

Modified:
    myfaces/trinidad/trunk/   (props changed)
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/FacesBean.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/PropertyKey.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyArrayMap.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyHashMap.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/UINodeFacesBean.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/UINodePropertyKey.java

Propchange: myfaces/trinidad/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu May  5 19:26:52 2011
@@ -8,4 +8,4 @@
 /myfaces/trinidad/branches/jwaldman_StyleMap:754977-770778
 /myfaces/trinidad/branches/trinidad-1.2.x:923447,923460,929241
 /myfaces/trinidad/branches/trinidad-2.0.x:823098-895949
-/myfaces/trinidad/trunk:819601,819622,834147,886881,888973,893043,896231-908455,908699-921461
+/myfaces/trinidad/trunk:819601,819622,834147,886881,888973,893043,896231-908455,908699-921461,1099510

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/FacesBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/FacesBean.java?rev=1099931&r1=1099930&r2=1099931&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/FacesBean.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/FacesBean.java
Thu May  5 19:26:52 2011
@@ -338,6 +338,15 @@ public interface FacesBean
       return registerKey(name, type, null, capabilities);
     }
 
+    public PropertyKey registerKey(
+      String   name,
+      Class<?> type,
+      Object   defaultValue,
+      int      capabilities)
+    {
+      return registerKey(name, type, defaultValue, capabilities, null);
+    }
+
     /**
      * Add an alias to an existing PropertyKey.
      * @exception IllegalStateException if the type is already locked,
@@ -361,19 +370,24 @@ public interface FacesBean
      *    or the key already exists.
      */
     public PropertyKey registerKey(
-      String   name,
-      Class<?> type,
-      Object   defaultValue,
-      int      capabilities)
+      String              name,
+      Class<?>            type,
+      Object              defaultValue,
+      int                 capabilities,
+      PropertyKey.Mutable mutable)
     {
       _checkLocked();
       _checkName(name);
 
+      if (mutable == null)
+        mutable = PropertyKey.Mutable.IMMUTABLE;
+
       PropertyKey key = createPropertyKey(name,
                                           type,
                                           defaultValue,
                                           capabilities,
-                                          getNextIndex());
+                                          getNextIndex(),
+                                          mutable);
       addKey(key);
       return key;
     }
@@ -429,13 +443,25 @@ public interface FacesBean
       int      capabilities,
       int      index)
     {
+      return createPropertyKey(name, type, defaultValue, capabilities, index, 
+                                                                    PropertyKey.Mutable.IMMUTABLE);
+    }
+
+    protected PropertyKey createPropertyKey(
+      String              name,
+      Class<?>            type,
+      Object              defaultValue,
+      int                 capabilities,
+      int                 index,
+      PropertyKey.Mutable mutable)
+    {      
       if (_superType != null)
       {
         return _superType.createPropertyKey(name, type, defaultValue,
-                                            capabilities, index);
+                                            capabilities, index, mutable);
       }
 
-      return new PropertyKey(name, type, defaultValue, capabilities, index);
+      return new PropertyKey(name, type, defaultValue, capabilities, index, mutable);
     }
 
     /**

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/PropertyKey.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/PropertyKey.java?rev=1099931&r1=1099930&r2=1099931&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/PropertyKey.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/PropertyKey.java
Thu May  5 19:26:52 2011
@@ -6,9 +6,9 @@
  *  to you 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
@@ -59,20 +59,28 @@ public class PropertyKey
    * Capability indicating this property can use the StateHolder API.
    */
   static public final int CAP_STATE_HOLDER = 8;
-  
+
   /**
    * Capability indicating this property can use the PartialStateHolder API.
    */
   static public final int CAP_PARTIAL_STATE_HOLDER = 16;
-  
+
   /**
-   * Capability indicating the type of this property is mutable.
-   * In partial state saving only the deltas are saved, and deltas are generated by sets
on 
-   * component attributes, without a set getting called an attribute will not be in the delta
list, 
-   * and therefore won't be state saved. This property can tell us whether the type of the
property
-   * is mutable and if so it can be put into the delta list.
-   */
-  static public final int CAP_MUTABLE = 32;
+   * Indicates whether or not a property is mutable, and if so how likely it is to actually
+   * be mutated. For example an array is always mutable, but it may be a string array
+   * that is very unlikely to be mutated
+   */
+  public enum Mutable {
+     IMMUTABLE,
+     RARELY,
+     SOMETIMES,
+     OFTEN;
+
+     public boolean isAtLeastSometimesMutable()
+     {
+       return (compareTo(SOMETIMES) > -1);
+     }
+  };
 
   /**
    * Create a named PropertyKey, not attached to any type.
@@ -82,28 +90,28 @@ public class PropertyKey
   {
     return new PropertyKey(name);
   }
-  
-  private static final ConcurrentMap<String, PropertyKey> _sDefaultKeyCache = 
+
+  private static final ConcurrentMap<String, PropertyKey> _sDefaultKeyCache =
                                             new ConcurrentHashMap<String, PropertyKey>();
-                             
+
   /**
    * Returns a named PropertyKey of type Object
    */
   public static PropertyKey getDefaultPropertyKey(String name)
   {
     PropertyKey cachedKey = _sDefaultKeyCache.get(name);
-    
+
     if (cachedKey == null)
     {
       cachedKey = new PropertyKey(name);
-      
+
       // we don't need putIfAbsent because we don't care about identity
       _sDefaultKeyCache.put(name, cachedKey);
     }
-    
+
     return cachedKey;
   }
-  
+
   //
   // Constructors, all package-private.  Only the constructor
   // that takes a simple String could be exposed at all safely;
@@ -117,7 +125,7 @@ public class PropertyKey
   {
     this(name, _TYPE_DEFAULT);
   }
-  
+
   PropertyKey(
     String   name,
     Class<?> type)
@@ -141,6 +149,21 @@ public class PropertyKey
     int      capabilities,
     int      index)
   {
+    this(name, type, defaultValue, capabilities, index, Mutable.IMMUTABLE);
+  }
+
+  // Needs to be protected for UINodePropertyKey implementation
+  protected PropertyKey(
+    String   name,
+    Class<?> type,
+    Object   defaultValue,
+    int      capabilities,
+    int      index,
+    Mutable  mutable)
+  {
+    if (mutable == null)
+      throw new NullPointerException();
+
     if (name == null)
       throw new NullPointerException();
 
@@ -166,14 +189,14 @@ public class PropertyKey
       if (defaultValue == null)
         defaultValue = _OBJECT_NULL;
     }
-        
+
     if ((capabilities & ~_CAPS_ALL) != 0)
       throw new IllegalStateException(_LOG.getMessage(
         "CAPABILITY_MASK_NOT_UNDERSTOOD", (capabilities & ~_CAPS_ALL)));
 
     // Lists cannot be bound
     boolean hasListCapability = (capabilities & CAP_LIST) != 0;
-                                                               
+
     if (hasListCapability)
       capabilities = capabilities | CAP_NOT_BOUND;
 
@@ -182,7 +205,8 @@ public class PropertyKey
     _default = defaultValue;
     _capabilities = capabilities;
     _index = index;
-    
+    _mutable = mutable;
+
     // save using StatUtils.saveList if the value is of type list
     _serializeAsList = hasListCapability || LIST_CLASS.isAssignableFrom(_type);
     _hashCode = _name.hashCode();
@@ -239,11 +263,11 @@ public class PropertyKey
   /**
    * Returns true if the type of this property is mutable
    */
-  public boolean isMutable()
+  public Mutable getMutable()
   {
-    return (_capabilities & CAP_MUTABLE) != 0;
+    return _mutable;
   }
-  
+
   /**
    * Returns true if the property is used to store a PartialStateHolder.
    */
@@ -275,18 +299,18 @@ public class PropertyKey
   {
     if ((_capabilities & CAP_STATE_HOLDER) != 0)
       return StateUtils.saveStateHolder(context, value);
-    
+
     // only serialize as list if this really is a list.  This is necessary because value
     // could be a ValueExpression
     if (this._serializeAsList && (value instanceof List))
       return StateUtils.saveList(context, value);
-    
+
     // warn if we are state saving non-serializable values, as this will cause client
     // state saving and fail-over to fail.  See JIRA 1236
     if ((value != null) && !(value instanceof Serializable) && _LOG.isWarning())
       _LOG.warning(_LOG.getMessage("UNSERIALIZABLE_PROPERTY_VALUE_NO_CONTAINER",
                                    new Object[]{value, this}));
-    
+
     return value;
   }
 
@@ -303,7 +327,7 @@ public class PropertyKey
     return savedValue;
   }
 
-  
+
   @Override
   public boolean equals(Object o)
   {
@@ -324,7 +348,7 @@ public class PropertyKey
     int index = this._index;
     if (index == -1)
     {
-      return ((that._index == -1) && 
+      return ((that._index == -1) &&
               (that._name.equals(_name)) &&
               (that._type.equals(_type)) &&
               (that._default.equals(_default)));
@@ -365,14 +389,14 @@ public class PropertyKey
   {
     return _PRIMITIVE_DEFAULTS.get(type);
   }
-  
+
   static private Class<?> _getBoxedType(
     Class<?> type)
   {
     Class<?> boxedType = _BOXED_PRIMITIVES.get(type);
     return (boxedType != null ? boxedType : type);
   }
-  
+
   static private Map<Class<?>, Object> _createPrimitiveDefaults()
   {
     Map<Class<?>, Object> map = new HashMap<Class<?>, Object>();
@@ -415,19 +439,19 @@ public class PropertyKey
   // true if we should use StateUtils.saveList() to save the state
   private final boolean  _serializeAsList;
   private       FacesBean.Type _owner;
+  private final Mutable  _mutable;
 
   private static final Class<List> LIST_CLASS = List.class;
-  
-  static private final int _CAPS_DEFAULT = 
+
+  static private final int _CAPS_DEFAULT =
     0;
-  
-  static private final int _CAPS_ALL = 
+
+  static private final int _CAPS_ALL =
     CAP_NOT_BOUND |
     CAP_TRANSIENT |
     CAP_LIST |
     CAP_STATE_HOLDER|
-    CAP_PARTIAL_STATE_HOLDER|
-    CAP_MUTABLE;
+    CAP_PARTIAL_STATE_HOLDER;
 
   static private final Class<Object> _TYPE_DEFAULT = Object.class;
 

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyArrayMap.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyArrayMap.java?rev=1099931&r1=1099930&r2=1099931&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyArrayMap.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyArrayMap.java
Thu May  5 19:26:52 2011
@@ -63,10 +63,10 @@ public class PropertyArrayMap extends Ar
      Object retValue = super.put(key, value);
      if (_createDeltas())
      {
-       if (key.isMutable() || !_equals(value, retValue))
+       if (key.getMutable().isAtLeastSometimesMutable() || !_equals(value, retValue))
          _deltas.put(key, value);
      }
-     else if (key.isMutable() && !(value instanceof ValueExpression))
+     else if (key.getMutable().isAtLeastSometimesMutable() && !(value instanceof
ValueExpression))
      {
        _getMutableTracker(true).addProperty(key);
      }
@@ -103,7 +103,7 @@ public class PropertyArrayMap extends Ar
          _getPartialStateHolderTracker(true).removeProperty(propKey);
        }
 
-       if (!useDeltas &&  propKey.isMutable())
+       if (!useDeltas &&  propKey.getMutable().isAtLeastSometimesMutable())
        {
          PropertyTracker mutableTracker = _getMutableTracker(false);
 
@@ -131,7 +131,7 @@ public class PropertyArrayMap extends Ar
         _getPartialStateHolderTracker(true).addProperty(key);
       }
 
-      if (!useDeltas && key.isMutable())
+      if (!useDeltas && key.getMutable().isAtLeastSometimesMutable())
       {
         Object value = t.get(key);
 
@@ -292,7 +292,7 @@ public class PropertyArrayMap extends Ar
 
     return a.equals(b);
   }
-
+  
   private PropertyTracker _getPartialStateHolderTracker(boolean create)
   {
     if (_tracker == null && create)

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyHashMap.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyHashMap.java?rev=1099931&r1=1099930&r2=1099931&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyHashMap.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/PropertyHashMap.java
Thu May  5 19:26:52 2011
@@ -19,9 +19,7 @@
 package org.apache.myfaces.trinidad.bean.util;
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
-
 import java.util.Set;
 
 import javax.el.ValueExpression;
@@ -69,10 +67,11 @@ public class PropertyHashMap extends Has
      Object retValue = super.put(key, value);
      if (_createDeltas())
      {
-       if (key.isMutable() || !_equals(value, retValue))
+       
+       if ( key.getMutable().isAtLeastSometimesMutable() || !_equals(value, retValue))
          _deltas.put(key, value);
      }
-     else if (key.isMutable() && !(value instanceof ValueExpression))
+     else if (key.getMutable().isAtLeastSometimesMutable() && !(value instanceof
ValueExpression))
      {
        _getMutableTracker(true).addProperty(key);
      }
@@ -109,7 +108,7 @@ public class PropertyHashMap extends Has
          _getPartialStateHolderTracker(true).removeProperty(propKey);
        }
        
-       if (!useDeltas &&  propKey.isMutable())
+       if (!useDeltas &&  propKey.getMutable().isAtLeastSometimesMutable())
        {
          PropertyTracker mutableTracker = _getMutableTracker(false);
          
@@ -137,7 +136,7 @@ public class PropertyHashMap extends Has
         _getPartialStateHolderTracker(true).addProperty(key);
       }  
       
-      if (!useDeltas && key.isMutable())
+      if (!useDeltas && key.getMutable().isAtLeastSometimesMutable())
       {
         Object value = t.get(key);
         

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/UINodeFacesBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/UINodeFacesBean.java?rev=1099931&r1=1099930&r2=1099931&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/UINodeFacesBean.java
(original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/UINodeFacesBean.java
Thu May  5 19:26:52 2011
@@ -6,9 +6,9 @@
  *  to you 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
@@ -86,9 +86,22 @@ public class UINodeFacesBean extends Fac
       int      capabilities,
       int      index)
     {
-      return new UINodePropertyKey(name, type, defaultValue, 
+      return new UINodePropertyKey(name, type, defaultValue,
                                    capabilities, index);
     }
+
+    @Override
+    protected PropertyKey createPropertyKey(
+      String              name,
+      Class<?>            type,
+      Object              defaultValue,
+      int                 capabilities,
+      int                 index,
+      PropertyKey.Mutable mutable)
+    {
+      return new UINodePropertyKey(name, type, defaultValue,
+                                   capabilities, index, mutable);
+    }
   }
 
   public UINodeFacesBean()
@@ -150,7 +163,7 @@ public class UINodeFacesBean extends Fac
       {
         setType(UINodeFacesBean.this.getType());
       }
-      
+
       @Override
       public Object put(PropertyKey key, Object value)
       {
@@ -329,7 +342,7 @@ public class UINodeFacesBean extends Fac
     _HAS_ICON_URL.add(UIXPanel.COMPONENT_FAMILY);
     // For "header"
     _HAS_ICON_URL.add(UIXShowDetail.COMPONENT_FAMILY);
-    
+
     // One reason components need ids when they submit events with source.
     // Another is PPR support.
     _ALWAYS_RENDER_ID.add(UIXShowDetail.COMPONENT_FAMILY);

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/UINodePropertyKey.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/UINodePropertyKey.java?rev=1099931&r1=1099930&r2=1099931&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/UINodePropertyKey.java
(original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/UINodePropertyKey.java
Thu May  5 19:26:52 2011
@@ -6,9 +6,9 @@
  *  to you 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
@@ -52,7 +52,18 @@ public class UINodePropertyKey extends P
     int      capabilities,
     int      index)
   {
-    super(name, type, defaultValue, capabilities, index);
+    this(name, type, defaultValue, capabilities, index, Mutable.IMMUTABLE);
+  }
+
+  UINodePropertyKey(
+    String              name,
+    Class<?>            type,
+    Object              defaultValue,
+    int                 capabilities,
+    int                 index,
+    PropertyKey.Mutable mutable)
+  {
+    super(name, type, defaultValue, capabilities, index, mutable);
     _attributeKey = _UICONSTANTS_KEYS.get(name);
   }
 



Mime
View raw message