public static final class Hk2RequestScope.Instance extends java.lang.Object implements RequestContext
Modifier and Type | Field and Description |
---|---|
private LazyUid |
id |
private ExtendedLogger |
logger |
private java.util.concurrent.atomic.AtomicInteger |
referenceCounter
Holds the number of snapshots of this scope.
|
private java.util.Map<ForeignDescriptor,java.lang.Object> |
store
A map of injectable instances in this scope.
|
Modifier | Constructor and Description |
---|---|
private |
Instance() |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(ForeignDescriptor provider) |
<T> T |
get(ForeignDescriptor descriptor)
Get an inhabitant stored in the scope instance that matches the active descriptor .
|
Hk2RequestScope.Instance |
getReference()
Get a "new" reference of the scope instance.
|
<T> T |
put(ForeignDescriptor descriptor,
T value)
Store a new inhabitant for the given descriptor.
|
void |
release()
Release a single reference to the current request scope instance.
|
<T> void |
remove(ForeignDescriptor descriptor)
Remove a value for the descriptor if present in the scope instance store.
|
java.lang.String |
toString() |
private final ExtendedLogger logger
private final LazyUid id
private final java.util.Map<ForeignDescriptor,java.lang.Object> store
private final java.util.concurrent.atomic.AtomicInteger referenceCounter
public Hk2RequestScope.Instance getReference()
release()
method is explicitly
called (once per each getReference()
method call).getReference
in interface RequestContext
public <T> T get(ForeignDescriptor descriptor)
T
- inhabitant type.descriptor
- inhabitant descriptor.null
if not matched.public <T> T put(ForeignDescriptor descriptor, T value)
T
- inhabitant type.descriptor
- inhabitant descriptor.value
- inhabitant value.null
if none stored.public <T> void remove(ForeignDescriptor descriptor)
descriptor
- key for the value to be removed.public boolean contains(ForeignDescriptor provider)
public void release()
Once all instance references are released, the instance will be recycled.
release
in interface RequestContext
public java.lang.String toString()
toString
in class java.lang.Object