git clone https://github.com/jchart-github/jaxrs2-starter-kit.git
It contains sample client and server that is easily built and run using Maven.
The project demonstrates:
- The new Client API
- Request/Response
- The Invocation Object and the Command Pattern
- Build-in Entity Resolvers for Object Unmarshalling
- Server Resource
- Server Filter
- Spring Integration
- Content Negotiation with using default Entity Resolvers
Browse the jaxrs2-starter-kit
The starter kits implements a /books resource.
It uses the following rules in its RESTFul implementation:
For collections
Resource /books
@POST create a new book
@GET list all books
@PUT bulk update books
@DELETE delete all books
For single resources
Resources /books/{id}
@POST Error
@GET return a book
@PUT if exists, update book; if not ERROR
@DELETE delete a book
Thanks Paul. That was helpful.
ReplyDeleteJust one question, on writing those data object, like Book and Books.
Does that just have to be JavaBeans or we do some thing with MessageBodyReader/MessageBodyWriter or Jettison or Jackson??
Bipin,
ReplyDeleteThe data objects are POJOs. They get automatically serialized/de-serialized to JSON by the Jackson providers. The nice thing is that for the simple case, one needs not to do anything to configure it. Jackson contains the @Provider annotation so it gets automatically discovered. https://github.com/FasterXML/jackson-jaxrs-providers/blob/master/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java
I'm glad it was helpful.