Class

com.twitter.finatra.http.marshalling

MessageBodyManager

Related Doc: package marshalling

Permalink

class MessageBodyManager extends AnyRef

Manages registration of message body components. I.e., components that specify how to parse an incoming Finagle HTTP request body into a model object ("message body reader") and how to render a given type as a response ("message body writer").

A default implementation for both a reader and a writer is necessary in order to specify the behavior to invoke when a reader or writer is not found for a requested type T. The framework binds two default implementations: DefaultMessageBodyReader and DefaultMessageBodyWriter via the com.twitter.finatra.http.modules.MessageBodyModule.

These defaults are overridable by providing a customized MessageBodyModule in your com.twitter.finatra.http.HttpServer by overriding the com.twitter.finatra.http.HttpServer.messageBodyModule.

When the MessageBodyManager is obtained from the injector (which is configured with the framework com.twitter.finatra.http.modules.MessageBodyModule) the framework default implementations for the reader and writer will be provided accordingly (along with the configured server injector).

Annotations
@Singleton()
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MessageBodyManager
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MessageBodyManager(injector: Injector, defaultMessageBodyReader: DefaultMessageBodyReader, defaultMessageBodyWriter: DefaultMessageBodyWriter)

    Permalink

    injector

    the configured com.twitter.inject.Injector for the server.

    defaultMessageBodyReader

    a default message body reader implementation.

    defaultMessageBodyWriter

    a default message body writer implementation.

    Annotations
    @Inject()

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def add[Component <: MessageBodyComponent]()(implicit arg0: Manifest[Component]): Unit

    Permalink

    Register a MessageBodyReader or MessageBodyWriter to its parameterized type.

    Register a MessageBodyReader or MessageBodyWriter to its parameterized type. E.g., a MessageBodyReader[Foo] will register the given reader for the Foo type.

    Component

    the MessageBodyComponent to register.

  5. final def addExplicit[Component <: MessageBodyComponent, T]()(implicit arg0: Manifest[Component], arg1: Manifest[T]): Unit

    Permalink

    Register a MessageBodyReader or MessageBodyWriter to an explicitly given type.

    Register a MessageBodyReader or MessageBodyWriter to an explicitly given type. E.g., given a MessageBodyReader[Car] and a type of Audi the MessageBodyReader[Car] will be registered to the Audi type. This is useful when you want to register subtypes to a reader/writer of their parent type.

    Component

    the MessageBodyComponent to register. An instance of the component will be obtained from the injector.

    T

    the type to associate to the registered MessageBodyComponent.

  6. final def addWriterByAnnotation[A <: Annotation, Writer <: MessageBodyWriter[_]]()(implicit arg0: Manifest[A], arg1: Manifest[Writer]): Unit

    Permalink

    Register a MessageBodyWriter to a given Annotation, A.

    Register a MessageBodyWriter to a given Annotation, A.

    A

    the Annotation type to register against the given MessageBodyWriter type.

    Writer

    the MessageBodyWriter type to associate to the given Annotation. An instance of the MessageBodyWriter will be obtained from the injector.

  7. final def addWriterByComponentType[Component <: MessageBodyComponent, Writer <: MessageBodyWriter[_]]()(implicit arg0: Manifest[Component], arg1: Manifest[Writer]): Unit

    Permalink

    Register a MessageBodyWriter to a given MessageBodyComponent.

    Component

    the MessageBodyComponent type to register against the given MessageBodyWriter type.

    Writer

    the MessageBodyWriter type to associate to the given MessageBodyComponent. An instance of the MessageBodyWriter will be obtained from the injector

  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def read[T](message: Message)(implicit arg0: Manifest[T]): T

    Permalink

    Read the body of a com.twitter.finagle.http.Message into a type T.

    Read the body of a com.twitter.finagle.http.Message into a type T. Performs a lookup of a matching MessageBodyReader for the type T and invokes the MessageBodyReader#parse method of the matching reader. Otherwise if no matching reader for the type T is found, the defaultMessageBodyReader#parse method is invoked.

    T

    the type into which to parse the message body.

    message

    the com.twitter.finagle.http.Message to read

    returns

    an instance of type T parsed from the Message body contents by a matching MessageBodyReader.

  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  21. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  22. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def writer(obj: Any): MessageBodyWriter[Any]

    Permalink

    Return a MessageBodyWriter over the type of the class from the given object.

    Return a MessageBodyWriter over the type of the class from the given object. If a suitable MessageBodyWriter cannot be located the defaultMessageBodyWriter will be returned.

    obj

    the Any type to use as the key for locating an appropriate MessageBodyWriter.

    returns

    a suitable writer for the type represented by the given object.

    Note

    the writerCache is bounded on the number of unique classes returned from controller routes

Inherited from AnyRef

Inherited from Any

Ungrouped