public class ClassReflectionHelperImpl extends java.lang.Object implements ClassReflectionHelper
Modifier and Type | Class and Description |
---|---|
private static class |
ClassReflectionHelperImpl.LifecycleKey |
Modifier and Type | Field and 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 and Description |
---|
ClassReflectionHelperImpl() |
Modifier and Type | Method and Description |
---|---|
void |
clean(java.lang.Class<?> clazz)
Removes this class (and all appropriate sub-classes) from the cache
|
MethodWrapper |
createMethodWrapper(java.lang.reflect.Method m)
Creates a method wrapper from the given method
|
void |
dispose()
Releases the entire cache, though the ClassReflectionHelper is
still usable after calling dispose
|
java.lang.reflect.Method |
findPostConstruct(java.lang.Class<?> clazz,
java.lang.Class<?> matchingClass)
Finds the postConstruct method on this class
|
java.lang.reflect.Method |
findPreDestroy(java.lang.Class<?> clazz,
java.lang.Class<?> matchingClass)
Finds the preDestroy method on this class
|
java.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 cache
|
java.lang.String |
toString() |
private final int MAX_CACHE_SIZE
private final LRUHybridCache<ClassReflectionHelperImpl.LifecycleKey,java.lang.reflect.Method> postConstructCache
private final LRUHybridCache<ClassReflectionHelperImpl.LifecycleKey,java.lang.reflect.Method> preDestroyCache
private final LRUHybridCache<java.lang.Class<?>,java.util.Set<MethodWrapper>> methodCache
private final LRUHybridCache<java.lang.Class<?>,java.util.Set<java.lang.reflect.Field>> fieldCache
public java.util.Set<MethodWrapper> getAllMethods(java.lang.Class<?> clazz)
ClassReflectionHelper
getAllMethods
in interface ClassReflectionHelper
clazz
- The class to analyze for all methodspublic java.util.Set<java.lang.reflect.Field> getAllFields(java.lang.Class<?> clazz)
ClassReflectionHelper
getAllFields
in interface ClassReflectionHelper
clazz
- The class to analyze for all fieldspublic java.lang.reflect.Method findPostConstruct(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass) throws java.lang.IllegalArgumentException
ClassReflectionHelper
findPostConstruct
in interface ClassReflectionHelper
clazz
- The class to check for the postConstruct methodmatchingClass
- The PostConstruct interface, a small performance improvementjava.lang.IllegalArgumentException
- If a method marked as postConstruct is invalidpublic java.lang.reflect.Method findPreDestroy(java.lang.Class<?> clazz, java.lang.Class<?> matchingClass) throws java.lang.IllegalArgumentException
ClassReflectionHelper
findPreDestroy
in interface ClassReflectionHelper
clazz
- The class to check for the postConstruct methodmatchingClass
- The PostConstruct interface, a small performance improvementjava.lang.IllegalArgumentException
- If a method marked as postConstruct is invalidpublic void clean(java.lang.Class<?> clazz)
ClassReflectionHelper
clean
in interface ClassReflectionHelper
clazz
- The class to remove. If null this method does nothingpublic MethodWrapper createMethodWrapper(java.lang.reflect.Method m)
ClassReflectionHelper
createMethodWrapper
in interface ClassReflectionHelper
m
- A non-null method to create a wrapper frompublic void dispose()
ClassReflectionHelper
dispose
in interface ClassReflectionHelper
public int size()
ClassReflectionHelper
size
in interface ClassReflectionHelper
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)
public java.lang.String toString()
toString
in class java.lang.Object