In this video, we are going to take a look at the state of RESTful web service development on the JVM platform to understand what options are available at the moment.
- [Voiceover] Hi, and welcome to the third and last video of this section. Here, we're going to to take a look at the state of RESTful web services development on the JVM platform and get a brief idea of the three key trends that drive the RESTful Web Services development in the Java ecosystem. We start off by taking an overview of the existing and upcoming Java specification requests, or JSRS, for the Java Enterprise Edition platform.
Then, we would escape from the Java universe, though only for a moment, and look at how other programming languages and frameworks inspired the RESTful web services development on JVM. Lastly, we will discuss how the latest movement to asynchronous and non-blocking programming models has affected the landscape of RESTful web services and API development, bringing even more options to the table.
The official Java process is known to be quite slow with respect to changes in the platform, and reacting to the latest industry trends. This explains why the 1.0 specification of Java API for RESTful web services, or simply JAX-RS, has been adopted only in 2008. Since then, the process has sped up, with the next major version, 2.0, being released in 2012.
The upcoming version, 2.1 of the specification, is a work in progress right now. The JAX-RS space is somewhat crowdy with at least four major players at the moment, Jersey, Rest Easy, Restlet, and Apache CXF. Mostly all of them implemented JAX-RS 2.0 specification, but also introduced their own features, and in most cases, non-portable extensions.
The Java ecosystem does not evolve in isolation, which is a very good thing. We as a community learn a lot from the successes or failures of other programming languages and frameworks. A couple of the most notable examples are Ruby on Rails and Django, since they inspired two very popular, full-fledged web application frameworks, Grails and Play. It's worth mentioning that although Grails and Play are often used to develop web sites and applications, they both provide excellent foundations for building RESTful web services and APIs, as well.
Traditionally, HTTP web requests from clients were handled on a one thread per request model. In essence, this means that for each client that invokes a RESTful web service or API end point, the server allocates a new thread that will serve the request up to the point when the response is sent back to the client. It is a simple model which has worked quite well in the past, however, this model has proven to be ineffective in addressing the scalability requirements of modern web services and APIs.
With thousands of requests hitting the server each minute or second, the one thread per request model led to quick exhaustion of the available resources. At this point, the search for scalable and efficient models turned the industry's attention towards asynchronous and non-blocking paradigms, which to some extent have affected the ways in which we build RESTful web services and APIs. We will see all these concepts in action while building our very first RESTful web service.
Let us take a look at the implementation based on event-driven loops and worker thread pulls, which is a norm these days. Conceptually, threads are still there, but the way they are being used is very different. The request and response processing are not tied to the same thread anymore. The niche of RESTful web services development on the JVM platform has really flourished in recent years. There are many micro and macro frameworks available out there, each one with its own pros and cons, so the choices are literally endless.
However, there are quite a few that are built with an emphasis on asynchronous and non-blocking programming models. They are being actively developed, have large communities, and are being used in production. Ratpack, Spring NVC, Vert X, and Spray, which is going to become a part of Akka project, namely Akka HTTP. Each of these frameworks is worthy of its own course, but in this one, we're going to focus on the Spray framework to be our foundation for building scalable, reliable, and powerful RESTful web services and APIs using Scala.
In this section, we got familiarized with REST architecture style and looked at the state of RESTful web services development on the JVM platform. We also brushed up on specifications and discussed a few modern programming models and frameworks. In the next section, we're going to switch our attention from RESTful web service development towards Actor model concepts and more focus on the Akka framework for the reference implementation.
Embark on an exciting journey into the universe of web development using the Scala programming language and frameworks—natural choices for back-end developers building highly scalable, reliable, and reactive RESTful web services and APIs. This training is the starting point for mastering the nonblocking and asynchronous programming models that lie in the heart of the Spray framework. It starts with an introduction to the REST architecture. Then switch gears to the Akka toolkit and framework, building a sample book catalog application along the way.
Once you've learned about the REST architectural style and Actor model—the foundations that the Spray framework is built upon—you'll shape out your own RESTful web services by providing simple route definitions. Further on in the course, author Andriy Redko delves into authentication and authorization, secure transport, documentation, testing, and caching support. Finally, you will learn how to develop the Spray client API to call external web services.
- The Actor model and Akka framework
- RESTful architecture principles and constraints
- Building RESTful services
- Core Spray framework modules such as spray-can, spray-routing, spray-json, spray-caching, and spray-client
- Securing RESTful web services and APIs with Spray
- Configuring Spray applications with HTTPS support
- Documenting Spray RESTful web services using Swagger
- Caching basics
- Calling external RESTful services