Software developers demanding resource based, RESTful APIs
Software developers are demanding APIs that are delivered in a RESTful, resource based way, and one way to do that is by building with the RESTlet framework.
Well seasoned enterprise architects know that there is no silver bullet when it comes to application integration,...
Continue Reading This Article
Enjoy this article as well as all of our content, including E-Guides, news, tips and more.
and no single middleware solution will ever meet every integration requirement criteria to the tee, but when it comes to modularization and web service development, a REST based approach is becoming more and more popular. REST may not be the best approach for every situation, but it does have enough virtues to put it on the short list for any organizations that is comparing the various different approaches to developing web service, creating OSGi components and deploying micro-services . And the fact is, a REST based approach can be effective in even the most challenging corner-cases, where other options like Java messaging or SOAP based web services run out of steam.
People always struggle to connect OSGi concepts with JAX-RS concepts.
Holger Staudacher, EclipseSource
The effective application of RESTful techniques
One of the key strengths of REST is its simplicity, but that simplicity sometimes raises objections from developers who question whether such a simple approach to application integration can deal with the complex challenges enterprises must deal with on a daily basis. For example, software architects often question the veracity of REST when it comes to handling complex, real world, transactional systems that involve coordinating multiple resources whose interactions need to be synchronized. Jerome Louvel (@jlouvel), coauthor of Restlet in Action and the creator of the Restlet framework, addresses the topic of transactional, e-commerce systems by framing it as a simple use case with a straightforward solution. For example, to make a traditionally developed online shopping application into a RESTful experience, an architect simply needs to break down the associated business transactions into all of their underlying components.
In a transactional, online e-commerce type of system, people need to be able to browse products, select products, view and edit their cart, enter payment and shipping information and then make a final decision to pay. At any point up to the point where the user completes their checkout, users need to be able to navigate back to a previous step. From a pure API standpoint, this means mapping all the important parts of the transaction into resources via URIs. At the end, the transaction is completed by sending a final HTTP request that coordinates the state of each of the resources involved in the transaction.“It’s just viewing your transaction as a set of one or multiple resources depending on the complexity of your business processes. Technically, nothing prevents you from doing that. It’s just not trying to map what you’re used to doing with RPC or putting too much context in one request,” says Louvel.
Of course, a RESTful approach to software design is only one piece of the puzzle when it comes to creating integration middleware that will tie together back-end services with mobile applications, browser based web sites and even embedded systems. Creating application integration middleware also means creating modular and reusable components, with the most proven approache for achieving these goals being the creation of micro-services using OSGi. Unfortunately, the manner in which JAX-RS, REST based applications connect with OSGi based components hasn't always been clear. "People always struggle to connect OSGi concepts with JAX-RS concepts," said Holger Staudacher, a software developer and consultant at EclipseSource. However, the integration path between RESTful web services and modular, OSGi components has become increasingly more clear through projects such the OSGi JSX-RS connector. These software tools help fill in the gaps, simplify the development of REST based micro-services, and make modularity easier to achieve by integrating OSGi with REST based, JAX-RS frameworks such as Jersey and Wink. "We provide the glue" said Staudacher about the various software projects that help simplify the development of application that use REST and OSGi. Needless to say, using a REST based approach for developing a distributed architecture effectively becomes a whole lot easier when there is a proven and effective structure within which applications can be built.
Easing into a resource based approach to APIs
A RESTful approach to software development can greatly simplify the task of application integration, but this new approach can often cause troubles for those with more of a legacy background in distributed computing. That’s when developers finds themselves creating more problems than they fix. Louvel’s advice is not to take the usual, traditional approach when developing RESTful APIs. Forget what you learned from the service-oriented, RPC based world. Then, you’ll discover that you are working without limitations and you can really start to solve your business problems. Furthermore, the modularity involved in developing a RESTful architecture means developers have smaller, more agile parts that provide greater flexibility when designing solutions that really work.
The main takeaway Louvel has for Java developers is this: apply as many principle from the tenants of RESTful development and design as possible, but at the same time, use only as much as is needed. See everything as a resource. Use calls from the HTTP protocol, especially GETs, PUTs, POSTs and DELETEs to effectively create and update your resources. Eventually, approaching the problem domain in a RESTful manner becomes second hand. By applying these foundational concepts, developers get a lot of built-in features that are common to the world-wide-web such as caching and automatic compression for free. And once the development team has got the basics down, kick it up a notch and try to see every problem as having a RESTful solution.
Have you found the RESTlet framework to be helpful in the development of RESTful web services? Let us know what you think.
RESTlet in Action by Jerome Louvel
Hadoop in Action By Chuck Lam
NoSQL Distilled By Martin Fowler
MongoDB: The Definitive Guide By Michael Dirolf
MongoDB in Action By Kyle Banker
Taming The Big Data Tidal Wave By Bill Franks
The Well-Grounded Java Developer By Martijn Verburg