Class DelegatingNamedActiveDescriptor
- java.lang.Object
-
- org.glassfish.hk2.configuration.internal.DelegatingNamedActiveDescriptor
-
- All Implemented Interfaces:
ActiveDescriptor<java.lang.Object>,Descriptor,SingleCache<java.lang.Object>
public class DelegatingNamedActiveDescriptor extends java.lang.Object implements ActiveDescriptor<java.lang.Object>
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Objectcacheprivate booleanisSetprivate java.lang.Objectlockprivate javax.inject.Namednameprivate ActiveDescriptor<?>parentprivate java.util.HashSet<java.lang.String>qualifierNamesprivate java.util.HashSet<java.lang.annotation.Annotation>qualifiersprivate intranking
-
Constructor Summary
Constructors Constructor Description DelegatingNamedActiveDescriptor(ActiveDescriptor<?> parent, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectcreate(ServiceHandle<?> root)Creates an instance of the ActiveDescriptor.voiddispose(java.lang.Object instance)Disposes this instance.java.util.Set<java.lang.String>getAdvertisedContracts()Returns the base class name of the contracts that this service describes.java.lang.ObjectgetCache()This can be used for scopes that will only every be created once.java.lang.StringgetClassAnalysisName()Returns the name of theClassAnalyzerservice 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.DescriptorTypegetDescriptorType()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 factoryDescriptorVisibilitygetDescriptorVisibility()Returns the visibility of this descriptor.java.lang.LonggetFactoryLocatorId()If this ActiveDescriptor has DescriptorType of PROVIDE_METHOD then this field will return the ServiceId of its associated Factory service.java.lang.LonggetFactoryServiceId()If this ActiveDescriptor has DescriptorType of PROVIDE_METHOD then this field will return the ServiceId of its associated Factory service.java.lang.StringgetImplementation()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.TypegetImplementationType()If known the Type of the implementation.java.util.List<Injectee>getInjectees()Returns the full list of Injectees this class has.HK2LoadergetLoader()This returns the loader that should be used when classloading this descriptor.java.lang.LonggetLocatorId()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 byjava.lang.StringgetName()The name of this descriptor.java.util.Set<java.lang.annotation.Annotation>getQualifierAnnotations()The full set of qualifiers that this ActiveDescriptor providesjava.util.Set<java.lang.String>getQualifiers()Returns all of the annotation classes that this object should be registered with or looked up byintgetRanking()Returns the ranking of this descriptor.java.lang.StringgetScope()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 tojava.lang.annotation.AnnotationgetScopeAsAnnotation()Returns the scope as anAnnotationimplementation that this ActiveDescriptor belongs tojava.lang.LonggetServiceId()This returns the unique identifier for this descriptor.booleanisCacheSet()Returns true if this cache has been setjava.lang.BooleanisProxiable()If this returns true then the system will create a proxy for instances of this descriptor.java.lang.BooleanisProxyForSameScope()This value determines whether or not this service should be proxied when being injected into other services of the same scope.booleanisReified()This method returns true if this descriptor has been reified (class loaded).voidreleaseCache()Removes the cached value and makes it such that this cache has not been setvoidsetCache(java.lang.Object cacheMe)Sets the value into the cacheintsetRanking(int ranking)Returns the ranking of this descriptor.
-
-
-
Field Detail
-
parent
private final ActiveDescriptor<?> parent
-
name
private final javax.inject.Named name
-
qualifierNames
private final java.util.HashSet<java.lang.String> qualifierNames
-
qualifiers
private final java.util.HashSet<java.lang.annotation.Annotation> qualifiers
-
ranking
private int ranking
-
lock
private java.lang.Object lock
-
cache
private java.lang.Object cache
-
isSet
private boolean isSet
-
-
Constructor Detail
-
DelegatingNamedActiveDescriptor
DelegatingNamedActiveDescriptor(ActiveDescriptor<?> parent, java.lang.String name)
-
-
Method Detail
-
getImplementation
public java.lang.String getImplementation()
Description copied from interface:DescriptorReturns the fully qualified class name of the implementation class. If this is a factory descriptor then this will return the fully qualified name of the class implementing the factory interface.- Specified by:
getImplementationin interfaceDescriptor- Returns:
- Might return null in some cases, but will usually return the fully qualified class name of the implementation class or of the factory class for this descriptor
-
getAdvertisedContracts
public java.util.Set<java.lang.String> getAdvertisedContracts()
Description copied from interface:DescriptorReturns the base class name of the contracts that this service describes. If the contract is a paramterized type this will return the raw class. If this service can be looked up by its implementation class then the name of the implementation class must also be found in this list- Specified by:
getAdvertisedContractsin interfaceDescriptor- Returns:
- Will never return null, but may return an empty set. The returned strings are the fully qualified class names of contracts the predicate describes
-
getScope
public java.lang.String getScope()
Description copied from interface:DescriptorReturns the fully qualified class name of the scope annotation that should be associated with this descriptor.- Specified by:
getScopein interfaceDescriptor- Returns:
- If this returns null then this descriptor is assumed to be in the default scope, which is PerLookup
-
getName
public java.lang.String getName()
Description copied from interface:DescriptorThe name of this descriptor. Note that if this returns not null then there must also be the Named qualifier in the set of qualifiers with the same value- Specified by:
getNamein interfaceDescriptor- Returns:
- The name of this descriptor, or null if there is no name associated with this qualifier
-
getQualifiers
public java.util.Set<java.lang.String> getQualifiers()
Description copied from interface:DescriptorReturns all of the annotation classes that this object should be registered with or looked up by- Specified by:
getQualifiersin interfaceDescriptor- Returns:
- Never returns null, but may return an empty set. The set of fully qualified class names that are annotations that this object must have
-
getDescriptorType
public DescriptorType getDescriptorType()
Description copied from interface:DescriptorReturns 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- Specified by:
getDescriptorTypein interfaceDescriptor- Returns:
- Either CLASS or PROVIDE_METHOD
-
getDescriptorVisibility
public DescriptorVisibility getDescriptorVisibility()
Description copied from interface:DescriptorReturns the visibility of this 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
- Specified by:
getDescriptorVisibilityin interfaceDescriptor- Returns:
- Either NORMAL or LOCAL
-
getMetadata
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMetadata()
Description copied from interface:DescriptorReturns all of the metadata associated that this object should be registered with or looked up by- Specified by:
getMetadatain interfaceDescriptor- Returns:
- Never returns null, but may return an empty set. The set of metadata associated with the object. The values in the returned map will never be null, and will always have at least one member
-
getLoader
public HK2Loader getLoader()
Description copied from interface:DescriptorThis returns the loader that should be used when classloading this descriptor. If this method returns null then the class will be loaded with the classloader of the Injectee if there is one, or with the classloader that loaded HK2 itself; failing that the context class loader on the thread will be tried.- Specified by:
getLoaderin interfaceDescriptor- Returns:
- An HK2Loader that can be used to load this descriptor, or null if the default classloading algorithm should be used
-
getRanking
public int getRanking()
Description copied from interface:DescriptorReturns the ranking of this descriptor. Rankings with higher value will be considered "better" than rankings of lower value. Descriptors with the same ranking will be returned in the reverse ServiceID order (in other words, the least service ID is considered "better" than any higher service ID).- Specified by:
getRankingin interfaceDescriptor- Returns:
- the ranking that should be associated with this descriptor
-
setRanking
public int setRanking(int ranking)
Description copied from interface:DescriptorReturns the ranking of this descriptor. Rankings with higher value will be considered "better" than rankings of lower value. Descriptors with the same ranking will be returned in the reverse ServiceID order (in other words, the least service ID is considered "better" than any higher service ID).The ranking of a service may change at any time during the life of the descriptor
- Specified by:
setRankingin interfaceDescriptor- Parameters:
ranking- The new ranking this descriptor should have- Returns:
- the previous ranking that this descriptor had
-
isProxiable
public java.lang.Boolean isProxiable()
Description copied from interface:DescriptorIf this returns true then the system will create a proxy for instances of this descriptor. As with all proxies, the proxy created will also implement theProxyCtlinterfaceIt is an error for this method to return true if the scope that this descriptor is in is
Unproxiable(such as PerLookup).- Specified by:
isProxiablein interfaceDescriptor- Returns:
- true if this descriptor must be proxied, false if this
descriptor must NOT be proxied (even if it is in an Unproxiable scope)
and null if this descriptor should take its proxiable status from
the scope it is in (i.e., it will only be proxied if the scope is
marked
Proxiable)
-
isProxyForSameScope
public java.lang.Boolean isProxyForSameScope()
Description copied from interface:DescriptorThis value determines whether or not this service should be proxied when being injected into other services of the same scope. If a scope is proxiable then it will have a default setting for whether or not its services should be proxied when being injected into the same scope. If this method returns null then the default setting for the scope will be used. Otherwise the value returned will determine whether or not this service will be proxied when being injected into a service of the same scope.- Specified by:
isProxyForSameScopein interfaceDescriptor- Returns:
- null if this descriptor should use the default ProxyForSameScope value for the scope. If it returns true then this service will be proxied even when being injected into the same scope. If it returns false then this service will NOT be proxied when being injected into the same scope (i.e., it cannot be used for lazy initialization of the service when injected into the same scope)
-
getClassAnalysisName
public java.lang.String getClassAnalysisName()
Description copied from interface:DescriptorReturns the name of theClassAnalyzerservice 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 hk2- Specified by:
getClassAnalysisNamein interfaceDescriptor- Returns:
- the possibly null name of the ClassAnalysis service that should be used to analyze the class represented by this descriptor. If null then the HK2 default analysis will be performed
-
getServiceId
public java.lang.Long getServiceId()
Description copied from interface:DescriptorThis returns the unique identifier for this descriptor. This field will be ignored upon binding, and will then be assigned by the system. However, this field can be set on search operations, in which case this search will match exactly one Provider in the system.- Specified by:
getServiceIdin interfaceDescriptor- Returns:
- The service id for this object. Note that this field may return null if this is an initial bind, as it is not the responsibility of the binder to set this value. If this returns non-null on a bind operation the return value will be ignored
-
getLocatorId
public java.lang.Long getLocatorId()
Description copied from interface:DescriptorThis returns the id of the ServiceLocator which this descriptor is registered with. Returns null if this descriptor is not yet registered with a ServiceLocator- Specified by:
getLocatorIdin interfaceDescriptor- Returns:
- The id of the ServiceLocator this Descriptor is registered with, or null if this Descriptor is not registered with a ServiceLocator
-
getCache
public java.lang.Object getCache()
Description copied from interface:SingleCacheThis can be used for scopes that will only every be created once. The returned value must have been set previously with setCache. If this is called when isCacheSet is false will result in a RuntimeException- Specified by:
getCachein interfaceSingleCache<java.lang.Object>- Returns:
- A value cached with this ActiveDescriptor
-
isCacheSet
public boolean isCacheSet()
Description copied from interface:SingleCacheReturns true if this cache has been set- Specified by:
isCacheSetin interfaceSingleCache<java.lang.Object>- Returns:
- true if there is a currently cached value, false otherwise
-
setCache
public void setCache(java.lang.Object cacheMe)
Description copied from interface:SingleCacheSets the value into the cache- Specified by:
setCachein interfaceSingleCache<java.lang.Object>- Parameters:
cacheMe- A single value that can be cached in this active descriptor
-
releaseCache
public void releaseCache()
Description copied from interface:SingleCacheRemoves the cached value and makes it such that this cache has not been set- Specified by:
releaseCachein interfaceSingleCache<java.lang.Object>
-
isReified
public boolean isReified()
Description copied from interface:ActiveDescriptorThis method returns true if this descriptor has been reified (class loaded). If this method returns false then the other methods in this interface will throw an IllegalStateException. Once this method returns true it may be- Specified by:
isReifiedin interfaceActiveDescriptor<java.lang.Object>- Returns:
- true if this descriptor has been reified, false otherwise
-
getImplementationClass
public java.lang.Class<?> getImplementationClass()
Description copied from interface:ActiveDescriptorThe implementation class that should be used to generate new instances of this descriptor.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
- Specified by:
getImplementationClassin interfaceActiveDescriptor<java.lang.Object>- Returns:
- The class that directly implements the contract types, or the class that is the factory for an object that implements the contract types
-
getImplementationType
public java.lang.reflect.Type getImplementationType()
Description copied from interface:ActiveDescriptorIf known the Type of the implementation. If unknown will return the same asActiveDescriptor.getImplementationClass()- Specified by:
getImplementationTypein interfaceActiveDescriptor<java.lang.Object>- Returns:
- The type of the implementation or the implementation class
-
getContractTypes
public java.util.Set<java.lang.reflect.Type> getContractTypes()
Description copied from interface:ActiveDescriptorThe set of types that this ActiveDescriptor must produce. These types may be Classes or ParameterizedTypes, and may be no other subclass of Type- Specified by:
getContractTypesin interfaceActiveDescriptor<java.lang.Object>- Returns:
- the set of types this ActiveDescriptor must implement or extend
-
getScopeAsAnnotation
public java.lang.annotation.Annotation getScopeAsAnnotation()
Description copied from interface:ActiveDescriptorReturns the scope as anAnnotationimplementation that this ActiveDescriptor belongs to- Specified by:
getScopeAsAnnotationin interfaceActiveDescriptor<java.lang.Object>- Returns:
- The scope of this ActiveDescriptor as an
Annotation
-
getScopeAnnotation
public java.lang.Class<? extends java.lang.annotation.Annotation> getScopeAnnotation()
Description copied from interface:ActiveDescriptorReturns the scope that this ActiveDescriptor belongs to- Specified by:
getScopeAnnotationin interfaceActiveDescriptor<java.lang.Object>- Returns:
- The scope of this ActiveDescriptor
-
getQualifierAnnotations
public java.util.Set<java.lang.annotation.Annotation> getQualifierAnnotations()
Description copied from interface:ActiveDescriptorThe full set of qualifiers that this ActiveDescriptor provides- Specified by:
getQualifierAnnotationsin interfaceActiveDescriptor<java.lang.Object>- Returns:
- The set of annotations that this ActiveDescriptor provides
-
getInjectees
public java.util.List<Injectee> getInjectees()
Description copied from interface:ActiveDescriptorReturns the full list of Injectees this class has. These references will be resolved prior to the class being constructed, even if these injectees are field or method injectees.If this descriptor is describing a factory created type then this list must have zero length
- Specified by:
getInjecteesin interfaceActiveDescriptor<java.lang.Object>- Returns:
- Will not return null, but may return an empty list. The set of Injectees that must be resolved before this ActiveDescriptor can be constructed
-
getFactoryServiceId
public java.lang.Long getFactoryServiceId()
Description copied from interface:ActiveDescriptorIf this ActiveDescriptor has DescriptorType of PROVIDE_METHOD then this field will return the ServiceId of its associated Factory service. Otherwise this method should return null- Specified by:
getFactoryServiceIdin interfaceActiveDescriptor<java.lang.Object>- Returns:
- The service ID of the associated factory service
-
getFactoryLocatorId
public java.lang.Long getFactoryLocatorId()
Description copied from interface:ActiveDescriptorIf this ActiveDescriptor has DescriptorType of PROVIDE_METHOD then this field will return the ServiceId of its associated Factory service. Otherwise this method should return null- Specified by:
getFactoryLocatorIdin interfaceActiveDescriptor<java.lang.Object>- Returns:
- The locator ID of the associated factory service
-
create
public java.lang.Object create(ServiceHandle<?> root)
Description copied from interface:ActiveDescriptorCreates an instance of the ActiveDescriptor. All of the Injectee's must be created prior to instantiation, and associated with the ExtendedProvider so that they can be destroyed properly- Specified by:
createin interfaceActiveDescriptor<java.lang.Object>- Parameters:
root- The root service handle, which can be used to associated all the PerLookup objects with this creation- Returns:
- An instance of this ActiveDescriptor
-
dispose
public void dispose(java.lang.Object instance)
Description copied from interface:ActiveDescriptorDisposes this instance. All the PerLookup objects that were created for this instance will be destroyed after this object has been destroyed- Specified by:
disposein interfaceActiveDescriptor<java.lang.Object>- Parameters:
instance- The instance to destroy
-
-