Chapter 8. Data-Driven Web Applications
Up until this point, the examples in this book have largely been based on contrived scenarios to demonstrate usability. Now that you have an in-depth understanding of Ratpack’s execution model, and the insight to build robust web applications with Ratpack, we can discuss leveraging the framework to solve real-world problems. This chapter will show you how to model data and your data access layer for asynchronicity and high performance. Indeed, the discussion throughout this chapter will familiarize you with solutions to a problem space that you will face with nearly every web application that you build: working with databases and providing data as HTTP resources.
The Java ecosystem is rich with libraries and utilities to help you build comprehensive data-driven web applications. A conundrum for most asynchronous JVM web frameworks, however, is that the large majority of these libraries are built on synchronous APIs such as JDBC. Luckily, with Ratpack, this does not mean that you cannot still use those libraries to build your data access objects and service layers. The execution model’s ability to seamlessly schedule synchronous, I/O-bound work to the blocking thread pool makes it the perfect foundation for working with database libraries with which you are likely already familiar. Furthermore, when the database call returns, processing is returned to the request-taking thread, affording your application optimum performance when working with ...
Get Learning Ratpack now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.