public class JerseyResourceContext extends java.lang.Object implements ExtendedResourceContext
resource context
.Modifier and Type | Class and Description |
---|---|
static class |
JerseyResourceContext.Binder
Injection binder for
JerseyResourceContext . |
Modifier and Type | Field and Description |
---|---|
private java.util.Set<java.lang.Class<?>> |
bindingCache |
private java.lang.Object |
bindingCacheLock |
private org.glassfish.hk2.api.ServiceLocator |
locator |
private ResourceModel |
resourceModel |
Constructor and Description |
---|
JerseyResourceContext(org.glassfish.hk2.api.ServiceLocator locator)
Create new JerseyResourceContext.
|
Modifier and Type | Method and Description |
---|---|
<T> void |
bindResource(java.lang.Class<T> resourceClass)
Binds
resourceClass into HK2 context as singleton. |
<T> void |
bindResourceIfSingleton(T resource)
Binds
resourceClass into HK2 context as singleton. |
<T> T |
getResource(java.lang.Class<T> resourceClass) |
ResourceModel |
getResourceModel()
Return
resource model from which the current jersey application is built. |
private static java.lang.Class<? extends java.lang.annotation.Annotation> |
getScope(java.lang.Class<?> resourceClass) |
<T> T |
initResource(T resource) |
void |
setResourceModel(ResourceModel resourceModel)
Set the
resource mode of the application associated with this context. |
<T> void |
unsafeBindResource(java.lang.Class<T> resourceClass,
ContractProvider providerModel,
org.glassfish.hk2.api.DynamicConfiguration dc)
Bind a resource class in a HK2 context.
|
void |
unsafeBindResource(java.lang.Object resource,
ContractProvider providerModel,
org.glassfish.hk2.api.DynamicConfiguration dc)
Bind a resource instance in a HK2 context.
|
private final org.glassfish.hk2.api.ServiceLocator locator
private final java.util.Set<java.lang.Class<?>> bindingCache
private final java.lang.Object bindingCacheLock
private volatile ResourceModel resourceModel
@Inject JerseyResourceContext(org.glassfish.hk2.api.ServiceLocator locator)
locator
- HK2 service locator.public <T> T getResource(java.lang.Class<T> resourceClass)
getResource
in interface javax.ws.rs.container.ResourceContext
public <T> T initResource(T resource)
initResource
in interface javax.ws.rs.container.ResourceContext
public <T> void bindResource(java.lang.Class<T> resourceClass)
resourceClass
into HK2 context as singleton.
The bound class is then cached internally so that any sub-sequent attempt to bind that class
as a singleton is silently ignored.T
- type of the resource class.resourceClass
- resource class that should be bound. If the class is not
annotated with Singleton annotation
it
will be ignored by this method.public <T> void bindResourceIfSingleton(T resource)
resourceClass
into HK2 context as singleton.
The bound class is then cached internally so that any sub-sequent attempt to bind that class
as a singleton is silently ignored.resource
- singleton resource instance that should be bound as singleton. If the class is not
annotated with Singleton annotation
it
will be ignored by this method.public void unsafeBindResource(java.lang.Object resource, ContractProvider providerModel, org.glassfish.hk2.api.DynamicConfiguration dc)
WARNING: This version of method is not synchronized as well as the cache is not checked for existing bindings before the resource is bound and cached.
resource
- resource instance to be bound.providerModel
- provider model for the resource class. If not null
, the class
wil be bound as a contract provider too.dc
- dynamic HK2 service locator configuration.private static java.lang.Class<? extends java.lang.annotation.Annotation> getScope(java.lang.Class<?> resourceClass)
public <T> void unsafeBindResource(java.lang.Class<T> resourceClass, ContractProvider providerModel, org.glassfish.hk2.api.DynamicConfiguration dc)
WARNING: This version of method is not synchronized as well as the cache is not checked for existing bindings before the resource is bound and cached.
T
- resource class type.resourceClass
- resource class to be bound.providerModel
- provider model for the class. If not null
, the class
wil be bound as a contract provider too.dc
- dynamic HK2 service locator configuration.public ResourceModel getResourceModel()
ExtendedResourceContext
resource model
from which the current jersey application is built.getResourceModel
in interface ExtendedResourceContext
resource processor
.public void setResourceModel(ResourceModel resourceModel)
resource mode
of the application associated with this context.resourceModel
- Resource model on which the application
is based.