This is a dockerized RESTful Dropwizard application, to provide an example on how to integrate MongoDB and JPA in Dropwizard, using dependency injection. This is using a Instead of using Morphia, MongoJack or MongoDB Java driver the decision was to investigate how to integrate MongoDB with JPA. Please read more about Hibernate OGM Reference Guide The example is a simple RESTful interface to easily manage a task planner.
- using Dropwizard v1.1.0 framework
- dependency injection achieve through Google Guice
- JPA implementation through Hibernate OGM
- FongoDB is an in-memory java implementation of MongoDB, intercepting call to the standard mongo-java-driver
- API documentation provided by swagger.io and swagger UI
- Docker as the containerisation solution
- using Hate library as HATEOAS with HAL implementation
- Run
mvn clean verify
to build your application - Start application with
java -jar target/dropwizard-guice-1.0-SNAPSHOT-uber.jar server target/config.yml
- To check that the application is running enter url
http://localhost:8080
- To interact with the application using Swagger UI endpoints enter url
http://localhost:8080/swagger
- To run the application inside a docker container,
./docker-run.sh
POST /tasks
Creates a new task. Task descriptions are not unique.
Type | Name | Description | Schema |
---|---|---|---|
Body | body required |
payload | A new task |
HTTP Code | Description | Schema |
---|---|---|
201 | Created | A new task |
application/json
application/json
GET /tasks
Returns all the tasks save on the database
HTTP Code | Schema |
---|---|
200 | < Task Entity > array |
application/json
GET /tasks/{taskId}
Returns task by Id. If it does not exist it will return a HTTP 404
Type | Name | Description | Schema |
---|---|---|---|
Path | taskId required |
taskId | string(uuid) |
HTTP Code | Description | Schema |
---|---|---|
200 | Task Entity | |
404 | Not Found | No Content |
application/json
PUT /tasks/{taskId}
Updates a task description if available in the database
Type | Name | Description | Schema |
---|---|---|---|
Path | taskId required |
taskId | string(uuid) |
Body | body required |
payload | A new task |
HTTP Code | Description | Schema |
---|---|---|
200 | Updated | No Content |
404 | Not Found | No Content |
application/json
application/json
DELETE /tasks/{taskId}
Deletes a if available in the database
Type | Name | Description | Schema |
---|---|---|---|
Path | taskId required |
taskId | string(uuid) |
HTTP Code | Description | Schema |
---|---|---|
204 | No Content | No Content |
404 | Not Found | No Content |
application/json
application/json