RESTful Web Service Implementation with RESTEasy

0
178
2 min read

Getting the tools

If you have already downloaded and installed Java’s JDK and the Tomcat web server, you only need to download the JBoss’s RESTEasy framework. Nevertheless, the complete list of the software needed for this article is as follows:

Software

Web Location

Java JDK

http://java.sun.com/

Apache Tomcat

http://tomcat.apache.org/download-60.cgi

Db4o

http://developer.db4o.com/files/default.aspx

RESTEasy Framework

http://www.jboss.org/resteasy/

Install the latest Java JDK along with the latest version of Tomcat, if you haven’t done so. Download and install Db4o and RESTEasy. Remember the location of the installs, as we’ll need the libraries to deploy with the web application.

RESTEasy — a JAX-RS implementation

  RESTEasy is a full open source implementation of the JAX-RS specification. This framework works within any Java Servlet container, but because it’s developed by JBoss, it offers extra features that are not part of the JAX-RS requirements. For example, RESTEasy offers out-of-the-box Atom support and also offers seamless integration with the EJB container portion of JBoss (none of these features are explored here).

Web service architecture

By now, you should be familiar with the coding pattern. Because we want to reuse a large portion of code already written, we have separate layers of abstraction. In this article, therefore, we only talk about the web layer and study in detail how to implement a full RESTful web service using RESTEasy.

The full architecture of our web service looks as follows:

RESTful Web Service Implementation with RESTEasy

In this diagram, we depict clients making HTTP requests to our web service. Each request comes to the web container, which then delegates the request to our RESTful layer that is composed of RESTEasy resource classes. The actual serialization of user and message records is delegated to our business layer, which in turns talks directly to our database layer (a Db4o database).

Again, RESTEasy is a platform independent framework and works within any Servlet container. For this article we deploy our web service in Tomcat, as we’ve been working with it so far and are now familiar with deploying web applications to it, though we could as easily use the JBoss web container.

LEAVE A REPLY

Please enter your comment!
Please enter your name here