Class JsrJsonbProvider

  • All Implemented Interfaces:
    javax.ws.rs.ext.MessageBodyReader<Object>, javax.ws.rs.ext.MessageBodyWriter<Object>

    @Produces({"application/json","text/json","application/*+json"})
    @Consumes({"application/json","text/json","application/*+json"})
    @Provider
    public class JsrJsonbProvider
    extends Object
    implements javax.ws.rs.ext.MessageBodyReader<Object>, javax.ws.rs.ext.MessageBodyWriter<Object>
    11.2.7 Java API for JSON Binding (JSR-370) In a product that supports the Java API for JSON Binding (JSON-B) [19], implementations MUST support entity providers for all Java types supported by JSON-B in combination with the following media types: application/json, text/json as well as any other media types matching "*"/json or "*"/"*"+json". Note that if JSON-B and JSON-P are both supported in the same environment, entity providers for JSON-B take precedence over those for JSON-P for all types except JsonValue and its sub-types.
    • Constructor Detail

      • JsrJsonbProvider

        public JsrJsonbProvider()
      • JsrJsonbProvider

        public JsrJsonbProvider​(javax.json.bind.Jsonb jsonb)
    • Method Detail

      • isWriteable

        public boolean isWriteable​(Class<?> type,
                                   Type genericType,
                                   Annotation[] annotations,
                                   javax.ws.rs.core.MediaType mediaType)
        Specified by:
        isWriteable in interface javax.ws.rs.ext.MessageBodyWriter<Object>
      • writeTo

        public void writeTo​(Object t,
                            Class<?> type,
                            Type genericType,
                            Annotation[] annotations,
                            javax.ws.rs.core.MediaType mediaType,
                            javax.ws.rs.core.MultivaluedMap<String,​Object> httpHeaders,
                            OutputStream entityStream)
                     throws IOException,
                            javax.ws.rs.WebApplicationException
        Specified by:
        writeTo in interface javax.ws.rs.ext.MessageBodyWriter<Object>
        Throws:
        IOException
        javax.ws.rs.WebApplicationException
      • isReadable

        public boolean isReadable​(Class<?> type,
                                  Type genericType,
                                  Annotation[] annotations,
                                  javax.ws.rs.core.MediaType mediaType)
        Specified by:
        isReadable in interface javax.ws.rs.ext.MessageBodyReader<Object>
      • readFrom

        public Object readFrom​(Class<Object> type,
                               Type genericType,
                               Annotation[] annotations,
                               javax.ws.rs.core.MediaType mediaType,
                               javax.ws.rs.core.MultivaluedMap<String,​String> httpHeaders,
                               InputStream entityStream)
                        throws IOException,
                               javax.ws.rs.WebApplicationException
        Specified by:
        readFrom in interface javax.ws.rs.ext.MessageBodyReader<Object>
        Throws:
        IOException
        javax.ws.rs.WebApplicationException
      • isSupportedMediaType

        protected boolean isSupportedMediaType​(javax.ws.rs.core.MediaType mediaType)