Class JsonWithPaddingInterceptor
java.lang.Object
org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor
- All Implemented Interfaces:
javax.ws.rs.ext.WriterInterceptor
@Priority(4100)
public class JsonWithPaddingInterceptor
extends Object
implements javax.ws.rs.ext.WriterInterceptor
A
WriterInterceptor
implementation for JSONP format. This interceptor wraps a JSON stream obtained by a underlying
JSON provider into a callback function that can be defined by the JSONP
annotation.- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
aroundWriteTo
(javax.ws.rs.ext.WriterInterceptorContext context) private String
getCallbackName
(JSONP jsonp) Returns a JavaScript callback name to wrap the JSON entity into.private JSONP
getJsonpAnnotation
(javax.ws.rs.ext.InterceptorContext context) Returns aJSONP
annotation of the resource method responsible for handling the current request.private boolean
isJavascript
(javax.ws.rs.core.MediaType mediaType) Returns a flag whether the givenmedia type
belongs to the group of JavaScript media types.
-
Field Details
-
JAVASCRIPT_TYPES
-
containerRequestProvider
-
-
Constructor Details
-
JsonWithPaddingInterceptor
public JsonWithPaddingInterceptor()
-
-
Method Details
-
aroundWriteTo
public void aroundWriteTo(javax.ws.rs.ext.WriterInterceptorContext context) throws IOException, javax.ws.rs.WebApplicationException - Specified by:
aroundWriteTo
in interfacejavax.ws.rs.ext.WriterInterceptor
- Throws:
IOException
javax.ws.rs.WebApplicationException
-
isJavascript
private boolean isJavascript(javax.ws.rs.core.MediaType mediaType) Returns a flag whether the givenmedia type
belongs to the group of JavaScript media types.- Parameters:
mediaType
- media type to check.- Returns:
true
if the given media type is a JavaScript type,false
otherwise (or if the media type isnull
}
-
getCallbackName
Returns a JavaScript callback name to wrap the JSON entity into. The callback name is determined from theJSONP
annotation.- Parameters:
jsonp
-JSONP
annotation to determine the callback name from.- Returns:
- a JavaScript callback name.
-
getJsonpAnnotation
Returns aJSONP
annotation of the resource method responsible for handling the current request.- Parameters:
context
- aninterceptor context
to obtain the annotation from.- Returns:
JSONP
annotation ornull
if the resource method is not annotated with this annotation.- See Also:
-