Rest.li can be run in a variety of HTTP frameworks. Out of the box, Rest.li supports both Netty and Servlet containers, such as Jetty.
Rest.li includes a restli-netty-standalone
artifact containing a single class: com.linkedin.restli.server.NettyStandaloneLauncher
. This launcher class configures a Netty server to dispatch requests to all Rest.li resources that are both in the current classpath and in the list of package names the launcher is provided when it is created.
import com.linkedin.restli.server.NettyStandaloneLauncher;
...
NettyStandaloneLauncher launcher = new NettyStandaloneLauncher(
8080 /*port*/,
"com.example.fortunes" /* resource package(s) */
);
launcher.start();
// ... server is running. launcher.stop() can be called to stop it.
Thread pool sizes may also optionally be configured using the overloaded constructor.
java -cp <classpath> com.linkedin.restli.server.NettyStandaloneLauncher 8080 com.example.fortunes
task startFortunesServer(type: JavaExec) {
main = 'com.linkedin.restli.server.NettyStandaloneLauncher'
args = ['-port', '8080', '-packages', 'com.example.fortune.impl']
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
}
Thread pool sizes may also optionally be configured by providing a number to the ‘-thread’ and ‘-parseqthreads’ args.