jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hor...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl ELEvaluator.java Evaluator.java
Date Thu, 21 Oct 2004 00:58:23 GMT
horwat      2004/10/20 17:58:23

  Modified:    standard/doc/web Tag: STANDARD_1_0_BRANCH ReleaseNotes.html
               standard/src/org/apache/taglibs/standard/lang/jstl Tag:
                        STANDARD_1_0_BRANCH ELEvaluator.java Evaluator.java
  Added:       standard/src/org/apache/taglibs/standard/extra/collections
                        Tag: STANDARD_1_0_BRANCH BoundedMap.java
                        IterableMap.java KeyValue.java MapIterator.java
                        OrderedIterator.java OrderedMap.java
                        OrderedMapIterator.java README.txt
                        ResettableIterator.java
               standard/src/org/apache/taglibs/standard/extra/collections/iterators
                        Tag: STANDARD_1_0_BRANCH AbstractEmptyIterator.java
                        EmptyIterator.java EmptyMapIterator.java
                        EmptyOrderedIterator.java
                        EmptyOrderedMapIterator.java
               standard/src/org/apache/taglibs/standard/extra/collections/map
                        Tag: STANDARD_1_0_BRANCH AbstractHashedMap.java
                        AbstractLinkedMap.java LRUMap.java
  Log:
  Bugzilla #31789
  http://issues.apache.org/bugzilla/show_bug.cgi?id=31789
  
  NOTE: With JSTL 1.1 Commons EL needs to be modified to address this issue. The JSP EG should
be involved in determining the best caching mechanism
  
  Copied Jakarta Commons Collections LRUMap implementation and dependencies. ELEvaluator now
uses an LRU Map. The map size can be customized using a context initialization parameter.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.37.2.13 +17 -0     jakarta-taglibs/standard/doc/web/ReleaseNotes.html
  
  Index: ReleaseNotes.html
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/doc/web/ReleaseNotes.html,v
  retrieving revision 1.37.2.12
  retrieving revision 1.37.2.13
  diff -u -r1.37.2.12 -r1.37.2.13
  --- ReleaseNotes.html	18 Oct 2004 22:40:08 -0000	1.37.2.12
  +++ ReleaseNotes.html	21 Oct 2004 00:58:23 -0000	1.37.2.13
  @@ -22,6 +22,23 @@
   <p>The Standard Taglib, which is hosted at Apache, is used as the source repository
for the <a href="http://java.sun.com/products/jstl">JSTL 1.0 reference implementation</a>
supplied by Sun Microsystems, Inc.</p>
   <hr/>
   
  +<h2>Configuration Parameters</h2>
  +<p>In addition to the parameters defined in the JSTL 1.0 specification, you can use
the following context initialization parameter to customize JSTL implementation behavior:</p>
  +<table width="95%" border="1">
  +  <tr>
  +    <th width="27%">
  +      <div align="center">Name</div>
  +    </th>
  +    <th width="73%">Value</th>
  +  </tr> 
  +  <tr>
  +    <td width="27%">
  +      <div align="center">org.apache.taglibs.standard.lang.jstl.exprCacheSize</div>
  +    </td>
  +    <td width="73%">The LRU cache size for expression strings. Default value is 100.
You may require a bigger cache depending on your configuration.</td>
  +  </tr> 
  +</table>
  +
   <h2>Release History</h2>
   
   <dt><b>Current &#x2022; Changes since Standard 1.0.6 release</b></dt>
  
  
  
  No                   revision
  No                   revision
  1.1.2.1   +48 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/Attic/BoundedMap.java
  
  
  
  
  1.1.2.1   +61 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/Attic/IterableMap.java
  
  
  
  
  1.1.2.1   +46 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/Attic/KeyValue.java
  
  
  
  
  1.1.2.1   +108 -0    jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/Attic/MapIterator.java
  
  
  
  
  1.1.2.1   +47 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/Attic/OrderedIterator.java
  
  
  
  
  1.1.2.1   +81 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/Attic/OrderedMap.java
  
  
  
  
  1.1.2.1   +45 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/Attic/OrderedMapIterator.java
  
  
  
  
  1.1.2.1   +10 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/Attic/README.txt
  
  
  
  
  1.1.2.1   +38 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/Attic/ResettableIterator.java
  
  
  
  
  No                   revision
  No                   revision
  1.1.2.1   +89 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/iterators/Attic/AbstractEmptyIterator.java
  
  
  
  
  1.1.2.1   +54 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/iterators/Attic/EmptyIterator.java
  
  
  
  
  1.1.2.1   +44 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/iterators/Attic/EmptyMapIterator.java
  
  
  
  
  1.1.2.1   +44 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/iterators/Attic/EmptyOrderedIterator.java
  
  
  
  
  1.1.2.1   +44 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/iterators/Attic/EmptyOrderedMapIterator.java
  
  
  
  
  No                   revision
  No                   revision
  1.1.2.1   +1327 -0   jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/map/Attic/AbstractHashedMap.java
  
  
  
  
  1.1.2.1   +608 -0    jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/map/Attic/AbstractLinkedMap.java
  
  
  
  
  1.1.2.1   +391 -0    jakarta-taglibs/standard/src/org/apache/taglibs/standard/extra/collections/map/Attic/LRUMap.java
  
  
  
  
  No                   revision
  No                   revision
  1.3.2.3   +66 -18    jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/ELEvaluator.java
  
  Index: ELEvaluator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/ELEvaluator.java,v
  retrieving revision 1.3.2.2
  retrieving revision 1.3.2.3
  diff -u -r1.3.2.2 -r1.3.2.3
  --- ELEvaluator.java	28 Feb 2004 06:08:08 -0000	1.3.2.2
  +++ ELEvaluator.java	21 Oct 2004 00:58:23 -0000	1.3.2.3
  @@ -27,6 +27,10 @@
   import org.apache.taglibs.standard.lang.jstl.parser.ParseException;
   import org.apache.taglibs.standard.lang.jstl.parser.Token;
   import org.apache.taglibs.standard.lang.jstl.parser.TokenMgrError;
  +import org.apache.taglibs.standard.extra.commons.collections.map.LRUMap;
  +
  +import javax.servlet.jsp.PageContext;
  +import javax.servlet.jsp.jstl.core.Config;
   
   /**
    *
  @@ -89,14 +93,30 @@
     // Member variables
     //-------------------------------------
   
  +  /**
  +   * Name of configuration setting for maximum number of entries in the
  +   * cached expression string map
  +   */
  +  private static final String EXPR_CACHE_PARAM
  +    = "org.apache.taglibs.standard.lang.jstl.exprCacheSize";
  +  /**
  +   * Default maximum  cache size
  +   */
  +  private static final int MAX_SIZE = 100;
  +
     /** The mapping from expression String to its parsed form (String,
  -      Expression, or ExpressionString) **/
  -  static Map sCachedExpressionStrings = 
  -    Collections.synchronizedMap (new HashMap ());
  +   *  Expression, or ExpressionString)
  +   *
  +   *  Using LRU Map with a maximum capacity to avoid out of bound map
  +   *  growth.
  +   *
  +   *  NOTE: use LinkedHashmap if a dependency on J2SE 1.4+ is ok
  +   */
  +  static Map sCachedExpressionStrings = null;
   
     /** The mapping from ExpectedType to Maps mapping literal String to
         parsed value **/
  -  static Map sCachedExpectedTypes = new HashMap ();
  +  static Map sCachedExpectedTypes = new HashMap();
   
     /** The static Logger **/
     static Logger sLogger = new Logger (System.out);
  @@ -107,6 +127,10 @@
     /** Flag if the cache should be bypassed **/
     boolean mBypassCache;
   
  +  /** The PageContext **/
  +  PageContext pageContext;
  +
  +
     //-------------------------------------
     /**
      *
  @@ -123,20 +147,11 @@
   
     //-------------------------------------
     /**
  +   * Enable cache bypass
      *
  -   * Constructor
  -   *
  -   * @param pResolver the object that should be used to resolve
  -   * variable names encountered in expressions.  If null, all variable
  -   * references will resolve to null.
  -   *
  -   * @param pBypassCache flag indicating if the cache should be
  -   * bypassed
  +   * @param pBypassCache flag indicating cache should be bypassed
      **/
  -  public ELEvaluator (VariableResolver pResolver,
  -		      boolean pBypassCache)
  -  {
  -    mResolver = pResolver;
  +  public void setBypassCache(boolean pBypassCache) {
       mBypassCache = pBypassCache;
     }
   
  @@ -187,6 +202,9 @@
   	(Constants.NULL_EXPRESSION_STRING);
       }
   
  +    // Set the PageContext;
  +    pageContext = (PageContext) pContext;
  +
       // Get the parsed version of the expression string
       Object parsedValue = parseExpressionString (pExpressionString);
   
  @@ -247,6 +265,10 @@
         return "";
       }
   
  +    if (!(mBypassCache) && (sCachedExpressionStrings == null)) {
  +      createExpressionStringMap();
  +    }
  +
       // See if it's in the cache
       Object ret = 
         mBypassCache ?
  @@ -259,7 +281,9 @@
         ELParser parser = new ELParser (r);
         try {
   	ret = parser.ExpressionString ();
  -	sCachedExpressionStrings.put (pExpressionString, ret);
  +        if (!mBypassCache) {
  +	  sCachedExpressionStrings.put (pExpressionString, ret);
  +        }
         }
         catch (ParseException exc) {
   	throw new ELException 
  @@ -339,6 +363,30 @@
         }
         return ret;
       }
  +  }
  +
  +  //-------------------------------------
  +  /**
  +   *
  +   * Creates LRU map of expression strings. If context parameter
  +   * specifying cache size is present use that as the maximum size
  +   * of the LRU map otherwise use default.
  +   **/
  +  private synchronized void createExpressionStringMap () {
  +      if (sCachedExpressionStrings != null) {
  +        return;
  +      }
  +
  +      String value = pageContext.getServletContext().
  +                     getInitParameter(EXPR_CACHE_PARAM);
  +      if (value != null) {
  +        sCachedExpressionStrings = 
  +          Collections.synchronizedMap(new LRUMap(Integer.parseInt(value)));
  +      }
  +      else {
  +        sCachedExpressionStrings = 
  +          Collections.synchronizedMap(new LRUMap(MAX_SIZE));
  +      }
     }
   
     //-------------------------------------
  
  
  
  1.10.2.3  +3 -1      jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/Evaluator.java
  
  Index: Evaluator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/Evaluator.java,v
  retrieving revision 1.10.2.2
  retrieving revision 1.10.2.3
  diff -u -r1.10.2.2 -r1.10.2.3
  --- Evaluator.java	28 Feb 2004 06:08:08 -0000	1.10.2.2
  +++ Evaluator.java	21 Oct 2004 00:58:23 -0000	1.10.2.3
  @@ -68,7 +68,9 @@
   			  String pAttributeValue)
     {
       try {
  +      sEvaluator.setBypassCache(true);
         sEvaluator.parseExpressionString (pAttributeValue);
  +      sEvaluator.setBypassCache(false);
         return null;
       }
       catch (ELException exc) {
  
  
  

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


Mime
View raw message