Interface MediaContext

All Superinterfaces:
RuntimeType.Api<MediaContextConfig>

public interface MediaContext extends RuntimeType.Api<MediaContextConfig>
Media context to obtain readers and writers of various supported content types.
  • Method Details

    • create

      static MediaContext create()
      Create a new media context from ServiceLoader.
      Returns:
      media context
    • create

      static MediaContext create(Config config)
      Create a new media context and apply provided configuration.
      Parameters:
      config - configuration to use
      Returns:
      media context
    • create

      static MediaContext create(MediaContextConfig config)
      Create media context from its prototype.
      Parameters:
      config - media context configuration
      Returns:
      a new media context
    • create

      Create media context, customizing its configuration.
      Parameters:
      consumer - consumer of media context builder
      Returns:
      a new media context
    • builder

      static MediaContextConfig.Builder builder()
      Builder to set up this media support context.
      Returns:
      a new builder
    • reader

      <T> EntityReader<T> reader(GenericType<T> type, Headers headers)
      Reader for entity.
      Type Parameters:
      T - type
      Parameters:
      type - type to read into (such as Pojo, JsonObject)
      headers - headers related to this entity
      Returns:
      entity reader for the type, or a reader that will fail if none found
    • writer

      <T> EntityWriter<T> writer(GenericType<T> type, Headers requestHeaders, WritableHeaders<?> responseHeaders)
      Writer for server response entity.
      Type Parameters:
      T - type
      Parameters:
      type - type to write
      requestHeaders - request headers, containing accepted types
      responseHeaders - response headers to be updated with content type
      Returns:
      entity writer for the type, or a writer that will fail if none found
    • reader

      <T> EntityReader<T> reader(GenericType<T> type, Headers requestHeaders, Headers responseHeaders)
      Reader for client response entity.
      Type Parameters:
      T - type
      Parameters:
      type - type to read into
      requestHeaders - request headers containing accepted types
      responseHeaders - response headers containing content type
      Returns:
      entity reader for the type, or a reader that will fail if none found
    • writer

      <T> EntityWriter<T> writer(GenericType<T> type, WritableHeaders<?> requestHeaders)
      Writer for client request entity.
      Type Parameters:
      T - type
      Parameters:
      type - type to write
      requestHeaders - request headers to write content type to
      Returns:
      entity writer for the type, or a writer that will fail if none found