Package org.jvnet.hk2.internal
Class PerLocatorUtilities
java.lang.Object
org.jvnet.hk2.internal.PerLocatorUtilities
These utilities are per service locator. Another service locator may have a different view
of the caches stored here
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Hk2ThreadLocal
<WeakHashMap<AnnotatedElement, Boolean>> private final ServiceLocatorImpl
private ProxyUtilities
private final Hk2ThreadLocal
<WeakHashMap<AnnotatedElement, SoftAnnotatedElementAnnotationInfo>> Must not be static, otherwise it can leak when using thread poolsprivate final Hk2ThreadLocal
<WeakHashMap<Class<?>, String>> Must not be static, otherwise it can leak when using thread pools -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate AnnotatedElementAnnotationInfo
getAutoAnalyzerName
(Class<?> c) Gets the analyzer name from the Service annotationprivate Annotation
getInjectAnnotation
(ServiceLocatorImpl locator, AnnotatedElement annotated, boolean checkParams, int position) Gets the annotation that was used for the injection(package private) InjectionResolver
<?> getInjectionResolver
(ServiceLocatorImpl locator, AnnotatedElement annotatedGuy) Returns an injection resolver for this AnnotatedElement.private InjectionResolver
<?> getInjectionResolver
(ServiceLocatorImpl locator, AnnotatedElement annotatedGuy, int position) getInjectionResolver
(ServiceLocatorImpl locator, Injectee injectee) Returns an injection resolver for the injectee(package private) boolean
hasInjectAnnotation
(AnnotatedElement annotated) Checks whether an annotated element has any annotation that was used for the injectionvoid
void
shutdown()
-
Field Details
-
threadLocalAutoAnalyzerNameCache
Must not be static, otherwise it can leak when using thread pools -
threadLocalAnnotationCache
private final Hk2ThreadLocal<WeakHashMap<AnnotatedElement,SoftAnnotatedElementAnnotationInfo>> threadLocalAnnotationCacheMust not be static, otherwise it can leak when using thread pools -
hasInjectCache
-
proxyUtilities
-
parent
-
-
Constructor Details
-
PerLocatorUtilities
PerLocatorUtilities(ServiceLocatorImpl parent)
-
-
Method Details
-
hasInjectAnnotation
Checks whether an annotated element has any annotation that was used for the injection- Parameters:
annotated
- the annotated elementlocator
- The service locator to use (as it will get all the annotations that were added on as well as the normal Inject)checkParams
- check the params if true- Returns:
- True if element contains at least one inject annotation
-
getAutoAnalyzerName
Gets the analyzer name from the Service annotation- Parameters:
c
- The class to get the analyzer name from- Returns:
- The name of the analyzer (null for default)
-
getInjectionResolver
public InjectionResolver<?> getInjectionResolver(ServiceLocatorImpl locator, Injectee injectee) throws IllegalStateException Returns an injection resolver for the injectee- Parameters:
locator
- The locator to use when finding the resolverinjectee
- Injectee from which the annotation should be extracted- Returns:
- Injection resolver used to resolve the injection for the injectee
- Throws:
IllegalStateException
- If we could not find a valid resolver
-
getInjectionResolver
InjectionResolver<?> getInjectionResolver(ServiceLocatorImpl locator, AnnotatedElement annotatedGuy) throws IllegalStateException Returns an injection resolver for this AnnotatedElement. The method cannot be used for constructors or methods.- Parameters:
locator
- The locator to use when finding the resolverannotatedGuy
- The annotated class or producer method- Returns:
- The scope of this class or producer method. If no scope is found will return the dependent scope
- Throws:
IllegalStateException
- If we could not find a valid resolver
-
getInjectionResolver
private InjectionResolver<?> getInjectionResolver(ServiceLocatorImpl locator, AnnotatedElement annotatedGuy, int position) throws IllegalStateException - Throws:
IllegalStateException
-
getInjectAnnotation
private Annotation getInjectAnnotation(ServiceLocatorImpl locator, AnnotatedElement annotated, boolean checkParams, int position) Gets the annotation that was used for the injection- Parameters:
locator
- The service locator to use (as it will get all the annotations that were added on as well as the normal Inject)annotated
- the annotated annotatedcheckParams
- check the params if trueposition
- index of constructor or method parameter which which will be checked for inject annotations. Theposition
parameter is only used whenannotated
is method or constructor otherwise the value will be ignored.- Returns:
- The annotation that is the inject annotation, or null if no inject annotation was found
-
computeElementAnnotationInfo
-
releaseCaches
public void releaseCaches() -
shutdown
public void shutdown() -
getProxyUtilities
-