Package org.glassfish.hk2.api
Interface ActiveDescriptor<T>
-
- Type Parameters:
T
- This is the type produced by the cache and consumed by the cache
- All Superinterfaces:
Descriptor
,SingleCache<T>
- All Known Implementing Classes:
AbstractActiveDescriptor
,ActiveDescriptorBuilderImpl.BuiltActiveDescriptor
,AliasDescriptor
,AutoActiveDescriptor
,ConstantActiveDescriptor
,ConstantActiveDescriptor
,CrossOverDescriptor
,DelegatingNamedActiveDescriptor
,OperationDescriptor
,SystemDescriptor
public interface ActiveDescriptor<T> extends Descriptor, SingleCache<T>
An ActiveDescriptor contains information about a Descriptor after it has been reified. Most of the methods in an ActiveDescriptor cannot be called until the isReified method return true. Prior to that the information is not yet known. ActiveDescriptors can be reified with theServiceLocator
.reifyDescriptor method.ActiveDescriptors may also be provided to the system pre-reified, which is useful when the Service described may be produced by a third-party system. In this case the ActiveDescriptors create method must use the third-party system in order to create instances of the described service
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
create(ServiceHandle<?> root)
Creates an instance of the ActiveDescriptor.void
dispose(T instance)
Disposes this instance.java.util.Set<java.lang.reflect.Type>
getContractTypes()
The set of types that this ActiveDescriptor must produce.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.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.java.util.Set<java.lang.annotation.Annotation>
getQualifierAnnotations()
The full set of qualifiers that this ActiveDescriptor providesjava.lang.Class<? extends java.lang.annotation.Annotation>
getScopeAnnotation()
Returns the scope that this ActiveDescriptor belongs tojava.lang.annotation.Annotation
getScopeAsAnnotation()
Returns the scope as anAnnotation
implementation that this ActiveDescriptor belongs toboolean
isReified()
This method returns true if this descriptor has been reified (class loaded).-
Methods inherited from interface org.glassfish.hk2.api.Descriptor
getAdvertisedContracts, getClassAnalysisName, getDescriptorType, getDescriptorVisibility, getImplementation, getLoader, getLocatorId, getMetadata, getName, getQualifiers, getRanking, getScope, getServiceId, isProxiable, isProxyForSameScope, setRanking
-
Methods inherited from interface org.glassfish.hk2.api.SingleCache
getCache, isCacheSet, releaseCache, setCache
-
-
-
-
Method Detail
-
isReified
boolean isReified()
This 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- Returns:
- true if this descriptor has been reified, false otherwise
-
getImplementationClass
java.lang.Class<?> getImplementationClass()
The 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
- 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
java.lang.reflect.Type getImplementationType()
If known the Type of the implementation. If unknown will return the same asgetImplementationClass()
- Returns:
- The type of the implementation or the implementation class
-
getContractTypes
java.util.Set<java.lang.reflect.Type> getContractTypes()
The set of types that this ActiveDescriptor must produce. These types may be Classes or ParameterizedTypes, and may be no other subclass of Type- Returns:
- the set of types this ActiveDescriptor must implement or extend
-
getScopeAsAnnotation
java.lang.annotation.Annotation getScopeAsAnnotation()
Returns the scope as anAnnotation
implementation that this ActiveDescriptor belongs to- Returns:
- The scope of this ActiveDescriptor as an
Annotation
-
getScopeAnnotation
java.lang.Class<? extends java.lang.annotation.Annotation> getScopeAnnotation()
Returns the scope that this ActiveDescriptor belongs to- Returns:
- The scope of this ActiveDescriptor
-
getQualifierAnnotations
java.util.Set<java.lang.annotation.Annotation> getQualifierAnnotations()
The full set of qualifiers that this ActiveDescriptor provides- Returns:
- The set of annotations that this ActiveDescriptor provides
-
getInjectees
java.util.List<Injectee> getInjectees()
Returns 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
- 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
java.lang.Long getFactoryServiceId()
If 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- Returns:
- The service ID of the associated factory service
-
getFactoryLocatorId
java.lang.Long getFactoryLocatorId()
If 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- Returns:
- The locator ID of the associated factory service
-
create
T create(ServiceHandle<?> root)
Creates 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- 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
void dispose(T instance)
Disposes this instance. All the PerLookup objects that were created for this instance will be destroyed after this object has been destroyed- Parameters:
instance
- The instance to destroy
-
-