To build and start local jetty server on port 8080 use this command:
./gradlew jettyRunWar
It builds war file, starts jetty, and deploys built war file.
- Customer contains a reference to an address
- Address is referenced by a customer
- Order contains references to a customer and to a list of order items
- OrderItem referenced by an order and contains reference to a product
- Product contains information abount a product
It is simple abstraction of a persistence layer. It does not connect to any database actually.
- CustomerRepository which contains such operations as:
void addCustomer(Customer customer);
List<Customer> getCustomers();
void updateCustomer(Long id, Customer customer);
Customer getCustomer(Long id);
void deleteCustomer(Long id);
- OrderRepository(TBD)
Contains a couple of REST resources:
- CustomerResource
- OrderResource(TBD)
-
CustomerResource is implemented by CustomerResourceImpl. CustomerResource endpoints:
Endpoints support JSON format so far:
- POST /customers is used to create customer:
curl -H "Content-Type: application/json" -X POST -d '{"id":1,"firstName":"John","lastName":"Konstantine","address":{"city":"London","country":"UK"}}' http://localhost:8080/jaxrs-example/customers
- GET /customers is used to query all customers(pagination TBD):
curl -i -H "Accept: application/json" http://localhost:8080/jaxrs-example/customers
- PUT /customers/{id} is used to update customer's info:
curl -H "Content-Type: application/json" -X PUT -d '{"firstName":"Vadym","lastName":"Konstantine","address":{"city":"London","country":"UK"}}' http://localhost:8080/jaxrs-example/customers/1
- GET /customers/{id} is used to get customer's info by id:
curl -i -H "Accept: application/json" http://localhost:8080/jaxrs-example/customers/1
- DELETE /customers/{id} is used to delete customer by id:
curl -i -H "Accept: application/json" -X DELETE http://localhost:8080/jaxrs-example/customers/1
- POST /customers is used to create customer:
-
OrderResource (TBD)
-
To query customers using start and size query params surrond url with quotation marks, otherwise the second query param will be ignored and set to default value, which is zero:
curl -i -H "Accept: application/json" "http://localhost:8080/jaxrs-example/customers?size=1&start=2"