This example demonstrates various Jersey features, namely:
Flight Management Web Application is a simple demo application for managing (creating, updating, deleting, reserving) flights and aircrafts and their subsequent animated flight simulation on HTML5 canvas using streamed SSE data.
The example consists of 3 main resource classes:
org.glassfish.jersey.examples.flight.resources.AircraftsResource
org.glassfish.jersey.examples.flight.resources.FlightsResource
org.glassfish.jersey.examples.flight.resources.FlightSimResource
All the application JAX-RS resources are deployed under the same api
root path.
The mapping of the URI path space for the individual resources is presented in the following table:
Resource class | URI path | HTTP method | Description |
---|---|---|---|
FlightsResource |
/flights |
GET |
Retrieve list of flights in various formats - XML, JSON, TXT, HTML, CSV, YAML |
POST |
Create a new flight (input: application/x-www-form-urlencoded ; output: XML, JSON); Requires "admin" role.
|
||
/flights/open |
GET |
Retrieve list of open flights (not closed for simulation) - XML, JSON | |
/flights/{id} |
GET |
Retrieve detailed information about a single flight - XML, JSON, HTML | |
DELETE |
Delete a single flight (output: deleted flight identifier - TXT); Requires "admin" role. | ||
/flights/{id}/new-booking |
POST |
Reserve a seat in a flight. (output: reservation identifier - TXT, HTML) | |
/flights/{id}/status |
POST |
Change flight status. (input: application/x-www-form-urlencoded ; output: new status name - TXT);
Requires "admin" role.
|
|
AircraftsResource |
/aircrafts |
GET |
Retrieve list of aircrafts in various formats - XML, JSON, HTML |
POST |
Create a new aircraft (input: application/x-www-form-urlencoded ; output: XML, JSON);
Requires "admin" role.
|
||
/aircrafts/available |
GET |
Retrieve list of available aircrafts (not assigned to a flight) - XML, JSON | |
/aircrafts/{id} |
GET |
Retrieve detailed information about a single aircraft - XML, JSON, HTML | |
DELETE |
Delete a single aircraft (output: deleted aircraft identifier - TXT); Requires "admin" role. | ||
FlightSimResource |
/simulation |
POST |
START/STOP simulation (input: application/x-www-form-urlencoded ; output: TXT) |
/simulation/events |
GET |
Receive simulation events as SSE stream. |
Flight Management Web Application Example is a web application (WAR) that can be deployed to any Servlet 3.x container. By default, the examples runs on Jetty using the Jetty Maven plugin. Before the example is run, it must be built first:
mvn clean package
This command builds the example WAR and runs all the unit tests against the example application.
Once the example is built, it can be run as follows:
mvn jetty:run
When the example is run using the Jetty Maven plugin as described above, the example Web application gets deployed to the
local host under port 8080
. As mentioned earlier, the resources can be accessed directly under common
api
root path. Here are a few links to directly access some of the HTTP GET
operations on the
application resources:
http://localhost:8080/api/flights
http://localhost:8080/api/flights/open
http://localhost:8080/api/aircrafts
http://localhost:8080/api/aircrafts/available
The HTML application root to be accessed via browser is represented by the application index.html
page:
http://localhost:8080/index.html