Play Framework – An Introduction

The Play framework is a clean option to bloated Enterprise Java stacks. It concentrates on designers’ profit and targets tranquil architectures. Play  framework is an immaculate friendly for nimble programming improvement. The Play framework’s objective is to provide web applications improvement while staying with Java.

A Java framework without Pain

Play is an unadulterated Java framework and permits you to keep your favoured improvement on devices and libraries. On the off chance that you as of now utilize Java as an improvement stage you don’t have to switch to an alternate dialect, an alternate IDE and different libraries. Simply switch to a more beneficial Java environment.

Fix the bug and hit Reload

The Java stage is scandalous for its low benefit, primarily because of rehashed and repetitive order bundle send cycles. That is the reason we re-examined the advancement cycle to make creating with play an effective methodology.

HTTP to code mapping

In case you’re as of now utilizing an alternate Java Web framework like the Servlet API or the Struts framework, you have officially utilized a dynamic perspective of the HTTP convention with weird Java APIs and ideas. We think in an unexpected way. A Web application framework ought to provide for you full, direct get to HTTP and its ideas. This is a basic contrast in the middle of Play and other Java web application frameworks. HTTP, the Request/Response design, the REST compositional style, substance sort transaction, URI are all significant ideas for the play framework.

For example, tying a URI example to a Java call is only one line:

READ  Play Framework - Working on JSON
GET /customers/{id}  

On the off chance that AJAX, REST and overseeing again/forward development between site pages are a percentage of the issues you confront in your normal web advancement, simply try play out.

Full Stack Application Framework

The play framework was at first enlivened by our own particular Java applications. It has all the devices required to make a current web application:

  • Relational Database help through JDBC.
  • Object-Relational Mapping utilizing Hibernate (with the JPA API).
  • Integrated Cache help, with simple utilization of the dispersed memory stored framework if necessary.
  • Straightforward Web administrations utilization either in JSON or XML.
  • OpenId help for conveyed verification.
  • Image control API.

The particular construction modeling gives you a chance to join together a web application with numerous others. Because of  re-use  of modules, you can use your java code, templates and static assets, for example, Javascript and CSS records in a straightforward manner.

The request life cycle

The play structure is completely stateless and just Request/Response situated. All HTTP Requests take after the same way:

  • A HTTP Request is gotten by the structure.
  • The Router part tries to discover the most particular course ready to acknowledge this request. The comparing activity strategy is then summoned.
  • The application code is executed.
  • In the event that a complex view needs to be produced, a layout document is rendered.

The after-effect of the activity technique (HTTP Response code, Content) is then composed as a HTTP Response. This chart outlines the HTTP Request way:


The Standard Application Format

The format of a play application is standardized to keep things as straightforward as could be allowed.

READ  Play Framework - Integrating with Akka

(A) The application directory

This directory holds all executable antiquities: Java source code and perspectives layouts.

There are three standard bundles in the application directory, one for each one layer of the MVC structural example. You container obviously include your own particular bundles like for instance an utils packages.

Also, the perspectives bundle is further composed into sub-bundles:

  • Tags, has application labels, e.g. reusable bits of layouts.
  • One sees organizer for every Controller, by meeting layouts identified with every Controller are put away in their own particular sub-bundle.

(B) The open directory

Assets put away in general society directory are static possessions and are served straightforwardly by the Web server.

This directory is part into three standard sub-registries: for pictures, CSS templates and Javascript records. You ought to attempt to arrange your static holdings like this to keep all play applications predictable.

(C) The conf directory

The conf directory holds all arrangement documents for the application.

There are two obliged arrangements documents:

  • application.conf, the primary arrangement document for the application. It holds standard design alternatives.
  • routes, the courses definition document.