Class IntrospectorCache
- java.lang.Object
-
- org.apache.velocity.util.introspection.IntrospectorCache
-
public final class IntrospectorCache extends java.lang.ObjectThis is the internal introspector cache implementation.- Since:
- 1.5
- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCACHEDUMP_MSGdefine a public string so that it can be looked for if interestedprivate java.util.Map<java.lang.Class<?>,ClassFieldMap>classFieldMapCacheHolds the field maps for the classes we know about.private java.util.Map<java.lang.Class<?>,ClassMap>classMapCacheHolds the method maps for the classes we know about.private java.util.Set<java.lang.String>classNameCacheKeep the names of the classes in another map.private TypeConversionHandlerconversionHandlerConversion handlerprivate org.slf4j.LoggerlogClass logger
-
Constructor Summary
Constructors Constructor Description IntrospectorCache(org.slf4j.Logger log, TypeConversionHandler conversionHandler)C'tor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the internal cache.ClassMapget(java.lang.Class<?> c)Lookup a given Class object in the cache.ClassFieldMapgetFieldMap(java.lang.Class<?> c)Lookup a given Class object in the cache.ClassMapput(java.lang.Class<?> c)Creates a class map for specific class and registers it in the cache.
-
-
-
Field Detail
-
CACHEDUMP_MSG
public static final java.lang.String CACHEDUMP_MSG
define a public string so that it can be looked for if interested- See Also:
- Constant Field Values
-
log
private final org.slf4j.Logger log
Class logger
-
classMapCache
private final java.util.Map<java.lang.Class<?>,ClassMap> classMapCache
Holds the method maps for the classes we know about. Map: Class --> ClassMap object.
-
classFieldMapCache
private final java.util.Map<java.lang.Class<?>,ClassFieldMap> classFieldMapCache
Holds the field maps for the classes we know about. Map: Class --> ClassFieldMap object.
-
classNameCache
private final java.util.Set<java.lang.String> classNameCache
Keep the names of the classes in another map. This is needed for a multi-classloader environment where it is possible to have Class 'Foo' loaded by a classloader and then get asked to introspect on 'Foo' from another class loader. While these two Class objects have the same name, aclassMethodMaps.get(Foo.class)will return null. For that case, we keep a set of class names to recognize this case.
-
conversionHandler
private final TypeConversionHandler conversionHandler
Conversion handler
-
-
Constructor Detail
-
IntrospectorCache
public IntrospectorCache(org.slf4j.Logger log, TypeConversionHandler conversionHandler)C'tor- Parameters:
log- logger.conversionHandler- conversion handler
-
-
Method Detail
-
clear
public void clear()
Clears the internal cache.
-
get
public ClassMap get(java.lang.Class<?> c)
Lookup a given Class object in the cache. If it does not exist, check whether this is due to a class change and purge the caches eventually.- Parameters:
c- The class to look up.- Returns:
- A ClassMap object or null if it does not exist in the cache.
-
getFieldMap
public ClassFieldMap getFieldMap(java.lang.Class<?> c)
Lookup a given Class object in the cache. If it does not exist, check whether this is due to a class change and purge the caches eventually.- Parameters:
c- The class to look up.- Returns:
- A ClassFieldMap object or null if it does not exist in the cache.
-
put
public ClassMap put(java.lang.Class<?> c)
Creates a class map for specific class and registers it in the cache. Also adds the qualified name to the name->class map for later Classloader change detection.- Parameters:
c- The class for which the class map gets generated.- Returns:
- A ClassMap object.
-
-