Monday, August 25, 2014

RESTful Java Part3: Basic terminologies on RESTful Java

Introduction:
The purpose of this article is to explain about the basic terminologies on JAX-RS / RESTful Java. Here we can understand how all the small pieces are playing its role

High Level Diagram:
image
Next we will go through the details about each component and its role in the whole REST world...

Resource:
  • Base resources and sub-resources can be annotated with @Path.
  • @Path represents the actual end-point for REST resources.
  • Only public methods can be exposed as resource end-points.
image

HTTP Methods:
  • GET
  • POST
  • PUT
  • DELETE
  • HEAD and OPTIONS (special cases)
Parameters:
  • PathParam
  • Extracts the values from the resource path. For example when a resource path is mentioned like, @Path("users/{id}"), the value of id will be passed along with the path. This will be accessed using @PathParam inside the method.
  • QueryParam
  • Extracts the values passed along with the query string. 
  • Example: http://<host_name>:<port>/users?response=json. Here "response" will be treated as a query parameter and will be accessed like @QueryParam inside the method
  • FormParam
  • Kind of special parameters. When a html form is submitted to the resource, all the form values will be available through @FormParam
  • MatrixParam
  • Just a key-value pair of parameters available through the resource end-point. This will extracts the path parameters
  • HeaderParam
  • The values passed through the HTTP headers will be available through @HeaderParam
  • Context
  • This indicates about the values available from client to server. For example UriInfo and HttpHeaders and some of the servlet information can be accessible through @Context annotations
  • CookieParam
  • Client cookie related variables can be accessed through @CookieParam annotations
Consumes:
Mentioned by the client what kind of data the server will accept (Exact match of the request content-type will be decided at the run-time based on the priority. We will see this in detail in the coming series)
Produces:
Based on the @produces value, the server will send the output packets to the client.

I hope this article has given you high level understanding on each terminologies mentioned by JAX-RS specification. HTTP Methods will be covered in details in separate article.
Thanks for your valuable time. We will meet again in few days... Don't forget to put your comments below if any...

No comments:

Post a Comment