This should look familiar as the structure is similar to creating an HttpServer.
The server can be thought of as a collection of controllers composed with
filters. Additionally, a server can define modules
for providing instances to the object graph.

Finatra assumes that users are using the Scrooge Thrift code generator
for generating code from a Thrift IDL. Scrooge allows for
code generation in multiple languages but Finatra supports either generated Java or generated Scala
code only.

If you choose to use generated Java code for your service (instead of generated Scala), you MUST
extend the AbstractThriftServer and configure the JavaThriftRouter.

Most typically this is done when the server is being written in Java but is not exclusively so. This
means:

if you write your server in Scala you can use either generated Java or generated Scala code.

The Finatra convention is to create a Scala object
with a name ending in “Main” that extends your server class. The server class can be used in
testing as this allows your server to be instantiated multiple times in tests without worrying about
static state persisting across test runs in the same JVM.

object ExampleServerMain extends ExampleServer

The static object, e.g., ExampleServerMain, which then contains a static main method for the server
would then be used as the application entry point
for running the server in all other cases.

If you want to further configure the underlying Finagle
server you can override configureThriftServer in your server to specify additional configuration
on (or override the default configuration of) the underlying Finagle server.

However, since the server-side ResponseClassifier could affect code not just at the Finagle level,
we actually recommend overriding the specific framework module, ThriftResponseClassifierModule
instead. This binds an instance of an ThriftResponseClassifier
to the object graph that is then available to be injected into things like the Thrift
StatsFilter
for a more accurate reporting of metrics that takes into account server-side response classification.