org.glassfish.jersey.server.internal
Class JerseyResourceContext

java.lang.Object
  extended by org.glassfish.jersey.server.internal.JerseyResourceContext
All Implemented Interfaces:
ResourceContext

public class JerseyResourceContext
extends Object
implements ResourceContext

Jersey implementation of JAX-RS resource context.

Author:
Marek Potociar (marek.potociar at oracle.com)

Nested Class Summary
static class JerseyResourceContext.Binder
          Injection binder for JerseyResourceContext.
 
Method Summary
<T> void
bindResource(Class<T> resourceClass)
          Binds resourceClass into HK2 context as singleton.
 void bindResourceIfSingleton(Object resource)
          Binds resourceClass into HK2 context as singleton.
<T> T
getResource(Class<T> resourceClass)
           
<T> T
initResource(T resource)
           
<T> void
unsafeBindResource(Class<T> resourceClass, ContractProvider providerModel, DynamicConfiguration dc)
          Bind a resource class in a HK2 context.
 void unsafeBindResource(Object resource, ContractProvider providerModel, DynamicConfiguration dc)
          Bind a resource instance in a HK2 context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getResource

public <T> T getResource(Class<T> resourceClass)
Specified by:
getResource in interface ResourceContext

initResource

public <T> T initResource(T resource)
Specified by:
initResource in interface ResourceContext

bindResource

public <T> void bindResource(Class<T> resourceClass)
Binds 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.

Type Parameters:
T - type of the resource class.
Parameters:
resourceClass - resource class that should be bound. If the class is not annotated with Singleton annotation it will be ignored by this method.

bindResourceIfSingleton

public void bindResourceIfSingleton(Object resource)
Binds 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.

Parameters:
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.

unsafeBindResource

public void unsafeBindResource(Object resource,
                               ContractProvider providerModel,
                               DynamicConfiguration dc)
Bind a resource instance in a HK2 context. The bound resource instance is internally cached to make sure any sub-sequent attempts to bind the class are silently ignored.

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.

Parameters:
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.

unsafeBindResource

public <T> void unsafeBindResource(Class<T> resourceClass,
                                   ContractProvider providerModel,
                                   DynamicConfiguration dc)
Bind a resource class in a HK2 context. The bound resource class is internally cached to make sure any sub-sequent attempts to bind the class are silently ignored.

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.

Type Parameters:
T - resource class type.
Parameters:
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.


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.