Package org.jvnet.hk2.internal
Class ConstantActiveDescriptor<T>
- java.lang.Object
-
- org.glassfish.hk2.utilities.DescriptorImpl
-
- org.glassfish.hk2.utilities.AbstractActiveDescriptor<T>
-
- org.jvnet.hk2.internal.ConstantActiveDescriptor<T>
-
- Type Parameters:
T
- The type of the constant
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,ActiveDescriptor<T>
,Descriptor
,SingleCache<T>
public class ConstantActiveDescriptor<T> extends AbstractActiveDescriptor<T>
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Long
locatorId
private static long
serialVersionUID
For serializationprivate T
theOne
-
Constructor Summary
Constructors Constructor Description ConstantActiveDescriptor()
For serializationConstantActiveDescriptor(T theOne, java.util.Set<java.lang.reflect.Type> advertisedContracts, java.lang.Class<? extends java.lang.annotation.Annotation> scope, java.lang.String name, java.util.Set<java.lang.annotation.Annotation> qualifiers, DescriptorVisibility visibility, int ranking, java.lang.Boolean proxy, java.lang.Boolean proxyForSameScope, java.lang.String analyzerName, long locatorId, java.util.Map<java.lang.String,java.util.List<java.lang.String>> metadata)
Constructor with more control over the fields of the descriptorConstantActiveDescriptor(T theOne, ServiceLocatorImpl locator)
Creates a constant active descriptor with the given locator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
create(ServiceHandle<?> root)
Creates an instance of the ActiveDescriptor.void
dispose(T instance)
Disposes this instance.T
getCache()
This can be used for scopes that will only every be created once.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.lang.Long
getLocatorId()
This returns the id of the ServiceLocator which this descriptor is registered with.boolean
isCacheSet()
Returns true if this cache has been setvoid
setImplementationType(java.lang.reflect.Type t)
-
Methods inherited from class org.glassfish.hk2.utilities.AbstractActiveDescriptor
addContractType, addQualifierAnnotation, equals, getContractTypes, getFactoryLocatorId, getFactoryServiceId, getInjectees, getQualifierAnnotations, getScopeAnnotation, getScopeAsAnnotation, hashCode, isReified, releaseCache, removeContractType, removeQualifierAnnotation, setCache, setFactoryId, setName, setReified, setScopeAnnotation, setScopeAsAnnotation
-
Methods inherited from class org.glassfish.hk2.utilities.DescriptorImpl
addAdvertisedContract, addMetadata, addMetadata, addQualifier, clearMetadata, descriptorEquals, getAdvertisedContracts, getClassAnalysisName, getDescriptorType, getDescriptorVisibility, getLoader, getMetadata, getName, getQualifiers, 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, getMetadata, getName, getQualifiers, getRanking, getScope, getServiceId, isProxiable, isProxyForSameScope, setRanking
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization- See Also:
- Constant Field Values
-
theOne
private T theOne
-
locatorId
private java.lang.Long locatorId
-
-
Constructor Detail
-
ConstantActiveDescriptor
public ConstantActiveDescriptor()
For serialization
-
ConstantActiveDescriptor
public ConstantActiveDescriptor(T theOne, ServiceLocatorImpl locator)
Creates a constant active descriptor with the given locator- Parameters:
theOne
- the object to create it fromlocator
- the locator this is being created for
-
ConstantActiveDescriptor
public ConstantActiveDescriptor(T theOne, java.util.Set<java.lang.reflect.Type> advertisedContracts, java.lang.Class<? extends java.lang.annotation.Annotation> scope, java.lang.String name, java.util.Set<java.lang.annotation.Annotation> qualifiers, DescriptorVisibility visibility, int ranking, java.lang.Boolean proxy, java.lang.Boolean proxyForSameScope, java.lang.String analyzerName, long locatorId, java.util.Map<java.lang.String,java.util.List<java.lang.String>> metadata)
Constructor with more control over the fields of the descriptor- Parameters:
theOne
- The non-null constantadvertisedContracts
- its advertised contractsscope
- its scopename
- its possibly null namequalifiers
- its set of qualifiersvisibility
- its visibilityranking
- its starting rankproxy
- can it be proxied (null for default)proxyForSameScope
- will it be proxied for the same scope (null for default)analyzerName
- The name of the analyzer (null for default)locatorId
- its locator parentmetadata
- The metadata associated with it
-
-
Method Detail
-
getImplementation
public java.lang.String getImplementation()
Description copied from interface:Descriptor
Returns 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:
getImplementation
in interfaceDescriptor
- Overrides:
getImplementation
in 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
-
getLocatorId
public java.lang.Long getLocatorId()
Description copied from interface:Descriptor
This 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:
getLocatorId
in interfaceDescriptor
- Overrides:
getLocatorId
in classDescriptorImpl
- Returns:
- The id of the ServiceLocator this Descriptor is registered with, or null if this Descriptor is not registered with a ServiceLocator
-
getCache
public T getCache()
Description copied from interface:SingleCache
This 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:
getCache
in interfaceSingleCache<T>
- Overrides:
getCache
in classAbstractActiveDescriptor<T>
- Returns:
- A value cached with this ActiveDescriptor
-
isCacheSet
public boolean isCacheSet()
Description copied from interface:SingleCache
Returns true if this cache has been set- Specified by:
isCacheSet
in interfaceSingleCache<T>
- Overrides:
isCacheSet
in classAbstractActiveDescriptor<T>
- Returns:
- true if there is a currently cached value, false otherwise
-
getImplementationClass
public java.lang.Class<?> getImplementationClass()
Description copied from interface:ActiveDescriptor
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
public java.lang.reflect.Type getImplementationType()
Description copied from interface:ActiveDescriptor
If known the Type of the implementation. If unknown will return the same asActiveDescriptor.getImplementationClass()
- Returns:
- The type of the implementation or the implementation class
-
setImplementationType
public void setImplementationType(java.lang.reflect.Type t)
- Overrides:
setImplementationType
in classAbstractActiveDescriptor<T>
-
create
public T create(ServiceHandle<?> root)
Description copied from interface:ActiveDescriptor
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
public void dispose(T instance)
Description copied from interface:ActiveDescriptor
Disposes this instance. All the PerLookup objects that were created for this instance will be destroyed after this object has been destroyed- Specified by:
dispose
in interfaceActiveDescriptor<T>
- Overrides:
dispose
in classAbstractActiveDescriptor<T>
- Parameters:
instance
- The instance to destroy
-
-