![Page 1: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/1.jpg)
Introduction to Play! Framework
![Page 2: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/2.jpg)
Rustem SunievRustem SunievSenior Developer at Autoquake.com Senior Developer at Autoquake.com Technologies we use: Java,JEE,Groovy,Grails,GWTTechnologies we use: Java,JEE,Groovy,Grails,GWT
My current interests are: Scala, Lift, Play, ClojureMy current interests are: Scala, Lift, Play, Clojure
Twitter: @vigosunTwitter: @vigosunEmail: [email protected]: [email protected]
About me
![Page 3: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/3.jpg)
Why another Web framework?I'm tired to learn all of them
![Page 4: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/4.jpg)
What is Play!
● Started 2008 by Guillaume Bort, play dev team and Zenexity
● A new unconventional for Java world approach● There is no traditional JEE stack● It's a platform not just a glue framework● Usability first● Current version is 1.0.3.2
![Page 5: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/5.jpg)
Main features● Stateless● RESTfull (Uses HTTP features not just as a
transport)● No-compilation● Refresh and see the changes● In-build compiler and classloader● Efficient error reporting system● Build in test framework● Templates
![Page 6: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/6.jpg)
MVC in Play!● Model (not anemic)● Controller● Convention based REST routing● View (efficient template system)
![Page 7: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/7.jpg)
What is Stateless exactly?
● Share nothing architecture● Easy to scale and support ● Simplifies the code
but sometimes we need a state?● Cache (EhCache, Memcached for scaling
options)● Workarounds
![Page 8: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/8.jpg)
Testing
● Can't execute tests outside of the framework
We have 3 types of tests:● Unit● Functional● Selenium simplified● Code coverage via Cobertura plugin● YAML and Fixtures
![Page 9: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/9.jpg)
Jobs
● Scheduled jobs ● Bootstrapping● Suspendable requests
Future<InputStream> task = new ReportAsPDFJob(report).now();
waitFor(task);
![Page 10: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/10.jpg)
Modules system
Some of the available modules:● CRUD● GAE,GWT● Guice, Spring● Stax, Playapps.net● Siena, Ebean DB, MongoDB● Installing is simple “play install scala”● Easy to create a module “play new-module”
![Page 11: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/11.jpg)
Small but nice things in Play! ● Framework ID's (play id, prod321.username=test)
● Localisation and I18N (<h1>&{'views.main.tools.login'}</h1>)
● User and SEO friendly URL's● Logging support (Logger.info("A log message"))
● Security support ● IDE support
![Page 12: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/12.jpg)
Where is Scala stuff? Enough Java Now onto Play! Scala
(created by Peter Hausel)
“I like Lift ;-) Play is my second choice for Scala-friendly web frameworks”David Pollak creator of Lift on SOF
![Page 13: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/13.jpg)
Why Scala?
● Alternative implementation but same platform● Java enhancers (ex get,set)● Traits● Improve expressiveness● Challenges (API, different language features,
Interoperability)● Another language in the future?
![Page 14: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/14.jpg)
What Scala brings to Play!
● Scala 2.8 support● ScalaTest● Scalate templates● Scala console (tab completion)● AKKA integration
![Page 15: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/15.jpg)
Ok let's build a simple app.
Demo time
![Page 16: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/16.jpg)
Any cons at all?
● Documentation is not up to date and scattered
● Scala module is still in dev (but API changes are less likely)
● Couldn't get cobertura working for 1.1 with Scala
● Sometimes changes in Scala classes are not picked (play clean)
● Start-up time grows with number of classes (play recompiles dependencies as well)
● Scala module (Had to compile from source code)
![Page 17: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/17.jpg)
Preparing for Production
● Can be compiled and packaged● Can be deployed to all major containers● Some security issue were found recently so it's
advised to keep it behind a proxy● Production behaviour is different ● Use server ID
![Page 18: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/18.jpg)
Summary
● Looking forward to 1.1 release ● Scala module looks promising and easy to use● Better IDE support is required● Other Scala modules need more
documentation● Better attention is required to keep Java and
Scala modules up to date● Start using Play! Java now
![Page 19: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/19.jpg)
Resourses
● www.playframework.org● http://groups.google.com/group/play-framework/● http://planet.playframework.org/
![Page 20: Rustem Suniev: London Scala Users' Group:Intro to Play - 11/08/2010](https://reader035.vdocument.in/reader035/viewer/2022081907/54631b7bb1af9f86228b53ca/html5/thumbnails/20.jpg)
Thank you!