Giter VIP home page Giter VIP logo

jerseyexample's Introduction

Jersey REST Server and Client

Java web application that provide REST web services. An example app for trying out some of the JDK 8 and Spring 4 features.

29/10/2014 : The Java 8 functional interfaces API do remind me of Google Guava library and Groovy closures....... =) The streams API seem interesting

And finally some thread-safe date time API within JDK!

Frameworks & Libraries

  • Gradle : build
  • Jersey : REST web service
  • Spring 4 : Dependencies injection
  • Jackson 2 : JSON processing
  • Jetty : Servlet container

Testing frameworks : jersey-test,rest-assured, spring-test, junit, spock

Jersey client is generated from the WADL using wadl2java tool

Requirements

  • Java 1.8
  • Gradle

Run the build and tests + Package

Execute the following command:

./gradlew clean build

This will compile, run the tests and package. The artifact should be available in the directory: build/

Refresh IDE - Intellij IDEA

Execute the following command :

./gradlew idea

Run the application

Compile and run the web application with Jetty plugin:

./gradlew clean jettyRunWar

With the web app running on Jetty, you can then access the application endpoint from base URL :

http://localhost:8080/jerseyexample/api/*

Accessing the REST API and versioning

You can use any REST client to access the REST api. If you're using Chrome browser, you can use extensions such as "Advanced Rest Client" to do so.

Example, api URL to access order :

http://localhost:8080/jerseyexample/api/order

The versioning of the API is by the Accept/Content-Type headers. So for example if you would like to access version 2 of the api, set the following headers on the client:

Accept : "application/vnd.org.wai.jerseyexample-v2+json"

Web Application Description Language (WADL)

With the web app running on Jetty, you can access the Jersey generated WADL from the URL below:

http://localhost:8080/jerseyexample/api/application.wadl

http://localhost:8080/jerseyexample/api/application.wadl?detail

jerseyexample's People

Watchers

 avatar  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.