KEMBAR78
Introduction to Play Framework | PPT
Play Framework



           wildfire tech team
前 言
Java 项目的开发效率
•   臃肿,框架繁杂
•   IDE: Eclipse
•   自动化: Ant
•   Redeploy: JRebel
•   敏捷开发的浪潮 (Rails)
OK , Play Framework is
coming...
前 言
邂逅 Play
• scala 用户组
• 仿 Rails
• 自动编译部署
OK , Let's run a simple example
Example
$ play new yabe
•   app/: model/, view/, controller
•   conf/: application.rb, routes, messages
•   lib/
•   public/
•   test/
Example
$ play run
•   http://localhost:9000
•   conf/routes
•   app/controllers/Application.java
•   app/views/Application/index.html
•   template: app/views/main.html
•   write an error then refresh, Woo~
•   write index.html
Example
connect to db
• conf/application.conf
• default: db=mem
• db=mysql://root:root@localhost/yabe
Example
$ play test
• http://localhost:9000/@tests
Example
create the data model
• use Hibernate but have no configuration
• play.db.jpa.Model = JPA + helper(e.g. id)
app/models/User.java
test/BasicTest.java
app/models/User.java
test/BasicTest.java
app/models/Post.java
test/BasicTest.java
app/models/Comment.java
test/BasicTest.java
app/models/Post.java
test/BasicTest.java
test/data.yml
test/BasicTest.java
All the tests is green?
Example




create the view
conf/data.yml
app/Bootstrap.java
app/controllers/Application.java
app/views/Application/index.html
...ugly version
...beautiful version
...so many works

•   The comments page
•   Setting up a Captcha
•   Add tagging support
•   A basic admin area using CRUD
•   Adding authentication
•   Creating a custom editor area
•   Completing the application tests
•   Preparing for production
•   Internationalisation and localisation
OK ,消化一下
Five cool things you can do with Play

  •   HTTP param and Java method param
  •   action and Java method
  •   DRY (template system)
  •   JPA on steroids
  •   Straightforward file upload management
Conclusion

  •   just reload when fix bug
  •   stateless model(REST, scalable)
  •   template system(groovy)
  •   Asynchronous(NIO model, long polling)
  •   pure java
  •   full stack
  •   Resolve and show errors
  •   Productive
Play 2.0 and scala ...
Resource
• http://www.playframework.org/
• http://www.playframework.org/2.0
Thank you !

Introduction to Play Framework