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 class
ClassReflectionHelperImpl.LifecycleKey
-
Field Summary
Fields Modifier and Type Field Description private LRUHybridCache<java.lang.Class<?>,java.util.Set<java.lang.reflect.Field>>
fieldCache
private int
MAX_CACHE_SIZE
private LRUHybridCache<java.lang.Class<?>,java.util.Set<MethodWrapper>>
methodCache
private LRUHybridCache<ClassReflectionHelperImpl.LifecycleKey,java.lang.reflect.Method>
postConstructCache
private 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 void
clean(java.lang.Class<?> clazz)
Removes this class (and all appropriate sub-classes) from the cacheMethodWrapper
createMethodWrapper(java.lang.reflect.Method m)
Creates a method wrapper from the given methodvoid
dispose()
Releases the entire cache, though the ClassReflectionHelper is still usable after calling disposejava.lang.reflect.Method
findPostConstruct(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass)
Finds the postConstruct method on this classjava.lang.reflect.Method
findPreDestroy(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.Method
getPostConstructMethod(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass)
private java.lang.reflect.Method
getPreDestroyMethod(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass)
int
size()
Returns an approximation of the current size of the cachejava.lang.String
toString()
-
-
-
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:ClassReflectionHelper
Gets all methods for a class (taking class heirarchy into account)- Specified by:
getAllMethods
in 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:ClassReflectionHelper
Gets all fields for a class (taking class heirarchy into account)- Specified by:
getAllFields
in 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.IllegalArgumentException
Description copied from interface:ClassReflectionHelper
Finds the postConstruct method on this class- Specified by:
findPostConstruct
in 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.IllegalArgumentException
Description copied from interface:ClassReflectionHelper
Finds the preDestroy method on this class- Specified by:
findPreDestroy
in 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:ClassReflectionHelper
Removes this class (and all appropriate sub-classes) from the cache- Specified by:
clean
in 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:ClassReflectionHelper
Creates a method wrapper from the given method- Specified by:
createMethodWrapper
in interfaceClassReflectionHelper
- Parameters:
m
- A non-null method to create a wrapper from- Returns:
- A method wrapper
-
dispose
public void dispose()
Description copied from interface:ClassReflectionHelper
Releases the entire cache, though the ClassReflectionHelper is still usable after calling dispose- Specified by:
dispose
in interfaceClassReflectionHelper
-
size
public int size()
Description copied from interface:ClassReflectionHelper
Returns an approximation of the current size of the cache- Specified by:
size
in 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:
toString
in classjava.lang.Object
-
-