|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Providers
An injectable interface providing runtime lookup of provider instances.
Context
,
MessageBodyReader
,
MessageBodyWriter
,
ContextResolver
,
ExceptionMapper
Method Summary | ||
---|---|---|
|
getContextResolver(java.lang.Class<T> contextType,
MediaType mediaType)
Get a context resolver for a particular type of context and media type. |
|
|
getExceptionMapper(java.lang.Class<T> type)
Get an exception mapping provider for a particular class of exception. |
|
|
getMessageBodyReader(java.lang.Class<T> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
MediaType mediaType)
Get a message body reader that matches a set of criteria. |
|
|
getMessageBodyWriter(java.lang.Class<T> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
MediaType mediaType)
Get a message body writer that matches a set of criteria. |
Method Detail |
---|
<T> MessageBodyReader<T> getMessageBodyReader(java.lang.Class<T> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, MediaType mediaType)
mediaType
with the value of each reader's
Consumes
, ensuring the supplied value of
type
is assignable to the generic type of the reader, and
eliminating those that do not match.
The list of matching readers is then ordered with those with the best
matching values of Consumes
(x/y > x/* > */*)
sorted first. Finally, the
MessageBodyReader#isReadable
method is called on each reader in order using the supplied criteria and
the first reader that returns true
is selected and returned.
type
- the class of object that is to be read.genericType
- 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
.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
Class.getParameterAnnotations
.mediaType
- the media type of the data that will be read.
<T> MessageBodyWriter<T> getMessageBodyWriter(java.lang.Class<T> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, MediaType mediaType)
mediaType
with the value of each writer's
Produces
, ensuring the supplied value of
type
is assignable to the generic type of the reader, and
eliminating those that do not match.
The list of matching writers is then ordered with those with the best
matching values of Produces
(x/y > x/* > */*)
sorted first. Finally, the
MessageBodyWriter#isWriteable
method is called on each writer in order using the supplied criteria and
the first writer that returns true
is selected and returned.
type
- the class of object that is to be written.genericType
- 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
.annotations
- 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.
<T extends java.lang.Throwable> ExceptionMapper<T> getExceptionMapper(java.lang.Class<T> type)
type
.
type
- the class of exception
ExceptionMapper
for the supplied type or null if none
is found.<T> ContextResolver<T> getContextResolver(java.lang.Class<T> contextType, MediaType mediaType)
mediaType
with the value of each resolver's
Produces
, ensuring the generic type of the context
resolver is assignable to the supplied value of contextType
, and
eliminating those that do not match. If only one resolver matches the
criteria then it is returned. If more than one resolver matches then the
list of matching resolvers is ordered with those with the best
matching values of Produces
(x/y > x/* > */*)
sorted first. A proxy is returned that delegates calls to
ContextResolver#getContext(java.lang.Class)
to each matching context
resolver in order and returns the first non-null value it obtains or null
if all matching context resolvers return null.
contextType
- the class of context desiredmediaType
- the media type of data for which a context is required.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.
Generated on 10-February-2011 12:41