play2 java
TRANSCRIPT
2 Java
@basav
Agenda
• Introduction to Play 2 Java framework
• Live Coding
• Deployment to Cloud
• QA
Who am I?
Software ArchitectEntrepreneur
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 Manifesto1. 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 TestFunctional Test
Integration TestUnit Test
GithubService
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
or ask back [email protected]
Thank You!
@basav