introduction to play framework

37
Play Framework wildfire tech team

Upload: warren-zhou

Post on 06-Dec-2014

2.691 views

Category:

Technology


1 download

DESCRIPTION

An introduction to play framework

TRANSCRIPT

Page 1: Introduction to Play Framework

Play Framework

wildfire tech team

Page 2: Introduction to Play Framework

前 言

• 臃肿,框架繁杂• IDE: Eclipse• 自动化: Ant• Redeploy: JRebel• 敏捷开发的浪潮 (Rails)

Java 项目的开发效率

Page 3: Introduction to Play Framework

OK , Play Framework is coming...

Page 4: Introduction to Play Framework

前 言

• scala 用户组• 仿 Rails• 自动编译部署

邂逅 Play

Page 5: Introduction to Play Framework

OK , Let's run a simple example

Page 6: Introduction to Play Framework

Example

• app/: model/, view/, controller• conf/: application.rb, routes, messages• lib/• public/• test/

$ play new yabe

Page 7: Introduction to Play Framework

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

Page 8: Introduction to Play Framework

Example

• conf/application.conf• default: db=mem• db=mysql://root:root@localhost/yabe

connect to db

Page 9: Introduction to Play Framework

Example

• http://localhost:9000/@tests

$ play test

Page 10: Introduction to Play Framework

Example

• use Hibernate but have no configuration• play.db.jpa.Model = JPA + helper(e.g. id)

create the data model

Page 11: Introduction to Play Framework

app/models/User.java

Page 12: Introduction to Play Framework

test/BasicTest.java

Page 13: Introduction to Play Framework

app/models/User.java

Page 14: Introduction to Play Framework

test/BasicTest.java

Page 15: Introduction to Play Framework

app/models/Post.java

Page 16: Introduction to Play Framework

test/BasicTest.java

Page 17: Introduction to Play Framework

app/models/Comment.java

Page 18: Introduction to Play Framework

test/BasicTest.java

Page 19: Introduction to Play Framework

app/models/Post.java

Page 20: Introduction to Play Framework

test/BasicTest.java

Page 21: Introduction to Play Framework

test/data.yml

Page 22: Introduction to Play Framework

test/BasicTest.java

Page 23: Introduction to Play Framework

All the tests is green?

Page 24: Introduction to Play Framework

Example

create the view

Page 25: Introduction to Play Framework

conf/data.yml

Page 26: Introduction to Play Framework

app/Bootstrap.java

Page 27: Introduction to Play Framework

app/controllers/Application.java

Page 28: Introduction to Play Framework

app/views/Application/index.html

Page 29: Introduction to Play Framework

...ugly version

Page 30: Introduction to Play Framework

...beautiful version

Page 31: Introduction to Play Framework

...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

Page 32: Introduction to Play Framework

OK ,消化一下

Page 33: Introduction to Play Framework

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

Page 34: Introduction to Play Framework

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

Page 35: Introduction to Play Framework

Play 2.0 and scala ...

Page 36: Introduction to Play Framework

Resource• http://www.playframework.org/• http://www.playframework.org/2.0

Page 37: Introduction to Play Framework

Thank you !