Introduction to Play 2
Upcoming SlideShare
Loading in...5
×
 

Introduction to Play 2

on

  • 2,567 views

Introduction to Play 2 framework made on JUG.fi on 3rd of May 2012

Introduction to Play 2 framework made on JUG.fi on 3rd of May 2012

Statistics

Views

Total Views
2,567
Views on SlideShare
2,567
Embed Views
0

Actions

Likes
1
Downloads
67
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction to Play 2 Introduction to Play 2 Presentation Transcript

  • INTRODUCTION TO PLAY FRAMEWORK 2.0 Luciano Fiandesio Founder and Architect @ Aestas IT http://aestasit.com @koevetFriday, May 4, 12
  • HISTORY • The Play! framework project by Zenexity started in 2007, release 1.0 was out in 2008. • Play! started to allow Scala development since version 1.1. • Version 2.0, released on March 2012, was completely rewritten in Scala. Uses the Akka framework as backend. • Version 2 is part of the Typesafe framework, which includes Scala and Akka. http://aestasit.comFriday, May 4, 12
  • WHAT IS PLAY ? • Play! is a stateless full web development stack that works with Scala and Java • Built and focused around HTTP - no need to hide it! • Allows an asynchronous HTTP programming model (comet, websocket, streams) • Scalable and high performance (Akka!) • Type safe and everything gets compiled (code, js, css, routes) http://aestasit.comFriday, May 4, 12
  • PLAY IS STATELESS • Statelessness promotes horizontal scalability • No session, only cache. Memcache for scalability • No need to replicate the state, just use a load balancer • The web is stateless, so Play! just matches the web architecture http://aestasit.comFriday, May 4, 12
  • DEVELOPING WITH PLAY • Probably the biggest “selling point” of the Play! framework. • No need to redeploy, just click “refresh” on your browser (Rails anyone?) • What can be reloaded? • Java/Scala classes • configuration files • templates http://aestasit.comFriday, May 4, 12
  • URLS MATTERS! • Play! handles URLs in a REST-like manner: resources! • http://localhost:9000/user/100 • http//localhost:9000/users • The app’s url can be easily bookmarked, mailed and tweeted • All app’s url are configured in one file: conf/routes http://aestasit.comFriday, May 4, 12
  • SHOW ME THE ERROR http://aestasit.comFriday, May 4, 12
  • SHOW ME ALL ERRORS! • The compilers also shows compilation errors for • Templates • Javascript/Coffee script • CSS (when using the Less framework) http://aestasit.comFriday, May 4, 12
  • ACTIONS AND TEMPLATES http://aestasit.comFriday, May 4, 12
  • ACTIONS AND TEMPLATES • Play! templates get compiled to Scala classes, therefore they share a lot with Scala. • Templates are type safe. They are like giant functions with parameters. Calling a template! http://aestasit.comFriday, May 4, 12
  • ACTIONS AND TEMPLATES products.scala.html http://aestasit.comFriday, May 4, 12
  • ACTIONS AND TEMPLATES http://aestasit.comFriday, May 4, 12
  • FLASH & SESSION • Play! has a Session, but as it’s based on Cookie and can only contain String (up to 4K) • There is also a request-scope session, called flash good for displaying messages upon a successful request. http://aestasit.comFriday, May 4, 12
  • BEAN FOREVER • Play! supports multiple datasources and it is possible to use a Connection object (if you are old school). • ORM is supported too, with Ebean (http://www.avaje.org/) and JPA. • Ebean has great support through the Model superclass. Define your entity and you are good to go. http://aestasit.comFriday, May 4, 12
  • BEAN FOREVER A model class http://aestasit.comFriday, May 4, 12
  • BEAN FOREVER http://aestasit.comFriday, May 4, 12
  • CACHE • Play! has a default cache mechanism based on EHCache - but is pluggable. • Cache can be accessed via API and even from the templates. • Basic Annotation based caching supported: http://aestasit.comFriday, May 4, 12
  • SWEDISH DELIGHT • Play! and Akka are totally integrated. • You can access an Actor system and run code asynchronously • Akka can also be used when dealing with asynchronous request/response (like Websocket). • Bottom line: it is very easy to create asynchronous applications with Play 2 http://aestasit.comFriday, May 4, 12
  • GET THINGS STRAIGHT • Deploy of a Play! 2 app on Tomcat or any other container doesn’t work (so far). • Many people on the newsgroup are complaining about the Scala syntax for templates • Scala compilation time is 3X slower than Java (some say 5X) • ORM has less features than Play 1 • No plugin eco-system (yet - is coming) http://aestasit.comFriday, May 4, 12