public static class OutboundJaxrsResponse.Builder extends Response.ResponseBuilder
Response.ResponseBuilder implementation.
The implementation delegates method calls to an underlying
outbound message context. Upon a call to a build() method
a new instance of OutboundJaxrsResponse is produced.| Constructor and Description |
|---|
Builder(OutboundMessageContext context)
Create new outbound JAX-RS response builder.
|
| Modifier and Type | Method and Description |
|---|---|
Response.ResponseBuilder |
allow(Set<String> methods)
Set the list of allowed methods for the resource.
|
Response.ResponseBuilder |
allow(String... methods)
Set the list of allowed methods for the resource.
|
Response |
build()
Create a Response instance from the current ResponseBuilder.
|
Response.ResponseBuilder |
cacheControl(CacheControl cacheControl)
Set the cache control data of the message.
|
static void |
clearBaseUri()
Remove the current thread's value for baseUri thread-local variable (set by
setBaseUri(java.net.URI)). |
Response.ResponseBuilder |
clone() |
Response.ResponseBuilder |
contentLocation(URI location)
Set the content location.
|
Response.ResponseBuilder |
cookie(NewCookie... cookies)
Add cookies to the response message.
|
Response.ResponseBuilder |
encoding(String encoding)
Set the message entity content encoding.
|
Response.ResponseBuilder |
entity(Object entity)
Set the response entity in the builder.
|
Response.ResponseBuilder |
entity(Object entity,
Annotation[] annotations)
Set the response entity in the builder.
|
Response.ResponseBuilder |
expires(Date expires)
Set the response expiration date.
|
Response.ResponseBuilder |
header(String name,
Object value)
Add an arbitrary header.
|
Response.ResponseBuilder |
language(Locale language)
Set the message entity language.
|
Response.ResponseBuilder |
language(String language)
Set the message entity language.
|
Response.ResponseBuilder |
lastModified(Date lastModified)
Set the response entity last modification date.
|
Response.ResponseBuilder |
link(String uri,
String rel)
Add a link header.
|
Response.ResponseBuilder |
link(URI uri,
String rel)
Add a link header.
|
Response.ResponseBuilder |
links(Link... links)
Add one or more link headers.
|
Response.ResponseBuilder |
location(URI location)
Set the location.
|
Response.ResponseBuilder |
replaceAll(MultivaluedMap<String,Object> headers)
Replaces all existing headers with the newly supplied headers.
|
static void |
setBaseUri(URI baseUri)
Set the
baseUri of the actual request into the InheritableThreadLocal. |
Response.ResponseBuilder |
status(int code)
Set the status on the ResponseBuilder.
|
Response.ResponseBuilder |
status(int status,
String reasonPhrase)
Set the status on the ResponseBuilder.
|
Response.ResponseBuilder |
status(Response.StatusType status)
Set the status on the ResponseBuilder.
|
Response.ResponseBuilder |
tag(EntityTag tag)
Set a response entity tag.
|
Response.ResponseBuilder |
tag(String tag)
Set a strong response entity tag.
|
Response.ResponseBuilder |
type(MediaType type)
Set the message entity media type.
|
Response.ResponseBuilder |
type(String type)
Set the message entity media type.
|
Response.ResponseBuilder |
variant(Variant variant)
Set message entity representation metadata.
|
Response.ResponseBuilder |
variants(List<Variant> variants)
Add a Vary header that lists the available variants.
|
Response.ResponseBuilder |
variants(Variant... variants)
Add a Vary header that lists the available variants.
|
newInstance, statuspublic Builder(OutboundMessageContext context)
context - underlying outbound message context.public static void setBaseUri(URI baseUri)
baseUri of the actual request into the InheritableThreadLocal.
The baseUri will be used for absolutizing the location header
content in case that only a relative URI is provided.
After resource method invocation when the value is not needed
any more to be stored in ThreadLocal clearBaseUri() should be
called for cleanup in order to prevent possible memory leaks.
baseUri - - baseUri of the actual requestlocation(java.net.URI)public static void clearBaseUri()
setBaseUri(java.net.URI)).
Should be called after resource method invocation for cleanup.location(java.net.URI)public Response build()
Response.ResponseBuilderbuild in class Response.ResponseBuilderpublic Response.ResponseBuilder clone()
Response.ResponseBuilderCreate a copy of the ResponseBuilder preserving its state.
clone in class Response.ResponseBuilderpublic Response.ResponseBuilder status(Response.StatusType status)
Response.ResponseBuilderstatus in class Response.ResponseBuilderstatus - the response status.public Response.ResponseBuilder status(int status, String reasonPhrase)
Response.ResponseBuilderstatus in class Response.ResponseBuilderstatus - the response status.reasonPhrase - the reason phrase.public Response.ResponseBuilder status(int code)
Response.ResponseBuilderstatus in class Response.ResponseBuildercode - the response status.public Response.ResponseBuilder entity(Object entity)
Response.ResponseBuilderSet the response entity in the builder.
Any Java type instance for a response entity, that is supported by the runtime can be passed. It is the callers
responsibility to wrap the actual entity with GenericEntity if preservation of its generic type is required.
Note that the entity can be also set as an input stream.
type(...) methods.entity in class Response.ResponseBuilderentity - the request entity.Response.ResponseBuilder.entity(java.lang.Object, java.lang.annotation.Annotation[]),
Response.ResponseBuilder.type(jakarta.ws.rs.core.MediaType),
Response.ResponseBuilder.type(java.lang.String)public Response.ResponseBuilder entity(Object entity, Annotation[] annotations)
Response.ResponseBuilderSet the response entity in the builder.
Any Java type instance for a response entity, that is supported by the runtime can be passed. It is the callers
responsibility to wrap the actual entity with GenericEntity if preservation of its generic type is required.
Note that the entity can be also set as an input stream.
type(...) methods.entity in class Response.ResponseBuilderentity - the request entity.annotations - annotations that will be passed to the MessageBodyWriter, (in addition to any annotations
declared directly on a resource method that returns the built response).Response.ResponseBuilder.entity(java.lang.Object),
Response.ResponseBuilder.type(jakarta.ws.rs.core.MediaType),
Response.ResponseBuilder.type(java.lang.String)public Response.ResponseBuilder type(MediaType type)
Response.ResponseBuildertype in class Response.ResponseBuildertype - the media type of the message entity. If null, any existing value for type will be removed.public Response.ResponseBuilder type(String type)
Response.ResponseBuildertype in class Response.ResponseBuildertype - the media type of the message entity. If null, any existing value for type will be removed.public Response.ResponseBuilder variant(Variant variant)
Response.ResponseBuilderSet message entity representation metadata.
Equivalent to setting the values of content type, content language, and content encoding separately using the values of the variant properties.variant in class Response.ResponseBuildervariant - metadata of the message entity, a null value is equivalent to a variant with all null
properties.Response.ResponseBuilder.encoding(java.lang.String),
Response.ResponseBuilder.language(java.util.Locale),
Response.ResponseBuilder.type(jakarta.ws.rs.core.MediaType)public Response.ResponseBuilder variants(List<Variant> variants)
Response.ResponseBuildervariants in class Response.ResponseBuildervariants - a list of available representation variants, a null value will remove an existing value for
Vary header.public Response.ResponseBuilder language(String language)
Response.ResponseBuilderlanguage in class Response.ResponseBuilderlanguage - the language of the message entity, if null any existing value for language will be removed.public Response.ResponseBuilder language(Locale language)
Response.ResponseBuilderlanguage in class Response.ResponseBuilderlanguage - the language of the message entity, if null any existing value for type will be removed.public Response.ResponseBuilder location(URI location)
Response.ResponseBuilderlocation in class Response.ResponseBuilderlocation - the location. If a relative URI is supplied it will be converted into an absolute URI by resolving it
relative to the base URI of the application (see UriInfo.getBaseUri()). If null any existing value for
location will be removed.public Response.ResponseBuilder contentLocation(URI location)
Response.ResponseBuildercontentLocation in class Response.ResponseBuilderlocation - the content location. Relative or absolute URIs may be used for the value of content location. If
null any existing value for content location will be removed.public Response.ResponseBuilder encoding(String encoding)
Response.ResponseBuilderencoding in class Response.ResponseBuilderencoding - the content encoding of the message entity, if null any existing value for content encoding
will be removed.public Response.ResponseBuilder tag(EntityTag tag)
Response.ResponseBuildertag in class Response.ResponseBuildertag - the entity tag, if null any existing entity tag value will be removed.public Response.ResponseBuilder tag(String tag)
Response.ResponseBuilderSet a strong response entity tag.
This is a shortcut fortag(new EntityTag(value)).tag in class Response.ResponseBuildertag - the string content of a strong entity tag. The JAX-RS runtime will quote the supplied value when creating
the header. If null any existing entity tag value will be removed.public Response.ResponseBuilder lastModified(Date lastModified)
Response.ResponseBuilderlastModified in class Response.ResponseBuilderlastModified - the last modified date, if null any existing last modified value will be removed.public Response.ResponseBuilder cacheControl(CacheControl cacheControl)
Response.ResponseBuildercacheControl in class Response.ResponseBuildercacheControl - the cache control directives, if null any existing cache control directives will be
removed.public Response.ResponseBuilder expires(Date expires)
Response.ResponseBuilderexpires in class Response.ResponseBuilderexpires - the expiration date, if null removes any existing expires value.public Response.ResponseBuilder cookie(NewCookie... cookies)
Response.ResponseBuildercookie in class Response.ResponseBuildercookies - new cookies that will accompany the response. A null value will remove all cookies, including
those added via the Response.ResponseBuilder.header(java.lang.String, java.lang.Object) method.public Response.ResponseBuilder header(String name, Object value)
Response.ResponseBuilderheader in class Response.ResponseBuildername - the name of the headervalue - the value of the header, the header will be serialized using a
RuntimeDelegate.HeaderDelegate if one is available via
RuntimeDelegate.createHeaderDelegate(java.lang.Class) for the class of value or using
its toString method if a header delegate is not available. If value is null then all current
headers of the same name will be removed.public Response.ResponseBuilder variants(Variant... variants)
Response.ResponseBuildervariants in class Response.ResponseBuildervariants - a list of available representation variants, a null value will remove an existing value for
Vary header.public Response.ResponseBuilder links(Link... links)
Response.ResponseBuilderlinks in class Response.ResponseBuilderlinks - links to be added to the message as headers, a null value will remove any existing Link headers.public Response.ResponseBuilder link(URI uri, String rel)
Response.ResponseBuilderlink in class Response.ResponseBuilderuri - underlying URI for link header.rel - value of "rel" parameter.public Response.ResponseBuilder link(String uri, String rel)
Response.ResponseBuilderlink in class Response.ResponseBuilderuri - underlying URI for link header.rel - value of "rel" parameter.public Response.ResponseBuilder allow(String... methods)
Response.ResponseBuilderallow in class Response.ResponseBuildermethods - the methods to be listed as allowed for the resource, if null any existing allowed method list
will be removed.public Response.ResponseBuilder allow(Set<String> methods)
Response.ResponseBuilderallow in class Response.ResponseBuildermethods - the methods to be listed as allowed for the resource, if null any existing allowed method list
will be removed.public Response.ResponseBuilder replaceAll(MultivaluedMap<String,Object> headers)
Response.ResponseBuilderreplaceAll in class Response.ResponseBuilderheaders - new headers to be set, if null all existing headers will be removed.Copyright © 2007-2023, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.