2 Java
@basav
Agenda
• Introduction to Play 2 Java framework
• Live Coding
• Deployment to Cloud
• QA
Who am I?
Software Architect
Entrepreneur
Web 2.0 JavaScript
WE ARE STARTING A NEW
PROJECT !YAY!
I AM READY TO CODE IT UP!!
STACK? What about POLYGLOT?
DILEMMA !!!
SON !! TRUST ME!

JAVA IS THE SAFE CHOICE!
Many come back (think
Twitter)
But there is a curse…
The risk of dying - waiting for server
start, complex tooling, redeployment,
maintaining XML, HTTPSession ..etc
CAN YOU HAVE YOUR CAKE AND
EAT IT TOO?
YES !!
Who is using Play?
What is Play?
• Easy to build web applications with Java & Scala.
• Based on a lightweight, stateless, web-friendly
architecture.
• Built on Akka, Play provides predictable and
minimal resource consumption (CPU, memory,
threads) for highly-scalable applications
History
• Play 1 Created By
Guillaume Bort at
Zengularity SA in 2007
• Play 2 release in 2012 by
Typesafe (rewrite using
Scala)
• Part of Typesafe Activator
Philosophy
• Build for Asynchronous
Programming
• Focused on Type Safety
• Native support for Java and
Scala
• Powerful Build System
• Datastore and Model
Integration
Full Stack Framework
• HTTP Server (Netty)
• Routing
• Body Parsers
• Action composition
• Security
• Caching
• Database
• i18n
• Dependency Injection
• Template engine (HTML,
XML...)
• HTTP forms (bindings,
validation)
• JSON, XML
• Javascript Closure Compiler
• Coffeescript, Less
Twelve-Factor Manifesto
1. Codebase
2. Dependencies
3. Config
4. Backing Services
5. Build, release, run
6. Processes
7. Port binding
8. Concurrency
9. Disposability
10. Dev/prod parity
11. Logs
12. Admin processes
http://12factor.net/
Lets CODE
Pre-Requisites
• Download (typesafe-activator - Play 2.4.2) from
• https://playframework.com/download
• Add activator your PATH
• activator new
IDE & JDK Support
• Play 2.4.2 is only supported JDK 8 onwards
• IntelliJ IDE
• Import as an SBT project
• Eclipse
• activator eclipse
Basic Demo
Whats the Usecase?
User
Service
GET /github/:username
User
Controller
GITHUB
User
Repository
GET /users/list/
https://api.github.com
create(User)
update(User)
getAllUsers
allUsers():List<User>
Route Test
Functional Test
Integration Test
Unit Test
Github
Service
findUser():User
Unit Test
save(User)
Coding..
Heroku Deployment
• Install the Heroku Toolbelt
• Write a Procfile
• $ git init
• $ git add .
• $ git commit -m “init"
• heroku create
• git push heroku master
Code on Github
https://github.com/basav/MyApp
or ask back later
bnagur@gmail.com
Thank You!
@basav

Play 2 Java Framework with TDD

  • 1.
  • 2.
    Agenda • Introduction toPlay 2 Java framework • Live Coding • Deployment to Cloud • QA
  • 3.
    Who am I? SoftwareArchitect Entrepreneur Web 2.0 JavaScript
  • 4.
    WE ARE STARTINGA NEW PROJECT !YAY!
  • 5.
    I AM READYTO CODE IT UP!!
  • 6.
    STACK? What aboutPOLYGLOT? DILEMMA !!!
  • 7.
    SON !! TRUSTME! JAVA IS THE SAFE CHOICE! Many come back (think Twitter) But there is a curse…
  • 8.
    The risk ofdying - waiting for server start, complex tooling, redeployment, maintaining XML, HTTPSession ..etc
  • 9.
    CAN YOU HAVEYOUR CAKE AND EAT IT TOO?
  • 10.
  • 11.
  • 12.
    What is Play? •Easy to build web applications with Java & Scala. • Based on a lightweight, stateless, web-friendly architecture. • Built on Akka, Play provides predictable and minimal resource consumption (CPU, memory, threads) for highly-scalable applications
  • 13.
    History • Play 1Created By Guillaume Bort at Zengularity SA in 2007 • Play 2 release in 2012 by Typesafe (rewrite using Scala) • Part of Typesafe Activator
  • 14.
    Philosophy • Build forAsynchronous Programming • Focused on Type Safety • Native support for Java and Scala • Powerful Build System • Datastore and Model Integration
  • 15.
    Full Stack Framework •HTTP Server (Netty) • Routing • Body Parsers • Action composition • Security • Caching • Database • i18n • Dependency Injection • Template engine (HTML, XML...) • HTTP forms (bindings, validation) • JSON, XML • Javascript Closure Compiler • Coffeescript, Less
  • 16.
    Twelve-Factor Manifesto 1. Codebase 2.Dependencies 3. Config 4. Backing Services 5. Build, release, run 6. Processes 7. Port binding 8. Concurrency 9. Disposability 10. Dev/prod parity 11. Logs 12. Admin processes http://12factor.net/
  • 17.
  • 18.
    Pre-Requisites • Download (typesafe-activator- Play 2.4.2) from • https://playframework.com/download • Add activator your PATH • activator new
  • 19.
    IDE & JDKSupport • Play 2.4.2 is only supported JDK 8 onwards • IntelliJ IDE • Import as an SBT project • Eclipse • activator eclipse
  • 20.
  • 21.
    Whats the Usecase? User Service GET/github/:username User Controller GITHUB User Repository GET /users/list/ https://api.github.com create(User) update(User) getAllUsers allUsers():List<User> Route Test Functional Test Integration Test Unit Test Github Service findUser():User Unit Test save(User)
  • 22.
  • 23.
    Heroku Deployment • Installthe Heroku Toolbelt • Write a Procfile • $ git init • $ git add . • $ git commit -m “init" • heroku create • git push heroku master
  • 24.
  • 25.
    or ask backlater bnagur@gmail.com
  • 26.