Interface ClassAnalyzer
- All Known Implementing Classes:
DefaultClassAnalyzer
HK2 will provide a default implementation of this service (with the name "default"). However, individual descriptors may choose a different class analyzer should they so choose. All user supplied implementations of this service must have a name. Implementations of this service must not be ClassAnalyzers for themselves.
The method ServiceLocator.setDefaultClassAnalyzerName(String)
can be used
to set the global ClassAnalyzer name that will be the name of the ClassAnalyzer used
when the method Descriptor.getClassAnalysisName()
returns null
Implementations of ClassAnalyzer will be instantiated as soon as
they are added to HK2 in order to avoid deadlocks and circular references.
Therefore it is recommended that implementations of ClassAnalyzer
make liberal use of Provider
or IterableProvider
when injecting dependent services so that these services are not instantiated
when the ClassAnalyzer is created
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The name of the default ClassAnalyzer service -
Method Summary
Modifier and TypeMethodDescription<T> Constructor
<T> getConstructor
(Class<T> clazz) Will return the constructor that it to be used when constructing this serviceWill return the set of initializer fields to be used when initializing this servicegetInitializerMethods
(Class<T> clazz) Will return the set of initializer method to be used when initializing this service<T> Method
getPostConstructMethod
(Class<T> clazz) Will return the postConstruct method of the class<T> Method
getPreDestroyMethod
(Class<T> clazz) Will return the preDestroy method of the class
-
Field Details
-
DEFAULT_IMPLEMENTATION_NAME
The name of the default ClassAnalyzer service- See Also:
-
-
Method Details
-
getConstructor
Will return the constructor that it to be used when constructing this serviceThe 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 theInjectionResolver.isConstructorParameterIndicator()
is set to true- Parameters:
clazz
- the non-null class to analyze- Returns:
- The non-null constructor to use for creating this service
- Throws:
MultiException
- on an error when analyzing the classNoSuchMethodException
- if there was no available constructor
-
getInitializerMethods
Will return the set of initializer method to be used when initializing this serviceThe default implementation will return all methods marked with Inject or that have a parameter that is covered by an
InjectionResolver
and theInjectionResolver.isMethodParameterIndicator()
is set to true. Also, any method that has a parameter marked withSubscribeTo
will NOT be returned, as these methods are instead meant to be called when an event is fired- Parameters:
clazz
- the non-null class to analyze- Returns:
- A non-null but possibly empty set of initialization methods
- Throws:
MultiException
- on an error when analyzing the class
-
getFields
Will return the set of initializer fields to be used when initializing this serviceThe default implementation will return all fields marked with Inject or that have a parameter that is covered by an
InjectionResolver
- Parameters:
clazz
- the non-null class to analyze- Returns:
- A non-null but possibly empty set of initialization fields
- Throws:
MultiException
- on an error when analyzing the class
-
getPostConstructMethod
Will return the postConstruct method of the classThe default implementation will return the
PostConstruct.postConstruct()
method or the method annotated with PostConstruct- Parameters:
clazz
- the non-null class to analyze- Returns:
- A possibly null method representing the postConstruct method to call
- Throws:
MultiException
- on an error when analyzing the class
-
getPreDestroyMethod
Will return the preDestroy method of the classThe default implementation will return the
PreDestroy.preDestroy()
method or the method annotated with PreDestroy- Parameters:
clazz
- the non-null class to analyze- Returns:
- A possibly null method representing the preDestroy method to call
- Throws:
MultiException
- on an error when analyzing the class
-