Class 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 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: ProviderBase
      Method 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 to ProviderBase.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 (iff ProviderBase.checkCanDeserialize(boolean) has been called with true argument -- otherwise assumption is there will be a handler)
      Specified by:
      isReadable in interface MessageBodyReader<Object>
      Overrides:
      isReadable in class ProviderBase<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 by Method.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 by Method.getParameterAnnotations.
      mediaType - the media type of the HTTP entity, if one is not specified in the request then application/octet-stream is used.
      Returns:
      true if the type is supported, otherwise false.
    • isWriteable

      public boolean isWriteable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType)
      Description copied from class: ProviderBase
      Method 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 to ProviderBase.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 (iff ProviderBase.checkCanSerialize(boolean) has been called with true argument -- otherwise assumption is there will be a handler)
      Specified by:
      isWriteable in interface MessageBodyWriter<Object>
      Overrides:
      isWriteable in class ProviderBase<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. GenericEntity provides 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:
      true if the type is supported, otherwise false.
    • readFrom

      public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,String> httpHeaders, InputStream entityStream) throws IOException
      Description copied from class: ProviderBase
      Method that Jakarta-RS container calls to deserialize given value.
      Specified by:
      readFrom in interface MessageBodyReader<Object>
      Overrides:
      readFrom in class ProviderBase<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 by Method.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 by Method.getParameterAnnotations.
      mediaType - the media type of the HTTP entity.
      httpHeaders - the read-only HTTP headers associated with HTTP entity.
      entityStream - the InputStream of 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 NoContentException in 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, NoContentException is 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 IOException
      Description copied from class: ProviderBase
      Method that Jakarta-RS container calls to serialize given value.
      Specified by:
      writeTo in interface MessageBodyWriter<Object>
      Overrides:
      writeTo in class ProviderBase<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. GenericEntity provides 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 - the OutputStream for the HTTP entity. The implementation must not close the output stream.
      Throws:
      IOException - if an IO error arises.
    • _locateMapperViaProvider

      protected ObjectMapper _locateMapperViaProvider(Class<?> type, MediaType mediaType)
      Description copied from class: ProviderBase
      Helper method that is called if no mapper has been explicitly configured.
      Overrides:
      _locateMapperViaProvider in class JacksonJsonProvider