|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.glassfish.hk2.utilities.DescriptorImpl
com.sun.hk2.component.AbstractInhabitantImpl<T>
com.sun.hk2.component.ExistingSingletonInhabitant<T>
@Deprecated public class ExistingSingletonInhabitant<T>
Inhabitant
built around an object that already exists.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.sun.hk2.component.Holder |
---|
Holder.Impl<T> |
Field Summary |
---|
Fields inherited from class com.sun.hk2.component.AbstractInhabitantImpl |
---|
descriptor, logger |
Constructor Summary | |
---|---|
ExistingSingletonInhabitant(Class<T> type,
T object)
Deprecated. |
|
ExistingSingletonInhabitant(Class<T> type,
T object,
Map<String,List<String>> metadata)
Deprecated. |
|
ExistingSingletonInhabitant(T object)
Deprecated. |
Method Summary | |
---|---|
T |
create(ServiceHandle<?> root)
Deprecated. Creates an instance of the ActiveDescriptor. |
void |
dispose(T instance)
Deprecated. Disposes this instance. |
T |
get(Inhabitant onBehalfOf)
Deprecated. Returns the instance of this inhabitant. |
T |
getCache()
Deprecated. This can be used for scopes that will only every be created once. |
Set<Type> |
getContractTypes()
Deprecated. The set of types that this ActiveDescriptor must produce. |
Long |
getFactoryLocatorId()
Deprecated. If this ActiveDescriptor has DescriptorType of PROVIDE_METHOD then this field will return the ServiceId of its associated Factory service. |
Long |
getFactoryServiceId()
Deprecated. If this ActiveDescriptor has DescriptorType of PROVIDE_METHOD then this field will return the ServiceId of its associated Factory service. |
Class<?> |
getImplementationClass()
Deprecated. The implementation class that should be used to generate new instances of this descriptor. |
List<Injectee> |
getInjectees()
Deprecated. Returns the full list of Injectees this class has. |
Set<Annotation> |
getQualifierAnnotations()
Deprecated. The full set of qualifiers that this ActiveDescriptor provides |
Class<? extends Annotation> |
getScopeAnnotation()
Deprecated. Returns the scope that this ActiveDescriptor belongs to |
boolean |
isActive()
Deprecated. Returns true if the component has been instantiated. |
boolean |
isCacheSet()
Deprecated. Returns true if this cache has been set |
boolean |
isReified()
Deprecated. This method returns true if this descriptor has been reified (class loaded). |
Map<String,List<String>> |
metadata()
Deprecated. Gets the metadata associated with this inhabitant. |
void |
release()
Deprecated. Called to orderly shutdown ServiceLocator . |
void |
releaseCache()
Deprecated. Removes the cached value and makes it such that this cache has not been set |
void |
setCache(T cacheMe)
Deprecated. Sets the value into the cache |
String |
toString()
Deprecated. |
Class<T> |
type()
Deprecated. Type of the inhabitant. |
String |
typeName()
Deprecated. The short-cut for type().getName()
but this allows us to defer loading the actual types. |
Methods inherited from class com.sun.hk2.component.AbstractInhabitantImpl |
---|
companions, get, getAnnotation, getAnnotation, getAnnotations, getByType, getDescriptor, getDescriptorFor, getProvider, getProvider, getSerializedMetadata, getSerializedMetadata, lead, matches, setCompanions |
Methods inherited from class org.glassfish.hk2.utilities.DescriptorImpl |
---|
addAdvertisedContract, addMetadata, addQualifier, equals, getAdvertisedContracts, getBaseDescriptor, getDescriptorType, getImplementation, getLoader, getLocatorId, getMetadata, getName, getQualifiers, getRanking, getScope, getServiceId, hashCode, pretty, readObject, removeAdvertisedContract, removeAllMetadata, removeMetadata, removeQualifier, setBaseDescriptor, setDescriptorType, setImplementation, setLoader, setLocatorId, setName, setRanking, setScope, setServiceId, 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, getImplementation, getLoader, getLocatorId, getMetadata, getName, getQualifiers, getRanking, getScope, getServiceId, setRanking |
Constructor Detail |
---|
public ExistingSingletonInhabitant(T object)
public ExistingSingletonInhabitant(Class<T> type, T object)
public ExistingSingletonInhabitant(Class<T> type, T object, Map<String,List<String>> metadata)
Method Detail |
---|
public String toString()
toString
in class AbstractInhabitantImpl<T>
public String typeName()
Inhabitant
type().getName()
but this allows us to defer loading the actual types.
typeName
in interface Inhabitant<T>
public Class<T> type()
Inhabitant
The only binding contract that needs to be honored is that the Inhabitant.get()
method returns an instance assignable to this type. That is,
get().getClass()==type()
doesn't necessarily have to hold,
but type().isInstance(get())
must.
This is particularly true when Factory
is involved, as in such
case HK2 has no way of knowing the actual type.
That said, this method is not designed for the semantics of
contract/implementation split --- implementations of a contract
should return the concrete type from this method, and use
habitat index
to support look-up by contract.
type
in interface Provider<T>
type
in interface Inhabitant<T>
public Map<String,List<String>> metadata()
Inhabitant
This data is usually used by a sub-system of HK2, and not really meant to
be used by applications. (At least for now.)
The main benefit of metadata is that it's available right away
as soon as the ServiceLocator
is properly initialized, even before
component classes are loaded. In contrast, accessing annotations would require
classes to be loaded and resolved.
metadata
in interface Inhabitant<T>
Service.metadata()
public T get(Inhabitant onBehalfOf) throws ComponentException
Inhabitant
THIS METHOD SHOULD BE ONLY USED BY HK2 IMPLEMENTATION.
Inhabitant
s are often used with the decorator pattern
(see AbstractCreatorInhabitantImpl
for example), yet during
the object initializtion inside the Inhabitant.get()
method, we often
need the reference to the outer-most Inhabitant
registered to
the ServiceLocator
(for example so that we can request the injection
of {link Inhabita} that represents itself, or to inject companions.)
So this overloaded version of the get method takes the outer-most
Inhabitant
. This method is only invoked from within HK2
where the decorator pattern is used.
get
in interface Inhabitant<T>
ComponentException
public boolean isActive()
Provider
isActive
in interface Provider<T>
public void release()
Inhabitant
ServiceLocator
.
The expected behavior is for objects to get its PreDestroy
callback invoked, and its reference released. For singleton
objects, this method is expected to dispose that object.
For scoped objects, those are released when ScopeInstance.release()
is invoked.
release
in interface Releasable
release
in interface Inhabitant<T>
public T getCache()
SingleCache
getCache
in interface SingleCache<T>
public boolean isCacheSet()
SingleCache
isCacheSet
in interface SingleCache<T>
public void setCache(T cacheMe)
SingleCache
setCache
in interface SingleCache<T>
cacheMe
- A single value that can be cached in this
active descriptorpublic void releaseCache()
SingleCache
releaseCache
in interface SingleCache<T>
public boolean isReified()
ActiveDescriptor
isReified
in interface ActiveDescriptor<T>
public Class<?> getImplementationClass()
ActiveDescriptor
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
getImplementationClass
in interface ActiveDescriptor<T>
public Set<Type> getContractTypes()
ActiveDescriptor
getContractTypes
in interface ActiveDescriptor<T>
public Class<? extends Annotation> getScopeAnnotation()
ActiveDescriptor
getScopeAnnotation
in interface ActiveDescriptor<T>
public Set<Annotation> getQualifierAnnotations()
ActiveDescriptor
getQualifierAnnotations
in interface ActiveDescriptor<T>
public Long getFactoryServiceId()
ActiveDescriptor
getFactoryServiceId
in interface ActiveDescriptor<T>
public Long getFactoryLocatorId()
ActiveDescriptor
getFactoryLocatorId
in interface ActiveDescriptor<T>
public List<Injectee> getInjectees()
ActiveDescriptor
If this descriptor is describing a factory created type then this list must have zero length
getInjectees
in interface ActiveDescriptor<T>
public T create(ServiceHandle<?> root)
ActiveDescriptor
create
in interface ActiveDescriptor<T>
root
- The root service handle, which can be used
to associated all the PerLookup objects with this creation
public void dispose(T instance)
ActiveDescriptor
dispose
in interface ActiveDescriptor<T>
dispose
in class AbstractInhabitantImpl<T>
instance
- The instance to destroy
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |