Learn Java for Web Development

(Tina Meador) #1
355

Chapter 8


Play with Java and Scala


Oh, throw away the worser part of it. And live the purer with the other half.

—William Shakespeare

Java EE continues to evolve in a, sort of, benign continuum. Inspired by frameworks such as Spring,
Java EE introduced features such as annotations and dependency injection to address complex
tasks like transactions and database connectivity. Java EE 7, the latest edition as of this writing,
further reinforces the advancements in the Java Persistence API (JPA) and JAX-RS for REST-based
web services, to name just a few. Most of the complexity involved with Java web development will
continue to be addressed, in many ways, by commercial or open web frameworks’ innovations.


However, the Play 2 web framework meanders off the beaten track. Play 2 is not Java EE–centric
and is not constrained by Java EE. It is part of the Typesafe stack that provides an alternative to the
Java EE stack. Typesafe redefines the layers of modern Java applications formerly defined by
Java EE, and in this new demarcation Play constitutes the web layer.


Play is an open source web application framework, written in Scala and Java, and provides
out-of-the-box support for the modern Web. Play was built for the needs of modern web and
mobile applications, leveraging technologies such as REST, JSON, and Web Sockets, among
others.


Play targets the JVM and focuses on enhancing developer productivity by providing features such
as convention over configuration, hot code reloading, and errors in the browser. Play implements
the MVC architecture by means of a route file that maps HTTP requests to controllers and view
templates that represent the result. Play 2 builds upon the functional paradigm by providing native
support for the Scala programming language and provides an adapted Java-specific API that
formulates a highly reactive web framework.

Free download pdf