|
||||||||||
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.AbstractCreatorImpl<T>
@Deprecated public abstract class AbstractCreatorImpl<T>
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.sun.hk2.component.Holder |
---|
Holder.Impl<T> |
Field Summary | |
---|---|
protected ServiceLocator |
serviceLocator
Deprecated. |
protected Class<? extends T> |
type
Deprecated. |
Fields inherited from class com.sun.hk2.component.AbstractInhabitantImpl |
---|
descriptor |
Constructor Summary | |
---|---|
AbstractCreatorImpl(Class<? extends T> type,
ServiceLocator serviceLocator,
Map<String,List<String>> metadata)
Deprecated. |
Method Summary | |
---|---|
T |
get(Inhabitant onBehalfOf)
Deprecated. Returns the instance of this inhabitant. |
protected InjectionResolver[] |
getInjectionResolvers(T t,
ServiceLocator h)
Deprecated. TODO: JRW This is another one that is going to need some thought |
void |
initialize(T t,
Inhabitant onBehalfOf)
Deprecated. Performs initialization of object, such as dependency injection. |
protected void |
inject(ServiceLocator habitat,
T t,
Inhabitant<?> onBehalfOf)
Deprecated. Performs resource injection on the given instance from the given habitat. |
boolean |
isActive()
Deprecated. Returns true if the component has been instantiated. |
Map<String,List<String>> |
metadata()
Deprecated. Gets the metadata associated with this inhabitant. |
void |
release()
Deprecated. Called to orderly shutdown ServiceLocator . |
Class<? extends 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, dispose, get, getAnnotation, getAnnotation, getAnnotations, getByType, getDescriptor, getDescriptorFor, getProvider, getProvider, getSerializedMetadata, getSerializedMetadata, lead, matches, setCompanions, toString |
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.jvnet.hk2.component.Creator |
---|
create, get |
Methods inherited from interface org.jvnet.hk2.component.Inhabitant |
---|
companions, getSerializedMetadata, getSerializedMetadata, lead, setCompanions |
Methods inherited from interface org.glassfish.hk2.Binding |
---|
getDescriptor, getProvider, getProvider |
Methods inherited from interface org.glassfish.hk2.Provider |
---|
getAnnotations, getByType |
Methods inherited from interface org.glassfish.hk2.api.Descriptor |
---|
getAdvertisedContracts, getBaseDescriptor, getDescriptorType, getImplementation, getLoader, getLocatorId, getMetadata, getName, getQualifiers, getRanking, getScope, getServiceId, setRanking |
Field Detail |
---|
protected final Class<? extends T> type
protected final ServiceLocator serviceLocator
Constructor Detail |
---|
public AbstractCreatorImpl(Class<? extends T> type, ServiceLocator serviceLocator, Map<String,List<String>> metadata)
Method Detail |
---|
public String typeName()
Inhabitant
type().getName()
but this allows us to defer loading the actual types.
typeName
in interface Inhabitant<T>
public final Class<? extends 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 final 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 initialize(T t, Inhabitant onBehalfOf) throws ComponentException
Creator
initialize
in interface Creator<T>
ComponentException
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 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()
protected void inject(ServiceLocator habitat, T t, Inhabitant<?> onBehalfOf)
This method is an utility method for subclasses for performing injection.
protected InjectionResolver[] getInjectionResolvers(T t, ServiceLocator h)
t
- h
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |