SlideShare a Scribd company logo
Web application development using Play
Framework (with Java)
Tehran JUG meeting February-2015
By: Saeed Zarinfam
History
 Play 1 Created By Guillaume Bort at Zengularity SA
in 2007
 Play 2 release in 2012 by Typesafe (rewrite using
Scala)
 Play 1 vs Play 2
 Part of Typesafe Activator
Introduction
• Inspired by Ruby on Rails and Django
• Run on JVM (use java library)
• MVC
• Stateless
• Hot code reloading (in development)
• Convention over configuration
• Lightweight
• Asynchronous and Non-blocking I/O
• Java 8 support
Architecture
• MVC architecture
• Netty as web server (no servlet container)
• Sbt as build tools (Ivy dependency manager)
• Stateless
Requirements
 Install Typesafe Activator (or sbt)

JDK 6 or later

activator new my-first-app play-java
 Open project in IDE (Eclipse and Intellij)

Run using
– command line (activator run)
– Activator console (activator)
– Activator UI (activator ui)
– Interactive Console (Only in Scala)
Activator UI
Project structure
• App
• Public
• Conf
• build.sbt
• Scala and Java
• ...
Route
• Scala syntax
• Optional parameters
• Reverse routing
• REST friendly
Controller
• Actions return Result
• Static method
• Use dependency injection (JSR 330 in Play 3)
• HTTP manipulation (body parsers)
– REST service (JSON and XML)
View
 Type safe template engine
 Scala Template (Twirl inspired by ASP.NET
Razor)
 Http form handling
Session
 Session data are not stored in the server
 Session data added to each subsequent HTTP
Request, using Cookie.
 Cookie are signed with a secret key so the
client can’t modify the cookie data or it will be
invalidated
 Use cache for sever side session data
Assets
 Public Assets
 WebJars
 Assets controller
 Etag

Gzip
 Caching
 Managed Assets
 CoffeeScript
 LESS CSS

Sbt-web plugins

js-engine plugin (able to execute plugins written to the Node API either
within the JVM via the excellent Trireme)
Hot code reloading (in
development)
 It is possible because Play is stateless and tightly integration between Play and sbt
 Classloader hierarchy manage by sbt

Tricky (You don't need JRebel)
 For each request reloader check if there's any code changes
 Compile changed codes
 remove the old application classloader
 create a new application classloader with the updated classes.
 restart application (only application, no need to restart the JVM)
Accessing Database
 JDBC
 JPA (2.0)
 Ebeans (default ORM)
 Database evolutions
 Connection Pool
 Transaction
 In-memory H2 database
Asynchronous
 Actions are asynchronous by default
 Each open connection does not need a thread
 application code should avoid blocking in
controllers
Other APIs

Integration with Akka

WebSockets and Comet sockets

Cache API

Internationalization

Interceptors

Filters(only in Scala)

JSON API (jackson)

XML API

Job scheduling (Using Akka)

Logging API (Logback)
Testing

Ready to use application stubs for test (several helper methods)

Junit

FEST assertions

Mock

Test every part of your application (router, action, controller and ...)

Testing with a browser using FluentLenium ( Selenium WebDriver
wrapper)
Plugins
 Several plugins
– Mail
– Open ID
– CRUD
– Security
Deployment
 Compile all class and assets in application
 Activator start
 Activator stage (without any dependency on Play)
 Activator dist (produces a ZIP file without any
dependency on Play)
 SBT Native Packager plugin(activator universal:package-
bin)
– MSI, OS X disk image, RPM, DEB and …
 Publishing to a Maven (or Ivy) repository
Scaleability
 Scale horizontally easily (using load balancer)
 Integrate with Akka clustring and remoting
features
 Asynchronous from bottom to top
Reactive

Play Iteratee library (Scala Library)

ReactiveMongo
Non-blocking
 ReturnPromise<Result>Promise<Result>
 Intensive computation will just be run on another thread
(thread pool in separate execution context ).
 The web client will be blocked while waiting for the
response, but nothing will be blocked on the server
‫تشکر‬
zarinfam.s@gmail.com
http://javabyab.com

More Related Content

PPTX
Play! Framework for JavaEE Developers
PDF
Play Framework and Activator
PDF
Play Framework workshop: full stack java web app
PDF
Using Play Framework 2 in production
PPT
Play framework
PDF
Play framework productivity formula
PPT
Introduction to Play Framework
PDF
Introduction in the play framework
Play! Framework for JavaEE Developers
Play Framework and Activator
Play Framework workshop: full stack java web app
Using Play Framework 2 in production
Play framework
Play framework productivity formula
Introduction to Play Framework
Introduction in the play framework

What's hot (20)

PDF
Play framework
PDF
Play Framework: The Basics
PPTX
Designing a play framework application
PDF
Play Framework 2.5
PPTX
Why Play Framework is fast
PPTX
Node.js Development with Apache NetBeans
PDF
Scala and Play with Gradle
PPTX
Faster Java EE Builds with Gradle
PPTX
Preparing for java 9 modules upload
PDF
Developing Modern Java Web Applications with Java EE 7 and AngularJS
PDF
Node.js vs Play Framework
PPTX
Getting Started with Java EE 7
PPTX
Spring boot Introduction
PPTX
Full stack development with node and NoSQL - All Things Open - October 2017
PDF
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
PDF
Introduction to Spring Boot
PDF
Java EE 6 CDI Integrates with Spring & JSF
PDF
[143]Inside fuse deview 2016
PPTX
Angular beans
PDF
Play vs Grails Smackdown - Devoxx France 2013
Play framework
Play Framework: The Basics
Designing a play framework application
Play Framework 2.5
Why Play Framework is fast
Node.js Development with Apache NetBeans
Scala and Play with Gradle
Faster Java EE Builds with Gradle
Preparing for java 9 modules upload
Developing Modern Java Web Applications with Java EE 7 and AngularJS
Node.js vs Play Framework
Getting Started with Java EE 7
Spring boot Introduction
Full stack development with node and NoSQL - All Things Open - October 2017
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Introduction to Spring Boot
Java EE 6 CDI Integrates with Spring & JSF
[143]Inside fuse deview 2016
Angular beans
Play vs Grails Smackdown - Devoxx France 2013
Ad

Viewers also liked (14)

PDF
Play Framework: async I/O with Java and Scala
PDF
Formation Play! framework
PDF
Introduction à Play Framework 2
PDF
Play framework - Human Talks Grenoble - 12.02.2013
PDF
Enib cours c.a.i. web - séance #5 : scala play! framework
PDF
O uso de frameworks em aplicações desktop baseadas na metodologia de desenvol...
PDF
Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
KEY
Enterprise Java Web Application Frameworks Sample Stack Implementation
PPTX
Real World Enterprise Reactive Programming using Vert.x
PDF
Play framework: lessons learned
PDF
Comparing JVM Web Frameworks - February 2014
PDF
DDS on the Web: Quick Recipes for Real-Time Web Applications
PPTX
Play Framework
PPT
Play : Premiers pas par l'exemple le 120613
Play Framework: async I/O with Java and Scala
Formation Play! framework
Introduction à Play Framework 2
Play framework - Human Talks Grenoble - 12.02.2013
Enib cours c.a.i. web - séance #5 : scala play! framework
O uso de frameworks em aplicações desktop baseadas na metodologia de desenvol...
Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
Enterprise Java Web Application Frameworks Sample Stack Implementation
Real World Enterprise Reactive Programming using Vert.x
Play framework: lessons learned
Comparing JVM Web Frameworks - February 2014
DDS on the Web: Quick Recipes for Real-Time Web Applications
Play Framework
Play : Premiers pas par l'exemple le 120613
Ad

Similar to Web application development using Play Framework (with Java) (20)

PDF
Java Programming - 01 intro to java
PPTX
Playframework + Twitter Bootstrap
PDF
Spring Boot 3 And Beyond
PPT
01 java intro
PDF
Java EE 6 workshop at Dallas Tech Fest 2011
PDF
The Java alternative to Javascript
PDF
AMIS Oracle OpenWorld 2013 Review Part 3 - Fusion Middleware
ODP
GlassFish and JavaEE, Today and Future
PDF
JCConf 2018 - Retrospect and Prospect of Java
PPTX
It pro dev_birbilis_20101127_en
PPS
Web Component Development with Servlet and JSP Technologies Unit 01
PPTX
Programming in HTML5 With Java Script and CSS3
PPTX
java slides
ODP
eXo Platform SEA - Play Framework Introduction
PPTX
Advance java prasentation
PPT
Object Oriented Programming-JAVA
PPTX
JAVAPart1_BasicIntroduction.pptx
PPTX
JAVA_Day1_BasicIntroduction.pptx
PDF
Spring Update | July 2023
PDF
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Java Programming - 01 intro to java
Playframework + Twitter Bootstrap
Spring Boot 3 And Beyond
01 java intro
Java EE 6 workshop at Dallas Tech Fest 2011
The Java alternative to Javascript
AMIS Oracle OpenWorld 2013 Review Part 3 - Fusion Middleware
GlassFish and JavaEE, Today and Future
JCConf 2018 - Retrospect and Prospect of Java
It pro dev_birbilis_20101127_en
Web Component Development with Servlet and JSP Technologies Unit 01
Programming in HTML5 With Java Script and CSS3
java slides
eXo Platform SEA - Play Framework Introduction
Advance java prasentation
Object Oriented Programming-JAVA
JAVAPart1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Spring Update | July 2023
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3

Recently uploaded (20)

PDF
Best Practices for Rolling Out Competency Management Software.pdf
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
Transform Your Business with a Software ERP System
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
A REACT POMODORO TIMER WEB APPLICATION.pdf
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
How to Confidently Manage Project Budgets
PDF
Build Multi-agent using Agent Development Kit
DOCX
The Five Best AI Cover Tools in 2025.docx
PDF
Digital Strategies for Manufacturing Companies
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PDF
Become an Agentblazer Champion Challenge Kickoff
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Best Practices for Rolling Out Competency Management Software.pdf
Online Work Permit System for Fast Permit Processing
Transform Your Business with a Software ERP System
How Creative Agencies Leverage Project Management Software.pdf
A REACT POMODORO TIMER WEB APPLICATION.pdf
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
How to Confidently Manage Project Budgets
Build Multi-agent using Agent Development Kit
The Five Best AI Cover Tools in 2025.docx
Digital Strategies for Manufacturing Companies
Softaken Excel to vCard Converter Software.pdf
Materi-Enum-and-Record-Data-Type (1).pptx
Become an Agentblazer Champion Challenge Kickoff
How to Migrate SBCGlobal Email to Yahoo Easily
2025 Textile ERP Trends: SAP, Odoo & Oracle
Upgrade and Innovation Strategies for SAP ERP Customers
PTS Company Brochure 2025 (1).pdf.......
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
L1 - Introduction to python Backend.pptx
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...

Web application development using Play Framework (with Java)

  • 1. Web application development using Play Framework (with Java) Tehran JUG meeting February-2015 By: Saeed Zarinfam
  • 2. History  Play 1 Created By Guillaume Bort at Zengularity SA in 2007  Play 2 release in 2012 by Typesafe (rewrite using Scala)  Play 1 vs Play 2  Part of Typesafe Activator
  • 3. Introduction • Inspired by Ruby on Rails and Django • Run on JVM (use java library) • MVC • Stateless • Hot code reloading (in development) • Convention over configuration • Lightweight • Asynchronous and Non-blocking I/O • Java 8 support
  • 4. Architecture • MVC architecture • Netty as web server (no servlet container) • Sbt as build tools (Ivy dependency manager) • Stateless
  • 5. Requirements  Install Typesafe Activator (or sbt)  JDK 6 or later  activator new my-first-app play-java  Open project in IDE (Eclipse and Intellij)  Run using – command line (activator run) – Activator console (activator) – Activator UI (activator ui) – Interactive Console (Only in Scala)
  • 7. Project structure • App • Public • Conf • build.sbt • Scala and Java • ...
  • 8. Route • Scala syntax • Optional parameters • Reverse routing • REST friendly
  • 9. Controller • Actions return Result • Static method • Use dependency injection (JSR 330 in Play 3) • HTTP manipulation (body parsers) – REST service (JSON and XML)
  • 10. View  Type safe template engine  Scala Template (Twirl inspired by ASP.NET Razor)  Http form handling
  • 11. Session  Session data are not stored in the server  Session data added to each subsequent HTTP Request, using Cookie.  Cookie are signed with a secret key so the client can’t modify the cookie data or it will be invalidated  Use cache for sever side session data
  • 12. Assets  Public Assets  WebJars  Assets controller  Etag  Gzip  Caching  Managed Assets  CoffeeScript  LESS CSS  Sbt-web plugins  js-engine plugin (able to execute plugins written to the Node API either within the JVM via the excellent Trireme)
  • 13. Hot code reloading (in development)  It is possible because Play is stateless and tightly integration between Play and sbt  Classloader hierarchy manage by sbt  Tricky (You don't need JRebel)  For each request reloader check if there's any code changes  Compile changed codes  remove the old application classloader  create a new application classloader with the updated classes.  restart application (only application, no need to restart the JVM)
  • 14. Accessing Database  JDBC  JPA (2.0)  Ebeans (default ORM)  Database evolutions  Connection Pool  Transaction  In-memory H2 database
  • 15. Asynchronous  Actions are asynchronous by default  Each open connection does not need a thread  application code should avoid blocking in controllers
  • 16. Other APIs  Integration with Akka  WebSockets and Comet sockets  Cache API  Internationalization  Interceptors  Filters(only in Scala)  JSON API (jackson)  XML API  Job scheduling (Using Akka)  Logging API (Logback)
  • 17. Testing  Ready to use application stubs for test (several helper methods)  Junit  FEST assertions  Mock  Test every part of your application (router, action, controller and ...)  Testing with a browser using FluentLenium ( Selenium WebDriver wrapper)
  • 18. Plugins  Several plugins – Mail – Open ID – CRUD – Security
  • 19. Deployment  Compile all class and assets in application  Activator start  Activator stage (without any dependency on Play)  Activator dist (produces a ZIP file without any dependency on Play)  SBT Native Packager plugin(activator universal:package- bin) – MSI, OS X disk image, RPM, DEB and …  Publishing to a Maven (or Ivy) repository
  • 20. Scaleability  Scale horizontally easily (using load balancer)  Integrate with Akka clustring and remoting features  Asynchronous from bottom to top
  • 21. Reactive  Play Iteratee library (Scala Library)  ReactiveMongo
  • 22. Non-blocking  ReturnPromise<Result>Promise<Result>  Intensive computation will just be run on another thread (thread pool in separate execution context ).  The web client will be blocked while waiting for the response, but nothing will be blocked on the server