@Provider @ConstrainedTo(value=SERVER) @Deprecated public class JacksonJsonpInterceptor extends Object implements WriterInterceptor
JSONP is an alternative to normal AJAX requests. Instead of using a XMLHttpRequest a script tag is added to the DOM. The browser will call the corresponding URL and download the JavaScript. The server creates a response which looks like a method call. The parameter is the body of the request. The name of the method to call is normally passed as query parameter. The method has to be present in the current JavaScript environment.
Jackson JSON processor can produce such an response. This interceptor checks if the media type is a JavaScript one if there is a query parameter with the method name. The default name of this query parameter is "callback". So this interceptor is compatible with jQuery.
Modifier and Type | Field and Description |
---|---|
static MediaType |
APPLICATION_JAVASCRIPT_MEDIA_TYPE
Deprecated.
"application/javascript" media type.
|
static MediaType |
APPLICATION_PLUS_JSON_TYPE
Deprecated.
"application/*+json" media type.
|
static String |
DEFAULT_CALLBACK_QUERY_PARAMETER
Deprecated.
Default name of the query parameter with the method name.
|
protected static org.codehaus.jackson.map.ObjectMapper |
DEFAULT_MAPPER
Deprecated.
Default
ObjectMapper for type resolution. |
static MediaTypeMap<String> |
jsonpCompatibleMediaTypes
Deprecated.
If response media type is one of this jsonp response may be created.
|
protected org.codehaus.jackson.map.ObjectMapper |
objectMapper
Deprecated.
The
ObjectMapper used to create typing information. |
protected Providers |
providers
Deprecated.
The
Providers used to retrieve the objectMapper from. |
static MediaType |
TEXT_JAVASCRIPT_MEDIA_TYPE
Deprecated.
"text/javascript" media type.
|
static MediaType |
TEXT_JSON_TYPE
Deprecated.
"text/json" media type.
|
Constructor and Description |
---|
JacksonJsonpInterceptor()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
aroundWriteTo(WriterInterceptorContext context)
Deprecated.
|
String |
getCallbackQueryParameter()
Deprecated.
Get the name of the query parameter which contains the JavaScript method name.
|
protected org.codehaus.jackson.map.ObjectMapper |
getObjectMapper(Class<?> type,
MediaType mediaType)
Deprecated.
Search for an
ObjectMapper for the given class and mediaType |
void |
setCallbackQueryParameter(String callbackQueryParameter)
Deprecated.
Set callback query parameter.
|
void |
setObjectMapper(org.codehaus.jackson.map.ObjectMapper objectMapper)
Deprecated.
Set an fix
ObjectMapper . |
void |
setProviders(Providers providers)
Deprecated.
Setter used by RESTeasy to provide the
Providers |
void |
setUri(UriInfo uri)
Deprecated.
Setter used by RESTeasy to provide the
UriInfo . |
public static final MediaType TEXT_JAVASCRIPT_MEDIA_TYPE
public static final MediaType APPLICATION_JAVASCRIPT_MEDIA_TYPE
public static final MediaType TEXT_JSON_TYPE
public static final MediaType APPLICATION_PLUS_JSON_TYPE
public static final String DEFAULT_CALLBACK_QUERY_PARAMETER
public static final MediaTypeMap<String> jsonpCompatibleMediaTypes
protected static final org.codehaus.jackson.map.ObjectMapper DEFAULT_MAPPER
ObjectMapper
for type resolution. Used if none is provided by Providers
.protected org.codehaus.jackson.map.ObjectMapper objectMapper
ObjectMapper
used to create typing information.protected Providers providers
Providers
used to retrieve the objectMapper
from.public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException
MessageBodyWriter.writeTo(T, java.lang.Class<?>, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String, java.lang.Object>, java.io.OutputStream)
method.
The parameters of the wrapped method called are available from context
.
Implementations of this method SHOULD explicitly call
WriterInterceptorContext.proceed()
to invoke the next interceptor in the chain,
and ultimately the wrapped MessageBodyWriter.writeTo
method.aroundWriteTo
in interface WriterInterceptor
context
- invocation context.IOException
- if an IO error arises or is thrown by the wrapped
MessageBodyWriter.writeTo
method.WebApplicationException
- thrown by the wrapped MessageBodyWriter.writeTo
method.protected org.codehaus.jackson.map.ObjectMapper getObjectMapper(Class<?> type, MediaType mediaType)
ObjectMapper
for the given class and mediaType@Context public void setUri(UriInfo uri)
UriInfo
.uri
- the uri to set@Context public void setProviders(Providers providers)
Providers
providers
- public void setObjectMapper(org.codehaus.jackson.map.ObjectMapper objectMapper)
ObjectMapper
. If this is not set Providers
are used for lookup. If there are is none too, use a default one.objectMapper
- public String getCallbackQueryParameter()
public void setCallbackQueryParameter(String callbackQueryParameter)
callbackQueryParameter
- the callbackQueryParameter to setgetCallbackQueryParameter()
Copyright © 2017 JBoss by Red Hat. All rights reserved.