Skip to content
Joe Betz edited this page Jul 26, 2013 · 7 revisions

Rest.li may be run in a variety of http frameworks. Out of the box, Rest.li supports both Netty and Servlet containers like Jetty.

This describes how to run Rest.li with Netty.

Basics

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.

Programmatically calling the Netty Launcher

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.

Calling the Netty Launcher from the command line

java -cp <classpath> com.linkedin.restli.server.NettyStandaloneLauncher 8080 com.example.fortunes

Calling the Netty Launcher from a Gradle task

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
}

Clone this wiki locally