Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Play Framework

An introduction to play framework

Related Books

Free with a 30 day trial from Scribd

See all
  • Be the first to comment

  • Be the first to like this

Introduction to Play Framework

  1. 1. Play Framework wildfire tech team
  2. 2. 前 言Java 项目的开发效率• 臃肿,框架繁杂• IDE: Eclipse• 自动化: Ant• Redeploy: JRebel• 敏捷开发的浪潮 (Rails)
  3. 3. OK , Play Framework iscoming...
  4. 4. 前 言邂逅 Play• scala 用户组• 仿 Rails• 自动编译部署
  5. 5. OK , Lets run a simple example
  6. 6. Example$ play new yabe• app/: model/, view/, controller• conf/: application.rb, routes, messages• lib/• public/• test/
  7. 7. 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
  8. 8. Exampleconnect to db• conf/application.conf• default: db=mem• db=mysql://root:root@localhost/yabe
  9. 9. Example$ play test• http://localhost:9000/@tests
  10. 10. Examplecreate the data model• use Hibernate but have no configuration• play.db.jpa.Model = JPA + helper(e.g. id)
  11. 11. app/models/User.java
  12. 12. test/BasicTest.java
  13. 13. app/models/User.java
  14. 14. test/BasicTest.java
  15. 15. app/models/Post.java
  16. 16. test/BasicTest.java
  17. 17. app/models/Comment.java
  18. 18. test/BasicTest.java
  19. 19. app/models/Post.java
  20. 20. test/BasicTest.java
  21. 21. test/data.yml
  22. 22. test/BasicTest.java
  23. 23. All the tests is green?
  24. 24. Examplecreate the view
  25. 25. conf/data.yml
  26. 26. app/Bootstrap.java
  27. 27. app/controllers/Application.java
  28. 28. app/views/Application/index.html
  29. 29. ...ugly version
  30. 30. ...beautiful version
  31. 31. ...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
  32. 32. OK ,消化一下
  33. 33. 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
  34. 34. 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
  35. 35. Play 2.0 and scala ...
  36. 36. Resource• http://www.playframework.org/• http://www.playframework.org/2.0
  37. 37. Thank you !

×