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).
- Alphabetic
- By Inheritance
- MessageBodyManager
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def add[Component <: MessageBodyComponent]()(implicit arg0: ClassTag[Component], tt: scala.reflect.api.JavaUniverse.TypeTag[Component]): Unit
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 theFootype.- Component
the MessageBodyComponent to register.
- final def addExplicit[Component <: MessageBodyComponent, T]()(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[Component], arg1: scala.reflect.api.JavaUniverse.TypeTag[T]): Unit
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 ofAuditheMessageBodyReader[Car]will be registered to theAuditype. 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.
- final def addWriterByAnnotation[A <: Annotation, Writer <: MessageBodyWriter[_]]()(implicit arg0: Manifest[A], arg1: Manifest[Writer]): Unit
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.
- final def addWriterByComponentType[Component <: MessageBodyComponent, Writer <: MessageBodyWriter[_]]()(implicit arg0: Manifest[Component], arg1: Manifest[Writer]): Unit
Register a MessageBodyWriter to a given MessageBodyComponent.
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
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def read[T](message: Message, clazz: Class[T]): T
For use from Java
- final def read[T](message: Message)(implicit tt: scala.reflect.api.JavaUniverse.TypeTag[T]): T
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.
- Note
Java users should prefer Message, clazz: Class.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def writer(obj: Any): MessageBodyWriter[Any]
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