|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.jersey.message.internal.MessageBodyFactory
public class MessageBodyFactory
A factory for managing MessageBodyReader and MessageBodyWriter
instances.
MessageBodyReader and MessageBodyWriter implementation
must not inject the instance of this type directly, e.g. @Inject MessageBodyWorkers w;.
Instead a Factory-based injection should be used to prevent
cycles in the injection framework caused by the eager initialization of the
providers in the current factory implementation:
@Inject Factory<MessageBodyWorkers> w;
| Nested Class Summary | |
|---|---|
static class |
MessageBodyFactory.Module
|
| Field Summary | |
|---|---|
static KeyComparator<javax.ws.rs.core.MediaType> |
MEDIA_TYPE_COMPARATOR
|
| Constructor Summary | |
|---|---|
MessageBodyFactory(ServiceProviders serviceProviders)
|
|
| Method Summary | ||
|---|---|---|
|
getMessageBodyReader(Class<T> c,
Type t,
Annotation[] as,
javax.ws.rs.core.MediaType mediaType)
Get a message body reader that matches a set of criteria. |
|
|
getMessageBodyReaderMediaTypes(Class<T> type,
Type genericType,
Annotation[] annotations)
Get the list of media types supported for a Java type. |
|
|
getMessageBodyWriter(Class<T> c,
Type t,
Annotation[] as,
javax.ws.rs.core.MediaType mediaType)
Get a message body writer that matches a set of criteria. |
|
|
getMessageBodyWriterMediaType(Class<T> c,
Type t,
Annotation[] as,
List<javax.ws.rs.core.MediaType> acceptableMediaTypes)
Get the most acceptable media type supported for a Java type given a set of acceptable media types. |
|
|
getMessageBodyWriterMediaTypes(Class<T> c,
Type t,
Annotation[] as)
Get the list of media types supported for a Java type. |
|
Map<javax.ws.rs.core.MediaType,List<javax.ws.rs.ext.MessageBodyReader>> |
getReaders(javax.ws.rs.core.MediaType mediaType)
Get the map of media type to list of message body writers that are compatible with a media type. |
|
Map<javax.ws.rs.core.MediaType,List<javax.ws.rs.ext.MessageBodyWriter>> |
getWriters(javax.ws.rs.core.MediaType mediaType)
Get the map of media type to list of message body writers that are compatible with a media type. |
|
String |
readersToString(Map<javax.ws.rs.core.MediaType,List<javax.ws.rs.ext.MessageBodyReader>> readers)
Convert a map media type to list of message body readers to a string. |
|
String |
writersToString(Map<javax.ws.rs.core.MediaType,List<javax.ws.rs.ext.MessageBodyWriter>> writers)
Convert a map media type to list of message body writers to a string. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final KeyComparator<javax.ws.rs.core.MediaType> MEDIA_TYPE_COMPARATOR
| Constructor Detail |
|---|
public MessageBodyFactory(ServiceProviders serviceProviders)
| Method Detail |
|---|
public Map<javax.ws.rs.core.MediaType,List<javax.ws.rs.ext.MessageBodyReader>> getReaders(javax.ws.rs.core.MediaType mediaType)
MessageBodyWorkers
getReaders in interface MessageBodyWorkersmediaType - the compatible media type.
public Map<javax.ws.rs.core.MediaType,List<javax.ws.rs.ext.MessageBodyWriter>> getWriters(javax.ws.rs.core.MediaType mediaType)
MessageBodyWorkers
getWriters in interface MessageBodyWorkersmediaType - the compatible media type.
public String readersToString(Map<javax.ws.rs.core.MediaType,List<javax.ws.rs.ext.MessageBodyReader>> readers)
MessageBodyWorkers
readersToString in interface MessageBodyWorkersreaders - the map media type to list of message body readers
public String writersToString(Map<javax.ws.rs.core.MediaType,List<javax.ws.rs.ext.MessageBodyWriter>> writers)
MessageBodyWorkers
writersToString in interface MessageBodyWorkerswriters - the map media type to list of message body readers
public <T> javax.ws.rs.ext.MessageBodyReader<T> getMessageBodyReader(Class<T> c,
Type t,
Annotation[] as,
javax.ws.rs.core.MediaType mediaType)
MessageBodyWorkers
getMessageBodyReader in interface MessageBodyWorkersT - the type of object to be read.c - the class of object to be read.t - the type of object 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
Class.getGenericParameterTypes.as - 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
Class.getParameterAnnotations.mediaType - the media type of the data that will be read, this will
be compared to the values of Consumes for
each candidate reader and only matching readers will be queried.
public <T> List<javax.ws.rs.core.MediaType> getMessageBodyReaderMediaTypes(Class<T> type,
Type genericType,
Annotation[] annotations)
MessageBodyWorkers
getMessageBodyReaderMediaTypes in interface MessageBodyWorkersT - the type of object that is to be read.type - the class of object that is to be read.genericType - the type of object to be read. E.g. if the
message body is to be read as a method parameter, this will be
the declared type of the parameter as returned by
Method.getGenericParameterTypes.annotations - an array of the annotations on the declaration of the
artifact that will be read. E.g. if the
message body is to be consumed as a method parameter, this will be
the annotations on that parameter returned by
Method.getParameterAnnotations.
public <T> javax.ws.rs.ext.MessageBodyWriter<T> getMessageBodyWriter(Class<T> c,
Type t,
Annotation[] as,
javax.ws.rs.core.MediaType mediaType)
MessageBodyWorkers
getMessageBodyWriter in interface MessageBodyWorkersT - the type of the object that is to be written.c - the class of object that is to be written.t - the type of object to be written. E.g. if the
message body is to be produced from a field, this will be
the declared type of the field as returned by
Field.getGenericType.as - an array of the annotations on the declaration of the
artifact that will be written. E.g. if the
message body is to be produced from a field, this will be
the annotations on that field returned by
Field.getDeclaredAnnotations.mediaType - the media type of the data that will be written, this will
be compared to the values of Produces for
each candidate writer and only matching writers will be queried.
public <T> List<javax.ws.rs.core.MediaType> getMessageBodyWriterMediaTypes(Class<T> c,
Type t,
Annotation[] as)
MessageBodyWorkers
getMessageBodyWriterMediaTypes in interface MessageBodyWorkersT - the type of object that is to be written.c - the class of object that is to be written.t - the type of object to be written. E.g. if the
message body is to be produced from a field, this will be
the declared type of the field as returned by
Field.getGenericType.as - an array of the annotations on the declaration of the
artifact that will be written. E.g. if the
message body is to be produced from a field, this will be
the annotations on that field returned by
Field.getDeclaredAnnotations.
public <T> javax.ws.rs.core.MediaType getMessageBodyWriterMediaType(Class<T> c,
Type t,
Annotation[] as,
List<javax.ws.rs.core.MediaType> acceptableMediaTypes)
MessageBodyWorkers
getMessageBodyWriterMediaType in interface MessageBodyWorkersT - the type of object that is to be written.c - the class of object that is to be written.t - the type of object to be written. E.g. if the
message body is to be produced from a field, this will be
the declared type of the field as returned by
Field.getGenericType.as - an array of the annotations on the declaration of the
artifact that will be written. E.g. if the
message body is to be produced from a field, this will be
the annotations on that field returned by
Field.getDeclaredAnnotations.acceptableMediaTypes - the list of acceptable media types, sorted
according to the quality with the media type of highest quality
occurring first first.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||