@Provider
@Consumes(value="*/*")
@Produces(value="*/*")
public class FastJson2Provider
extends java.lang.Object
implements javax.ws.rs.ext.MessageBodyReader<java.lang.Object>, javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>
MessageBodyReader,
MessageBodyWriter| Modifier and Type | Field and Description |
|---|---|
private java.lang.Class<?>[] |
clazzes
allow serialize/deserialize types in clazzes
|
static java.lang.Class<?>[] |
DEFAULT_UNREADABLES
These are classes that we never use for reading
(never try to deserialize instances of these types).
|
static java.lang.Class<?>[] |
DEFAULT_UNWRITABLES
These are classes that we never use for writing
(never try to serialize instances of these types).
|
private FastJsonConfig |
fastJsonConfig
with fastJson config
|
protected javax.ws.rs.ext.Providers |
providers
Injectable context object used to locate configured
instance of
FastJsonConfig to use for actual
serialization. |
| Constructor and Description |
|---|
FastJson2Provider()
Can serialize/deserialize all types.
|
FastJson2Provider(java.lang.Class<?>[] clazzes)
Only serialize/deserialize all types in clazzes.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
hasNotMatchingMediaType(javax.ws.rs.core.MediaType mediaType)
Check media type like "application/json".
|
protected boolean |
isNotAssignableFrom(java.lang.Class<?> type,
java.lang.Class<?>[] classes)
Check some are interface/abstract classes to exclude.
|
boolean |
isReadable(java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to check whether values of
given type (and media type) can be deserialized by this provider.
|
protected boolean |
isValidType(java.lang.Class<?> type,
java.lang.annotation.Annotation[] classAnnotations)
Check whether a class can be serialized or deserialized.
|
boolean |
isWriteable(java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to check whether given value
(of specified type) can be serialized by this provider.
|
protected FastJsonConfig |
locateConfigProvider(java.lang.Class<?> type,
javax.ws.rs.core.MediaType mediaType)
Helper method that is called if no config has been explicitly configured.
|
java.lang.Object |
readFrom(java.lang.Class<java.lang.Object> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> httpHeaders,
java.io.InputStream entityStream)
Method that JAX-RS container calls to deserialize given value.
|
void |
writeTo(java.lang.Object object,
java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders,
java.io.OutputStream entityStream)
Method that JAX-RS container calls to serialize given value.
|
public static final java.lang.Class<?>[] DEFAULT_UNREADABLES
public static final java.lang.Class<?>[] DEFAULT_UNWRITABLES
@Context protected javax.ws.rs.ext.Providers providers
FastJsonConfig to use for actual
serialization.private FastJsonConfig fastJsonConfig
private java.lang.Class<?>[] clazzes
public FastJson2Provider()
public FastJson2Provider(java.lang.Class<?>[] clazzes)
protected boolean isNotAssignableFrom(java.lang.Class<?> type,
java.lang.Class<?>[] classes)
type - the typeclasses - the classesprotected boolean isValidType(java.lang.Class<?> type,
java.lang.annotation.Annotation[] classAnnotations)
type - class need to checkprotected boolean hasNotMatchingMediaType(javax.ws.rs.core.MediaType mediaType)
mediaType - media typepublic boolean isWriteable(java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
isWriteable in interface javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>public void writeTo(java.lang.Object object,
java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders,
java.io.OutputStream entityStream)
throws java.io.IOException,
javax.ws.rs.WebApplicationException
writeTo in interface javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>java.io.IOExceptionjavax.ws.rs.WebApplicationExceptionpublic boolean isReadable(java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
isReadable in interface javax.ws.rs.ext.MessageBodyReader<java.lang.Object>public java.lang.Object readFrom(java.lang.Class<java.lang.Object> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> httpHeaders,
java.io.InputStream entityStream)
throws java.io.IOException,
javax.ws.rs.WebApplicationException
readFrom in interface javax.ws.rs.ext.MessageBodyReader<java.lang.Object>java.io.IOExceptionjavax.ws.rs.WebApplicationExceptionprotected FastJsonConfig locateConfigProvider(java.lang.Class<?> type, javax.ws.rs.core.MediaType mediaType)