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 intprivate final LRUHybridCache<Class<?>, Set<MethodWrapper>> private final LRUHybridCache<ClassReflectionHelperImpl.LifecycleKey, Method> private final LRUHybridCache<ClassReflectionHelperImpl.LifecycleKey, Method> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves this class (and all appropriate sub-classes) from the cacheCreates a method wrapper from the given methodvoiddispose()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 MethodgetPostConstructMethod(Class<?> clazz, Class<?> matchingClass) private MethodgetPreDestroyMethod(Class<?> clazz, Class<?> matchingClass) intsize()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: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
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 Method findPostConstruct(Class<?> clazz, Class<?> matchingClass) throws IllegalArgumentException Description 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:
IllegalArgumentException- If a method marked as postConstruct is invalid
-
findPreDestroy
public Method findPreDestroy(Class<?> clazz, Class<?> matchingClass) throws IllegalArgumentException Description 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:
IllegalArgumentException- If a method marked as postConstruct is invalid
-
clean
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
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
-
getPreDestroyMethod
-
toString
-