You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mc...@apache.org on 2011/10/16 23:39:52 UTC

svn commit: r1184940 - /commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/OgnlRuntime.java

Author: mcucchiara
Date: Sun Oct 16 21:39:51 2011
New Revision: 1184940

URL: http://svn.apache.org/viewvc?rev=1184940&view=rev
Log:
_ctorParameterTypesCache now use the new cache implementation

Modified:
    commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/OgnlRuntime.java

Modified: commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/OgnlRuntime.java?rev=1184940&r1=1184939&r2=1184940&view=diff
==============================================================================
--- commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/OgnlRuntime.java (original)
+++ commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/OgnlRuntime.java Sun Oct 16 21:39:51 2011
@@ -198,8 +198,15 @@ public class OgnlRuntime
 
     static final Cache<GenericMethodParameterTypeCacheEntry, Class<?>[]> _genericMethodParameterTypesCache = new ConcurrentHashMapCache<GenericMethodParameterTypeCacheEntry, Class<?>[]>( new GenericMethodParameterTypeFactory( ) );;
 
-    static final Map<Constructor<?>, Class<?>[]> _ctorParameterTypesCache =
-        new HashMap<Constructor<?>, Class<?>[]>( 101 );
+    static final Cache<Constructor<?>, Class<?>[]> _ctorParameterTypesCache =
+        new ConcurrentHashMapCache<Constructor<?>, Class<?>[]>( new CacheEntryFactory<Constructor<?>, Class<?>[]>( )
+        {
+            public Class<?>[] create( Constructor<?> key )
+                throws CacheException
+            {
+                return key.getParameterTypes( );
+            }
+        });
 
     static SecurityManager _securityManager = System.getSecurityManager( );
 
@@ -723,17 +730,9 @@ public class OgnlRuntime
      * Returns the parameter types of the given method.
      */
     public static Class<?>[] getParameterTypes( Constructor<?> c )
+        throws CacheException
     {
-        synchronized ( _ctorParameterTypesCache )
-        {
-            Class<?>[] result;
-
-            if ( ( result = _ctorParameterTypesCache.get( c ) ) == null )
-            {
-                _ctorParameterTypesCache.put( c, result = c.getParameterTypes( ) );
-            }
-            return result;
-        }
+        return _ctorParameterTypesCache.get( c );
     }
 
     /**