Package org.jvnet.hk2.internal
Class PerLocatorUtilities
- java.lang.Object
-
- org.jvnet.hk2.internal.PerLocatorUtilities
-
public class PerLocatorUtilities extends java.lang.ObjectThese utilities are per service locator. Another service locator may have a different view of the caches stored here
-
-
Field Summary
Fields Modifier and Type Field Description private Hk2ThreadLocal<java.util.WeakHashMap<java.lang.reflect.AnnotatedElement,java.lang.Boolean>>hasInjectCacheprivate ServiceLocatorImplparentprivate ProxyUtilitiesproxyUtilitiesprivate Hk2ThreadLocal<java.util.WeakHashMap<java.lang.reflect.AnnotatedElement,SoftAnnotatedElementAnnotationInfo>>threadLocalAnnotationCacheMust not be static, otherwise it can leak when using thread poolsprivate Hk2ThreadLocal<java.util.WeakHashMap<java.lang.Class<?>,java.lang.String>>threadLocalAutoAnalyzerNameCacheMust not be static, otherwise it can leak when using thread pools
-
Constructor Summary
Constructors Constructor Description PerLocatorUtilities(ServiceLocatorImpl parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private AnnotatedElementAnnotationInfocomputeElementAnnotationInfo(java.lang.reflect.AnnotatedElement ae)java.lang.StringgetAutoAnalyzerName(java.lang.Class<?> c)Gets the analyzer name from the Service annotationprivate java.lang.annotation.AnnotationgetInjectAnnotation(ServiceLocatorImpl locator, java.lang.reflect.AnnotatedElement annotated, boolean checkParams, int position)Gets the annotation that was used for the injection(package private) InjectionResolver<?>getInjectionResolver(ServiceLocatorImpl locator, java.lang.reflect.AnnotatedElement annotatedGuy)Returns an injection resolver for this AnnotatedElement.private InjectionResolver<?>getInjectionResolver(ServiceLocatorImpl locator, java.lang.reflect.AnnotatedElement annotatedGuy, int position)InjectionResolver<?>getInjectionResolver(ServiceLocatorImpl locator, Injectee injectee)Returns an injection resolver for the injecteeProxyUtilitiesgetProxyUtilities()(package private) booleanhasInjectAnnotation(java.lang.reflect.AnnotatedElement annotated)Checks whether an annotated element has any annotation that was used for the injectionvoidreleaseCaches()voidshutdown()
-
-
-
Field Detail
-
threadLocalAutoAnalyzerNameCache
private final Hk2ThreadLocal<java.util.WeakHashMap<java.lang.Class<?>,java.lang.String>> threadLocalAutoAnalyzerNameCache
Must not be static, otherwise it can leak when using thread pools
-
threadLocalAnnotationCache
private final Hk2ThreadLocal<java.util.WeakHashMap<java.lang.reflect.AnnotatedElement,SoftAnnotatedElementAnnotationInfo>> threadLocalAnnotationCache
Must not be static, otherwise it can leak when using thread pools
-
hasInjectCache
private final Hk2ThreadLocal<java.util.WeakHashMap<java.lang.reflect.AnnotatedElement,java.lang.Boolean>> hasInjectCache
-
proxyUtilities
private volatile ProxyUtilities proxyUtilities
-
parent
private final ServiceLocatorImpl parent
-
-
Constructor Detail
-
PerLocatorUtilities
PerLocatorUtilities(ServiceLocatorImpl parent)
-
-
Method Detail
-
hasInjectAnnotation
boolean hasInjectAnnotation(java.lang.reflect.AnnotatedElement annotated)
Checks whether an annotated element has any 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 elementcheckParams- check the params if true- Returns:
- True if element contains at least one inject annotation
-
getAutoAnalyzerName
public java.lang.String getAutoAnalyzerName(java.lang.Class<?> c)
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 java.lang.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:
java.lang.IllegalStateException- If we could not find a valid resolver
-
getInjectionResolver
InjectionResolver<?> getInjectionResolver(ServiceLocatorImpl locator, java.lang.reflect.AnnotatedElement annotatedGuy) throws java.lang.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:
java.lang.IllegalStateException- If we could not find a valid resolver
-
getInjectionResolver
private InjectionResolver<?> getInjectionResolver(ServiceLocatorImpl locator, java.lang.reflect.AnnotatedElement annotatedGuy, int position) throws java.lang.IllegalStateException
- Throws:
java.lang.IllegalStateException
-
getInjectAnnotation
private java.lang.annotation.Annotation getInjectAnnotation(ServiceLocatorImpl locator, java.lang.reflect.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. Thepositionparameter is only used whenannotatedis 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
private AnnotatedElementAnnotationInfo computeElementAnnotationInfo(java.lang.reflect.AnnotatedElement ae)
-
releaseCaches
public void releaseCaches()
-
shutdown
public void shutdown()
-
getProxyUtilities
public ProxyUtilities getProxyUtilities()
-
-