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:32:20 UTC
svn commit: r1184936 -
/commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
Author: mcucchiara
Date: Sun Oct 16 21:32:20 2011
New Revision: 1184936
URL: http://svn.apache.org/viewvc?rev=1184936&view=rev
Log:
new _methodParameterTypesCache 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=1184936&r1=1184935&r2=1184936&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:32:20 2011
@@ -29,6 +29,7 @@ import org.apache.commons.ognl.internal.
import org.apache.commons.ognl.internal.ClassCacheHandler;
import org.apache.commons.ognl.internal.ConcurrentClassCache;
import org.apache.commons.ognl.internal.ConcurrentHashMapCache;
+import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
import org.apache.commons.ognl.internal.entry.ConstructorCacheEntryFactory;
import org.apache.commons.ognl.internal.entry.DeclaredMethodCacheEntry;
import org.apache.commons.ognl.internal.entry.DeclaredMethodCacheEntryFactory;
@@ -179,7 +180,14 @@ public class OgnlRuntime
static final ClassCache _primitiveDefaults = new ConcurrentClassCache( );
- static final Map<Method, Class<?>[]> _methodParameterTypesCache = new HashMap<Method, Class<?>[]>( 101 );
+ static final Cache<Method, Class<?>[]> _methodParameterTypesCache = new ConcurrentHashMapCache<Method, Class<?>[]>( new CacheEntryFactory<Method, Class<?>[]>( )
+ {
+ public Class<?>[] create( Method key )
+ throws CacheException
+ {
+ return key.getParameterTypes( );
+ }
+ } );
static final Cache<GenericMethodParameterTypeCacheEntry, Class<?>[]> _genericMethodParameterTypesCache = new ConcurrentHashMapCache<GenericMethodParameterTypeCacheEntry, Class<?>[]>( new GenericMethodParameterTypeFactory( ) );;
@@ -649,17 +657,10 @@ public class OgnlRuntime
* Returns the parameter types of the given method.
*/
public static Class<?>[] getParameterTypes( Method m )
+ throws CacheException
{
- synchronized ( _methodParameterTypesCache )
- {
- Class<?>[] result;
+ return _methodParameterTypesCache.get( m );
- if ( ( result = _methodParameterTypesCache.get( m ) ) == null )
- {
- _methodParameterTypesCache.put( m, result = m.getParameterTypes( ) );
- }
- return result;
- }
}
/**
@@ -1939,6 +1940,7 @@ public class OgnlRuntime
}
private static boolean indexMethodCheck( List<Method> methods )
+ throws CacheException
{
boolean result = false;