
Full Answer
REST
REST (Representational State Transfer) is a architectural pattern with set of rules to be used for creating web services, and web services which follows these rules are called RESTful web services.
RESTful web services in Java
We can create RESTful web services in java by using JAX-RS, Spring or we can write our own servlets which expose required HTTP methods.
JAX-RS
JAX-RS is nothing but a specification or a contract in form of interfaces and annotations which can be used to create RESTful web services.
JAX-RS implementations
So I just have to annotation my java class with these annotation and it will be expose as web service ?
Conclusion
So JAX-RS is a specification which provides syntax and semantics of annotations which helps to expose RESTful web services and does not contain any logic to expose api, for the actual logic like decoding the request, parsing request details like performing marshaling and un-marshaling of received content, and executing java method mapped with annotation you need to select JAX-RS implementation..
What is URI path template?
URI path templates are URIs with variables embedded within the URI syntax. These variables are substituted at runtime in order for a resource to respond to a request based on the substituted URI. Variables are denoted by curly braces. For example, look at the following @Path annotation:
What is @path annotation?
The @Path annotation's value is a relative URI path. In the example above, the Java class will be hosted at the URI path /helloworld. This is an extremely simple use of the @Path annotation. What makes JAX-RS so useful is that you can embed variables in the URIs.
What is resource method?
Resource methods are methods of a resource class annotated with a resource method designator (resource method designator annotation such as @GET , @PUT , @POST , @DELETE ).
What is root resource class?
Root resource classes are POJOs (Plain Old Java Objects) that are annotated with @Path have at least one method annotated with @Path or a resource method designator annotation such as @GET , @PUT , @POST , @DELETE.
What is the post HTTP method?
The POST HTTP method is commonly used to create a resource. This example code persists the new book object in the database.
What is the generic entity wrapper used for?
Note that the GenericEntity wrapper is used to maintain the generic type of the List as Book.
Where is the resource ID passed?
Usually, the resource or its id is passed to the resource method parameter from the URI variable as you can see in this example.
