◀︎ Airlift • ◀︎ Getting Started
This following is a detailed explanation of the Getting Started example.
In Step 1 you create a simple Maven POM file. If you are new to Apache Maven please see the Maven Website for details.
-
Parent POM - every Airlift Service has Airbase as its parent.
-
properties
dep.airlift.version
- declares the version of airlift in useair.check.skip-license
- for this example we don't require license headers. But, for production, you shoulddep.packaging.version
- ensure that a project uses the same version for airbase while building and packagingproject.build.targetJdk
- the JDK being used
-
dependencyManagement
- declare Airlift's dependency versions via the Maven BOM convention -
dependencies
- Notice that Airlift's parent has pre-defined versions for all the dependencies you will need to start a service.
In Step 2 you create a standard JAX-RS Resource file. Notice that there is nothing Airlift-specific here. Just standard JAX-RS. If you are not familiar with JAX-RS see the Jersey Website for details.
In Step 3 you "bind" the JAX-RS resource using Guice. Airlift makes this very easy with its jaxrsBinder
. If you're not familiar with Guice see the Guice Website for details.
In Step 4 you create your Main class. This uses Airlift's "Bootstrap" mechanism. It
handles all the scaffolding and housework of initializing Jersey, creates a best-practices HttpServer, etc. These chores are normally a huge headache and it's hard to
get it right. In addition to your ServiceModule
there are a few required Airlift
modules here.
Once the bootstrap instance is created, the Service is started via:
app.initialize();