|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.hk2.component.AbstractInhabitantImpl<T>
com.sun.hk2.component.EventPublishingInhabitant<T>
com.sun.hk2.component.RunLevelInhabitant<T,V>
public class RunLevelInhabitant<T,V>
An inhabitant that prevents activation unless the sufficient RunLevelState has been scheduled.
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.EventPublishingInhabitant |
---|
real |
Method Summary | |
---|---|
T |
get(Inhabitant onBehalfOf)
Returns the instance of this inhabitant. |
RunLevelState<?> |
getState()
|
java.lang.Class<T> |
type()
Type of the inhabitant. |
protected void |
verifyState()
Verifies that the state of the RunLevelService is appropriate for this instance activation. |
Methods inherited from class com.sun.hk2.component.EventPublishingInhabitant |
---|
addInhabitantListener, fetch, isInstantiated, metadata, notify, release, removeInhabitantListener, toString, typeName |
Methods inherited from class com.sun.hk2.component.AbstractInhabitantImpl |
---|
companions, get, getAnnotation, getAnnotation, getSerializedMetadata, getSerializedMetadata, lead, setCompanions |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public java.lang.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 Inhabitant<T>
type
in class EventPublishingInhabitant<T>
public T get(Inhabitant onBehalfOf)
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 Habitat
(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>
get
in class EventPublishingInhabitant<T>
protected void verifyState() throws ComponentException
ComponentException
- if not in an appropriate statepublic RunLevelState<?> getState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |