|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.hk2.component.AbstractInhabitantImpl<T>
public abstract class AbstractInhabitantImpl<T>
Partial implementation of Inhabitant that defines methods whose
semantics is fixed by Habitat.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.sun.hk2.component.Holder |
|---|
Holder.Impl<T> |
| Constructor Summary | |
|---|---|
AbstractInhabitantImpl()
|
|
| Method Summary | ||
|---|---|---|
java.util.Collection<Inhabitant> |
companions()
Returns the companion inhabitants associated with this inhabitant. |
|
T |
get()
Returns the instance of this inhabitant. |
|
static
|
getAnnotation(java.lang.Class<?> annotated,
java.lang.Class<V> annotation,
boolean walkParentChain)
FOR INTERNAL USE TO HK2 |
|
|
getAnnotation(java.lang.Class<V> annotation)
|
|
|
getSerializedMetadata(java.lang.Class<T> type)
Obtains the metadata serialized into String. |
|
|
getSerializedMetadata(java.lang.Class<T> type,
java.lang.String key)
Obtains the serialized metadata. |
|
Inhabitant |
lead()
If this inhabitant is a companion to another inhabitant (called "lead"), This method returns that inhabitant. |
|
void |
setCompanions(java.util.Collection<Inhabitant> companions)
This method is only meant to be invoked by Habitat. |
|
java.lang.String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.jvnet.hk2.component.Inhabitant |
|---|
get, isInstantiated, metadata, release, type, typeName |
| Constructor Detail |
|---|
public AbstractInhabitantImpl()
| Method Detail |
|---|
public java.lang.String toString()
toString in class java.lang.Objectpublic final T get()
Inhabitant
Some Inhabitants return the same instance for multiple
invocations (AKA singleton), but
the method may return different instances to invocations from different
context (AKA scope.) The extreme case is where the each invocation
returns a different object.
get in interface Holder<T>get in interface Inhabitant<T>
public <T> T getSerializedMetadata(java.lang.Class<T> type,
java.lang.String key)
Inhabitant
This method is a wrapper around Inhabitant.metadata() and useful for
defining a highly structured metadata that doesn't easily fit
a simple string representation.
The implementation of this method is to obtain the value associated with
this key as metadata().getOne(key), and if that exists, treat
the value as base64-encoded binary, and deserializes it and returns the object.
The classes used in the serialization need to be available during the build time (normally during the HK2 compile mojo runs) so that the metadata can be serialized. The evolution of these classes need to be careful done, otherwise the deserialization of the metadata may fail unexpectedly.
getSerializedMetadata in interface Inhabitant<T>public final <T> T getSerializedMetadata(java.lang.Class<T> type)
Inhabitant
This is a convenient short-cut that does getSerializedMetadata(type,type.getName())
getSerializedMetadata in interface Inhabitant<T>public Inhabitant lead()
Inhabitant
lead in interface Inhabitant<T>public final java.util.Collection<Inhabitant> companions()
Inhabitant
This method works with the Inhabitant.lead() method in pairs, such
that the following condition always holds:
x.companions().contains(y) <-> y.lead()==x
companions in interface Inhabitant<T>public final void setCompanions(java.util.Collection<Inhabitant> companions)
InhabitantHabitat.
setCompanions in interface Inhabitant<T>public <V extends java.lang.annotation.Annotation> V getAnnotation(java.lang.Class<V> annotation)
public static <V extends java.lang.annotation.Annotation> V getAnnotation(java.lang.Class<?> annotated,
java.lang.Class<V> annotation,
boolean walkParentChain)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||