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/22 01:41:02 UTC
svn commit: r1187594 - in
/commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl:
OgnlRuntime.java internal/CacheFactory.java
internal/ConcurrentHashMapCacheFactory.java
Author: mcucchiara
Date: Fri Oct 21 23:41:02 2011
New Revision: 1187594
URL: http://svn.apache.org/viewvc?rev=1187594&view=rev
Log:
Added CacheFactory and his setter
Added:
commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/CacheFactory.java
commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java (contents, props changed)
- copied, changed from r1187585, commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/CacheFactory.java
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=1187594&r1=1187593&r2=1187594&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 Fri Oct 21 23:41:02 2011
@@ -28,6 +28,7 @@ import org.apache.commons.ognl.internal.
import org.apache.commons.ognl.internal.CacheFactory;
import org.apache.commons.ognl.internal.ClassCache;
import org.apache.commons.ognl.internal.ClassCacheHandler;
+import org.apache.commons.ognl.internal.ConcurrentHashMapCacheFactory;
import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
import org.apache.commons.ognl.internal.entry.DeclaredMethodCacheEntry;
@@ -156,19 +157,21 @@ public class OgnlRuntime
private static boolean _jdkChecked = false;
- static final ClassCache<MethodAccessor> _methodAccessors = CacheFactory.createClassCache( );
+ private static CacheFactory cacheFactory = new ConcurrentHashMapCacheFactory( );
- static final ClassCache<PropertyAccessor> _propertyAccessors = CacheFactory.createClassCache( );
+ static final ClassCache<MethodAccessor> _methodAccessors = cacheFactory.createClassCache( );
- static final ClassCache<ElementsAccessor> _elementsAccessors = CacheFactory.createClassCache( );
+ static final ClassCache<PropertyAccessor> _propertyAccessors = cacheFactory.createClassCache( );
- static final ClassCache<NullHandler> _nullHandlers = CacheFactory.createClassCache( );
+ static final ClassCache<ElementsAccessor> _elementsAccessors = cacheFactory.createClassCache( );
+
+ static final ClassCache<NullHandler> _nullHandlers = cacheFactory.createClassCache( );
static final ClassCache<Map<String, PropertyDescriptor>> _propertyDescriptorCache =
- CacheFactory.createClassCache( new PropertyDescriptorCacheEntryFactory( ) );
+ cacheFactory.createClassCache( new PropertyDescriptorCacheEntryFactory( ) );
static final ClassCache<List<Constructor<?>>> _constructorCache =
- CacheFactory.createClassCache( new ClassCacheEntryFactory<List<Constructor<?>>>( )
+ cacheFactory.createClassCache( new ClassCacheEntryFactory<List<Constructor<?>>>( )
{
public List<Constructor<?>> create( Class<?> key )
throws CacheException
@@ -178,20 +181,20 @@ public class OgnlRuntime
} );
static final Cache<DeclaredMethodCacheEntry, Map<String, List<Method>>> _methodCache =
- CacheFactory.createCache(new DeclaredMethodCacheEntryFactory( ) );
+ cacheFactory.createCache( new DeclaredMethodCacheEntryFactory( ) );
static final Cache<PermissionCacheEntry, Permission> _invokePermissionCache =
- CacheFactory.createCache( new PermissionCacheEntryFactory( ) );
+ cacheFactory.createCache( new PermissionCacheEntryFactory( ) );
static final ClassCache<Map<String, Field>> _fieldCache =
- CacheFactory.createClassCache( new FiedlCacheEntryFactory( ) );
+ cacheFactory.createClassCache( new FiedlCacheEntryFactory( ) );
static final Map<String, Class<?>> _primitiveTypes = new HashMap<String, Class<?>>( 101 );
- static final ClassCache<Object> _primitiveDefaults = CacheFactory.createClassCache( );
+ static final ClassCache<Object> _primitiveDefaults = cacheFactory.createClassCache( );
static final Cache<Method, Class<?>[]> _methodParameterTypesCache =
- CacheFactory.createCache( new CacheEntryFactory<Method, Class<?>[]>( )
+ cacheFactory.createCache( new CacheEntryFactory<Method, Class<?>[]>( )
{
public Class<?>[] create( Method key )
throws CacheException
@@ -201,10 +204,10 @@ public class OgnlRuntime
} );
static final Cache<GenericMethodParameterTypeCacheEntry, Class<?>[]> _genericMethodParameterTypesCache =
- CacheFactory.createCache( new GenericMethodParameterTypeFactory( ) );
+ cacheFactory.createCache( new GenericMethodParameterTypeFactory( ) );
static final Cache<Constructor<?>, Class<?>[]> _ctorParameterTypesCache =
- CacheFactory.createCache( new CacheEntryFactory<Constructor<?>, Class<?>[]>( )
+ cacheFactory.createCache( new CacheEntryFactory<Constructor<?>, Class<?>[]>( )
{
public Class<?>[] create( Constructor<?> key )
throws CacheException
@@ -220,13 +223,13 @@ public class OgnlRuntime
static final ObjectArrayPool _objectArrayPool = new ObjectArrayPool( );
static final Cache<Method, MethodAccessEntryValue> _methodAccessCache =
- CacheFactory.createCache( new MethodAccessCacheEntryFactory( ) );
+ cacheFactory.createCache( new MethodAccessCacheEntryFactory( ) );
private static final MethodPermCacheEntryFactory methodPermCacheEntryFactory =
new MethodPermCacheEntryFactory( _securityManager );
static final Cache<Method, Boolean> _methodPermCache =
- CacheFactory.createCache( methodPermCacheEntryFactory );
+ cacheFactory.createCache( methodPermCacheEntryFactory );
static ClassCacheInspector _cacheInspector;
@@ -2796,4 +2799,9 @@ public class OgnlRuntime
return source;
}
+
+ public static void setCacheFactory( CacheFactory cacheFactory )
+ {
+ OgnlRuntime.cacheFactory = cacheFactory;
+ }
}
Added: commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/CacheFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/CacheFactory.java?rev=1187594&view=auto
==============================================================================
--- commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/CacheFactory.java (added)
+++ commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/CacheFactory.java Fri Oct 21 23:41:02 2011
@@ -0,0 +1,18 @@
+package org.apache.commons.ognl.internal;
+
+import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
+import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/22/11
+ * Time: 1:35 AM
+ */
+public interface CacheFactory
+{
+ <K,V> Cache<K,V> createCache( CacheEntryFactory<K, V> entryFactory );
+
+ <V> ClassCache<V> createClassCache( );
+
+ <V> ClassCache<V> createClassCache( ClassCacheEntryFactory<V> entryFactory );
+}
Copied: commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java (from r1187585, commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/CacheFactory.java)
URL: http://svn.apache.org/viewvc/commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java?p2=commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java&p1=commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/CacheFactory.java&r1=1187585&r2=1187594&rev=1187594&view=diff
==============================================================================
--- commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/CacheFactory.java (original)
+++ commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java Fri Oct 21 23:41:02 2011
@@ -24,20 +24,21 @@ package org.apache.commons.ognl.internal
import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
-public class CacheFactory
+public class ConcurrentHashMapCacheFactory
+ implements CacheFactory
{
- public static <K,V> Cache<K,V> createCache(CacheEntryFactory<K,V> entryFactory )
+ public <K,V> Cache<K,V> createCache(CacheEntryFactory<K,V> entryFactory )
{
return new ConcurrentHashMapCache<K, V>(entryFactory );
}
- public static <V> ClassCache<V> createClassCache( )
+ public <V> ClassCache<V> createClassCache( )
{
return createClassCache( null );
}
- public static <V> ClassCache<V> createClassCache( ClassCacheEntryFactory<V> entryFactory )
+ public <V> ClassCache<V> createClassCache( ClassCacheEntryFactory<V> entryFactory )
{
return new ConcurrentHashMapClassCache<V>(entryFactory );
}
Propchange: commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/ognl/branches/new-cache-approach/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL