Class ClassReflectionHelperImpl
java.lang.Object
org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl
- All Implemented Interfaces:
ClassReflectionHelper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LRUHybridCache
<Class<?>, Set<Field>> private final int
private final LRUHybridCache
<Class<?>, Set<MethodWrapper>> private final LRUHybridCache
<ClassReflectionHelperImpl.LifecycleKey, Method> private final LRUHybridCache
<ClassReflectionHelperImpl.LifecycleKey, Method> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Removes this class (and all appropriate sub-classes) from the cacheCreates a method wrapper from the given methodvoid
dispose()
Releases the entire cache, though the ClassReflectionHelper is still usable after calling disposefindPostConstruct
(Class<?> clazz, Class<?> matchingClass) Finds the postConstruct method on this classfindPreDestroy
(Class<?> clazz, Class<?> matchingClass) Finds the preDestroy method on this classgetAllFields
(Class<?> clazz) Gets all fields for a class (taking class heirarchy into account)getAllMethods
(Class<?> clazz) Gets all methods for a class (taking class heirarchy into account)private Method
getPostConstructMethod
(Class<?> clazz, Class<?> matchingClass) private Method
getPreDestroyMethod
(Class<?> clazz, Class<?> matchingClass) int
size()
Returns an approximation of the current size of the cachetoString()
-
Field Details
-
MAX_CACHE_SIZE
private final int MAX_CACHE_SIZE- See Also:
-
postConstructCache
-
preDestroyCache
-
methodCache
-
fieldCache
-
-
Constructor Details
-
ClassReflectionHelperImpl
public ClassReflectionHelperImpl()
-
-
Method Details
-
getAllMethods
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
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 Method findPostConstruct(Class<?> clazz, Class<?> matchingClass) throws 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:
IllegalArgumentException
- If a method marked as postConstruct is invalid
-
findPreDestroy
public Method findPreDestroy(Class<?> clazz, Class<?> matchingClass) throws 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:
IllegalArgumentException
- If a method marked as postConstruct is invalid
-
clean
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
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
-
getPreDestroyMethod
-
toString
-