Top Description Fields Constructors Methods
org.jvnet.hk2.internal

public Class PerLocatorUtilities

extends Object
Class Inheritance
Imports
java.lang.annotation.Annotation, java.lang.reflect.AnnotatedElement, .Constructor, .Method, java.util.WeakHashMap, java.util.concurrent.locks.ReentrantLock, jakarta.inject.Inject, org.glassfish.hk2.api.Injectee, .InjectionPointIndicator, .InjectionResolver, org.glassfish.hk2.utilities.general.Hk2ThreadLocal, org.glassfish.hk2.utilities.reflection.Pretty, org.jvnet.hk2.annotations.Service

These utilities are per service locator. Another service locator may have a different view of the caches stored here
Author
jwells

Field Summary

Modifier and TypeField and Description
private final Hk2ThreadLocal<WeakHashMap<AnnotatedElement, Boolean>>
private final ReentrantLock
private final ServiceLocatorImpl
private volatile ProxyUtilities
private final Hk2ThreadLocal<WeakHashMap<AnnotatedElement, SoftAnnotatedElementAnnotationInfo>>
threadLocalAnnotationCache

Must not be static, otherwise it can leak when using thread pools

private final Hk2ThreadLocal<WeakHashMap<Class<?>, String>>
threadLocalAutoAnalyzerNameCache

Must not be static, otherwise it can leak when using thread pools

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private AnnotatedElementAnnotationInfo
public String

Returns:

The name of the analyzer (null for default)
getAutoAnalyzerName
(Class<?>
The class to get the analyzer name from
c
)

Gets the analyzer name from the Service annotation

private Annotation

Returns:

The annotation that is the inject annotation, or null if no inject annotation was found
getInjectAnnotation
(final ServiceLocatorImpl
The service locator to use (as it will get all the annotations that were added on as well as the normal Inject)
locator
,
final AnnotatedElement
the annotated annotated
annotated
,
final boolean
check the params if true
checkParams
,
final int
index of constructor or method parameter which which will be checked for inject annotations. The position parameter is only used when annotated is method or constructor otherwise the value will be ignored.
position
)

Gets the annotation that was used for the injection

public InjectionResolver<?>

Returns:

Injection resolver used to resolve the injection for the injectee
getInjectionResolver
(ServiceLocatorImpl
The locator to use when finding the resolver
locator
,
Injectee
Injectee from which the annotation should be extracted
injectee
)

Returns an injection resolver for the injectee

pack-priv InjectionResolver<?>

Returns:

The scope of this class or producer method. If no scope is found will return the dependent scope
getInjectionResolver
(ServiceLocatorImpl
The locator to use when finding the resolver
locator
,
AnnotatedElement
The annotated class or producer method
annotatedGuy
)

Returns an injection resolver for this AnnotatedElement.

private InjectionResolver<?>
getInjectionResolver(ServiceLocatorImpl locator, AnnotatedElement annotatedGuy, int position)

public ProxyUtilities
pack-priv boolean

Returns:

True if element contains at least one inject annotation
hasInjectAnnotation
(AnnotatedElement
the annotated element
annotated
)

Checks whether an annotated element has any annotation that was used for the injection

public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hasInjectCacheback to summary
private final Hk2ThreadLocal<WeakHashMap<AnnotatedElement, Boolean>> hasInjectCache
lockback to summary
private final ReentrantLock lock
parentback to summary
private final ServiceLocatorImpl parent
proxyUtilitiesback to summary
private volatile ProxyUtilities proxyUtilities
threadLocalAnnotationCacheback to summary
private final Hk2ThreadLocal<WeakHashMap<AnnotatedElement, SoftAnnotatedElementAnnotationInfo>> threadLocalAnnotationCache

Must not be static, otherwise it can leak when using thread pools

threadLocalAutoAnalyzerNameCacheback to summary
private final Hk2ThreadLocal<WeakHashMap<Class<?>, String>> threadLocalAutoAnalyzerNameCache

Must not be static, otherwise it can leak when using thread pools

Constructor Detail

PerLocatorUtilitiesback to summary
pack-priv PerLocatorUtilities(ServiceLocatorImpl parent)

Method Detail

computeElementAnnotationInfoback to summary
private AnnotatedElementAnnotationInfo computeElementAnnotationInfo(AnnotatedElement ae)
getAutoAnalyzerNameback to summary
public String getAutoAnalyzerName(Class<?> c)

Gets the analyzer name from the Service annotation

Parameters
c:Class<?>

The class to get the analyzer name from

Returns:String

The name of the analyzer (null for default)

getInjectAnnotationback to summary
private Annotation getInjectAnnotation(final ServiceLocatorImpl locator, final AnnotatedElement annotated, final boolean checkParams, final int position)

Gets the annotation that was used for the injection

Parameters
locator:ServiceLocatorImpl

The service locator to use (as it will get all the annotations that were added on as well as the normal Inject)

annotated:AnnotatedElement

the annotated annotated

checkParams:boolean

check the params if true

position:int

index of constructor or method parameter which which will be checked for inject annotations. The position parameter is only used when annotated is method or constructor otherwise the value will be ignored.

Returns:Annotation

The annotation that is the inject annotation, or null if no inject annotation was found

getInjectionResolverback to summary
public InjectionResolver<?> getInjectionResolver(ServiceLocatorImpl locator, Injectee injectee) throws IllegalStateException

Returns an injection resolver for the injectee

Parameters
locator:ServiceLocatorImpl

The locator to use when finding the resolver

injectee:Injectee

Injectee from which the annotation should be extracted

Returns:InjectionResolver<?>

Injection resolver used to resolve the injection for the injectee

Exceptions
IllegalStateException:
If we could not find a valid resolver
getInjectionResolverback to summary
pack-priv 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:ServiceLocatorImpl

The locator to use when finding the resolver

annotatedGuy:AnnotatedElement

The annotated class or producer method

Returns:InjectionResolver<?>

The scope of this class or producer method. If no scope is found will return the dependent scope

Exceptions
IllegalStateException:
If we could not find a valid resolver
getInjectionResolverback to summary
private InjectionResolver<?> getInjectionResolver(ServiceLocatorImpl locator, AnnotatedElement annotatedGuy, int position) throws IllegalStateException
getProxyUtilitiesback to summary
public ProxyUtilities getProxyUtilities()
hasInjectAnnotationback to summary
pack-priv boolean hasInjectAnnotation(AnnotatedElement annotated)

Checks whether an annotated element has any annotation that was used for the injection

Parameters
annotated:AnnotatedElement

the annotated element

Returns:boolean

True if element contains at least one inject annotation

releaseCachesback to summary
public void releaseCaches()
shutdownback to summary
public void shutdown()