SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The Basics
Philip Langer
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJava EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSF
Jiayun Zhou
 

Was ist angesagt? (20)

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

Andere mochten auch

Play framework - Human Talks Grenoble - 12.02.2013
Play framework - Human Talks Grenoble - 12.02.2013Play framework - Human Talks Grenoble - 12.02.2013
Play framework - Human Talks Grenoble - 12.02.2013
Xavier NOPRE
 
Enib cours c.a.i. web - séance #5 : scala play! framework
Enib   cours c.a.i. web - séance #5 : scala play! frameworkEnib   cours c.a.i. web - séance #5 : scala play! framework
Enib cours c.a.i. web - séance #5 : scala play! framework
Horacio Gonzalez
 
O uso de frameworks em aplicações desktop baseadas na metodologia de desenvol...
O uso de frameworks em aplicações desktop baseadas na metodologia de desenvol...O uso de frameworks em aplicações desktop baseadas na metodologia de desenvol...
O uso de frameworks em aplicações desktop baseadas na metodologia de desenvol...
Rogério Batista
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
Mert Çalışkan
 
Play framework: lessons learned
Play framework: lessons learnedPlay framework: lessons learned
Play framework: lessons learned
Peter Hilton
 
Play Framework
Play FrameworkPlay Framework
Play Framework
Armaklan
 

Andere mochten auch (14)

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

Ähnlich wie Web application development using Play Framework (with Java)

Playframework + Twitter Bootstrap
Playframework + Twitter BootstrapPlayframework + Twitter Bootstrap
Playframework + Twitter Bootstrap
Kevingo Tsai
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
vstorm83
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Murugesh33
 

Ähnlich wie Web application development using Play Framework (with Java) (20)

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

Kürzlich hochgeladen

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Kürzlich hochgeladen (20)

WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 

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