introduction to play framework
DESCRIPTION
An introduction to play frameworkTRANSCRIPT
Play Framework
wildfire tech team
前 言
• 臃肿,框架繁杂• IDE: Eclipse• 自动化: Ant• Redeploy: JRebel• 敏捷开发的浪潮 (Rails)
Java 项目的开发效率
OK , Play Framework is coming...
前 言
• scala 用户组• 仿 Rails• 自动编译部署
邂逅 Play
OK , Let's run a simple example
Example
• app/: model/, view/, controller• conf/: application.rb, routes, messages• lib/• public/• test/
$ play new yabe
Example
• 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
$ play run
Example
• conf/application.conf• default: db=mem• db=mysql://root:root@localhost/yabe
connect to db
Example
• http://localhost:9000/@tests
$ play test
Example
• use Hibernate but have no configuration• play.db.jpa.Model = JPA + helper(e.g. id)
create the data model
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 !