T
- The type from the cachepublic class SystemDescriptor<T> extends java.lang.Object implements ActiveDescriptor<T>, Closeable
Modifier and Type | Field and Description |
---|---|
private ActiveDescriptor<T> |
activeDescriptor |
private Descriptor |
baseDescriptor |
private T |
cachedValue |
private java.lang.Object |
cacheLock |
private boolean |
cacheSet |
private boolean |
closed |
private java.util.Set<java.lang.reflect.Type> |
contracts |
private Creator<T> |
creator |
private java.lang.Long |
factoryLocatorId |
private java.lang.Long |
factoryServiceId |
private java.lang.Long |
id |
private java.lang.Class<?> |
implClass |
private java.lang.reflect.Type |
implType |
private java.util.List<InstanceLifecycleListener> |
instanceListeners |
private java.util.Set<IndexedListData> |
myLists |
private boolean |
preAnalyzed |
private java.util.Set<java.lang.annotation.Annotation> |
qualifiers |
private boolean |
reified |
private boolean |
reifying |
private java.lang.Class<? extends java.lang.annotation.Annotation> |
scope |
private java.lang.annotation.Annotation |
scopeAnnotation |
private ServiceLocatorImpl |
sdLocator |
private int |
singletonGeneration |
private java.util.HashMap<ValidationService,java.lang.Boolean> |
validationServiceCache |
Constructor and Description |
---|
SystemDescriptor(Descriptor baseDescriptor,
boolean requiresDeepCopy,
ServiceLocatorImpl locator,
java.lang.Long serviceId) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
addList(IndexedListData indexedList) |
private void |
checkState() |
boolean |
close()
Idempotent close method.
|
T |
create(ServiceHandle<?> root)
Creates an instance of the ActiveDescriptor.
|
void |
dispose(T instance)
Disposes this instance.
|
boolean |
equals(java.lang.Object o) |
java.util.Set<java.lang.String> |
getAdvertisedContracts()
Returns the base class name of the contracts that
this service describes.
|
T |
getCache()
This can be used for scopes that will only every be created once.
|
java.lang.String |
getClassAnalysisName()
Returns the name of the
ClassAnalyzer service that
should be used to discover the constructors, initialization methods,
field and postConstruct and preDestory methods. |
java.util.Set<java.lang.reflect.Type> |
getContractTypes()
The set of types that this ActiveDescriptor must produce.
|
DescriptorType |
getDescriptorType()
Returns CLASS if this is a class descriptor
and FACTORY if this is a descriptor describing
a factory for a type, in which case the
implClass should point to the implementation
class of the factory
|
DescriptorVisibility |
getDescriptorVisibility()
Returns the visibility of this descriptor.
|
private ActiveDescriptor<?> |
getFactoryDescriptor(java.lang.reflect.Method provideMethod,
java.lang.reflect.Type factoryProvidedType,
ServiceLocatorImpl locator,
Collector collector) |
java.lang.Long |
getFactoryLocatorId()
If this ActiveDescriptor has DescriptorType of PROVIDE_METHOD then
this field will return the ServiceId of its associated Factory
service.
|
java.lang.Long |
getFactoryServiceId()
If this ActiveDescriptor has DescriptorType of PROVIDE_METHOD then
this field will return the ServiceId of its associated Factory
service.
|
java.lang.String |
getImplementation()
Returns the fully qualified class
name of the implementation
class.
|
java.lang.Class<?> |
getImplementationClass()
The implementation class that should be used
to generate new instances of this descriptor.
|
java.lang.reflect.Type |
getImplementationType()
If known the Type of the implementation.
|
java.util.List<Injectee> |
getInjectees()
Returns the full list of Injectees this class has.
|
HK2Loader |
getLoader()
This returns the loader that should be used when
classloading this descriptor.
|
java.lang.Long |
getLocatorId()
This returns the id of the ServiceLocator which this descriptor
is registered with.
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getMetadata()
Returns all of the metadata associated
that this object should be registered
with or looked up by
|
java.lang.String |
getName()
The name of this descriptor.
|
(package private) java.lang.Class<?> |
getPreAnalyzedClass() |
java.util.Set<java.lang.annotation.Annotation> |
getQualifierAnnotations()
The full set of qualifiers that this ActiveDescriptor
provides
|
java.util.Set<java.lang.String> |
getQualifiers()
Returns all of the annotation classes
that this object should be registered
with or looked up by
|
int |
getRanking()
Returns the ranking of this descriptor.
|
java.lang.String |
getScope()
Returns the fully qualified class name of
the scope annotation that should be
associated with this descriptor.
|
java.lang.Class<? extends java.lang.annotation.Annotation> |
getScopeAnnotation()
Returns the scope that this ActiveDescriptor belongs to
|
java.lang.annotation.Annotation |
getScopeAsAnnotation()
Returns the scope as an
Annotation
implementation that this ActiveDescriptor belongs to |
java.lang.Long |
getServiceId()
This returns the unique identifier for this descriptor.
|
(package private) int |
getSingletonGeneration() |
int |
hashCode() |
private void |
internalReify(java.lang.Class<?> implClass,
Collector collector)
The service locator must hold its lock for this cal
|
(package private) void |
invokeInstanceListeners(InstanceLifecycleEvent event) |
boolean |
isCacheSet()
Returns true if this cache has been set
|
boolean |
isClosed()
Returns true if the instance has been
closed
|
java.lang.Boolean |
isProxiable()
If this returns true then the system will create a proxy for
instances of this descriptor.
|
java.lang.Boolean |
isProxyForSameScope()
This value determines whether or not this service should be
proxied when being injected into other services of the same
scope.
|
boolean |
isReified()
This method returns true if this descriptor has been reified
(class loaded).
|
(package private) boolean |
isValidating(ValidationService service)
Gets the decision of the filter from this service.
|
(package private) void |
reify(java.lang.Class<?> implClass,
Collector collector) |
void |
releaseCache()
Removes the cached value and makes it such
that this cache has not been set
|
(package private) void |
removeList(IndexedListData indexedList) |
(package private) void |
reupInstanceListeners(java.util.List<InstanceLifecycleListener> listeners) |
void |
setCache(T cacheMe)
Sets the value into the cache
|
(package private) void |
setFactoryIds(java.lang.Long factoryLocatorId,
java.lang.Long factoryServiceId) |
int |
setRanking(int ranking)
Returns the ranking of this descriptor.
|
(package private) int |
setRankWithLock(int ranking) |
(package private) void |
setSingletonGeneration(int gen) |
java.lang.String |
toString() |
private final Descriptor baseDescriptor
private final java.lang.Long id
private final ActiveDescriptor<T> activeDescriptor
private final ServiceLocatorImpl sdLocator
private volatile boolean reified
private boolean reifying
private boolean preAnalyzed
private volatile boolean closed
private final java.lang.Object cacheLock
private boolean cacheSet
private T cachedValue
private java.lang.Class<?> implClass
private java.lang.annotation.Annotation scopeAnnotation
private java.lang.Class<? extends java.lang.annotation.Annotation> scope
private java.util.Set<java.lang.reflect.Type> contracts
private java.util.Set<java.lang.annotation.Annotation> qualifiers
private java.lang.Long factoryLocatorId
private java.lang.Long factoryServiceId
private java.lang.reflect.Type implType
private final java.util.HashMap<ValidationService,java.lang.Boolean> validationServiceCache
private final java.util.List<InstanceLifecycleListener> instanceListeners
private final java.util.Set<IndexedListData> myLists
private int singletonGeneration
SystemDescriptor(Descriptor baseDescriptor, boolean requiresDeepCopy, ServiceLocatorImpl locator, java.lang.Long serviceId)
public java.lang.String getImplementation()
Descriptor
getImplementation
in interface Descriptor
public java.util.Set<java.lang.String> getAdvertisedContracts()
Descriptor
getAdvertisedContracts
in interface Descriptor
public java.lang.String getScope()
Descriptor
getScope
in interface Descriptor
public java.lang.String getName()
Descriptor
getName
in interface Descriptor
public java.util.Set<java.lang.String> getQualifiers()
Descriptor
getQualifiers
in interface Descriptor
public DescriptorType getDescriptorType()
Descriptor
getDescriptorType
in interface Descriptor
public DescriptorVisibility getDescriptorVisibility()
Descriptor
If the visibility is NORMAL then this descriptor may be seen by all children locators of the locator in which this descriptor is bound
If the visibility is LOCAL then this descriptor may only be seen by the servcie locator in which it is bound, and in none of the children of that locator
getDescriptorVisibility
in interface Descriptor
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMetadata()
Descriptor
getMetadata
in interface Descriptor
public HK2Loader getLoader()
Descriptor
getLoader
in interface Descriptor
public int getRanking()
Descriptor
getRanking
in interface Descriptor
public java.lang.Boolean isProxiable()
Descriptor
ProxyCtl
interface
It is an error for this method to return true if the scope that
this descriptor is in is Unproxiable
(such as PerLookup).
isProxiable
in interface Descriptor
Proxiable
)public java.lang.Boolean isProxyForSameScope()
Descriptor
isProxyForSameScope
in interface Descriptor
public java.lang.String getClassAnalysisName()
Descriptor
ClassAnalyzer
service that
should be used to discover the constructors, initialization methods,
field and postConstruct and preDestory methods. If null the default
implementation will be used. Will be ignored for descriptors that
are not automatically analyzed by hk2getClassAnalysisName
in interface Descriptor
public int setRanking(int ranking)
Descriptor
The ranking of a service may change at any time during the life of the descriptor
setRanking
in interface Descriptor
ranking
- The new ranking this descriptor should haveint setRankWithLock(int ranking)
void addList(IndexedListData indexedList)
void removeList(IndexedListData indexedList)
public java.lang.Long getServiceId()
Descriptor
getServiceId
in interface Descriptor
public T getCache()
SingleCache
getCache
in interface SingleCache<T>
public boolean isCacheSet()
SingleCache
isCacheSet
in interface SingleCache<T>
public void setCache(T cacheMe)
SingleCache
setCache
in interface SingleCache<T>
cacheMe
- A single value that can be cached in this
active descriptorpublic void releaseCache()
SingleCache
releaseCache
in interface SingleCache<T>
public boolean isReified()
ActiveDescriptor
isReified
in interface ActiveDescriptor<T>
public java.lang.Class<?> getImplementationClass()
ActiveDescriptor
If the class returned is a Factory, then the factory is used to create instances. In this case the system will get an instance of the factory and use it to create the instances
getImplementationClass
in interface ActiveDescriptor<T>
public java.lang.reflect.Type getImplementationType()
ActiveDescriptor
ActiveDescriptor.getImplementationClass()
getImplementationType
in interface ActiveDescriptor<T>
public java.util.Set<java.lang.reflect.Type> getContractTypes()
ActiveDescriptor
getContractTypes
in interface ActiveDescriptor<T>
public java.lang.annotation.Annotation getScopeAsAnnotation()
ActiveDescriptor
Annotation
implementation that this ActiveDescriptor belongs togetScopeAsAnnotation
in interface ActiveDescriptor<T>
Annotation
public java.lang.Class<? extends java.lang.annotation.Annotation> getScopeAnnotation()
ActiveDescriptor
getScopeAnnotation
in interface ActiveDescriptor<T>
public java.util.Set<java.lang.annotation.Annotation> getQualifierAnnotations()
ActiveDescriptor
getQualifierAnnotations
in interface ActiveDescriptor<T>
public java.util.List<Injectee> getInjectees()
ActiveDescriptor
If this descriptor is describing a factory created type then this list must have zero length
getInjectees
in interface ActiveDescriptor<T>
public java.lang.Long getFactoryServiceId()
ActiveDescriptor
getFactoryServiceId
in interface ActiveDescriptor<T>
public java.lang.Long getFactoryLocatorId()
ActiveDescriptor
getFactoryLocatorId
in interface ActiveDescriptor<T>
void setFactoryIds(java.lang.Long factoryLocatorId, java.lang.Long factoryServiceId)
void invokeInstanceListeners(InstanceLifecycleEvent event)
public T create(ServiceHandle<?> root)
ActiveDescriptor
create
in interface ActiveDescriptor<T>
root
- The root service handle, which can be used
to associated all the PerLookup objects with this creationpublic void dispose(T instance)
ActiveDescriptor
dispose
in interface ActiveDescriptor<T>
instance
- The instance to destroyprivate void checkState()
private ActiveDescriptor<?> getFactoryDescriptor(java.lang.reflect.Method provideMethod, java.lang.reflect.Type factoryProvidedType, ServiceLocatorImpl locator, Collector collector)
void reify(java.lang.Class<?> implClass, Collector collector)
private void internalReify(java.lang.Class<?> implClass, Collector collector)
implClass
- The impl class to reifycollector
- An error collector for errorspublic java.lang.Long getLocatorId()
Descriptor
getLocatorId
in interface Descriptor
public boolean close()
Closeable
public boolean isClosed()
Closeable
boolean isValidating(ValidationService service)
service
- The service to get the isValidating decision fromvoid reupInstanceListeners(java.util.List<InstanceLifecycleListener> listeners)
java.lang.Class<?> getPreAnalyzedClass()
int getSingletonGeneration()
void setSingletonGeneration(int gen)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object