If you have some basic idea about pojo classes in java,
then it will be beneficial to get good understanding. So I’ve a simple example
that will give idea about pojo classes. Let see it first.
POJO is a Pure Old Java object that will not be bound by any
restriction other than those forced by the Java Language Specification.
Properties of POJO
classes are defined as below:-
1.
Each property must be
public setter and getter methods.
2.
All instance variables
within should be private.
3.
There should not extend
pre-specified classes.
4.
There should not implement
pre-specified interfaces.
5.
There should not
contain pre-specified annotations.
6. There must not have any argument constructors
in the class.
Simple Example is as below:-
public class User
{
//instance variables should be private
private String userid;
//public setter and getter methods
public String getUserid() {
return userid;
}
public void setUserid(String
userid) {
this.userid = userid;
}
//not have any argument constructors
public User()
{
}
}
Thus, any one will
now get good understanding to continue learning about Root resource classes.
So, Root
resource classes are POJOs. There are many
ways to use with annotations like it can be either annotated with @Path or have at least one method annotated
with @Path or a request
method designator.
A request method designator is nothing but HTTP methods, which are most commonly used in a REST based architecture.
They are annotated as @GET, @PUT, @POST,
or @DELETE.
Resource methods are methods of a resource class annotated with a request
method designator.
We have
to first understand in this session, how
to use JAX-RS to annotate Java classes to create RESTful web services.