Package org.glassfish.jersey.inject.hk2
Class Hk2RequestScope.Instance
java.lang.Object
org.glassfish.jersey.inject.hk2.Hk2RequestScope.Instance
- All Implemented Interfaces:
RequestContext
- Enclosing class:
- Hk2RequestScope
Implementation of the request scope instance.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(org.glassfish.jersey.internal.inject.ForeignDescriptor provider) <T> Tget(org.glassfish.jersey.internal.inject.ForeignDescriptor descriptor) Get an inhabitant stored in the scope instance that matches the active descriptor .Get a "new" reference of the scope instance.<T> Tput(org.glassfish.jersey.internal.inject.ForeignDescriptor descriptor, T value) Store a new inhabitant for the given descriptor.voidrelease()Release a single reference to the current request scope instance.<T> voidremove(org.glassfish.jersey.internal.inject.ForeignDescriptor descriptor) Remove a value for the descriptor if present in the scope instance store.toString()
-
Method Details
-
getReference
Get a "new" reference of the scope instance. This will increase the internal reference counter which prevents the scope instance to be destroyed until arelease()method is explicitly called (once per eachgetReference()method call).- Specified by:
getReferencein interfaceRequestContext- Returns:
- referenced scope instance.
-
get
public <T> T get(org.glassfish.jersey.internal.inject.ForeignDescriptor descriptor) Get an inhabitant stored in the scope instance that matches the active descriptor .- Type Parameters:
T- inhabitant type.- Parameters:
descriptor- inhabitant descriptor.- Returns:
- matched inhabitant stored in the scope instance or
nullif not matched.
-
put
public <T> T put(org.glassfish.jersey.internal.inject.ForeignDescriptor descriptor, T value) Store a new inhabitant for the given descriptor.- Type Parameters:
T- inhabitant type.- Parameters:
descriptor- inhabitant descriptor.value- inhabitant value.- Returns:
- old inhabitant previously stored for the given descriptor or
nullif none stored.
-
remove
public <T> void remove(org.glassfish.jersey.internal.inject.ForeignDescriptor descriptor) Remove a value for the descriptor if present in the scope instance store.- Parameters:
descriptor- key for the value to be removed.
-
contains
public boolean contains(org.glassfish.jersey.internal.inject.ForeignDescriptor provider) -
release
public void release()Release a single reference to the current request scope instance.Once all instance references are released, the instance will be recycled.
- Specified by:
releasein interfaceRequestContext
-
toString
-