Sunday, October 15, 2017

Different implementation of RESTFUL webservices

The JAX-RS is a Java specification request (JSR 311 & JSR 339) which standardize development and deployment of RESTful web services using Java and JEE technologies. It provides API in Java Programming language to create web services according to the REST (Representational State Transfer) architectural pattern. Both Restlet and Jersey are two of the most popular implementation of JAX-RS used for developing RESTful web services in Java ecosystem but there are a couple of other implementation also exist e.g. Apache Wink, Apache CXF, and JBoss RESTEasy. In this article, I'll introduce with these RESTful web services framework in Java world. It's not a very detailed post about strength and weakness of each of the framework but will just give you enough to understand them in detail later.

It will also help you to answer the RESTful web service questions like, what is the difference between Restlet, Jersey, and Apache CFX? which one you have used in past, or which one will you choose for your next project and why?

Difference between JAX-RS, Restlet, Jersey, RESTEasy, and Apache CXF Frameworks

Jersey



Jersey RESTful Web Services framework is open source, production quality, a framework for developing RESTful Web Services in Java that provides support for JAX-RS APIs and serves as a JAX-RS (JSR 311 & JSR 339) reference Implementation and initially provided by Sun Microsystem.
Jersey framework is more than the JAX-RS Reference Implementation. Jersey provides its own API that extends the JAX-RS toolkit with additional features and utilities to further simplify RESTful service and client development. Jersey also exposes numerous extension SPIs so that developers may extend Jersey to best suit their needs.

Jersey also has some of the best tooling (IDE) support especially if you are using Netbeans. So you can achieve better productivity from the tooling perspective. There are some challenges with Jersey-Spring integration, especially with AOP.

The latest release of Jersey is 2.26


Restlet


One of the first open source framework for developing RESTful web services in Java. Restlet Framework helps Java developers build better web APIs that follow the REST architecture style. Restlet has a light core but thanks to its pluggable extension, it is also a comprehensive REST framework for Java. It supports all REST concepts (Resource, Representation, Connector, Component, etc.) and is suitable for both client and server Web applications.


It supports major Web standards like HTTP, SMTP, XML, JSON, OData, OAuth, RDF, RSS, WADL, and Atom.

Many extensions are also available to integrate with Servlet, Spring, Jetty, Simple, JAXB, JAX-RS, JiBX, Velocity, FreeMarker, XStream, Jackson, SLF4J, SDC and much more!

Special editions for Android, GWT, GAE, Java SE, Java EE, and OSGi are also available and kept synchronized with an automated porting process.

Another advantage of using Restlet framework is that Restlet based program can run as a standalone Java application. The Restlet also supports Java EE environment with the help of Jetty web container. So this may result in a light-weight implementation and have a unique value that way. There are some challenges or manual work involved in de-marshalling the response into java object. See Restlet in Action to learn more about the Restlet framework.


Apache CXF

The CXF is another free and open source web service framework and a JAX-RS implementation from Apache. CXF helps you to build and develop services using frontend programming APIs like JAX-RS and JAX-WS. These services can speak a variety of protocols such as SOAP, XML/HTTP, RESTful HTTP, or CORBA and work over a variety of transports such as HTTP, JMS, and JBI.

One of the key difference between Apache CXF and Jersy's JAX-RS implementation is that it is implemented as a CXF filter sitting behind the servlets, while Jersey and RestEasy are, servlet filters.

One more advantage of using ApacheCXF is that it makes it easy to produce both a JAX-RS and JAX-WS (SOAP) endpoint from the exact same data model and service interface at the same time. So if that is something which matters to you, this may be the way to go. CXF had issues with handling SSL and HTTP proxies which seem to have been addressed in recent releases.  You can also read Developing Web Services with Apache CXF and Axis2 to learn more about developing RESTful web services using Apache CXF framework in Java.



RESTEasy

The RESTEasy is another good JBoss project that provides various frameworks to help you build RESTful Web Services and RESTful Java applications. It is a fully certified and portable implementation of the JAX-RS specification.

RESTEasy may be a good choice if your environment is JBoss oriented e.g. you are using JBoss Application Server, Hibernate and RedHat Middleware, Linux etc. It also provides good integration with EJB 3.0 and SEAM (something to consider if you have a need for that). Also, it has a proprietary caching for URL or query which could be handy for high volume applications.


That's all about the difference between JAX-RS, Restlet, and Jersey in Java. In short, JAX-RS provides the API and these two are the implementation of that API, where Jersey serves as reference implementation but Restlet has got bigger and more matured community around it.

All of these are also mature and production ready frameworks. Chances of going wrong with any of them are quite less. They all have integration capabilities with Spring.  So You can use either Restlet, Jersey or any other framework to develop RESTful web services in Java.


Happy Reading...

Click here to installl Flipkart App

1 comment:

  1. Could you please tell me the correct example for each types of web servives

    ReplyDelete

Java garbage collection

In this post , we ’ ll take a look at how garbage collection works , why it ’ s important in Java , and how it works in...