Package org.glassfish.hk2.utilities
Class AliasDescriptor<T>
- java.lang.Object
-
- org.glassfish.hk2.utilities.DescriptorImpl
-
- org.glassfish.hk2.utilities.AbstractActiveDescriptor<T>
-
- org.glassfish.hk2.utilities.AliasDescriptor<T>
-
- Type Parameters:
T- The cache type
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,ActiveDescriptor<T>,Descriptor,SingleCache<T>
public class AliasDescriptor<T> extends AbstractActiveDescriptor<T>
An active descriptor class that serves as an alias for another descriptor. This alias can have only one contract that may or may not also be advertised by the host descriptor. An AliasDescriptor can have a different name from the host descriptor as well- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringALIAS_FREE_DESCRIPTORThis is the value the metadata field ALIAS_METADATA_MARKER will take if the descriptor being aliased does not have a locator id or a service idstatic java.lang.StringALIAS_METADATA_MARKERThis will be put in all Alias descriptors.private java.lang.StringcontractThe contract type of this descriptor.private ActiveDescriptor<T>descriptorThe descriptor that this descriptor will alias.private static java.util.Set<java.lang.annotation.Annotation>EMPTY_ANNOTATION_SETEmpty set of annotations used to construct this descriptor.private static java.util.Set<java.lang.reflect.Type>EMPTY_CONTRACT_SETEmpty set of contracts used to construct this descriptor.private booleaninitializedIndicates whether or not this descriptor has been initialized.private ServiceLocatorlocatorThe service locator.private java.util.Set<java.lang.String>qualifierNamesThe set of qualifier names for this descriptor.private java.util.Set<java.lang.annotation.Annotation>qualifiersThe set of annotations for this descriptor.private static longserialVersionUIDFor serialization
-
Constructor Summary
Constructors Constructor Description AliasDescriptor()For serializationAliasDescriptor(ServiceLocator locator, ActiveDescriptor<T> descriptor, java.lang.String contract, java.lang.String name)Construct an AliasDescriptor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Tcreate(ServiceHandle<?> root)Creates an instance of the ActiveDescriptor.voiddispose(T instance)Disposes this instance.private voidensureInitialized()Ensure that this descriptor has been initialized.booleanequals(java.lang.Object o)This equals matches only if the following fields of the descriptor match: implementation contracts name scope qualifiers descriptorType descriptorVisibility metadata proxiable proxyForSameScope analysisNameprivate static java.lang.StringgetAliasMetadataValue(ActiveDescriptor<?> descriptor)java.util.Set<java.lang.reflect.Type>getContractTypes()The set of types that this ActiveDescriptor must produce.ActiveDescriptor<T>getDescriptor()Get the descriptor being aliased.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.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 byjava.lang.Class<? extends java.lang.annotation.Annotation>getScopeAnnotation()Returns the scope that this ActiveDescriptor belongs tointhashCode()booleanisReified()This method returns true if this descriptor has been reified (class loaded).-
Methods inherited from class org.glassfish.hk2.utilities.AbstractActiveDescriptor
addContractType, addQualifierAnnotation, getCache, getFactoryLocatorId, getFactoryServiceId, getScopeAsAnnotation, isCacheSet, releaseCache, removeContractType, removeQualifierAnnotation, setCache, setFactoryId, setImplementationType, setName, setReified, setScopeAnnotation, setScopeAsAnnotation
-
Methods inherited from class org.glassfish.hk2.utilities.DescriptorImpl
addAdvertisedContract, addMetadata, addMetadata, addQualifier, clearMetadata, descriptorEquals, getAdvertisedContracts, getClassAnalysisName, getDescriptorType, getDescriptorVisibility, getLoader, getLocatorId, getMetadata, getName, getRanking, getScope, getServiceId, isProxiable, isProxyForSameScope, pretty, readExternal, readObject, removeAdvertisedContract, removeAllMetadata, removeMetadata, removeQualifier, setClassAnalysisName, setDescriptorType, setDescriptorVisibility, setImplementation, setLoader, setLocatorId, setMetadata, setProxiable, setProxyForSameScope, setRanking, setScope, setServiceId, toString, writeExternal, writeObject
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.glassfish.hk2.api.Descriptor
getAdvertisedContracts, getClassAnalysisName, getDescriptorType, getDescriptorVisibility, getLoader, getLocatorId, getMetadata, getName, getRanking, getScope, getServiceId, isProxiable, isProxyForSameScope, setRanking
-
-
-
-
Field Detail
-
ALIAS_METADATA_MARKER
public static final java.lang.String ALIAS_METADATA_MARKER
This will be put in all Alias descriptors. The value will be ALIAS_FREE_DESCRIPTOR if the descritpor being aliased does not have a locator and service id. If the descriptor being aliased does have a locator and service id the value will be. - See Also:
- Constant Field Values
-
ALIAS_FREE_DESCRIPTOR
public static final java.lang.String ALIAS_FREE_DESCRIPTOR
This is the value the metadata field ALIAS_METADATA_MARKER will take if the descriptor being aliased does not have a locator id or a service id- See Also:
- Constant Field Values
-
serialVersionUID
private static final long serialVersionUID
For serialization- See Also:
- Constant Field Values
-
locator
private ServiceLocator locator
The service locator.
-
descriptor
private ActiveDescriptor<T> descriptor
The descriptor that this descriptor will alias.
-
contract
private java.lang.String contract
The contract type of this descriptor.
-
qualifiers
private java.util.Set<java.lang.annotation.Annotation> qualifiers
The set of annotations for this descriptor.
-
qualifierNames
private java.util.Set<java.lang.String> qualifierNames
The set of qualifier names for this descriptor.
-
initialized
private boolean initialized
Indicates whether or not this descriptor has been initialized.
-
EMPTY_CONTRACT_SET
private static final java.util.Set<java.lang.reflect.Type> EMPTY_CONTRACT_SET
Empty set of contracts used to construct this descriptor.
-
EMPTY_ANNOTATION_SET
private static final java.util.Set<java.lang.annotation.Annotation> EMPTY_ANNOTATION_SET
Empty set of annotations used to construct this descriptor.
-
-
Constructor Detail
-
AliasDescriptor
public AliasDescriptor()
For serialization
-
AliasDescriptor
public AliasDescriptor(ServiceLocator locator, ActiveDescriptor<T> descriptor, java.lang.String contract, java.lang.String name)
Construct an AliasDescriptor.- Parameters:
locator- the service locatordescriptor- the descriptor to be aliasedcontract- the contactname- the name
-
-
Method Detail
-
getAliasMetadataValue
private static java.lang.String getAliasMetadataValue(ActiveDescriptor<?> descriptor)
-
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
- 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()- Returns:
- The type of the implementation or the implementation class
-
create
public T 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- 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
-
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<T>- Overrides:
isReifiedin classAbstractActiveDescriptor<T>- Returns:
- true if this descriptor has been reified, false otherwise
-
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- Overrides:
getImplementationin classDescriptorImpl- 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
-
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<T>- Overrides:
getContractTypesin classAbstractActiveDescriptor<T>- Returns:
- the set of types this ActiveDescriptor must implement or extend
-
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<T>- Overrides:
getScopeAnnotationin classAbstractActiveDescriptor<T>- 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<T>- Overrides:
getQualifierAnnotationsin classAbstractActiveDescriptor<T>- Returns:
- The set of annotations that this ActiveDescriptor provides
-
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- Overrides:
getQualifiersin classDescriptorImpl- 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
-
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<T>- Overrides:
getInjecteesin classAbstractActiveDescriptor<T>- 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
-
dispose
public void dispose(T 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<T>- Overrides:
disposein classAbstractActiveDescriptor<T>- Parameters:
instance- The instance to destroy
-
getDescriptor
public ActiveDescriptor<T> getDescriptor()
Get the descriptor being aliased.- Returns:
- the descriptor
-
ensureInitialized
private void ensureInitialized()
Ensure that this descriptor has been initialized.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractActiveDescriptor<T>
-
equals
public boolean equals(java.lang.Object o)
Description copied from class:DescriptorImplThis equals matches only if the following fields of the descriptor match:- implementation
- contracts
- name
- scope
- qualifiers
- descriptorType
- descriptorVisibility
- metadata
- proxiable
- proxyForSameScope
- analysisName
- Overrides:
equalsin classAbstractActiveDescriptor<T>- Parameters:
o- The object to compare to this one. May be null (which will result in a false)- Returns:
- true if the descriptors are equal
-
-