Class ClassReflectionHelperImpl
- java.lang.Object
-
- org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl
-
- All Implemented Interfaces:
ClassReflectionHelper
public class ClassReflectionHelperImpl extends java.lang.Object implements ClassReflectionHelper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classClassReflectionHelperImpl.LifecycleKey
-
Field Summary
Fields Modifier and Type Field Description private LRUHybridCache<java.lang.Class<?>,java.util.Set<java.lang.reflect.Field>>fieldCacheprivate intMAX_CACHE_SIZEprivate LRUHybridCache<java.lang.Class<?>,java.util.Set<MethodWrapper>>methodCacheprivate LRUHybridCache<ClassReflectionHelperImpl.LifecycleKey,java.lang.reflect.Method>postConstructCacheprivate LRUHybridCache<ClassReflectionHelperImpl.LifecycleKey,java.lang.reflect.Method>preDestroyCache
-
Constructor Summary
Constructors Constructor Description ClassReflectionHelperImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclean(java.lang.Class<?> clazz)Removes this class (and all appropriate sub-classes) from the cacheMethodWrappercreateMethodWrapper(java.lang.reflect.Method m)Creates a method wrapper from the given methodvoiddispose()Releases the entire cache, though the ClassReflectionHelper is still usable after calling disposejava.lang.reflect.MethodfindPostConstruct(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass)Finds the postConstruct method on this classjava.lang.reflect.MethodfindPreDestroy(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass)Finds the preDestroy method on this classjava.util.Set<java.lang.reflect.Field>getAllFields(java.lang.Class<?> clazz)Gets all fields for a class (taking class heirarchy into account)java.util.Set<MethodWrapper>getAllMethods(java.lang.Class<?> clazz)Gets all methods for a class (taking class heirarchy into account)private java.lang.reflect.MethodgetPostConstructMethod(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass)private java.lang.reflect.MethodgetPreDestroyMethod(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass)intsize()Returns an approximation of the current size of the cachejava.lang.StringtoString()
-
-
-
Field Detail
-
MAX_CACHE_SIZE
private final int MAX_CACHE_SIZE
- See Also:
- Constant Field Values
-
postConstructCache
private final LRUHybridCache<ClassReflectionHelperImpl.LifecycleKey,java.lang.reflect.Method> postConstructCache
-
preDestroyCache
private final LRUHybridCache<ClassReflectionHelperImpl.LifecycleKey,java.lang.reflect.Method> preDestroyCache
-
methodCache
private final LRUHybridCache<java.lang.Class<?>,java.util.Set<MethodWrapper>> methodCache
-
fieldCache
private final LRUHybridCache<java.lang.Class<?>,java.util.Set<java.lang.reflect.Field>> fieldCache
-
-
Method Detail
-
getAllMethods
public java.util.Set<MethodWrapper> getAllMethods(java.lang.Class<?> clazz)
Description copied from interface:ClassReflectionHelperGets all methods for a class (taking class heirarchy into account)- Specified by:
getAllMethodsin interfaceClassReflectionHelper- Parameters:
clazz- The class to analyze for all methods- Returns:
- The set of all methods on this class (and all subclasses)
-
getAllFields
public java.util.Set<java.lang.reflect.Field> getAllFields(java.lang.Class<?> clazz)
Description copied from interface:ClassReflectionHelperGets all fields for a class (taking class heirarchy into account)- Specified by:
getAllFieldsin interfaceClassReflectionHelper- Parameters:
clazz- The class to analyze for all fields- Returns:
- The set of all fields on this class (and all subclasses)
-
findPostConstruct
public java.lang.reflect.Method findPostConstruct(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass) throws java.lang.IllegalArgumentExceptionDescription copied from interface:ClassReflectionHelperFinds the postConstruct method on this class- Specified by:
findPostConstructin interfaceClassReflectionHelper- Parameters:
clazz- The class to check for the postConstruct methodmatchingClass- The PostConstruct interface, a small performance improvement- Returns:
- A matching method, or null if none can be found
- Throws:
java.lang.IllegalArgumentException- If a method marked as postConstruct is invalid
-
findPreDestroy
public java.lang.reflect.Method findPreDestroy(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass) throws java.lang.IllegalArgumentExceptionDescription copied from interface:ClassReflectionHelperFinds the preDestroy method on this class- Specified by:
findPreDestroyin interfaceClassReflectionHelper- Parameters:
clazz- The class to check for the postConstruct methodmatchingClass- The PostConstruct interface, a small performance improvement- Returns:
- A matching method, or null if none can be found
- Throws:
java.lang.IllegalArgumentException- If a method marked as postConstruct is invalid
-
clean
public void clean(java.lang.Class<?> clazz)
Description copied from interface:ClassReflectionHelperRemoves this class (and all appropriate sub-classes) from the cache- Specified by:
cleanin interfaceClassReflectionHelper- Parameters:
clazz- The class to remove. If null this method does nothing
-
createMethodWrapper
public MethodWrapper createMethodWrapper(java.lang.reflect.Method m)
Description copied from interface:ClassReflectionHelperCreates a method wrapper from the given method- Specified by:
createMethodWrapperin interfaceClassReflectionHelper- Parameters:
m- A non-null method to create a wrapper from- Returns:
- A method wrapper
-
dispose
public void dispose()
Description copied from interface:ClassReflectionHelperReleases the entire cache, though the ClassReflectionHelper is still usable after calling dispose- Specified by:
disposein interfaceClassReflectionHelper
-
size
public int size()
Description copied from interface:ClassReflectionHelperReturns an approximation of the current size of the cache- Specified by:
sizein interfaceClassReflectionHelper- Returns:
- An approximation of the current size of the cache
-
getPostConstructMethod
private java.lang.reflect.Method getPostConstructMethod(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass)
-
getPreDestroyMethod
private java.lang.reflect.Method getPreDestroyMethod(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-