javax.ws.rs.ext

Interface Providers

    • Method Detail

      • getMessageBodyReader

        <T> MessageBodyReader<T> getMessageBodyReader(Class<T> type,
                                                      Type genericType,
                                                      Annotation[] annotations,
                                                      MediaType mediaType)
        Get a message body reader that matches a set of criteria. The set of readers is first filtered by comparing the supplied value of 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(Class, Type, Annotation[], MediaType) method is called on each reader in order using the supplied criteria and the first reader that returns true is selected and returned.
        Type Parameters:
        T - type of the the object that is to be read.
        Parameters:
        type - the class of the 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.
        Returns:
        a MessageBodyReader that matches the supplied criteria or null if none is found.
      • getMessageBodyWriter

        <T> MessageBodyWriter<T> getMessageBodyWriter(Class<T> type,
                                                      Type genericType,
                                                      Annotation[] annotations,
                                                      MediaType mediaType)
        Get a message body writer that matches a set of criteria. The set of writers is first filtered by comparing the supplied value of 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(Class, Type, Annotation[], MediaType) method is called on each writer in order using the supplied criteria and the first writer that returns true is selected and returned.
        Type Parameters:
        T - type of the object that is to be written.
        Parameters:
        type - the class of the 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.
        Returns:
        a MessageBodyReader that matches the supplied criteria or null if none is found.
      • getExceptionMapper

        <T extends ThrowableExceptionMapper<T> getExceptionMapper(Class<T> type)
        Get an exception mapping provider for a particular class of exception. Returns the provider whose generic type is the nearest superclass of type.
        Type Parameters:
        T - type of the exception handled by the exception mapping provider.
        Parameters:
        type - the class of exception.
        Returns:
        an ExceptionMapper for the supplied type or null if none is found.
      • getContextResolver

        <T> ContextResolver<T> getContextResolver(Class<T> contextType,
                                                  MediaType mediaType)
        Get a context resolver for a particular type of context and media type. The set of resolvers is first filtered by comparing the supplied value of 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.
        Type Parameters:
        T - type of the context.
        Parameters:
        contextType - the class of context desired.
        mediaType - the media type of data for which a context is required.
        Returns:
        a matching context resolver instance or null if no matching context providers are found.

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Version en cache

21/08/2025 19:10:28 Cette version de la page est en cache (à la date du 21/08/2025 19:10:28) afin d'accélérer le traitement.
Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.

Document créé le 11/06/2005, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/ws/rs/ext/providers.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.