MessageBodyReader implementation may be annotated
with javax.ws.rs.Consumes to restrict the media types for which it will
be considered suitable.
Providers implementing MessageBodyReader contract must be either programmatically
registered in a JAX-RS runtime or must be annotated with
@Provider annotation to be automatically discovered
by the JAX-RS runtime during a provider scanning phase.
Provider, javax.ws.rs.Consumes
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the type is supported, otherwise false.the class of instance to be produced. type, 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
genericType, Annotation[] Method.getGenericParameterTypes.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
annotations, MediaType Method.getParameterAnnotations.the media type of the HTTP entity, if one is not
specified in the request then mediaType)application/octet-stream is
used.Ascertain if the MessageBodyReader can produce an instance of a particular type. |
| public T | 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 ajavax.ws.rs.core.NoContentException in case no zero-length entity representation is
defined for the supported Java type.the type that is to be read from the entity stream. type, 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
genericType, Annotation[] Method.getGenericParameterTypes.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
annotations, MediaType Method.getParameterAnnotations.the media type of the HTTP entity. mediaType, MultivaluedMap<String, String> the read-only HTTP headers associated with HTTP entity. httpHeaders, InputStream the entityStream)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.Read a type from the |
| isReadable | back to summary |
|---|---|
| public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) Ascertain if the MessageBodyReader can produce an instance of a
particular type. The
| |
| readFrom | back to summary |
|---|---|
| public T readFrom(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException Read a type from the
In case the entity input stream is empty, the reader is expected to either return a
Java representation of a zero-length entity or throw a
| |