Top Description Inners Fields Constructors Methods
javax.ws.rs.ext

public abstract Class RuntimeDelegate

extends Object
Class Inheritance
Imports
java.lang.reflect.ReflectPermission, java.net.URL, javax.ws.rs.core.Application, .Link, .Response.ResponseBuilder, .UriBuilder, .Variant.VariantListBuilder

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.
Authors
Paul Sandoz, Marc Hadley
Since
1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
RuntimeDelegate.HeaderDelegate<
a JAX-RS type that corresponds to the value of a HTTP header.
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

Modifier and TypeField and Description
private static volatile RuntimeDelegate
private static final String
public static final String
JAXRS_RUNTIME_DELEGATE_PROPERTY

Name of the property identifying the RuntimeDelegate implementation to be returned from RuntimeDelegate#getInstance().

private static final Object
private static ReflectPermission

Constructor Summary

AccessConstructor and Description
protected
RuntimeDelegate()

Allows custom implementations to extend the RuntimeDelegate class.

Method Summary

Modifier and TypeMethod and Description
public abstract <
endpoint type.
T
>
T

Returns:

a configured instance of the requested type.
createEndpoint
(Application
the application configuration.
application
,
Class<T>
the type of endpoint instance to be created.
endpointType
)

Create a configured instance of the supplied endpoint type.

public abstract <
header type.
T
>
RuntimeDelegate.HeaderDelegate<T>

Returns:

an instance of HeaderDelegate for the supplied type.
createHeaderDelegate
(Class<T>
the class of the header.
type
)

Obtain an instance of a HeaderDelegate for the supplied class.

public abstract Link.Builder

Returns:

new Link.Builder instance.
createLinkBuilder
()

Create a new instance of a javax.ws.rs.core.Link.Builder.

public abstract Response.ResponseBuilder

Returns:

new ResponseBuilder instance.
createResponseBuilder
()

Create a new instance of a javax.ws.rs.core.Response.ResponseBuilder.

public abstract UriBuilder

Returns:

new UriBuilder instance.
createUriBuilder
()

Create a new instance of a javax.ws.rs.core.UriBuilder.

public abstract Variant.VariantListBuilder

Returns:

new VariantListBuilder instance.
createVariantListBuilder
()

Create a new instance of a javax.ws.rs.core.Variant.VariantListBuilder.

private static RuntimeDelegate

Returns:

an instance of RuntimeDelegate.
findDelegate
()

Obtain a RuntimeDelegate instance using the method described in getInstance.

public static RuntimeDelegate

Returns:

an instance of RuntimeDelegate.
getInstance
()

Obtain a RuntimeDelegate instance.

public static void
setInstance(final RuntimeDelegate
the runtime delegate instance
rd
)

Set the runtime delegate that will be used by JAX-RS classes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cachedDelegateback to summary
private static volatile RuntimeDelegate cachedDelegate
JAXRS_DEFAULT_RUNTIME_DELEGATEback to summary
private static final String JAXRS_DEFAULT_RUNTIME_DELEGATE
JAXRS_RUNTIME_DELEGATE_PROPERTYback to summary
public static final String JAXRS_RUNTIME_DELEGATE_PROPERTY

Name of the property identifying the RuntimeDelegate implementation to be returned from RuntimeDelegate#getInstance().

RD_LOCKback to summary
private static final Object RD_LOCK
suppressAccessChecksPermissionback to summary
private static ReflectPermission suppressAccessChecksPermission

Constructor Detail

RuntimeDelegateback to summary
protected RuntimeDelegate()

Allows custom implementations to extend the RuntimeDelegate class.

Method Detail

createEndpointback to summary
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.

Parameters
<T>
endpoint type.
application:Application

the application configuration.

endpointType:Class<T>

the type of endpoint instance to be created.

Returns:T

a configured instance of the requested type.

Exceptions
IllegalArgumentException:
if application is null or the requested endpoint type is not supported.
UnsupportedOperationException:
if the implementation supports no endpoint types.
createHeaderDelegateback to summary
public abstract <T> RuntimeDelegate.HeaderDelegate<T> createHeaderDelegate(Class<T> type) throws IllegalArgumentException

Obtain an instance of a HeaderDelegate for the supplied class. An implementation is required to support the following values for type: javax.ws.rs.core.CacheControl, javax.ws.rs.core.Cookie, javax.ws.rs.core.EntityTag, javax.ws.rs.core.Link, javax.ws.rs.core.NewCookie, javax.ws.rs.core.MediaType and java.util.Date.

Parameters
<T>
header type.
type:Class<T>

the class of the header.

Returns:RuntimeDelegate.HeaderDelegate<T>

an instance of HeaderDelegate for the supplied type.

Exceptions
IllegalArgumentException:
if type is null.
See Also
javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate
createLinkBuilderback to summary
public abstract Link.Builder createLinkBuilder()

Create a new instance of a javax.ws.rs.core.Link.Builder.

Returns:Link.Builder

new Link.Builder instance.

See Also
javax.ws.rs.core.Link.Builder
createResponseBuilderback to summary
public abstract Response.ResponseBuilder createResponseBuilder()

Create a new instance of a javax.ws.rs.core.Response.ResponseBuilder.

Returns:Response.ResponseBuilder

new ResponseBuilder instance.

See Also
javax.ws.rs.core.Response.ResponseBuilder
createUriBuilderback to summary
public abstract UriBuilder createUriBuilder()

Create a new instance of a javax.ws.rs.core.UriBuilder.

Returns:UriBuilder

new UriBuilder instance.

See Also
javax.ws.rs.core.UriBuilder
createVariantListBuilderback to summary
public abstract Variant.VariantListBuilder createVariantListBuilder()

Create a new instance of a javax.ws.rs.core.Variant.VariantListBuilder.

Returns:Variant.VariantListBuilder

new VariantListBuilder instance.

See Also
javax.ws.rs.core.Variant.VariantListBuilder
findDelegateback to summary
private static RuntimeDelegate findDelegate()

Obtain a RuntimeDelegate instance using the method described in getInstance.

Returns:RuntimeDelegate

an instance of RuntimeDelegate.

getInstanceback to summary
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:

  • If a resource with the name of META-INF/services/javax.ws.rs.ext.RuntimeDelegate exists, then its first line, if present, is used as the UTF-8 encoded name of the implementation class.
  • If the $java.home/lib/jaxrs.properties file exists and it is readable by the java.util.Properties.load(InputStream) method and it contains an entry whose key is javax.ws.rs.ext.RuntimeDelegate, then the value of that entry is used as the name of the implementation class.
  • If a system property with the name javax.ws.rs.ext.RuntimeDelegate is defined, then its value is used as the name of the implementation class.
  • Finally, a default implementation class name is used.
Returns:RuntimeDelegate

an instance of RuntimeDelegate.

setInstanceback to summary
public static void setInstance(final RuntimeDelegate rd)

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:RuntimeDelegate

the runtime delegate instance

Exceptions
SecurityException:
if there is a security manager and the permission ReflectPermission("suppressAccessChecks") has not been granted.
javax.ws.rs.ext back to summary

public Interface RuntimeDelegate.HeaderDelegate<T>

Type Parameters
<T>
a JAX-RS type that corresponds to the value of a HTTP header.

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.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

the newly created instance of T.
fromString
(String
the string value.
value
)

Parse the supplied value and create an instance of T.

public String

Returns:

a String representation of the value.
toString
(T
the value of type T.
value
)

Convert the supplied value to a String.

Method Detail

fromStringback to summary
public T fromString(String value)

Parse the supplied value and create an instance of T.

Parameters
value:String

the string value.

Returns:T

the newly created instance of T.

Exceptions
IllegalArgumentException:
if the supplied string cannot be parsed or is null.
toStringback to summary
public String toString(T value)

Convert the supplied value to a String.

Parameters
value:T

the value of type T.

Returns:String

a String representation of the value.

Exceptions
IllegalArgumentException:
if the supplied object cannot be serialized or is null.