javax.ws.rs.ext
Class RuntimeDelegate

java.lang.Object
  extended by javax.ws.rs.ext.RuntimeDelegate

public abstract class RuntimeDelegate
extends Object

Implementations of JAX-RS provide a concrete subclass of RuntimeDelegate and various JAX-RS API methods defer to methods of RuntimeDelegate for their functionality. Regular users of JAX-RS are not expected to use this class directly and overriding an implementation of this class with a user supplied subclass may cause unexpected behavior.

Since:
1.0
Author:
Paul Sandoz, Marc Hadley

Nested Class Summary
static interface RuntimeDelegate.HeaderDelegate<T>
          Defines the contract for a delegate that is responsible for converting between the String form of a HTTP header and the corresponding JAX-RS type T.
 
Field Summary
static String JAXRS_RUNTIME_DELEGATE_PROPERTY
          Name of the property identifying the RuntimeDelegate implementation to be returned from getInstance().
 
Constructor Summary
protected RuntimeDelegate()
          Allows custom implementations to extend the RuntimeDelegate class.
 
Method Summary
abstract
<T> T
createEndpoint(Application application, Class<T> endpointType)
          Create a configured instance of the supplied endpoint type.
abstract
<T> RuntimeDelegate.HeaderDelegate<T>
createHeaderDelegate(Class<T> type)
          Obtain an instance of a RuntimeDelegate.HeaderDelegate for the supplied class.
abstract  Response.ResponseBuilder createResponseBuilder()
          Create a new instance of a Response.ResponseBuilder.
abstract  UriBuilder createUriBuilder()
          Create a new instance of a UriBuilder.
abstract  Variant.VariantListBuilder createVariantListBuilder()
          Create a new instance of a Variant.VariantListBuilder.
static RuntimeDelegate getInstance()
          Obtain a RuntimeDelegate instance.
static void setInstance(RuntimeDelegate rd)
          Set the runtime delegate that will be used by JAX-RS classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAXRS_RUNTIME_DELEGATE_PROPERTY

public static final String JAXRS_RUNTIME_DELEGATE_PROPERTY
Name of the property identifying the RuntimeDelegate implementation to be returned from getInstance().

See Also:
Constant Field Values
Constructor Detail

RuntimeDelegate

protected RuntimeDelegate()
Allows custom implementations to extend the RuntimeDelegate class.

Method Detail

getInstance

public static RuntimeDelegate getInstance()
Obtain a RuntimeDelegate instance. If an instance had not already been created and set via setInstance(RuntimeDelegate), the first invocation will create an instance which will then be cached for future use.

The algorithm used to locate the RuntimeDelegate subclass to use consists of the following steps:

Returns:
an instance of RuntimeDelegate

setInstance

public static void setInstance(RuntimeDelegate rd)
                        throws SecurityException
Set the runtime delegate that will be used by JAX-RS classes. If this method is not called prior to getInstance() then an implementation will be sought as described in getInstance().

Parameters:
rd - the runtime delegate instance
Throws:
SecurityException - if there is a security manager and the permission ReflectPermission("suppressAccessChecks") has not been granted.

createUriBuilder

public abstract UriBuilder createUriBuilder()
Create a new instance of a UriBuilder.

Returns:
new UriBuilder instance
See Also:
UriBuilder

createResponseBuilder

public abstract Response.ResponseBuilder createResponseBuilder()
Create a new instance of a Response.ResponseBuilder.

Returns:
new ResponseBuilder instance
See Also:
Response.ResponseBuilder

createVariantListBuilder

public abstract Variant.VariantListBuilder createVariantListBuilder()
Create a new instance of a Variant.VariantListBuilder.

Returns:
new VariantListBuilder instance
See Also:
Variant.VariantListBuilder

createEndpoint

public abstract <T> T createEndpoint(Application application,
                                     Class<T> endpointType)
                          throws IllegalArgumentException,
                                 UnsupportedOperationException
Create a configured instance of the supplied endpoint type. How the returned endpoint instance is published is dependent on the type of endpoint.

Type Parameters:
T - endpoint type.
Parameters:
application - the application configuration
endpointType - the type of endpoint instance to be created.
Returns:
a configured instance of the requested type.
Throws:
IllegalArgumentException - if application is null or the requested endpoint type is not supported.
UnsupportedOperationException - if the implementation supports no endpoint types.

createHeaderDelegate

public abstract <T> RuntimeDelegate.HeaderDelegate<T> createHeaderDelegate(Class<T> type)
                                                                throws IllegalArgumentException
Obtain an instance of a RuntimeDelegate.HeaderDelegate for the supplied class. An implementation is required to support the following values for type: Cookie, CacheControl, EntityTag, NewCookie, MediaType and java.util.Date.

Type Parameters:
T - header type.
Parameters:
type - the class of the header
Returns:
an instance of HeaderDelegate for the supplied type
Throws:
IllegalArgumentException - if type is null


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