org.glassfish.hk2.internal
Class ConstantActiveDescriptor<T>

java.lang.Object
  extended by org.glassfish.hk2.utilities.DescriptorImpl
      extended by org.glassfish.hk2.utilities.AbstractActiveDescriptor<T>
          extended by org.glassfish.hk2.internal.ConstantActiveDescriptor<T>
Type Parameters:
T - The type of the constant
All Implemented Interfaces:
Serializable, ActiveDescriptor<T>, Descriptor, SingleCache<T>

public class ConstantActiveDescriptor<T>
extends AbstractActiveDescriptor<T>

Author:
jwells
See Also:
Serialized Form

Constructor Summary
ConstantActiveDescriptor()
          For serializable
ConstantActiveDescriptor(T theOne, Set<Type> advertisedContracts, Class<? extends Annotation> scope, String name, Set<Annotation> qualifiers, Map<String,List<String>> metadata)
          Creates the constant descriptor
 
Method Summary
 T create(ServiceHandle<?> root)
          Creates an instance of the ActiveDescriptor.
 T getCache()
          This can be used for scopes that will only every be created once.
 String getImplementation()
          Returns the fully qualified class name of the implementation class.
 Class<?> getImplementationClass()
          The implementation class that should be used to generate new instances of this descriptor.
 boolean isCacheSet()
          Returns true if this cache has been set
 
Methods inherited from class org.glassfish.hk2.utilities.AbstractActiveDescriptor
addContractType, addQualifierAnnotation, dispose, getContractTypes, getFactoryLocatorId, getFactoryServiceId, getInjectees, getQualifierAnnotations, getScopeAnnotation, isReified, releaseCache, removeContractType, removeQualifierAnnotation, setCache, setFactoryId, setReified
 
Methods inherited from class org.glassfish.hk2.utilities.DescriptorImpl
addAdvertisedContract, addMetadata, addQualifier, equals, getAdvertisedContracts, getBaseDescriptor, getDescriptorType, getLoader, getLocatorId, getMetadata, getName, getQualifiers, getRanking, getScope, getServiceId, hashCode, pretty, readObject, removeAdvertisedContract, removeAllMetadata, removeMetadata, removeQualifier, setBaseDescriptor, setDescriptorType, setImplementation, setLoader, setLocatorId, setName, setRanking, setScope, setServiceId, toString, 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, getBaseDescriptor, getDescriptorType, getLoader, getLocatorId, getMetadata, getName, getQualifiers, getRanking, getScope, getServiceId, setRanking
 

Constructor Detail

ConstantActiveDescriptor

public ConstantActiveDescriptor()
For serializable


ConstantActiveDescriptor

public ConstantActiveDescriptor(T theOne,
                                Set<Type> advertisedContracts,
                                Class<? extends Annotation> scope,
                                String name,
                                Set<Annotation> qualifiers,
                                Map<String,List<String>> metadata)
Creates the constant descriptor

Parameters:
theOne - May not be null
advertisedContracts -
scope -
name -
qualifiers -
Method Detail

getImplementation

public 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 interface Descriptor
Overrides:
getImplementation in class DescriptorImpl
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

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 interface SingleCache<T>
Overrides:
getCache in class AbstractActiveDescriptor<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 interface SingleCache<T>
Overrides:
isCacheSet in class AbstractActiveDescriptor<T>
Returns:
true if there is a currently cached value, false otherwise

getImplementationClass

public 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

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


Copyright © 2013 Oracle Corporation. All Rights Reserved.