I'm new to creating web services in Java, thus the question.
I have an object,
public class Course {
private int _id;
private String _name;
private Person _person;
}
I have data about the object stored in a file, which I've already parsed and stored in a local array list.
My DataService object does this.
public DataService(){
_personList = new ArrayList<>();
_courseList = new ArrayList<>();
//logic to parse data and read into a QueryHandler object.
_handler = new QueryHandler(_personList, _courseList);
}
Now this data service has a GET method which displays the list of all courses.
@GET
@Produces("application/JSON")
public ArrayList<Course> getAllCourses(){
return _handler.getAllCourses();
}
My question is how do I expose this method as an endpoint, so that the caller can get a link like example.com/getAllCourses or something like example.com/getCourseById/21(method already created) which will return the data in JSON format ?