Class ResteasyJackson2Provider
java.lang.Object
com.fasterxml.jackson.jakarta.rs.base.ProviderBase<JacksonJsonProvider,ObjectMapper,JsonEndpointConfig,JsonMapperConfigurator>
com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider
org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider
- All Implemented Interfaces:
Versioned,MessageBodyReader<Object>,MessageBodyWriter<Object>,AsyncBufferedMessageBodyWriter<Object>,AsyncMessageBodyWriter<Object>
@Provider
@Consumes({"application/json","application/*+json","text/json"})
@Produces({"application/json","application/*+json","text/json"})
public class ResteasyJackson2Provider
extends JacksonJsonProvider
implements AsyncBufferedMessageBodyWriter<Object>
Only different from Jackson one is *+json in @Produces/@Consumes
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ConcurrentHashMap<org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.ClassAnnotationKey,JsonEndpointConfig> protected final ConcurrentHashMap<org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.ClassAnnotationKey,JsonEndpointConfig> protected final ConcurrentHashMap<org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.ClassAnnotationKey,Boolean> Fields inherited from class com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider
_jsonpFunctionName, _providers, BASIC_ANNOTATIONS, MIME_JAVASCRIPT, MIME_JAVASCRIPT_MSFields inherited from class com.fasterxml.jackson.jakarta.rs.base.ProviderBase
_cfgCheckCanDeserialize, _cfgCheckCanSerialize, _cfgCustomUntouchables, _defaultReadView, _defaultWriteView, _jakartaRSFeatures, _mapperConfig, _unreadableClasses, _untouchables, _unwritableClasses, DEFAULT_UNREADABLES, DEFAULT_UNTOUCHABLES, DEFAULT_UNWRITABLES, HEADER_CONTENT_TYPE_OPTIONS, JAKARTA_RS_FEATURE_DEFAULTS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectMapper_locateMapperViaProvider(Class<?> type, MediaType mediaType) Helper method that is called if no mapper has been explicitly configured.booleanisReadable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) Method that Jakarta-RS container calls to try to check whether values of given type (and media type) can be deserialized by this provider.booleanisWriteable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) Method that Jakarta-RS container calls to try to check whether given value (of specified type) can be serialized by this provider.readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) Method that Jakarta-RS container calls to deserialize given value.voidwriteTo(Object value, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) Method that Jakarta-RS container calls to serialize given value.Methods inherited from class com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider
_configForReading, _configForWriting, hasMatchingMediaType, setJSONPFunctionName, versionMethods inherited from class com.fasterxml.jackson.jakarta.rs.base.ProviderBase
_addSuperTypes, _configForReading, _configForWriting, _containedIn, _createGenerator, _createNoContentException, _createParser, _endpointForReading, _endpointForWriting, _findCustomUntouchable, _isIgnorableForReading, _isIgnorableForWriting, _isSpecialReadable, _modifyHeaders, addUntouchable, checkCanDeserialize, checkCanSerialize, configure, configure, configure, configure, configure, disable, disable, disable, disable, disable, disable, enable, enable, enable, enable, enable, enable, findEncoding, findSuperTypes, findSuperTypes, getSize, hasMatchingMediaTypeForReading, hasMatchingMediaTypeForWriting, isEnabled, locateMapper, removeUntouchable, setAnnotationsToUse, setDefaultReadView, setDefaultView, setDefaultWriteView, setMapperMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jboss.resteasy.core.messagebody.AsyncBufferedMessageBodyWriter
asyncWriteToMethods inherited from interface jakarta.ws.rs.ext.MessageBodyWriter
getSize
-
Field Details
-
_readers
protected final ConcurrentHashMap<org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.ClassAnnotationKey,JsonEndpointConfig> _readers -
decorators
protected final ConcurrentHashMap<org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.ClassAnnotationKey,Boolean> decorators -
_writers
protected final ConcurrentHashMap<org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.ClassAnnotationKey,JsonEndpointConfig> _writers
-
-
Constructor Details
-
ResteasyJackson2Provider
public ResteasyJackson2Provider()
-
-
Method Details
-
isReadable
public boolean isReadable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) Description copied from class:ProviderBaseMethod that Jakarta-RS container calls to try to check whether values of given type (and media type) can be deserialized by this provider. Implementation will first check that expected media type is a JSON type (via call toProviderBase.hasMatchingMediaType(jakarta.ws.rs.core.MediaType)); then verify that type is not one of "untouchable" types (types we will never automatically handle), and finally that there is a deserializer for type (iffProviderBase.checkCanDeserialize(boolean)has been called with true argument -- otherwise assumption is there will be a handler)- Specified by:
isReadablein interfaceMessageBodyReader<Object>- Overrides:
isReadablein classProviderBase<JacksonJsonProvider,ObjectMapper, JsonEndpointConfig, JsonMapperConfigurator> - Parameters:
aClass- the class of instance to be produced.type- the type of instance to be produced. E.g. if the message body is to be converted into a method parameter, this will be the formal type of the method parameter as returned byMethod.getGenericParameterTypes.annotations- an array of the annotations on the declaration of the artifact that will be initialized with the produced instance. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned byMethod.getParameterAnnotations.mediaType- the media type of the HTTP entity, if one is not specified in the request thenapplication/octet-streamis used.- Returns:
trueif the type is supported, otherwisefalse.
-
isWriteable
public boolean isWriteable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) Description copied from class:ProviderBaseMethod that Jakarta-RS container calls to try to check whether given value (of specified type) can be serialized by this provider. Implementation will first check that expected media type is expected one (by call toProviderBase.hasMatchingMediaType(jakarta.ws.rs.core.MediaType)); then verify that type is not one of "untouchable" types (types we will never automatically handle), and finally that there is a serializer for type (iffProviderBase.checkCanSerialize(boolean)has been called with true argument -- otherwise assumption is there will be a handler)- Specified by:
isWriteablein interfaceMessageBodyWriter<Object>- Overrides:
isWriteablein classProviderBase<JacksonJsonProvider,ObjectMapper, JsonEndpointConfig, JsonMapperConfigurator> - Parameters:
aClass- the class of instance that is to be written.type- the type of instance to be written, obtained either by reflection of a resource method return type or via inspection of the returned instance.GenericEntityprovides a way to specify this information at runtime.annotations- an array of the annotations attached to the message entity instance.mediaType- the media type of the HTTP entity.- Returns:
trueif the type is supported, otherwisefalse.
-
readFrom
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOExceptionDescription copied from class:ProviderBaseMethod that Jakarta-RS container calls to deserialize given value.- Specified by:
readFromin interfaceMessageBodyReader<Object>- Overrides:
readFromin classProviderBase<JacksonJsonProvider,ObjectMapper, JsonEndpointConfig, JsonMapperConfigurator> - Parameters:
type- the type that is to be read from the entity stream.genericType- the type of instance to be produced. E.g. if the message body is to be converted into a method parameter, this will be the formal type of the method parameter as returned byMethod.getGenericParameterTypes.annotations- an array of the annotations on the declaration of the artifact that will be initialized with the produced instance. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned byMethod.getParameterAnnotations.mediaType- the media type of the HTTP entity.httpHeaders- the read-only HTTP headers associated with HTTP entity.entityStream- theInputStreamof the HTTP entity. The caller is responsible for ensuring that the input stream ends when the entity has been consumed. The implementation should not close the input stream.- Returns:
- the type that was read from the stream. In case the entity input stream is empty, the reader is expected to
either return an instance representing a zero-length entity or throw a
NoContentExceptionin case no zero-length entity representation is defined for the supported Java type. - Throws:
IOException- if an IO error arises. In case the entity input stream is empty and the reader is not able to produce a Java representation for a zero-length entity,NoContentExceptionis expected to be thrown.
-
writeTo
public void writeTo(Object value, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOExceptionDescription copied from class:ProviderBaseMethod that Jakarta-RS container calls to serialize given value.- Specified by:
writeToin interfaceMessageBodyWriter<Object>- Overrides:
writeToin classProviderBase<JacksonJsonProvider,ObjectMapper, JsonEndpointConfig, JsonMapperConfigurator> - Parameters:
value- the instance to write.type- the class of instance that is to be written.genericType- the type of instance to be written.GenericEntityprovides a way to specify this information at runtime.annotations- an array of the annotations attached to the message entity instance.mediaType- the media type of the HTTP entity.httpHeaders- a mutable map of the HTTP message headers.entityStream- theOutputStreamfor the HTTP entity. The implementation must not close the output stream.- Throws:
IOException- if an IO error arises.
-
_locateMapperViaProvider
Description copied from class:ProviderBaseHelper method that is called if no mapper has been explicitly configured.- Overrides:
_locateMapperViaProviderin classJacksonJsonProvider
-