Java Reference
In-Depth Information
think REST is neater. If the legacy interface is already exposed as a WSDL, that helps decide
the matter for you.
Finally, remember that you can write bad code in any language. You can create big, sloppy,
monster designs that paint you into a really expensive corner using any tool. Some might say,
“a fool with a tool is still a fool.” Use the right tool for the job. The best hammer in the world
doesn't help you if your problem isn't a nail.
Strides have been made to take the best ideas from both SOAP and REST and incorporate
them into the other. For example, WS-Addressing can be said to provide a unique URI for
SOAP operations in a manner similar to how REST URIs provide unique IDs to resources. If
you have both REST and SOAP in your toolbox, you can do what's best for your customer.
So let's get out of the middle of this touchy subject already and start looking at how to put
together REST applications in Java.
Restlet
In 2005, Jérôme Louvel founded the Restlet project, hosted at http://www.restlet.org . Louvel
needed to build a website and wanted to do so using the REST architectural style as much as
possible. But he noticed a lack of Java support for REST using the Servlet API, which led him
to develop his own.
The Restlet project is divided into two parts: the API, which provides utilities and a way to
register API implementations, and a reference implementation of that API. The reference im-
plementation is called Noelios, which includes connectors for clients of different protocols,
including HTTP, SMTP, and JDBC. The project allows you to work with multiple protocols
within a single API and forego the context switching required by JavaMail, Servlet, JDBC,
and so on as you work.
The primary aim of Restlet is to provide Java developers with a way to “think RESTfully”:
its core classes are named directly for the key concepts within REST, including resource, rep-
resentation, connector, and so on. The API is intended to bridge the impedance mismatch
between an object-oriented and a RESTful mode of development. However, if you want to
use the Restlet API within the context of a servlet container, there is a lightweight adapter that
allows you to do that.
JAX-RS
JSR 311 represents the Java API for RESTful Web Services. Like JAX-WS, JAX-RS uses an-
notations on POJOs (Plain Old Java Objects) to map to the RESTful style of presenting web
applications. For example, methods on classes that represent a resource use the @Path annota-
Search WWH ::




Custom Search