Skip to main content

Microservice Jetty Overview

The Jetty Microservice API consists of a combination of the Juneau Core, Server, and Client APIs and an embedded Eclipse Jetty Servlet Container.

The API builds upon the Core Microservices classes to produce easy-to-create and easy-to-use microservices in a standard Java 1.8+ environment.

The juneau-microservice-jetty library consists of the following classes:

org.apache.juneau.microservice.jetty - PackageJettyMicroservice - The Jetty microservice class.JettyMicroservice.Builder - Builder for the microservice class.JettyMicroserviceListener - Interface for hooking into lifecyle events of the microservice.BasicJettyMicroserviceListener - Adapter for JettyMicroserviceListener class.JettyServerFactory - Interface for defining custom Jetty servers.BasicJettyServerFactory - Adapter for JettyServerFactory class.

The most-basic creation of a Jetty microservice from an entry-point method is shown below:

public class App {
public static void main(String[] args) {
JettyMicroservice
.create() // Create builder.
.args(args) // Pass in args.
.servlets(RootResource.class) // A Juneau RestServlet class.
.build() // Create microservice.
.start() // Start microservice.
;
}
}