Java Reference
In-Depth Information
@Path("students")
@Stateless
@Produces({MediaType.APPLICATION_JSON})
public class StudentInformation {
@PersistenceContext(unitName =
"integrationPU")
private EntityManager em;
@GET
@Path("getListOfStudents")
public List<Student> getListOfStudents(){
TypedQuery<Student> query =
em.createQuery("SELECT s FROM Student s",
Student.class);
return query.getResultList();
}
} }
The latest improvements in action
JAX-RS 2.0 not only simplified the implementation of RESTful Web Services, but
also introduced new features in the API, among which we have client API, asyn-
chronous processing, filters, and interceptors.
The Client API
Since Version 1.0, the JAX-RS Specification did not define client APIs to interact with
a RESTful service. So, each implementation provided a proprietary API, which had
the effect of limiting the portability of applications. JAX-RS 2.0 fills this gap by provid-
ing a standard client API.
The following code demonstrates the implementation of a client that will access the
list of selected students through the REST service exposed in the preceding code:
String baseURI ="http://localhost:8080/
chapter06EISintegration-web";
Search WWH ::




Custom Search