SlideShare a Scribd company logo
The High Velocity Web Framework
For Java and Scala
The High Velocity Web Framework
For Java and Scala
Myself
https://github.com/mkurz
Using Play since 2010 (v1.1)
Official collaborator (“integrator”)
since June 2015
Self-employed
You are a developer using
Java to build web services
Play Framework Introduction
F
O
R
G
E
T
E
V
E
R
Y
T
H
I
N
G
What is Play?
Full stack java web framework - Open Source!
Based on a non-blocking architecture
Lots of built in features for fast development
Written in Scala and Java
Extendable by modules
Play is developer friendly
Strong focus on productivity. Fast turnaround.
No (=very short) compile time and restart cycle
Hot reloading: Fix the bug and hit reload!
Play is developer friendly
Play is developer friendly
Type safe all the way, even templates and route files!
Use Scala or Java: Your choice. You can even mix them!
All Java 8 goodness (lambdas, streams, etc.)
Play is stateless
Lightweight, asynchronous
Share nothing system - no state on the server!
Uses a signed cookie to save “state” on the client
Concurrent and highly scalable
Play thread model
Play doesn’t tie a request to a thread
Play doesn’t tie a HTTP session to memory
Play is non-blocking
Per default Play just uses only handful threads (1 per CPU + 1)
Event driven (netty/akka) - Thread is only occupied if there is something to do
http://www.reactivemanifesto.org
Play is full stack
Template engine (called “twirl”, a bit of scala syntax but not too bad)
Websocket support
Create REST APIs
JSON support
assets compiler (CoffeScript, LESS, SASS, TypeScript,...) -> assets pipeline
No servlet support -> Built on netty / akka(-http)
Play is full stack
Form handling (extracting data, validation, formatting, file uploads,...)
Persistence: JPA, Ebean, JOOQ, ...
Plus: filters, i18n, WS support, and much more
Secure
Write JUnit and integration tests
History
Started as internal project by a french company, written in pure Java
Play 1.0 in October 2009
Play 1.2 in April 2011
Play 2 is completely rewritten from scratch, mainly in Scala
Released in March 2012
2007
2012
Backed by Lightbend, Inc.
Backed by Lightbend, Inc.
A couple of full-time devs working on it
$$$ Commercial support available $$$
Today
Latest version:
New major version coming soon:
Awesome!
Who uses Play Framework?
What about community?
GitHub
Get involved via GitHub!
Very active mailing list - 14 000 members!
> 14 000 questions on Stack Overflow tagged [playframwork]
1 600 people joined the conversation already
That’s me!
Many high quality modules available (decentralised)
Big companies contribute
blogs about Play ;)
open sourced their whole website! (But in Scala)
Books
Great documentation with code snippets and migration guides
Let’s get started!
What do I need?
What do I need?
`sbt help`
Create a project
Create a project
Create a project
Create a project
Create a project
You can create your own seed projects.
They are just git repos.
Create a project
(Downloading all dependencies
can take a while on first run)
Play uses Ivy
Play uses Ivy
You can add repositories via build.sbt
Example projects available
Run the project
Run the project
Run the project
Run the project
Run the project
Open your browser
Lets make a change
Now, restart the server.
Nah, just kidding.
(We have real work to do)
Nah, just kidding.
(We have real work to do)
No restart
Required!
Hit F5
Opens JPDA debug port which you can attach to in the IDE
Debugging
Check the Play documentation how to set up the IDEs
IDE support
Eclipse
Eclipse
Play Application overview
routes
Before I continue...
Play is designed modular
It’s not opinionated
E.g. JPA is just one option
You can use Ebean ORM, jOOQ,...
You can enable just the stuff you need
The Play application layout
The Play application layout
project/plugins.sbt
project/plugins.sbt
The Play application layout
build.sbt
build.sbt
ehcache, javaWs, openId, guice, ...
The Play application layout
logback.xml -> Configure logging
conf/application.conf (Simple example)
(P/B)RO TIP!
Search for reference.conf
The Play application layout
conf/routes
conf/routes
Variable extraction (:id)
Dynamic parts spanning several / (path*)
Regular expressions ($name<[a-z]>.js)
conf/routes
route files get transformed into *.scala files.
scala files will be compiled into bytecode.
app/controllers/HomeController.java
app/views/customer.scala.html
app/views/customer.scala.html
We call another view: views/html/main.scala.html
app/views/customer.scala.html
view files get transformed into *.scala files.
scala files will be compiled into bytecode.
So views are just functions -> `@main` is a scala function
Various extensions supported
myview.scala.html -> views.html.myview.render(...)
myview.scala.js -> views.js.myview.render(...)
myview.scala.xml -> views.xml.myview.render(...)
myview.scala.txt -> views.txt.myview.render(...)
The Play application layout
The Play application layout
The Play application layout
The Play application layout
Track your db schema changes
Evolutions FTW
Up (create, insert,...) /Down (drop, delete,...) sections
Can be enabled/disabled per database
Interactive for DEV, command line in PROD mode
1.sql, 2.sql, 3.sql, etc.
conf/evolutions/default/1.sql
When you hit refresh
Form handling & DI
PetForm.java
petform.scala.html
petform.scala.html
Reverse route
Reverse routes
In views:
In controllers:
Even in JavaScript:
Handle the form in the action
(Comment after the talk:
This is a bad example because this
code would block because of db
access. The code should actually
run in another “threadpool”)
Play uses Dependency Injection
Dependency Injection in Play
guice is the default but replaceable
Just inject any components you need in the controller or the view
That’s how the module system in Play works
Dynamic forms
Displaying errors in views
Form helpers (@form.input(...) etc.) handle this for you already
Checkout “play-bootstrap” module on GitHub -> It’s awesome!
Asynchronous action
We don’t block when waiting for I/O
A few words on security
Session cookie is signed but not encrypted
Play 2.6: SameSite cookie attribute enabled for session cookie by default
Built-in filters can be used:
CORS, CSRFFilter (POST), SecurityHeadersFilter (CSP, ...), AllowedHostsFilter
Templates escape by default (XSS)
A few words on security
Authentication & authorization modules available:
deadbolt, SecureSocial, ...
Play security vulnerability mailing list
Let’s go into production
General notes for deploying
No servlet container or application server needed!
(Deploying into container is supported but not recommended - do not do it!)
HTTPS support built-in if needed
Usually you use a proxy like nginx in front anyway
General notes for deploying
During development you run Play in DEV mode
In production Play runs in PROD mode
Build native packages for different systems
● Universal zip, tar.gz, xz archives (run it via ./bin/my-web-app)
● deb and rpm packages for Debian/RHEL based systems
● dmg for OSX
● msi for Windows
● docker images!
Puts packages into
./target/universal/
Future of Play: v3.0
Maven, Gradle support as alternative (already available via 3rd party modules)
Merge Java/Scala APIs
Even more type safety
Completely remove global state, DI all the way (already possible in Play 2.6)
Roadmap & Play 3 Implementation Plan:
https://docs.google.com/document/d/11sVi1-REAIDFVHvwBrfRt1uXkBzROHQYgmcZNGJtDnA
https://docs.google.com/document/d/1OejviUX5TDlRVeKg1JD9L4qh2Tn21giItmyxRXCydN0
Questions? Get in touch!
m.kurz@irregular.at
https://github.com/mkurz
Questions? Get in touch!
m.kurz@irregular.at
https://github.com/mkurz

More Related Content

PPTX
java slides
PPSX
JAVA.ppsx java code java edv java development
PPTX
Programming in HTML5 With Java Script and CSS3
PPT
Django, What is it, Why is it cool?
PDF
Expanding XPages with Bootstrap Plugins for Ultimate Usability
PDF
Flutter vs Java Graphical User Interface Frameworks - text
ODP
eXo Platform SEA - Play Framework Introduction
PDF
005528214.pdf
java slides
JAVA.ppsx java code java edv java development
Programming in HTML5 With Java Script and CSS3
Django, What is it, Why is it cool?
Expanding XPages with Bootstrap Plugins for Ultimate Usability
Flutter vs Java Graphical User Interface Frameworks - text
eXo Platform SEA - Play Framework Introduction
005528214.pdf

Similar to Play Framework Introduction (20)

PPTX
whats-new-netbeans-ide-7x.pptx
PPTX
JAVA introduction and basic understanding.pptx
PPT
Play framework
PPTX
Silicon Valley Code Camp 2011: Play! as you REST
PDF
The Play Framework at LinkedIn: productivity and performance at scale - Jim B...
PDF
The Play Framework at LinkedIn
PDF
What’s New & Cool in NetBeans IDE 7.x
PDF
What's New in NetBeans IDE 7.x
PPTX
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
PDF
Janus Workshop @ ClueCon 2020
PDF
OSGi enRoute Unveiled - P Kriens
PPTX
Android developer's toolbox
PPT
Joomla Day Austin Part 4
PPTX
Spring MVC framework
ODP
NetBeans 6.5
DOCX
Project report for final year project
PPT
Introduction to Software Development
PDF
Developing FirefoxOS
PPTX
1.introduction to java
PDF
Gwt and JSR 269's Pluggable Annotation Processing API
whats-new-netbeans-ide-7x.pptx
JAVA introduction and basic understanding.pptx
Play framework
Silicon Valley Code Camp 2011: Play! as you REST
The Play Framework at LinkedIn: productivity and performance at scale - Jim B...
The Play Framework at LinkedIn
What’s New & Cool in NetBeans IDE 7.x
What's New in NetBeans IDE 7.x
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
Janus Workshop @ ClueCon 2020
OSGi enRoute Unveiled - P Kriens
Android developer's toolbox
Joomla Day Austin Part 4
Spring MVC framework
NetBeans 6.5
Project report for final year project
Introduction to Software Development
Developing FirefoxOS
1.introduction to java
Gwt and JSR 269's Pluggable Annotation Processing API
Ad

Recently uploaded (20)

PDF
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Complete Guide to Website Development in Malaysia for SMEs
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
assetexplorer- product-overview - presentation
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Digital Systems & Binary Numbers (comprehensive )
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
Oracle Fusion HCM Cloud Demo for Beginners
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Complete Guide to Website Development in Malaysia for SMEs
Monitoring Stack: Grafana, Loki & Promtail
AutoCAD Professional Crack 2025 With License Key
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Salesforce Agentforce AI Implementation.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Internet Downloader Manager (IDM) Crack 6.42 Build 41
17 Powerful Integrations Your Next-Gen MLM Software Needs
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
assetexplorer- product-overview - presentation
Reimagine Home Health with the Power of Agentic AI​
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
CHAPTER 2 - PM Management and IT Context
wealthsignaloriginal-com-DS-text-... (1).pdf
Digital Systems & Binary Numbers (comprehensive )
Ad

Play Framework Introduction