Class ServiceLocatorImpl
- java.lang.Object
-
- org.jvnet.hk2.internal.ServiceLocatorImpl
-
- All Implemented Interfaces:
ServiceLocator
public class ServiceLocatorImpl extends java.lang.Object implements ServiceLocator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classServiceLocatorImpl.CheckConfigurationDataprivate static classServiceLocatorImpl.IgdCacheKeyprivate classServiceLocatorImpl.IgdValueprivate static classServiceLocatorImpl.UnqualifiedIndexedFilter
-
Field Summary
Fields Modifier and Type Field Description private IndexedListDataallDescriptorsprivate java.util.concurrent.ConcurrentHashMap<java.lang.Class<? extends java.lang.annotation.Annotation>,InjectionResolver<?>>allResolversprivate java.util.LinkedHashSet<ValidationService>allValidatorsprivate static java.lang.StringBIND_TRACING_PATTERNprivate static java.lang.StringBIND_TRACING_PATTERN_PROPERTYprivate static booleanBIND_TRACING_STACKSprivate static java.lang.StringBIND_TRACING_STACKS_PROPERTYprivate static intCACHE_SIZEprivate java.util.Map<ServiceLocatorImpl,ServiceLocatorImpl>childrenprivate java.lang.ObjectclassAnalyzerLockprivate java.util.HashMap<java.lang.String,ClassAnalyzer>classAnalyzersprivate ClassReflectionHelperclassReflectionHelperprivate java.util.LinkedList<ServiceHandle<?>>configListenersprivate Cache<java.lang.Class<? extends java.lang.annotation.Annotation>,Context<?>>contextCacheprivate static longcurrentLocatorIdprivate java.lang.StringdefaultClassAnalyzerprivate UnqualifieddefaultUnqualified(package private) static DescriptorComparatorDESCRIPTOR_COMPARATORprivate java.util.HashMap<java.lang.String,IndexedListData>descriptorsByAdvertisedContractprivate java.util.HashMap<java.lang.String,IndexedListData>descriptorsByNameprivate java.util.LinkedList<ErrorService>errorHandlersprivate static ServiceHandleComparatorHANDLE_COMPARATORprivate booleanhasInterceptionServicesprivate longidprivate WeakCARCache<ServiceLocatorImpl.IgdCacheKey,ServiceLocatorImpl.IgdValue>igashCacheprivate WeakCARCache<ServiceLocatorImpl.IgdCacheKey,ServiceLocatorImpl.IgdValue>igdCacheprivate Cache<SystemInjecteeImpl,InjectionResolver<?>>injecteeToResolverCacheprivate java.util.LinkedList<InterceptionService>interceptionServicesprivate java.lang.StringlocatorNameprivate booleanneutralContextClassLoaderprivate java.util.concurrent.atomic.AtomicLongnextServiceIdprivate ServiceLocatorImplparentprivate PerLocatorUtilitiesperLocatorUtilitiesprivate Context<PerLookup>perLookupContextprivate java.util.concurrent.locks.ReentrantReadWriteLockreadWriteLockprivate java.util.concurrent.locks.ReentrantReadWriteLock.ReadLockrLockprivate Context<javax.inject.Singleton>singletonContextprivate static java.lang.ObjectsLockprivate ServiceLocatorStatestateprivate java.util.concurrent.locks.ReentrantReadWriteLock.WriteLockwLock
-
Constructor Summary
Constructors Constructor Description ServiceLocatorImpl(java.lang.String name, ServiceLocatorImpl parent)Called by the Generator, and hence must be a public method
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private Context<?>_resolveContext(java.lang.Class<? extends java.lang.annotation.Annotation> scope)private voidaddChild(ServiceLocatorImpl child)(package private) voidaddConfiguration(DynamicConfigurationImpl dci)private java.util.List<SystemDescriptor<?>>addConfigurationInternal(DynamicConfigurationImpl dci)java.lang.ObjectassistedInject(java.lang.Object injectMe, java.lang.reflect.Method method, MethodParameter... params)This will invoke the given method on the given object.java.lang.ObjectassistedInject(java.lang.Object injectMe, java.lang.reflect.Method method, ServiceHandle<?> root, MethodParameter... params)This will invoke the given method on the given object.private voidcallAllConfigurationListeners(java.util.List<ServiceHandle<?>> allListeners)private booleancallValidate(ValidationService vs, ValidationInformation vi)Must have read lock heldprivate ServiceLocatorImpl.CheckConfigurationDatacheckConfiguration(DynamicConfigurationImpl dci)Checks the configuration operation before anything happens to the internal data structures.private voidcheckState()(package private) voidclearReflectionCache()(package private) voidclearServiceCache()<T> Tcreate(java.lang.Class<T> createMe)This method will analyze the given class, and create it if can.<T> Tcreate(java.lang.Class<T> createMe, java.lang.String strategy)This method will analyze the given class, and create it if can.<U> UcreateAndInitialize(java.lang.Class<U> createMe)Creates, injects and postConstructs, all in one<U> UcreateAndInitialize(java.lang.Class<U> createMe, java.lang.String strategy)Creates, injects and postConstructs, all in oneprivate static booleandoTrace(ActiveDescriptor<?> desc)private voidgetAllChildren(java.util.LinkedList<ServiceLocatorImpl> allMyChildren)private static java.util.List<java.lang.String>getAllContracts(ActiveDescriptor<?> desc)java.util.List<ServiceHandle<?>>getAllServiceHandles(java.lang.annotation.Annotation qualifier, java.lang.annotation.Annotation... qualifiers)Gets a list ofServiceHandlethat can be used to get and destroy services associated with descriptors that match the provided criteria<T> java.util.List<ServiceHandle<T>>getAllServiceHandles(java.lang.Class<T> contractOrImpl, java.lang.annotation.Annotation... qualifiers)Gets a list ofServiceHandlethat can be used to get and destroy services associated with descriptors that match the provided criteriajava.util.List<ServiceHandle<?>>getAllServiceHandles(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers)Gets a list ofServiceHandlethat can be used to get and destroy services associated with descriptors that match the provided criteriajava.util.List<ServiceHandle<?>>getAllServiceHandles(Filter searchCriteria)Gets a list ofServiceHandlewhoseActiveDescriptors match the supplied filter.<T> java.util.List<T>getAllServices(java.lang.annotation.Annotation qualifier, java.lang.annotation.Annotation... qualifiers)Gets all services from this locator that have the provided qualifiers<T> java.util.List<T>getAllServices(java.lang.Class<T> contractOrImpl, java.lang.annotation.Annotation... qualifiers)Gets all services from this locator that implement this contract or have this implementation and have the provided qualifiers<T> java.util.List<T>getAllServices(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers)Gets all services from this locator that implement this contract or have this implementation and have the provided qualifiersjava.util.List<?>getAllServices(Filter searchCriteria)Gets all services from this locator that match the providedFilter(package private) java.util.List<ServiceHandle<?>>getAllUnqualifiedServiceHandles(java.lang.reflect.Type contractOrImpl, Unqualified unqualified, boolean isIterable, java.lang.annotation.Annotation... qualifiers)private java.util.LinkedHashSet<ValidationService>getAllValidators()(package private) ClassAnalyzergetAnalyzer(java.lang.String name, Collector collector)private static longgetAndIncrementLocatorId()ActiveDescriptor<?>getBestDescriptor(Filter filter)Gets the descriptor that best matches this filter, taking ranking and service id into account(package private) ClassReflectionHelpergetClassReflectionHelper()java.lang.StringgetDefaultClassAnalyzerName()Gets the name of the default class analyzer serviceUnqualifiedgetDefaultUnqualified()This returns the defaultUnqualifiedannotation that will be put on all injection points that do not have any qualifiers.java.util.List<ActiveDescriptor<?>>getDescriptors(Filter filter)Gets the list of descriptors that match the given filterprivate java.util.List<SystemDescriptor<?>>getDescriptors(Filter filter, Injectee onBehalfOf, boolean getParents, boolean doValidation, boolean getLocals)private UnqualifiedgetEffectiveUnqualified(Unqualified givenUnqualified, boolean isIterable, java.lang.annotation.Annotation[] qualifiers)(package private) java.util.LinkedList<ErrorService>getErrorHandlers()ActiveDescriptor<?>getInjecteeDescriptor(Injectee injectee)This method will first find a descriptor for this injectee, and then reify that descriptor.(package private) InjectionResolver<?>getInjectionResolver(java.lang.Class<? extends java.lang.annotation.Annotation> annoType)(package private) InjectionResolver<?>getInjectionResolverForInjectee(SystemInjecteeImpl injectee)(package private) java.util.List<InterceptionService>getInterceptionServices()longgetLocatorId()This returns the unique locator ID for this locator.private ServiceLocatorImplgetMe()Used to get the ServiceLocatorImpl in inner classesjava.lang.StringgetName()Returns the name of this ServiceLocatorprivate static java.lang.StringgetName(java.lang.String name, java.lang.annotation.Annotation... qualifiers)booleangetNeutralContextClassLoader()This returns the value of neutralContextClassLoader.(package private) longgetNextServiceId()(package private) intgetNumberOfChildren()(package private) intgetNumberOfDescriptors()ServiceLocatorgetParent()Gets the parent service locator for this locator(package private) PerLocatorUtilitiesgetPerLocatorUtilities()(package private) intgetReflectionCacheSize()<T> TgetService(java.lang.Class<T> contractOrImpl, java.lang.annotation.Annotation... qualifiers)Gets the best service from this locator that implements this contract or has this implementation<T> TgetService(java.lang.Class<T> contractOrImpl, java.lang.String name, java.lang.annotation.Annotation... qualifiers)Gets the best service from this locator that implements this contract or has this implementation and has the given name<T> TgetService(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers)Gets the best service from this locator that implements this contract or has this implementation<T> TgetService(java.lang.reflect.Type contractOrImpl, java.lang.String name, java.lang.annotation.Annotation... qualifiers)Gets the best service from this locator that implements this contract or has this implementation and has the given name<T> TgetService(ActiveDescriptor<T> activeDescriptor, ServiceHandle<?> root)Deprecated.<T> TgetService(ActiveDescriptor<T> activeDescriptor, ServiceHandle<?> root, Injectee originalRequest)This method should be called by code resolving injectee's on behalf of some root service, usually by an implementation ofInjectionResolver.resolve(Injectee, ServiceHandle).(package private) intgetServiceCacheMaximumSize()(package private) intgetServiceCacheSize()<T> ServiceHandle<T>getServiceHandle(java.lang.Class<T> contractOrImpl, java.lang.annotation.Annotation... qualifiers)Gets aServiceHandlethat can be used to get and destroy the service that best matches the given criteria<T> ServiceHandle<T>getServiceHandle(java.lang.Class<T> contractOrImpl, java.lang.String name, java.lang.annotation.Annotation... qualifiers)Gets aServiceHandlethat can be used to get and destroy the service that best matches the given criteria<T> ServiceHandle<T>getServiceHandle(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers)Gets aServiceHandlethat can be used to get and destroy the service that best matches the given criteria<T> ServiceHandle<T>getServiceHandle(java.lang.reflect.Type contractOrImpl, java.lang.String name, java.lang.annotation.Annotation... qualifiers)Gets aServiceHandlethat can be used to get and destroy the service that best matches the given criteria<T> ServiceHandle<T>getServiceHandle(ActiveDescriptor<T> activeDescriptor)Gets aServiceHandlethat can be used to get and destroy the service described by theActiveDescriptor.<T> ServiceHandle<T>getServiceHandle(ActiveDescriptor<T> activeDescriptor, Injectee injectee)Gets aServiceHandlethat can be used to get and destroy the service described by theActiveDescriptor.private <T> ServiceHandleImpl<T>getServiceHandleImpl(ActiveDescriptor<T> activeDescriptor, Injectee injectee)ServiceLocatorStategetState()Returns the current state of this service locator.(package private) <T> TgetUnqualifiedService(java.lang.reflect.Type contractOrImpl, Unqualified unqualified, boolean isIterable, java.lang.annotation.Annotation... qualifiers)This method is only called from the get of IterableProvider.(package private) <T> ServiceHandle<T>getUnqualifiedServiceHandle(java.lang.reflect.Type contractOrImpl, Unqualified unqualified, boolean isIterable, java.lang.annotation.Annotation... qualifiers)(package private) booleanhasInjectAnnotation(java.lang.reflect.AnnotatedElement annotated)private ServiceLocatorImpl.IgdValueigdCacheCompute(ServiceLocatorImpl.IgdCacheKey key)voidinject(java.lang.Object injectMe)This will analyze the given object and inject into its fields and methods.voidinject(java.lang.Object injectMe, java.lang.String strategy)This will analyze the given object and inject into its fields and methods.private java.util.List<?>internalGetAllServiceHandles(java.lang.reflect.Type contractOrImpl, Unqualified unqualified, boolean getHandles, boolean isIterable, java.lang.annotation.Annotation... qualifiers)private <T> ActiveDescriptor<T>internalGetDescriptor(Injectee onBehalfOf, java.lang.reflect.Type contractOrImpl, java.lang.String name, Unqualified unqualified, boolean isIterable, boolean calledFromSecondChanceResolveMethod, java.lang.annotation.Annotation... qualifiers)private <T> ActiveDescriptor<T>internalGetDescriptor(Injectee onBehalfOf, java.lang.reflect.Type contractOrImpl, java.lang.String name, Unqualified unqualified, boolean isIterable, java.lang.annotation.Annotation... qualifiers)private ActiveDescriptor<?>internalGetInjecteeDescriptor(Injectee injectee, boolean calledFromSecondChanceResolveMethod)private <T> TinternalGetService(java.lang.reflect.Type contractOrImpl, java.lang.String name, Unqualified unqualified, boolean calledFromSecondChanceResolveMethod, java.lang.annotation.Annotation... qualifiers)private <T> TinternalGetService(java.lang.reflect.Type contractOrImpl, java.lang.String name, Unqualified unqualified, java.lang.annotation.Annotation... qualifiers)private <T> ServiceHandleImpl<T>internalGetServiceHandle(ActiveDescriptor<T> activeDescriptor, java.lang.reflect.Type requestedType, Injectee originalRequest)(package private) booleanisInjectAnnotation(java.lang.annotation.Annotation annotation)(package private) booleanisInjectAnnotation(java.lang.annotation.Annotation annotation, boolean isConstructor)private java.lang.Class<?>loadClass(Descriptor descriptor, Injectee injectee)private ImmediateResultsnarrow(ServiceLocator locator, java.util.List<SystemDescriptor<?>> candidates, java.lang.reflect.Type requiredType, java.lang.String name, Injectee injectee, boolean onlyOne, boolean doValidation, NarrowResults cachedResults, Filter filter, java.lang.annotation.Annotation... qualifiers)voidpostConstruct(java.lang.Object postConstructMe)This will analyze the given object and call the postConstruct method.voidpostConstruct(java.lang.Object postConstructMe, java.lang.String strategy)This will analyze the given object and call the postConstruct method.voidpreDestroy(java.lang.Object preDestroyMe)This will analyze the given object and call the preDestroy method.voidpreDestroy(java.lang.Object preDestroyMe, java.lang.String strategy)This will analyze the given object and call the preDestroy method.private java.util.List<ServiceHandle<?>>protectedGetAllServiceHandles(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers)private <T> java.util.List<T>protectedGetAllServices(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers)private java.util.List<ActiveDescriptor<?>>protectedGetDescriptors(Filter filter)ActiveDescriptor<?>reifyDescriptor(Descriptor descriptor)Converts a descriptor to an ActiveDescriptor.ActiveDescriptor<?>reifyDescriptor(Descriptor descriptor, Injectee injectee)Converts a descriptor to an ActiveDescriptor.private voidremoveChild(ServiceLocatorImpl child)private voidremoveConfigurationInternal(java.util.List<SystemDescriptor<?>> unbinds)(package private) Context<?>resolveContext(java.lang.Class<? extends java.lang.annotation.Annotation> scope)private voidreup(java.util.List<SystemDescriptor<?>> thingsAdded, boolean instanceListenersModified, boolean injectionResolversModified, boolean errorHandlersModified, boolean classAnalyzersModified, boolean dynamicConfigurationListenersModified, java.util.HashSet<java.lang.String> affectedContracts, boolean interceptionServicesModified)private voidreupCache(java.util.HashSet<java.lang.String> affectedContracts)private voidreupClassAnalyzers()private voidreupConfigListeners()private voidreupErrorHandlers()private voidreupInjectionResolvers()private voidreupInstanceListenersHandlers(java.util.Collection<SystemDescriptor<?>> checkList)private voidreupInterceptionServices()private ActiveDescriptor<?>secondChanceResolve(Injectee injectee)voidsetDefaultClassAnalyzerName(java.lang.String defaultClassAnalyzer)Sets the name of the default class analyzer that should be used for allDescriptors that return null as their class analyzer.voidsetDefaultUnqualified(Unqualified unqualified)This sets the defaultUnqualifiedannotation that will be put on all injection points that do not have any qualifiers.voidsetNeutralContextClassLoader(boolean neutralContextClassLoader)This sets the value of neutralContextClassLoader.voidshutdown()This method will shutdown every service associated with this ServiceLocator.java.lang.StringtoString()(package private) intunsortIndexes(int newRank, SystemDescriptor<?> desc, java.util.Set<IndexedListData> myLists)private booleanvalidate(SystemDescriptor<?> descriptor, Injectee onBehalfOf, Filter filter)Must be called under lock
-
-
-
Field Detail
-
BIND_TRACING_PATTERN_PROPERTY
private static final java.lang.String BIND_TRACING_PATTERN_PROPERTY
- See Also:
- Constant Field Values
-
BIND_TRACING_PATTERN
private static final java.lang.String BIND_TRACING_PATTERN
-
BIND_TRACING_STACKS_PROPERTY
private static final java.lang.String BIND_TRACING_STACKS_PROPERTY
- See Also:
- Constant Field Values
-
BIND_TRACING_STACKS
private static boolean BIND_TRACING_STACKS
-
CACHE_SIZE
private static final int CACHE_SIZE
- See Also:
- Constant Field Values
-
sLock
private static final java.lang.Object sLock
-
currentLocatorId
private static long currentLocatorId
-
DESCRIPTOR_COMPARATOR
static final DescriptorComparator DESCRIPTOR_COMPARATOR
-
HANDLE_COMPARATOR
private static final ServiceHandleComparator HANDLE_COMPARATOR
-
readWriteLock
private final java.util.concurrent.locks.ReentrantReadWriteLock readWriteLock
-
wLock
private final java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock wLock
-
rLock
private final java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock rLock
-
nextServiceId
private final java.util.concurrent.atomic.AtomicLong nextServiceId
-
locatorName
private final java.lang.String locatorName
-
id
private final long id
-
parent
private final ServiceLocatorImpl parent
-
neutralContextClassLoader
private volatile boolean neutralContextClassLoader
-
classReflectionHelper
private final ClassReflectionHelper classReflectionHelper
-
perLocatorUtilities
private final PerLocatorUtilities perLocatorUtilities
-
allDescriptors
private final IndexedListData allDescriptors
-
descriptorsByAdvertisedContract
private final java.util.HashMap<java.lang.String,IndexedListData> descriptorsByAdvertisedContract
-
descriptorsByName
private final java.util.HashMap<java.lang.String,IndexedListData> descriptorsByName
-
singletonContext
private final Context<javax.inject.Singleton> singletonContext
-
allValidators
private final java.util.LinkedHashSet<ValidationService> allValidators
-
errorHandlers
private final java.util.LinkedList<ErrorService> errorHandlers
-
configListeners
private final java.util.LinkedList<ServiceHandle<?>> configListeners
-
hasInterceptionServices
private volatile boolean hasInterceptionServices
-
interceptionServices
private final java.util.LinkedList<InterceptionService> interceptionServices
-
contextCache
private final Cache<java.lang.Class<? extends java.lang.annotation.Annotation>,Context<?>> contextCache
-
children
private final java.util.Map<ServiceLocatorImpl,ServiceLocatorImpl> children
-
classAnalyzerLock
private final java.lang.Object classAnalyzerLock
-
classAnalyzers
private final java.util.HashMap<java.lang.String,ClassAnalyzer> classAnalyzers
-
defaultClassAnalyzer
private java.lang.String defaultClassAnalyzer
-
defaultUnqualified
private volatile Unqualified defaultUnqualified
-
allResolvers
private java.util.concurrent.ConcurrentHashMap<java.lang.Class<? extends java.lang.annotation.Annotation>,InjectionResolver<?>> allResolvers
-
injecteeToResolverCache
private final Cache<SystemInjecteeImpl,InjectionResolver<?>> injecteeToResolverCache
-
state
private ServiceLocatorState state
-
igdCache
private final WeakCARCache<ServiceLocatorImpl.IgdCacheKey,ServiceLocatorImpl.IgdValue> igdCache
-
igashCache
private final WeakCARCache<ServiceLocatorImpl.IgdCacheKey,ServiceLocatorImpl.IgdValue> igashCache
-
-
Constructor Detail
-
ServiceLocatorImpl
public ServiceLocatorImpl(java.lang.String name, ServiceLocatorImpl parent)Called by the Generator, and hence must be a public method- Parameters:
name- The name of this locatorparent- The parent of this locator (may be null)
-
-
Method Detail
-
getAndIncrementLocatorId
private static long getAndIncrementLocatorId()
-
callValidate
private boolean callValidate(ValidationService vs, ValidationInformation vi)
Must have read lock held- Parameters:
vi- The non-null validation- Returns:
-
validate
private boolean validate(SystemDescriptor<?> descriptor, Injectee onBehalfOf, Filter filter)
Must be called under lock- Parameters:
descriptor- The descriptor to validateonBehalfOf- The fella who is being validated (or null)- Returns:
- true if every validator returned true
-
getDescriptors
private java.util.List<SystemDescriptor<?>> getDescriptors(Filter filter, Injectee onBehalfOf, boolean getParents, boolean doValidation, boolean getLocals)
-
protectedGetDescriptors
private java.util.List<ActiveDescriptor<?>> protectedGetDescriptors(Filter filter)
-
getDescriptors
public java.util.List<ActiveDescriptor<?>> getDescriptors(Filter filter)
Description copied from interface:ServiceLocatorGets the list of descriptors that match the given filter- Specified by:
getDescriptorsin interfaceServiceLocator- Parameters:
filter- A filter to use when determining which services should apply- Returns:
- A non-null but possibly empty list of descriptors in ranked order that match the given filter
-
getBestDescriptor
public ActiveDescriptor<?> getBestDescriptor(Filter filter)
Description copied from interface:ServiceLocatorGets the descriptor that best matches this filter, taking ranking and service id into account- Specified by:
getBestDescriptorin interfaceServiceLocator- Parameters:
filter- The non-null filter to use to retrieve the best descriptor- Returns:
- The best descriptor matching the filter, or null if there is no descriptor that matches the filter
-
reifyDescriptor
public ActiveDescriptor<?> reifyDescriptor(Descriptor descriptor, Injectee injectee) throws MultiException
Description copied from interface:ServiceLocatorConverts a descriptor to an ActiveDescriptor. Will use the registered HK2Loaders to perform this action. If no HK2Loader is available for the descriptor, will use the injectee to discover a classloader- Specified by:
reifyDescriptorin interfaceServiceLocator- Parameters:
descriptor- The descriptor to convert, may not be nullinjectee- The injectee on behalf of whom this descriptor is being injected. May be null if the injectee is unknown- Returns:
- The active descriptor as loaded with the first valid
HK2Loader - Throws:
MultiException- if there were errors when loading or analyzing the class
-
reifyDescriptor
public ActiveDescriptor<?> reifyDescriptor(Descriptor descriptor) throws MultiException
Description copied from interface:ServiceLocatorConverts a descriptor to an ActiveDescriptor. Will use the registered HK2Loaders to perform this action- Specified by:
reifyDescriptorin interfaceServiceLocator- Parameters:
descriptor- The descriptor to convert, may not be null- Returns:
- The active descriptor as loaded with the first valid
HK2Loader - Throws:
MultiException- if there were errors when loading or analyzing the class
-
secondChanceResolve
private ActiveDescriptor<?> secondChanceResolve(Injectee injectee)
-
internalGetInjecteeDescriptor
private ActiveDescriptor<?> internalGetInjecteeDescriptor(Injectee injectee, boolean calledFromSecondChanceResolveMethod)
-
getInjecteeDescriptor
public ActiveDescriptor<?> getInjecteeDescriptor(Injectee injectee) throws MultiException
Description copied from interface:ServiceLocatorThis method will first find a descriptor for this injectee, and then reify that descriptor. If multiple descriptors are found, they will be reified in ranking order until an ActiveDescriptor matching the Injectee is found.This method is responsible for using the available
JustInTimeInjectionResolverto add in new descriptors should the descriptor for the given injectee not be found initially- Specified by:
getInjecteeDescriptorin interfaceServiceLocator- Parameters:
injectee- the injection point for whom to find the ActiveDescriptor- Returns:
- The active descriptor for this injection point
- Throws:
MultiException- if there were errors when loading or analyzing the class
-
getServiceHandle
public <T> ServiceHandle<T> getServiceHandle(ActiveDescriptor<T> activeDescriptor, Injectee injectee) throws MultiException
Description copied from interface:ServiceLocatorGets aServiceHandlethat can be used to get and destroy the service described by theActiveDescriptor. The injectee may be used to discover the proper classloader to use when attempting to reify theActiveDescriptor- Specified by:
getServiceHandlein interfaceServiceLocator- Parameters:
activeDescriptor- The descriptor for which to create aServiceHandle. May not be nullinjectee- The injectee on behalf of whom this service is being injected. May be null if the injectee is unknown- Returns:
- A
ServiceHandlethat may be used to create or destroy the service associated with thisActiveDescriptor - Throws:
MultiException- if there was an error during service handle creation
-
getServiceHandleImpl
private <T> ServiceHandleImpl<T> getServiceHandleImpl(ActiveDescriptor<T> activeDescriptor, Injectee injectee) throws MultiException
- Throws:
MultiException
-
getServiceHandle
public <T> ServiceHandle<T> getServiceHandle(ActiveDescriptor<T> activeDescriptor) throws MultiException
Description copied from interface:ServiceLocatorGets aServiceHandlethat can be used to get and destroy the service described by theActiveDescriptor.- Specified by:
getServiceHandlein interfaceServiceLocator- Parameters:
activeDescriptor- The descriptor for which to create aServiceHandle. May not be null- Returns:
- A
ServiceHandlethat may be used to create or destroy the service associated with thisActiveDescriptor - Throws:
MultiException- if there was an error during service handle creation
-
internalGetServiceHandle
private <T> ServiceHandleImpl<T> internalGetServiceHandle(ActiveDescriptor<T> activeDescriptor, java.lang.reflect.Type requestedType, Injectee originalRequest)
-
getService
@Deprecated public <T> T getService(ActiveDescriptor<T> activeDescriptor, ServiceHandle<?> root) throws MultiException
Deprecated.Description copied from interface:ServiceLocatorThis method should be called by code resolving injectee's on behalf of some root service, usually by an implementation ofInjectionResolver.resolve(Injectee, ServiceHandle). In this way the objects associated with the root object can be destroyed in the proper sequence- Specified by:
getServicein interfaceServiceLocator- Parameters:
activeDescriptor- The descriptor whose service to createroot- The ultimate parent of this service creation. May be null- Returns:
- The service matching this descriptor
- Throws:
MultiException- if there was an error during service creation
-
getService
public <T> T getService(ActiveDescriptor<T> activeDescriptor, ServiceHandle<?> root, Injectee originalRequest) throws MultiException
Description copied from interface:ServiceLocatorThis method should be called by code resolving injectee's on behalf of some root service, usually by an implementation ofInjectionResolver.resolve(Injectee, ServiceHandle). In this way the objects associated with the root object can be destroyed in the proper sequence- Specified by:
getServicein interfaceServiceLocator- Parameters:
activeDescriptor- The descriptor whose service to createroot- The ultimate parent of this service creation. May be nulloriginalRequest- The injectee passed into theInjectionResolver.resolve(Injectee, ServiceHandle)if known, null otherwise- Returns:
- The service matching this descriptor
- Throws:
MultiException- if there was an error during service creation
-
getService
public <T> T getService(java.lang.Class<T> contractOrImpl, java.lang.annotation.Annotation... qualifiers) throws MultiExceptionDescription copied from interface:ServiceLocatorGets the best service from this locator that implements this contract or has this implementationUse this method only if destroying the service is not important, otherwise use
ServiceLocator.getServiceHandle(Class, Annotation...)- Specified by:
getServicein interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofqualifiers- The set of qualifiers that must match this service definition- Returns:
- An instance of the contract or impl. May return null if there is no provider that provides the given implementation or contract
- Throws:
MultiException- if there was an error during service creation
-
getService
public <T> T getService(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers) throws MultiExceptionDescription copied from interface:ServiceLocatorGets the best service from this locator that implements this contract or has this implementationUse this method only if destroying the service is not important, otherwise use
ServiceLocator.getServiceHandle(Type, Annotation...)- Specified by:
getServicein interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofqualifiers- The set of qualifiers that must match this service definition- Returns:
- An instance of the contract or impl. May return null if there is no provider that provides the given implementation or contract
- Throws:
MultiException- if there was an error during service creation
-
getService
public <T> T getService(java.lang.Class<T> contractOrImpl, java.lang.String name, java.lang.annotation.Annotation... qualifiers) throws MultiExceptionDescription copied from interface:ServiceLocatorGets the best service from this locator that implements this contract or has this implementation and has the given nameUse this method only if destroying the service is not important, otherwise use
ServiceLocator.getServiceHandle(Class, String, Annotation...)- Specified by:
getServicein interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofname- May be null (to indicate any name is ok), and is the name of the implementation to be returnedqualifiers- The set of qualifiers that must match this service definition- Returns:
- An instance of the contract or impl. May return null if there is no provider that provides the given implementation or contract
- Throws:
MultiException- if there was an error during service creation
-
getService
public <T> T getService(java.lang.reflect.Type contractOrImpl, java.lang.String name, java.lang.annotation.Annotation... qualifiers) throws MultiExceptionDescription copied from interface:ServiceLocatorGets the best service from this locator that implements this contract or has this implementation and has the given nameUse this method only if destroying the service is not important, otherwise use
ServiceLocator.getServiceHandle(Type, String, Annotation...)- Specified by:
getServicein interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofname- May be null (to indicate any name is ok), and is the name of the implementation to be returnedqualifiers- The set of qualifiers that must match this service definition- Returns:
- An instance of the contract or impl. May return null if there is no provider that provides the given implementation or contract
- Throws:
MultiException- if there was an error during service creation
-
internalGetService
private <T> T internalGetService(java.lang.reflect.Type contractOrImpl, java.lang.String name, Unqualified unqualified, java.lang.annotation.Annotation... qualifiers)
-
internalGetService
private <T> T internalGetService(java.lang.reflect.Type contractOrImpl, java.lang.String name, Unqualified unqualified, boolean calledFromSecondChanceResolveMethod, java.lang.annotation.Annotation... qualifiers)
-
getUnqualifiedService
<T> T getUnqualifiedService(java.lang.reflect.Type contractOrImpl, Unqualified unqualified, boolean isIterable, java.lang.annotation.Annotation... qualifiers) throws MultiExceptionThis method is only called from the get of IterableProvider. IterableProvider has already called the JIT resolvers and so should not do so again, since it is too much work and doesn't have the information about the original injectee- Throws:
MultiException
-
protectedGetAllServices
private <T> java.util.List<T> protectedGetAllServices(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers)
-
getAllServices
public <T> java.util.List<T> getAllServices(java.lang.Class<T> contractOrImpl, java.lang.annotation.Annotation... qualifiers) throws MultiExceptionDescription copied from interface:ServiceLocatorGets all services from this locator that implement this contract or have this implementation and have the provided qualifiersUse this method only if destroying the service is not important, otherwise use
ServiceLocator.getAllServiceHandles(Class, Annotation...)- Specified by:
getAllServicesin interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofqualifiers- The set of qualifiers that must match this service definition- Returns:
- A list of services implementing this contract or concrete implementation. May not return null, but may return an empty list
- Throws:
MultiException- if there was an error during service creation
-
getAllServices
public <T> java.util.List<T> getAllServices(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers) throws MultiExceptionDescription copied from interface:ServiceLocatorGets all services from this locator that implement this contract or have this implementation and have the provided qualifiersUse this method only if destroying the service is not important, otherwise use
ServiceLocator.getAllServiceHandles(Type, Annotation...)- Specified by:
getAllServicesin interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofqualifiers- The set of qualifiers that must match this service definition- Returns:
- A list of services implementing this contract or concrete implementation. May not return null, but may return an empty list
- Throws:
MultiException- if there was an error during service creation
-
getAllServices
public <T> java.util.List<T> getAllServices(java.lang.annotation.Annotation qualifier, java.lang.annotation.Annotation... qualifiers) throws MultiExceptionDescription copied from interface:ServiceLocatorGets all services from this locator that have the provided qualifiersUse this method only if destroying the services is not important, otherwise use
ServiceLocator.getAllServiceHandles(Annotation, Annotation...)- Specified by:
getAllServicesin interfaceServiceLocator- Parameters:
qualifier- May not be null, and is a qualifier that must match the service definitionqualifiers- The set of qualifiers that must match this service definition- Returns:
- A list of services implementing this contract or concrete implementation. May not return null, but may return an empty list
- Throws:
MultiException- if there was an error during service creation
-
getAllServices
public java.util.List<?> getAllServices(Filter searchCriteria) throws MultiException
Description copied from interface:ServiceLocatorGets all services from this locator that match the providedFilterUse this method only if destroying the service is not important, otherwise use
ServiceLocator.getAllServiceHandles(Filter)This method should also be used with care to avoid classloading a large number of services
- Specified by:
getAllServicesin interfaceServiceLocator- Parameters:
searchCriteria- The returned service will match the Filter (in other words, searchCriteria.matches returns true). May not be null- Returns:
- A list of services matching this filter. May not return null, but may return an empty list
- Throws:
MultiException- if there was an error during service creation
-
getName
public java.lang.String getName()
Description copied from interface:ServiceLocatorReturns the name of this ServiceLocator- Specified by:
getNamein interfaceServiceLocator- Returns:
- The name of this ServiceLocator, will not return null
-
getState
public ServiceLocatorState getState()
Description copied from interface:ServiceLocatorReturns the current state of this service locator. This method will work in all service locator states- Specified by:
getStatein interfaceServiceLocator- Returns:
- The current state of the service locator
-
shutdown
public void shutdown()
Description copied from interface:ServiceLocatorThis method will shutdown every service associated with this ServiceLocator. Those services that have a preDestroy shall have their preDestroy called- Specified by:
shutdownin interfaceServiceLocator
-
create
public <T> T create(java.lang.Class<T> createMe)
Description copied from interface:ServiceLocatorThis method will analyze the given class, and create it if can. The object created in this way will not be managed by HK2. It is the responsibility of the caller to ensure that any lifecycle this object has is honored- Specified by:
createin interfaceServiceLocator- Parameters:
createMe- The class to create, may not be null- Returns:
- An instance of the object
-
create
public <T> T create(java.lang.Class<T> createMe, java.lang.String strategy)Description copied from interface:ServiceLocatorThis method will analyze the given class, and create it if can. The object created in this way will not be managed by HK2. It is the responsibility of the caller to ensure that any lifecycle this object has is honored- Specified by:
createin interfaceServiceLocator- Parameters:
createMe- The class to create, may not be nullstrategy- The name of theClassAnalyzerthat should be used. If null the default analyzer will be used- Returns:
- An instance of the object
-
inject
public void inject(java.lang.Object injectMe)
Description copied from interface:ServiceLocatorThis will analyze the given object and inject into its fields and methods. The object injected in this way will not be managed by HK2- Specified by:
injectin interfaceServiceLocator- Parameters:
injectMe- The object to be analyzed and injected into
-
assistedInject
public java.lang.Object assistedInject(java.lang.Object injectMe, java.lang.reflect.Method method, MethodParameter... params)Description copied from interface:ServiceLocatorThis will invoke the given method on the given object. The values for the method will either be taken from the params list or will be gotten from this ServiceLocator taking into account all injection resolvers- Specified by:
assistedInjectin interfaceServiceLocator- Parameters:
injectMe- The non-null object to inject intomethod- The non-null method to inject intoparams- A list of parameter values known by the caller. The indexes in params may not repeat and must be in the valid range of parameters for the passed in method- Returns:
- The return value of the method (null if the method is void type)
-
assistedInject
public java.lang.Object assistedInject(java.lang.Object injectMe, java.lang.reflect.Method method, ServiceHandle<?> root, MethodParameter... params)Description copied from interface:ServiceLocatorThis will invoke the given method on the given object. The values for the method will either be taken from the params list or will be gotten from this ServiceLocator taking into account all injection resolvers- Specified by:
assistedInjectin interfaceServiceLocator- Parameters:
injectMe- The non-null object to inject intomethod- The non-null method to inject intoroot- A possibly null ServiceHandle that can be used after this call to destroy any hanging PerLookup instances createdparams- A list of parameter values known by the caller. The indexes in params may not repeat and must be in the valid range of parameters for the passed in method- Returns:
- The return value of the method (null if the method is void type)
-
inject
public void inject(java.lang.Object injectMe, java.lang.String strategy)Description copied from interface:ServiceLocatorThis will analyze the given object and inject into its fields and methods. The object injected in this way will not be managed by HK2- Specified by:
injectin interfaceServiceLocator- Parameters:
injectMe- The object to be analyzed and injected intostrategy- The name of theClassAnalyzerthat should be used. If null the default analyzer will be used
-
postConstruct
public void postConstruct(java.lang.Object postConstructMe)
Description copied from interface:ServiceLocatorThis will analyze the given object and call the postConstruct method. The object given will not be managed by HK2- Specified by:
postConstructin interfaceServiceLocator- Parameters:
postConstructMe- The object to postConstruct
-
postConstruct
public void postConstruct(java.lang.Object postConstructMe, java.lang.String strategy)Description copied from interface:ServiceLocatorThis will analyze the given object and call the postConstruct method. The object given will not be managed by HK2- Specified by:
postConstructin interfaceServiceLocator- Parameters:
postConstructMe- The object to postConstructstrategy- The name of theClassAnalyzerthat should be used. If null the default analyzer will be used
-
preDestroy
public void preDestroy(java.lang.Object preDestroyMe)
Description copied from interface:ServiceLocatorThis will analyze the given object and call the preDestroy method. The object given will not be managed by HK2- Specified by:
preDestroyin interfaceServiceLocator- Parameters:
preDestroyMe- The object to preDestroy
-
preDestroy
public void preDestroy(java.lang.Object preDestroyMe, java.lang.String strategy)Description copied from interface:ServiceLocatorThis will analyze the given object and call the preDestroy method. The object given will not be managed by HK2- Specified by:
preDestroyin interfaceServiceLocator- Parameters:
preDestroyMe- The object to preDestroystrategy- The name of theClassAnalyzerthat should be used. If null the default analyzer will be used
-
createAndInitialize
public <U> U createAndInitialize(java.lang.Class<U> createMe)
Creates, injects and postConstructs, all in one- Specified by:
createAndInitializein interfaceServiceLocator- Parameters:
createMe- The non-null class to create this object from- Returns:
- An instance of the object that has been created, injected and post constructed
-
createAndInitialize
public <U> U createAndInitialize(java.lang.Class<U> createMe, java.lang.String strategy)Creates, injects and postConstructs, all in one- Specified by:
createAndInitializein interfaceServiceLocator- Parameters:
createMe- The non-null class to create this object fromstrategy- The name of theClassAnalyzerthat should be used. If null the default analyzer will be used- Returns:
- An instance of the object that has been created, injected and post constructed
-
getName
private static java.lang.String getName(java.lang.String name, java.lang.annotation.Annotation... qualifiers)
-
igdCacheCompute
private ServiceLocatorImpl.IgdValue igdCacheCompute(ServiceLocatorImpl.IgdCacheKey key)
-
getEffectiveUnqualified
private Unqualified getEffectiveUnqualified(Unqualified givenUnqualified, boolean isIterable, java.lang.annotation.Annotation[] qualifiers)
-
internalGetDescriptor
private <T> ActiveDescriptor<T> internalGetDescriptor(Injectee onBehalfOf, java.lang.reflect.Type contractOrImpl, java.lang.String name, Unqualified unqualified, boolean isIterable, java.lang.annotation.Annotation... qualifiers) throws MultiException
- Throws:
MultiException
-
internalGetDescriptor
private <T> ActiveDescriptor<T> internalGetDescriptor(Injectee onBehalfOf, java.lang.reflect.Type contractOrImpl, java.lang.String name, Unqualified unqualified, boolean isIterable, boolean calledFromSecondChanceResolveMethod, java.lang.annotation.Annotation... qualifiers) throws MultiException
- Throws:
MultiException
-
getServiceHandle
public <T> ServiceHandle<T> getServiceHandle(java.lang.Class<T> contractOrImpl, java.lang.annotation.Annotation... qualifiers) throws MultiException
Description copied from interface:ServiceLocatorGets aServiceHandlethat can be used to get and destroy the service that best matches the given criteria- Specified by:
getServiceHandlein interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofqualifiers- The set of qualifiers that must match this service definition- Returns:
- Will return the service handle corresponding to the service or null if none were found
- Throws:
MultiException- if there was an issue during lookup
-
getServiceHandle
public <T> ServiceHandle<T> getServiceHandle(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers) throws MultiException
Description copied from interface:ServiceLocatorGets aServiceHandlethat can be used to get and destroy the service that best matches the given criteria- Specified by:
getServiceHandlein interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofqualifiers- The set of qualifiers that must match this service definition- Returns:
- Will return the service handle corresponding to the service or null if none were found
- Throws:
MultiException- if there was an issue during lookup
-
getUnqualifiedServiceHandle
<T> ServiceHandle<T> getUnqualifiedServiceHandle(java.lang.reflect.Type contractOrImpl, Unqualified unqualified, boolean isIterable, java.lang.annotation.Annotation... qualifiers) throws MultiException
- Throws:
MultiException
-
protectedGetAllServiceHandles
private java.util.List<ServiceHandle<?>> protectedGetAllServiceHandles(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers)
-
getAllServiceHandles
public <T> java.util.List<ServiceHandle<T>> getAllServiceHandles(java.lang.Class<T> contractOrImpl, java.lang.annotation.Annotation... qualifiers) throws MultiException
Description copied from interface:ServiceLocatorGets a list ofServiceHandlethat can be used to get and destroy services associated with descriptors that match the provided criteria- Specified by:
getAllServiceHandlesin interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofqualifiers- The set of qualifiers that must match this service definition- Returns:
- A non-null but possibly empty list of service handles matching the given criteria
- Throws:
MultiException- if there was an error during service lookup
-
getAllServiceHandles
public java.util.List<ServiceHandle<?>> getAllServiceHandles(java.lang.reflect.Type contractOrImpl, java.lang.annotation.Annotation... qualifiers) throws MultiException
Description copied from interface:ServiceLocatorGets a list ofServiceHandlethat can be used to get and destroy services associated with descriptors that match the provided criteria- Specified by:
getAllServiceHandlesin interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofqualifiers- The set of qualifiers that must match this service definition- Returns:
- A non-null but possibly empty list of service handles matching the given criteria
- Throws:
MultiException- if there was an error during service lookup
-
getAllUnqualifiedServiceHandles
java.util.List<ServiceHandle<?>> getAllUnqualifiedServiceHandles(java.lang.reflect.Type contractOrImpl, Unqualified unqualified, boolean isIterable, java.lang.annotation.Annotation... qualifiers) throws MultiException
- Throws:
MultiException
-
internalGetAllServiceHandles
private java.util.List<?> internalGetAllServiceHandles(java.lang.reflect.Type contractOrImpl, Unqualified unqualified, boolean getHandles, boolean isIterable, java.lang.annotation.Annotation... qualifiers) throws MultiException- Throws:
MultiException
-
getServiceHandle
public <T> ServiceHandle<T> getServiceHandle(java.lang.Class<T> contractOrImpl, java.lang.String name, java.lang.annotation.Annotation... qualifiers) throws MultiException
Description copied from interface:ServiceLocatorGets aServiceHandlethat can be used to get and destroy the service that best matches the given criteria- Specified by:
getServiceHandlein interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofname- The name to use to further qualify the search (may be null, indicating that any name will match)qualifiers- The set of qualifiers that must match this service definition- Returns:
- Will the service handle for the best service matching the given criteria, or null if no matching service could be found
- Throws:
MultiException- if there was an error during lookup
-
getServiceHandle
public <T> ServiceHandle<T> getServiceHandle(java.lang.reflect.Type contractOrImpl, java.lang.String name, java.lang.annotation.Annotation... qualifiers) throws MultiException
Description copied from interface:ServiceLocatorGets aServiceHandlethat can be used to get and destroy the service that best matches the given criteria- Specified by:
getServiceHandlein interfaceServiceLocator- Parameters:
contractOrImpl- May not be null, and is the contract or concrete implementation to get the best instance ofname- The name to use to further qualify the search (may be null, indicating that any name will match)qualifiers- The set of qualifiers that must match this service definition- Returns:
- Will the service handle for the best service matching the given criteria, or null if no matching service could be found
- Throws:
MultiException- if there was an error during service lookup
-
getAllServiceHandles
public java.util.List<ServiceHandle<?>> getAllServiceHandles(Filter searchCriteria) throws MultiException
Description copied from interface:ServiceLocatorGets a list ofServiceHandlewhoseActiveDescriptors match the supplied filter. The returnedServiceHandles may be used to get or destroy the services associated with the matching descriptors- Specified by:
getAllServiceHandlesin interfaceServiceLocator- Parameters:
searchCriteria- A filter to use when determining which descriptors should apply- Returns:
- A non-null but possibly empty list of service handles that match the given filter
- Throws:
MultiException- if there was an error during service handle creation
-
getAllServiceHandles
public java.util.List<ServiceHandle<?>> getAllServiceHandles(java.lang.annotation.Annotation qualifier, java.lang.annotation.Annotation... qualifiers) throws MultiException
Description copied from interface:ServiceLocatorGets a list ofServiceHandlethat can be used to get and destroy services associated with descriptors that match the provided criteria- Specified by:
getAllServiceHandlesin interfaceServiceLocator- Parameters:
qualifier- May not be null, and is a qualifier that must match the service definitionqualifiers- The set of qualifiers that must match this service definition- Returns:
- A non-null but possibly empty list of service handles matching the given criteria
- Throws:
MultiException- if there was an error during service lookup
-
getInterceptionServices
java.util.List<InterceptionService> getInterceptionServices()
-
checkConfiguration
private ServiceLocatorImpl.CheckConfigurationData checkConfiguration(DynamicConfigurationImpl dci)
Checks the configuration operation before anything happens to the internal data structures.- Parameters:
dci- The configuration that contains the proposed modifications- Returns:
- A set of descriptors that is being removed fromthe configuration
-
getAllContracts
private static java.util.List<java.lang.String> getAllContracts(ActiveDescriptor<?> desc)
-
removeConfigurationInternal
private void removeConfigurationInternal(java.util.List<SystemDescriptor<?>> unbinds)
-
doTrace
private static boolean doTrace(ActiveDescriptor<?> desc)
-
addConfigurationInternal
private java.util.List<SystemDescriptor<?>> addConfigurationInternal(DynamicConfigurationImpl dci)
-
reupInjectionResolvers
private void reupInjectionResolvers()
-
reupInterceptionServices
private void reupInterceptionServices()
-
reupErrorHandlers
private void reupErrorHandlers()
-
reupConfigListeners
private void reupConfigListeners()
-
reupInstanceListenersHandlers
private void reupInstanceListenersHandlers(java.util.Collection<SystemDescriptor<?>> checkList)
-
reupClassAnalyzers
private void reupClassAnalyzers()
-
reupCache
private void reupCache(java.util.HashSet<java.lang.String> affectedContracts)
-
reup
private void reup(java.util.List<SystemDescriptor<?>> thingsAdded, boolean instanceListenersModified, boolean injectionResolversModified, boolean errorHandlersModified, boolean classAnalyzersModified, boolean dynamicConfigurationListenersModified, java.util.HashSet<java.lang.String> affectedContracts, boolean interceptionServicesModified)
-
getAllChildren
private void getAllChildren(java.util.LinkedList<ServiceLocatorImpl> allMyChildren)
-
callAllConfigurationListeners
private void callAllConfigurationListeners(java.util.List<ServiceHandle<?>> allListeners)
-
addConfiguration
void addConfiguration(DynamicConfigurationImpl dci)
-
isInjectAnnotation
boolean isInjectAnnotation(java.lang.annotation.Annotation annotation)
-
isInjectAnnotation
boolean isInjectAnnotation(java.lang.annotation.Annotation annotation, boolean isConstructor)
-
getInjectionResolver
InjectionResolver<?> getInjectionResolver(java.lang.Class<? extends java.lang.annotation.Annotation> annoType)
-
_resolveContext
private Context<?> _resolveContext(java.lang.Class<? extends java.lang.annotation.Annotation> scope) throws java.lang.IllegalStateException
- Throws:
java.lang.IllegalStateException
-
resolveContext
Context<?> resolveContext(java.lang.Class<? extends java.lang.annotation.Annotation> scope) throws java.lang.IllegalStateException
- Throws:
java.lang.IllegalStateException
-
loadClass
private java.lang.Class<?> loadClass(Descriptor descriptor, Injectee injectee)
-
narrow
private ImmediateResults narrow(ServiceLocator locator, java.util.List<SystemDescriptor<?>> candidates, java.lang.reflect.Type requiredType, java.lang.String name, Injectee injectee, boolean onlyOne, boolean doValidation, NarrowResults cachedResults, Filter filter, java.lang.annotation.Annotation... qualifiers)
-
getLocatorId
public long getLocatorId()
Description copied from interface:ServiceLocatorThis returns the unique locator ID for this locator. The locator ID will be assigned at the time of creation and must be a monotonacally increasing number (starting at zero)- Specified by:
getLocatorIdin interfaceServiceLocator- Returns:
- The identifier for this service locator
-
getNextServiceId
long getNextServiceId()
-
addChild
private void addChild(ServiceLocatorImpl child)
-
removeChild
private void removeChild(ServiceLocatorImpl child)
-
checkState
private void checkState()
-
getAllValidators
private java.util.LinkedHashSet<ValidationService> getAllValidators()
-
getDefaultClassAnalyzerName
public java.lang.String getDefaultClassAnalyzerName()
Description copied from interface:ServiceLocatorGets the name of the default class analyzer service- Specified by:
getDefaultClassAnalyzerNamein interfaceServiceLocator- Returns:
- The name of the default class analyzer. Will not return null
-
setDefaultClassAnalyzerName
public void setDefaultClassAnalyzerName(java.lang.String defaultClassAnalyzer)
Description copied from interface:ServiceLocatorSets the name of the default class analyzer that should be used for allDescriptors that return null as their class analyzer. If null is given then the default class analyzer name ofClassAnalyzer.DEFAULT_IMPLEMENTATION_NAMEwill be used- Specified by:
setDefaultClassAnalyzerNamein interfaceServiceLocator- Parameters:
defaultClassAnalyzer- The possibly null name of the default class analyzer (the class analyzer that will be used if a descriptor has not explicitly set the name of its class analyzer)
-
getDefaultUnqualified
public Unqualified getDefaultUnqualified()
Description copied from interface:ServiceLocatorThis returns the defaultUnqualifiedannotation that will be put on all injection points that do not have any qualifiers. ThisUnqualifiedwill not be returned by theInjectee.getUnqualified()method as it is considered to be the systems defaultUnqualifiedannotation. If an injection point has its ownUnqualifiedannotation returned fromInjectee.getUnqualified()then that one takes precedence over this one. Further any injection point that is aIterableProviderwill not have the default unqualified applied to it- Specified by:
getDefaultUnqualifiedin interfaceServiceLocator- Returns:
- The
Unqualifiedannotation that will be (virtually) put on injection points that have no qualifiers and no otherUnqualifiedannotation. If null then this ServiceLocator has no defaultUnqualifiedannotation to be applied
-
setDefaultUnqualified
public void setDefaultUnqualified(Unqualified unqualified)
Description copied from interface:ServiceLocatorThis sets the defaultUnqualifiedannotation that will be put on all injection points that do not have any qualifiers. ThisUnqualifiedwill not be returned by theInjectee.getUnqualified()method as it is considered to be the systems defaultUnqualifiedannotation. If an injection point has its ownUnqualifiedannotation returned fromInjectee.getUnqualified()then that one takes precedence over this one. Further any injection point that is aIterableProviderwill not have the default unqualified applied to itThis method may be called at any time, but will only affect lookups and injections that have not yet occurred
- Specified by:
setDefaultUnqualifiedin interfaceServiceLocator- Parameters:
unqualified- TheUnqualifiedannotation that will be (virtually) put on injection points that have no qualifiers and no otherUnqualifiedannotation. If null then this ServiceLocator has no defaultUnqualifiedannotation to be applied- See Also:
UnqualifiedImpl
-
getAnalyzer
ClassAnalyzer getAnalyzer(java.lang.String name, Collector collector)
-
getParent
public ServiceLocator getParent()
Description copied from interface:ServiceLocatorGets the parent service locator for this locator- Specified by:
getParentin interfaceServiceLocator- Returns:
- The parent service locator for this locator, or null if this service locator does not have a parent
-
getNeutralContextClassLoader
public boolean getNeutralContextClassLoader()
Description copied from interface:ServiceLocatorThis returns the value of neutralContextClassLoader. If this value is true then HK2 will ensure that the context class loader on the thread is maintained whenever hk2 calls into user code. If this value is false then the value of the context class loader on the thread may be changed by the code hk2 is calling.When set to false this value is used to increase performance since getting and setting the context class loader can be expensive. However, if the user code being called by hk2 may change the context class loader of the thread, this value should be true to ensure that tricky and hard to find bugs don't arise when this thread is used for other purposes later on
All new ServiceLocator implementation have this value initially set to true
- Specified by:
getNeutralContextClassLoaderin interfaceServiceLocator- Returns:
- If true hk2 will ensure that the context class loader cannot be changed by user code. If false hk2 will not modify the context class loader of the thread when user code has finished
-
setNeutralContextClassLoader
public void setNeutralContextClassLoader(boolean neutralContextClassLoader)
Description copied from interface:ServiceLocatorThis sets the value of neutralContextClassLoader. If this value is true then HK2 will ensure that the context class loader on the thread is maintained whenever hk2 calls into user code. If this value is false then the value of the context class loader on the thread may be changed by the code hk2 is calling.When set to false this value is used to increase performance since getting and setting the context class loader can be expensive. However, if the user code being called by hk2 may change the context class loader of the thread, this value should be true to ensure that tricky and hard to find bugs don't arise when this thread is used for other purposes later on
All new ServiceLocator implementation have this value initially set to true
- Specified by:
setNeutralContextClassLoaderin interfaceServiceLocator- Parameters:
neutralContextClassLoader- true if hk2 should ensure context class loader neutrality, false if hk2 should not change the context class loader on the thread around user code calls
-
getMe
private ServiceLocatorImpl getMe()
Used to get the ServiceLocatorImpl in inner classes- Returns:
- This current object
-
hasInjectAnnotation
boolean hasInjectAnnotation(java.lang.reflect.AnnotatedElement annotated)
-
getInjectionResolverForInjectee
InjectionResolver<?> getInjectionResolverForInjectee(SystemInjecteeImpl injectee)
-
getClassReflectionHelper
ClassReflectionHelper getClassReflectionHelper()
-
getErrorHandlers
java.util.LinkedList<ErrorService> getErrorHandlers()
-
getPerLocatorUtilities
PerLocatorUtilities getPerLocatorUtilities()
-
getNumberOfDescriptors
int getNumberOfDescriptors()
-
getNumberOfChildren
int getNumberOfChildren()
-
getServiceCacheSize
int getServiceCacheSize()
-
getServiceCacheMaximumSize
int getServiceCacheMaximumSize()
-
clearServiceCache
void clearServiceCache()
-
getReflectionCacheSize
int getReflectionCacheSize()
-
clearReflectionCache
void clearReflectionCache()
-
unsortIndexes
int unsortIndexes(int newRank, SystemDescriptor<?> desc, java.util.Set<IndexedListData> myLists)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-