Code Monkey home page Code Monkey logo

dropwizard-guice-jpa-seed's Introduction

Build Status

dropwizard-guice-jpa-seed

This a sample REST application written in Java. It's purpose is to create a generic project that can be used as a starting point for a new project, but also for learning efforts (I am building an open game database at www.oregami.org).

  • built on Dropwizard version 0.7.0
  • dependency injection with Google Guice (no Spring dependencies!)
  • Hibernate / JPA 2.1 as database access framework
  • HSQLDB as database
  • read database configuration from Dropwizard yaml config file, persistence.xml is not used
  • "Session-per-HTTP-request" with Guice PersistentFilter
  • suport for cross-origin resource sharing
  • JPA entities with UUIDs as primary keys
  • Auditing/Version control of entities with hibernate envers
  • authentication with JSON Web Token via dropwizard-auth-jwt
  • Integration tests with rest-assured
  • a pattern for accessing and manipulation entities with HTTP REST calls (Resource => Service => DAO => entity)
  • a pattern for ServiceResult objects which contain ServiceErrorMessages (which can later be bound to web form fields in the client)

Feel free to suggest corrections, optimizations or extensions via pull requests!

A corresponding JavaScript client application (AngularJS) is available at https://github.com/oregami/angularjs-rest-client/

system architecture

road map / things to do

  • more complex entities
  • hypermedia / HATEOAS

Usage

  • Start the application with the class "ToDoApplication" with the parameters "server todo.yml".

  • List all tasks with:

      GET => http://localhost:8080/task
    
  • Add a new task with:

      POST => http://localhost:8080/task
    

    Header:

      Content-Type:application/json
    

    JSON-Body e.g. :

      {"name" : "task 1", "description" : "This is a description"}
    
  • Modify a task:

      PUT => http://localhost:8080/task/[id]
    

    Header:

      Content-Type:application/json
      Accept:application/json
    

    JSON-Body e.g.:

      {
      "id": "402880944687600101468760d9ea0000",
      "version": "0",
      "name": "task 1 with new name",
      "description": "This is an updated description",
      "finished": "false"
      }
    
  • Remove a task:

      DELETE => http://localhost:8080/task/[id]
    
  • List all revision numbers of a task with:

      GET => http://localhost:8080/task/[id]/revisions
    
  • Show a single task with:

      GET => http://localhost:8080/task/[id]      
    
  • Show a special revision of a single task with:

      GET => http://localhost:8080/task/[id]/revisions/[revisionNumber]
    
  • Create JSON Web Token for authentication:

      POST => http://localhost:8080/jwt/login?username=[username]&password=[password]
      e.g. with user1/password1 or user2/password2
    
  • Check if your JSON Web Token is valid for authentication:

      GET => http://localhost:8080/jwt/test
      Authentication-Header: "Bearer [token]"
    

I recommend you use the great chrome extension Postman to make such HTTP calls!

Data model

see http://wiki.oregami.org/display/DTA/Data+Model

dropwizard-guice-jpa-seed's People

Contributors

sebeichholz avatar

Watchers

James Cloos avatar Shabeesh Balan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.