@Singleton @Named(value="default") @Visibility(value=LOCAL) public class DefaultClassAnalyzer extends java.lang.Object implements ClassAnalyzer
Modifier and Type | Field and Description |
---|---|
private ServiceLocatorImpl |
locator |
DEFAULT_IMPLEMENTATION_NAME
Constructor and Description |
---|
DefaultClassAnalyzer(ServiceLocatorImpl locator)
The DefaultClassAnalyzer is per ServiceLocatorImpl
|
Modifier and Type | Method and Description |
---|---|
<T> java.lang.reflect.Constructor<T> |
getConstructor(java.lang.Class<T> clazz)
Will return the constructor that it to be used when constructing this
service
|
<T> java.util.Set<java.lang.reflect.Field> |
getFields(java.lang.Class<T> clazz)
Will return the set of initializer fields to be used when initializing
this service
|
<T> java.util.Set<java.lang.reflect.Method> |
getInitializerMethods(java.lang.Class<T> clazz)
Will return the set of initializer method to be used when initializing
this service
|
<T> java.lang.reflect.Method |
getPostConstructMethod(java.lang.Class<T> clazz)
Will return the postConstruct method of the class
|
<T> java.lang.reflect.Method |
getPreDestroyMethod(java.lang.Class<T> clazz)
Will return the preDestroy method of the class
|
private final ServiceLocatorImpl locator
public DefaultClassAnalyzer(ServiceLocatorImpl locator)
locator
- The non-null locator associated with this analyzerpublic <T> java.lang.reflect.Constructor<T> getConstructor(java.lang.Class<T> clazz) throws MultiException, java.lang.NoSuchMethodException
ClassAnalyzer
The default implementation will use the zero-arg constructor if no single
constructor with Inject is found. Also will return any constructor
that is covered by an InjectionResolver
and the
InjectionResolver.isConstructorParameterIndicator()
is
set to true
getConstructor
in interface ClassAnalyzer
clazz
- the non-null class to analyzeMultiException
- on an error when analyzing the classjava.lang.NoSuchMethodException
- if there was no available constructorpublic <T> java.util.Set<java.lang.reflect.Method> getInitializerMethods(java.lang.Class<T> clazz) throws MultiException
ClassAnalyzer
The default implementation will return all methods marked with Inject
or that have a parameter that is covered by an InjectionResolver
and the InjectionResolver.isMethodParameterIndicator()
is set
to true. Also, any method that has a parameter marked with
SubscribeTo
will NOT be returned,
as these methods are instead meant to be called when an event is fired
getInitializerMethods
in interface ClassAnalyzer
clazz
- the non-null class to analyzeMultiException
- on an error when analyzing the classpublic <T> java.util.Set<java.lang.reflect.Field> getFields(java.lang.Class<T> clazz) throws MultiException
ClassAnalyzer
The default implementation will return all fields marked with Inject
or that have a parameter that is covered by an InjectionResolver
getFields
in interface ClassAnalyzer
clazz
- the non-null class to analyzeMultiException
- on an error when analyzing the classpublic <T> java.lang.reflect.Method getPostConstructMethod(java.lang.Class<T> clazz) throws MultiException
ClassAnalyzer
The default implementation will return the PostConstruct.postConstruct()
method or the method annotated with PostConstruct
getPostConstructMethod
in interface ClassAnalyzer
clazz
- the non-null class to analyzeMultiException
- on an error when analyzing the classpublic <T> java.lang.reflect.Method getPreDestroyMethod(java.lang.Class<T> clazz) throws MultiException
ClassAnalyzer
The default implementation will return the PreDestroy.preDestroy()
method or the method annotated with PreDestroy
getPreDestroyMethod
in interface ClassAnalyzer
clazz
- the non-null class to analyzeMultiException
- on an error when analyzing the class