SlideShare ist ein Scribd-Unternehmen logo
1 von 74
Play  framework  2
@PeterHilton  at  #JAXLondon  on  17  October  2012
2
Peter  Hilton

■   (sorry, I am not Guillaume Bort)
■   Web developer and Operations Director at
    Lunatech Research in Rotterdam
    ■   Web application architecture, design and construction
    ■   Technical project management and functional design
■   Play framework committer since 2010
■   Co-author of the book Play for Scala (Manning)
3
About  Lunatech

■   Founded  in  Ro*erdam  in  1993  as  an  IT  consul6ng,  product  
    research  and  development  team
■   We  build  web  applica6ons,  web  services,  large-­‐scale  document-­‐
    processing  and  message-­‐processing  applica6ons,  online  products
■   Leverage  cuBng-­‐edge  open-­‐source  soCware  plaDorms
■   Invest  in  product  research  and  development
■   Play  framework;  Java  EE  -­‐  JBoss  AS,  Seam,  JPA,  jBPM,  Drools;  
    back-­‐end  -­‐  PostgreSQL,  Linux;  front-­‐end  -­‐  jQuery,  Backbone,  _.js
■   Agile  soCware  development  -­‐  self-­‐managing  technical  teams
4




“   Play  introduces  high-­‐produc6vity  
    type  safe  web  development
    Presenta6on  goal:  show  you  how  cool  Play  is
5
Outline

■   What Play is and why it matters
    (web architecture)
■   High-productivity web development
    (but for Java and Scala developers)
■   Developer Experience (DX) that doesn’t suck
■   Type safe compile-time checked web development
■   HTML5 front-end development
6
What  Play  is

■   Full-stack web framework (what you need to build an app)
■   Simple, flexible and powerful HTTP interface
■   High-productivity web development
■   High-performance scalable architecture
■   Designed by web developers for web developers
■   Play is fun
h&p://www.flickr.com/photos/roninsfx/5568957616/
h&p://www.flickr.com/photos/deerwooduk/579761138/
9




“   What  is  the  focal-­‐point  of  web  
    applica6on  architecture?
10




“   It’s  the  web  browser,  stupid
11
Why  Play  maCers




The  Back  bu*on  works

Play’s  stateless  architecture  is  based  on  HTTP.  

When  a  web  framework  starts  an  architecture  fight  
with  the  web,  the  framework  loses.
12
Why  Play  maCers




 Back                                    The  Reload  bu*on  works
 bu*on
                    During   development,   just   reload   the   page  
                    to  see  changes  in  your  Java  (or  Scala)  code.
                    That’s  high-­‐produc6vity  web  development.
13
Why  Play  maCers




 Back               You  design  the  URL           Reload  
 bu*on                                              bu*on
                    You  can  use  ‘clean’  URLs:
                    /products
                    /product/42
                    /product/42/comments
14
Why  Play  maCers




 Back               Usability  (DX)             URL   Reload  
 bu*on                                                bu*on
                    Convenient  HTTP  API  
                    and  template  syntax
                    Clear  error  messages  
                    and  short  stack  traces
15




“   What’s  the  story  behind  the  heart  icon?


“   There  isn’t  one.
    Feel  free  to  make  one  up  :)
    Guillaume  Bort
16




“   Play  doesn’t  fight  web  architecture
    Stateless,  HTTP-­‐centric  architecture…
18
Stateless  architecture

■   No state in the application’s web tier
    ■   e.g. Java Servlet API’s HTTP session
        (which isn’t actually part of HTTP)
■   State belongs in other tiers
    ■   HTTP client, server cache or database
■   Web application behaviour defined by URLs (requests)
■   Exception for identifying authenticated user by cookie
19
Stateless  architecture  -­‐  why

■   Simplifies application development and testing
    ■   (a URL is all you need for reproducability)
■   Matches the web’s stateless HTTP architecture
■   Avoids synchronising state between additional layers
    ■   (‘synchronisation’ should ring tech design alarm bells)
■   Enables cloud deployment and horizontal scalability
    ■   (search the web for “Play framework Heroku”)
www.12factor.net
21




“   Dear  Java  devs,  PHP  and  Rails  devs  
    have  been  laughing  at  you  for  years
    …  every  6me  they  reload  a  page’s  code  changes
22
Code  reloading

■   During development, reload the page to see changes in:
    ■   Java and Scala classes
    ■   configuration files
    ■   templates.
■   Play pre-compiles classes and templates for better
    performance in production mode
■   This just works out-of-the-box
23




“   URLs  want  to  be  loved  too
    REST  architecture  isn’t  just  for  web  service  APIs
24




h  t  t  p  :  /     a  p  p  .  e     a  m  p  l  e  .  c  o  m  /  W     r     o  o  t  D    r     
                /                   x                                      a R                     i e
c  t  o  r     1  /     e        l  e     s        A     l  a     e     s     s  s    o  n  I  d  =  x  8  
          y S rv t On P n ? e i
1  n  j  3  8  a  v     g    L  O  L  d  x  p  a     e  w  q  &  a  c  t  i  o  n  =  N  e  x  t  
                      n j                           n
P  a  g     &  H     n  e     B  a  d     e  r        r     s  =     a  l  s  e     e  n  t    t  y  
          e o y                               g Ca e f                                & i
I  d     1  2  9  9  1  2  7  4  3  &  p  r  o  c  e  s  s  N     m  e  =     n  l  a  d  e  n  
    =                                                              a               U
S  w  a  l  l  o  w  C  o  m  p  u  t  a  t  i  o  n  &  r  o  l  e  =  p  e  o  n  &  d  a  t  
e  =  1  4  %  2  F     2  %  2  F  2  0  1  2  &  f  l     g     e     t  i  n  g     =  0  1  0  
                         0                                      a S t                     s
1  0  1  1  &  r  e  t  u  r  n  =  %  2  F  v  i  d  e  o  s  %  2  F  r  i  c  k  r  o  l  l  .  a  v  i
h&p://www.flickr.com/photos/shyroii/4817446191/
26
URL  design  (HTTP  rouMng)

■   Clean URLs are stable URLs:
    ■   http://example.com/products
    ■   http://example.com/product/42
■   Read it, bookmark it, mail it, tweet it
■   URL-centric design:
    ■   Design the URL scheme before you start coding
    ■   Configure your application’s URLs in one file
27
URL  design  (HTTP  rouMng)

■   Designed URLs are clean URLs:
    ■    http://example.com/products
    ■    http://example.com/product/42
■   Corresponding Play routing configuration:

        #	
  HTTP	
  routes	
  configuration	
  file

        #	
  method,	
  URL	
  path,	
  controller	
  action	
  method	
  (and	
  params)

        GET	
  	
  /products	
  	
  	
  	
  	
  	
  controllers.Products.list()

        GET	
  	
  /product/:id	
  	
  	
  controllers.Products.details(id:Long)
28
#  HTTP  routes  configuraMon  file


GET	
  	
  	
  	
  /	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  controllers.Application.index()



GET	
  	
  	
  	
  /products	
  	
  	
  	
  	
  	
  controllers.Products.list()

POST	
  	
  	
  /products	
  	
  	
  	
  	
  	
  controllers.Products.add(p:	
  Product)

GET	
  	
  	
  	
  /product/:id	
  	
  	
  controllers.Products.details(id:	
  Long)

DELETE	
  /product/:id	
  	
  	
  controllers.Products.delete(id:	
  Long)



GET	
  /products.json	
  	
  	
  	
  controllers.Products.listJSON()

GET	
  /product/:id.json	
  controllers.Products.detailsJSON(id:Long)
29




“   You  have  to  be  a  genius  to  successfully  
    use  some  web  frameworks
    For  the  rest  of  us,  there  are  good  error  messages
30
31
Where’s  the  actual  error  message?

13:07:55,796	
  ERROR	
  [[PersonServlet]]	
  Servlet.service()	
  for	
  servlet	
  
PersonServlet	
  threw	
  exception
javax.ejb.EJBException:	
  null;	
  CausedByException	
  is:
	
    null
	
    at	
  org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:46)
	
    at	
  org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:70)
	
    at	
  org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
	
    at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
    at	
  org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
	
    at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
    at	
  org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
	
    at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
    at	
  org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
	
    at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
    at	
  org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)
	
    at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
    at	
  org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
	
    at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
    at	
  org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:189)
	
    at	
  org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
	
    at	
  org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:37)
	
    at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
    at	
  org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:88)
	
    at	
  $Proxy76.getAllPeople(Unknown	
  Source)
	
    at	
  uk.co.mediaport.web.PersonServlet.showTelephones(PersonServlet.java:54)
	
    at	
  uk.co.mediaport.web.PersonServlet.doPost(PersonServlet.java:45)
	
    at	
  uk.co.mediaport.web.PersonServlet.doGet(PersonServlet.java:34)
	
    at	
  javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
	
    at	
  javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
	
    at	
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	
    at	
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	
    at	
  org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
	
    at	
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	
    at	
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	
    at	
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	
    at	
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	
    at	
  org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
	
    at	
  org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
	
    at	
  org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
	
    at	
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	
    at	
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	
    at	
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	
    at	
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	
    at	
  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    at	
  org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
	
     at	
  org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
	
     at	
  org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                                                                                                                          32
	
     at	
  java.lang.Thread.run(Thread.java:595)
	
     java.lang.NullPointerException
	
     at	
  uk.co.mediaport.core.PeopleBean.getAllPeople(PeopleBean.java:33)
	
     at	
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native	
  Method)
	
     at	
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	
     at	
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	
     at	
  java.lang.reflect.Method.invoke(Method.java:585)
	
     at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
	
     at	
  org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:32)
	
     at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
     at	
  org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
	
     at	
  org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
	
     at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
     at	
  org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
	
     at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
     at	
  org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
	
     at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
     at	
  org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
	
     at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
     at	
  org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)
	
     at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
     at	
  org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
	
     at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
     at	
  org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:189)
	
     at	
  org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
	
     at	
  org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:37)
	
     at	
  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
	
     at	
  org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:88)
	
     at	
  $Proxy76.getAllPeople(Unknown	
  Source)
	
     at	
  uk.co.mediaport.web.PersonServlet.showTelephones(PersonServlet.java:54)
	
     at	
  uk.co.mediaport.web.PersonServlet.doPost(PersonServlet.java:45)
	
     at	
  uk.co.mediaport.web.PersonServlet.doGet(PersonServlet.java:34)
	
     at	
  javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
	
     at	
  javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
	
     at	
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	
     at	
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	
     at	
  org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
	
     at	
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	
     at	
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	
     at	
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	
     at	
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	
     at	
  org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
	
     at	
  org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
	
     at	
  org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
	
     at	
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	
     at	
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	
     at	
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	
     at	
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
http://localhost/                            33




Parse error: syntax error, unexpected T_VARIABLE
in /usr/local/www/htdocs/index.php on line 3
35




“   Play  2  con6nues  the  innova6on
    First-­‐class  support  for  both  Java  and  Scala
    Type-­‐safe  templates
    Compile-­‐6me  checking
    Asynchronous  HTTP  programming
h&p://www.flickr.com/photos/anoldent/3642351368
37
Play  in  Java  and  Scala

■   Play 2.0 provides parallel APIs for Java and Scala,
    for example, a controller action:

    //	
  Java	
  controller	
  action	
  method
    public	
  static	
  Result	
  index(String	
  name)	
  {
    	
  	
  return	
  ok("Hello"	
  +	
  name);
    }



    //	
  Scala	
  controller	
  action	
  method
    def	
  hello(name:	
  String)	
  =	
  Action	
  {
    	
  	
  Ok("Hello	
  "	
  +	
  name)
    }
38
Play  2.0  Scala  implementaMon

■   Play 2.0 is itself implemented in Scala
■   Scala removes the need for so much bytecode
    enhancement in the Java API (which is how Play 1.x works)
    ■   There is less ‘magic’ and strangeness in the API
    ■   The code you see in the IDE is the code that runs
■   Scala source code not necessarily harder to read
39




“   Templates  want  to  be  beau6ful  too
    Type  safe  template  parameter  delcara6ons
    Minimal  interference  with  HTML  mark-­‐up
40
Type-­‐safe  template  parameters

■   Templates include type-safe parameter declarations
■   Similar to the lightweight template syntax in Play 1.x
■   Templates are compiled into class files for run-time speed

    @(products:	
  List[Product])
    <ul>	
  
    @for(product	
  <-­‐	
  products)	
  {
    	
  	
  <li	
  class="@product.type">@product.name</li>
    }	
  
    </ul>
41
Template  funcMons

■   Play 2.0’s template system is based on Scala
■   A template is a Scala function that you call from your code

    //	
  Render	
  the	
  ‘Products.list’	
  template	
  in	
  Java	
  code.
    Html	
  html	
  =	
  views.html.Products.list.render(products);


    //	
  e.g.	
  as	
  the	
  result	
  of	
  a	
  controller	
  action	
  method.
    public	
  static	
  Result	
  list()	
  {
    	
  	
  final	
  List<Product>	
  products	
  =	
  Products.list();
    	
  	
  return	
  ok(views.html.Products.list.render(products));
    }
Template syntax starts with @                                   42




                      Template parameter declaration

@(products:	
  List[Product])


@if(products.isEmpty)	
  {

	
  	
  <h1>No	
  products</h1>

}                                 No delimiter for the end of
                                  a template syntax section
43




@(products:	
  List[Product])


@if(products.isEmpty)	
  {

	
  	
  <h1>No	
  products</h1>

}	
  else	
  {

	
  	
  <h1>@items.size	
  products</h1>

}
                 Output the value of an expression
44

      Define a ‘tag’ - output a details page link


@display(product:	
  models.Product)	
  =	
  {
	
  	
  <a	
  href="@routes.Products.details(product.id)">
	
  	
  	
  	
  @product.name
	
  	
  </a>
}


<ul>
@for(product	
  <-­‐	
  products)	
  {
	
  	
  @display(product)
}	
  
</ul>
              Use the ‘display’ tag
45




<section	
  class="content">

	
  	
  …

</section>

@footer()


              Include the ‘footer’ template
              (i.e. call the ‘footer’ function)
main.scala.html                       46



@(title:	
  String)(content:	
  Html)
<!DOCTYPE	
  html>
<html>
                                      Two parameter lists
	
  	
  <head>
                                      (one parameter each)
	
  	
  	
  	
  <title>@title</title>
	
  	
  </head>
	
  	
  <body>
	
  	
  	
  	
  @content
	
  	
  </body>                       Define a page layout
</html>                               template called ‘main’

                         index.scala.html
@main("Home	
  page")	
  {          Render the ‘main’ template,
	
  	
  <h1>Welcome</h1>            passing two parameters
}
47




“   Dear  PHP  and  Rails  developers,  
    run6me  errors  make  you  look  bad
    Using  unit  tests  to  find  syntax  errors  is  a  hack
    There  is  a  solu6on…
48
49
Compile-­‐Mme  checking

■   Not just Java and Scala classes
    ■   HTTP routes file (maps URLs to controller actions)
    ■   Templates
    ■   JavaScript files (using Google Closure Compiler)
    ■   CoffeeScript files (alternative to JavaScript)
    ■   LESS style sheets (alternative to CSS)
■   Fewer errors at run-time
controllers/Products.java                      50


public	
  class	
  Products	
  extends	
  Controller	
  {

	
  	
  public	
  static	
  Result	
  details(final	
  Long	
  id)	
  {
	
  	
  	
  	
  return	
  ok();
	
  	
  }
}




                                    conf/routes
GET	
  /product/:id	
  	
  	
  controllers.Products.details(id:	
  String)
controllers/Products.java                          50


public	
  class	
  Products	
  extends	
  Controller	
  {

	
  	
  public	
  static	
  Result	
  details(final	
  Long	
  id)	
  {
	
  	
  	
  	
  return	
  ok();
	
  	
  }
}


                                                         Incompatible types



                                    conf/routes
GET	
  /product/:id	
  	
  	
  controllers.Products.details(id:	
  String)
controllers/Products.java                          50


public	
  class	
  Products	
  extends	
  Controller	
  {

	
  	
  public	
  static	
  Result	
  details(final	
  Long	
  id)	
  {
	
  	
  	
  	
  return	
  ok();
	
  	
  }
}


                                                         Incompatible types



                                    conf/routes
GET	
  /product/:id	
  	
  	
  controllers.Products.details(id:	
  String)
h&p://www.flickr.com/photos/jameswragg/4688532009/
@rainbow:	
  -­‐webkit-­‐gradient(linear,	
  left	
  top,	
  left	
  bottom,
	
  	
  color-­‐stop(0.00,	
  red),
	
  	
  color-­‐stop(20%,	
  orange),
	
  	
  color-­‐stop(25%,	
  yellow),
	
  	
  color-­‐stop(30%,	
  yellow),
	
  	
  color-­‐stop(45%,	
  green),
	
  	
  color-­‐stop(65%,	
  blue),
	
  	
  color-­‐stop(80%,	
  indigo),
	
  	
  color-­‐stop(1.00,	
  violet));
57




“   Use  HTML5  technologies
    Choose  a  web  framework  that  lets  you
    Hire  or  become  a  front-­‐end  expert
    Use  HTML  ‘bricks’  instead  of  moulded  components
59
60
Modern  web  development

■   Play is designed to work with HTML5 technologies
■   No constraints on HTML output (front-end dev-friendly)
■   UI components belong in the client, e.g. JQuery UI
■   Built-in support for improvements to CSS and JavaScript:
    ■   LESS http://lesscss.org/
    ■   CoffeeScript http://coffeescript.org/
    ■   Closure Compiler http://code.google.com/closure/compiler
61
Single-­‐page  JavaScript  applicaMons

■   Server-side HTML templates are not the only game in town
■   JavaScript and mobile apps need web services
■   Play is great for building web services
    ■   You’ve already seen HTTP routing
    ■   Play has a type safe API for parsing/generating JSON
    ■   Play application architecture is natural fit for REST
    ■   Functionality is not tied to view templates
62
GeneraMng  a  JSON  response

$	
  curl	
  -­‐i	
  http://localhost:9000/products/5010255079763

HTTP/1.1	
  200	
  OK
Content-­‐Type:	
  application/json;	
  charset=utf-­‐8
Content-­‐Length:	
  88

{
	
  	
  "ean":5010255079763,
	
  	
  "name":"Paperclips	
  Large",
	
  	
  "description":"Large	
  Plain	
  Pack	
  of	
  1000"
}
63
GeneraMng  a  JSON  response

//	
  Value	
  object
case	
  class	
  Product(ean:	
  Long,	
  name:	
  String,	
  
	
  	
  description:	
  String)

//	
  JSON	
  formatter
implicit	
  object	
  ProductWrites	
  extends	
  Writes[Product]	
  {
	
  	
  
	
  	
  def	
  writes(p:	
  Product)	
  =	
  Json.toJson(
	
  	
  	
  	
  Map(
	
  	
  	
  	
  	
  	
  "ean"	
  -­‐>	
  Json.toJson(p.ean),
	
  	
  	
  	
  	
  	
  "name"	
  -­‐>	
  Json.toJson(p.name),
	
  	
  	
  	
  	
  	
  "description"	
  -­‐>	
  Json.toJson(p.description)
	
  	
  	
  	
  )
	
  	
  )
}

//	
  Controller	
  response
Ok(Json.toJson(product))
64
Parsing  a  JSON  request

implicit	
  object	
  ProductReads	
  extends	
  Reads[Product]	
  {

	
  	
  def	
  reads(json:	
  JsValue)	
  =	
  Product(
	
  	
  	
  	
  (json	
  	
  "ean").as[Long],
	
  	
  	
  	
  (json	
  	
  "name").as[String],
	
  	
  	
  	
  (json	
  	
  "description").as[String]
	
  	
  )
}


//	
  Controller	
  method	
  -­‐	
  using	
  the	
  parse.json	
  body	
  parser
def	
  save(ean:	
  Long)	
  =	
  Action(parse.json)	
  {	
  request	
  =>
	
  	
  val	
  productJson	
  =	
  request.body
	
  	
  val	
  product	
  =	
  productJson.as[Product]

	
  	
  //	
  …
}
h&p://www.flickr.com/photos/chris24dotca/3374782984/
66
Asynchronous  HTTP  programming  model

■   The future of web programming is asynchronous:
    ■   Perform simultaneous web service requests
    ■   Process streams, instead of filling up memory or disk
    ■   Publish real-time data
    ■   Predictable and minimal resource consumption
■   Play’s internal architecture uses a reactive model based on
    Iteratee IO (read about ‘Iteratees’ in the Play 2.0 docs)
67
Other  Play  2.0  features

■   Asynchronous web programming
■   Build environment based on sbt
    ■   Scala REPL (irb eat your heart out)
■   Designed for easy cloud deployment, e.g. Heroku
■   Persistence - use your favourite framework
    ■   Ebean (Java) or Anorm (Scala) included with Play
■   Test framework integration
$	
  play	
  
[info]	
  Loading	
  project	
  definition	
  from	
  /demo/project
[info]	
  Set	
  current	
  project	
  to	
  demo	
  (in	
  build	
  file:/
Users/pedro/Documents/code/examples-­‐play/demo/)
	
  	
  	
  	
  	
  	
  	
  _	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  _	
  
	
  _	
  __	
  |	
  |	
  __	
  _	
  _	
  	
  _|	
  |
|	
  '_	
  |	
  |/	
  _'	
  |	
  ||	
  |_|
|	
  	
  __/|_|____|__	
  (_)
|_|	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  |__/	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  
play!	
  2.0.1,	
  http://www.playframework.org

>	
  Type	
  "help"	
  or	
  "license"	
  for	
  more	
  information.
>	
  Type	
  "exit"	
  or	
  use	
  Ctrl+D	
  to	
  leave	
  this	
  console.

[demo-­‐app]	
  $
[jfokus-­‐app]	
  $	
  console
[info]	
  Starting	
  scala	
  interpreter...
[info]	
  
Welcome	
  to	
  Scala	
  version	
  2.9.1.final	
  (Java	
  HotSpot(TM)	
  
64-­‐Bit	
  Server	
  VM,	
  Java	
  1.6.0_31).
Type	
  in	
  expressions	
  to	
  have	
  them	
  evaluated.
Type	
  :help	
  for	
  more	
  information.

scala>
scala>	
  views.html.rainbow.render
res0:	
  play.api.templates.Html	
  =	
  

<!DOCTYPE	
  html>
<html>
	
  	
  <head>
	
  	
  	
  	
  <title>rainbow</title>
	
  	
  	
  	
  <link	
  rel="stylesheet"	
  type="text/css"	
  href="/
assets/colours.css">
	
  	
  </head>
	
  	
  <body>
	
  	
  	
  	
  
	
  	
  <div	
  class="nyan">
	
  	
  <div	
  class="trail"></div>
	
  	
  <div	
  class="cat">insert	
  meme</div>
	
  	
  </div>

	
  	
  </body>
</html>
71
Play  2  books

■   Play 2 for Scala,
    Peter Hilton, Erik Bakker,
    Francisco Canedo
    http://bit.ly/playforscala
■   Play 2 for Java, Nicolas
    Leroux, Sietse de Kaper
    http://bit.ly/playjava
■   Early Access (MEAP)
    editions now available
@PeterHilton       @PlayFramework

www.lunatech.com   www.playframework.org

Weitere ähnliche Inhalte

Was ist angesagt?

SharePoint Development 101
SharePoint Development 101SharePoint Development 101
SharePoint Development 101Greg Hurlman
 
Untangling spring week5
Untangling spring week5Untangling spring week5
Untangling spring week5Derek Jacoby
 
Creating a Plug-In Architecture
Creating a Plug-In ArchitectureCreating a Plug-In Architecture
Creating a Plug-In Architectureondrejbalas
 
The development workflow of git github for beginners
The development workflow of git github for beginnersThe development workflow of git github for beginners
The development workflow of git github for beginnersGunjan Patel
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Max Andersen
 
Untangling spring week7
Untangling spring week7Untangling spring week7
Untangling spring week7Derek Jacoby
 
Spring rest-doc-2015-11
Spring rest-doc-2015-11Spring rest-doc-2015-11
Spring rest-doc-2015-11Eric Ahn
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpMatthew Davis
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Pantheon
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
CollabSphere 2018 - Java in Domino After XPages
CollabSphere 2018 - Java in Domino After XPagesCollabSphere 2018 - Java in Domino After XPages
CollabSphere 2018 - Java in Domino After XPagesJesse Gallagher
 
APIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsAPIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsSauce Labs
 
Building a Drupal site with Git
Building a Drupal site with GitBuilding a Drupal site with Git
Building a Drupal site with Gitdirtytactics
 
From zero to hero with React Native!
From zero to hero with React Native!From zero to hero with React Native!
From zero to hero with React Native!Commit University
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalNAVER D2
 
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
IBM Drupal Users Group Discussion on Managing and Deploying ConfigurationIBM Drupal Users Group Discussion on Managing and Deploying Configuration
IBM Drupal Users Group Discussion on Managing and Deploying ConfigurationDevelopment Seed
 
Geb for testing your grails application
Geb for testing your grails applicationGeb for testing your grails application
Geb for testing your grails applicationJacobAae
 

Was ist angesagt? (20)

SharePoint Development 101
SharePoint Development 101SharePoint Development 101
SharePoint Development 101
 
Untangling spring week5
Untangling spring week5Untangling spring week5
Untangling spring week5
 
Creating a Plug-In Architecture
Creating a Plug-In ArchitectureCreating a Plug-In Architecture
Creating a Plug-In Architecture
 
The development workflow of git github for beginners
The development workflow of git github for beginnersThe development workflow of git github for beginners
The development workflow of git github for beginners
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
 
Untangling spring week7
Untangling spring week7Untangling spring week7
Untangling spring week7
 
Spring rest-doc-2015-11
Spring rest-doc-2015-11Spring rest-doc-2015-11
Spring rest-doc-2015-11
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
CollabSphere 2018 - Java in Domino After XPages
CollabSphere 2018 - Java in Domino After XPagesCollabSphere 2018 - Java in Domino After XPages
CollabSphere 2018 - Java in Domino After XPages
 
Angular beans
Angular beansAngular beans
Angular beans
 
Take a Stroll in the Bazaar
Take a Stroll in the BazaarTake a Stroll in the Bazaar
Take a Stroll in the Bazaar
 
Untangling4
Untangling4Untangling4
Untangling4
 
APIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsAPIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page Objects
 
Building a Drupal site with Git
Building a Drupal site with GitBuilding a Drupal site with Git
Building a Drupal site with Git
 
From zero to hero with React Native!
From zero to hero with React Native!From zero to hero with React Native!
From zero to hero with React Native!
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_final
 
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
IBM Drupal Users Group Discussion on Managing and Deploying ConfigurationIBM Drupal Users Group Discussion on Managing and Deploying Configuration
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
 
Geb for testing your grails application
Geb for testing your grails applicationGeb for testing your grails application
Geb for testing your grails application
 

Andere mochten auch

TCE introduction (scalability with Scala and Akka)
TCE introduction (scalability with Scala and Akka)TCE introduction (scalability with Scala and Akka)
TCE introduction (scalability with Scala and Akka)Andrew Skiba
 
From Second Screen Social App to Continuous Multi-Screen Experience
From Second Screen Social App to Continuous Multi-Screen ExperienceFrom Second Screen Social App to Continuous Multi-Screen Experience
From Second Screen Social App to Continuous Multi-Screen ExperienceJian Wu
 
Vaadin7 coding ui components
Vaadin7   coding ui componentsVaadin7   coding ui components
Vaadin7 coding ui componentsmp technology
 
Simple Open Source Java Cloud App Stack with Guice, Hibernate, Jersey and Vaadin
Simple Open Source Java Cloud App Stack with Guice, Hibernate, Jersey and VaadinSimple Open Source Java Cloud App Stack with Guice, Hibernate, Jersey and Vaadin
Simple Open Source Java Cloud App Stack with Guice, Hibernate, Jersey and VaadinJian Wu
 
Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...
Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...
Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...Magneta AI
 
Osgi based cloud system architecture - Open Cloud Engine
Osgi based cloud system architecture - Open Cloud EngineOsgi based cloud system architecture - Open Cloud Engine
Osgi based cloud system architecture - Open Cloud EngineuEngine Solutions
 
Play framework: lessons learned
Play framework: lessons learnedPlay framework: lessons learned
Play framework: lessons learnedPeter Hilton
 

Andere mochten auch (8)

TCE introduction (scalability with Scala and Akka)
TCE introduction (scalability with Scala and Akka)TCE introduction (scalability with Scala and Akka)
TCE introduction (scalability with Scala and Akka)
 
From Second Screen Social App to Continuous Multi-Screen Experience
From Second Screen Social App to Continuous Multi-Screen ExperienceFrom Second Screen Social App to Continuous Multi-Screen Experience
From Second Screen Social App to Continuous Multi-Screen Experience
 
Vaadin7 coding ui components
Vaadin7   coding ui componentsVaadin7   coding ui components
Vaadin7 coding ui components
 
Play framework
Play frameworkPlay framework
Play framework
 
Simple Open Source Java Cloud App Stack with Guice, Hibernate, Jersey and Vaadin
Simple Open Source Java Cloud App Stack with Guice, Hibernate, Jersey and VaadinSimple Open Source Java Cloud App Stack with Guice, Hibernate, Jersey and Vaadin
Simple Open Source Java Cloud App Stack with Guice, Hibernate, Jersey and Vaadin
 
Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...
Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...
Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...
 
Osgi based cloud system architecture - Open Cloud Engine
Osgi based cloud system architecture - Open Cloud EngineOsgi based cloud system architecture - Open Cloud Engine
Osgi based cloud system architecture - Open Cloud Engine
 
Play framework: lessons learned
Play framework: lessons learnedPlay framework: lessons learned
Play framework: lessons learned
 

Ähnlich wie Play framework 2 : Peter Hilton

Architecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web AppsArchitecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web AppsRasheed Waraich
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraLINAGORA
 
Raising ux bar with offline first design
Raising ux bar with offline first designRaising ux bar with offline first design
Raising ux bar with offline first designKyrylo Reznykov
 
Pain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakPain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakSigma Software
 
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...Building Blocks
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performanceAndrew Rota
 
Sps Boston The Share Point Beast
Sps Boston   The Share Point BeastSps Boston   The Share Point Beast
Sps Boston The Share Point Beastgueste918732
 
Isomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And ScalabilityIsomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And ScalabilityDenis Izmaylov
 
JavaScript All The Things
JavaScript All The ThingsJavaScript All The Things
JavaScript All The ThingsJordan Yaker
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Henry S
 
SOA Knowledge Kit, Developer Productivity and Performance Comparison Analysis
SOA Knowledge Kit, Developer Productivity  and Performance Comparison AnalysisSOA Knowledge Kit, Developer Productivity  and Performance Comparison Analysis
SOA Knowledge Kit, Developer Productivity and Performance Comparison AnalysisClever Moe
 
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdfAstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdfFarHanWasif1
 
Shining a light on performance (js meetup)
Shining a light on performance (js meetup)Shining a light on performance (js meetup)
Shining a light on performance (js meetup)Yoav Niran
 
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)Christian Catalan
 
Single Page Applications – Know The Ecosystem system
Single Page Applications – Know The Ecosystem systemSingle Page Applications – Know The Ecosystem system
Single Page Applications – Know The Ecosystem systemSynerzip
 
Accelerating Time To Market with Sitecore & Helix
Accelerating Time To Market with Sitecore & HelixAccelerating Time To Market with Sitecore & Helix
Accelerating Time To Market with Sitecore & HelixVarunNehra
 
Introduction to Web Development with Ruby on Rails
Introduction to Web Development with Ruby on RailsIntroduction to Web Development with Ruby on Rails
Introduction to Web Development with Ruby on Railspmatsinopoulos
 
AFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack EncoreAFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack EncoreEngineor
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendVlad Fedosov
 

Ähnlich wie Play framework 2 : Peter Hilton (20)

Architecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web AppsArchitecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web Apps
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - Linagora
 
Raising ux bar with offline first design
Raising ux bar with offline first designRaising ux bar with offline first design
Raising ux bar with offline first design
 
Pain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakPain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr Sugak
 
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performance
 
Sps Boston The Share Point Beast
Sps Boston   The Share Point BeastSps Boston   The Share Point Beast
Sps Boston The Share Point Beast
 
Isomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And ScalabilityIsomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And Scalability
 
JavaScript All The Things
JavaScript All The ThingsJavaScript All The Things
JavaScript All The Things
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
 
SOA Knowledge Kit, Developer Productivity and Performance Comparison Analysis
SOA Knowledge Kit, Developer Productivity  and Performance Comparison AnalysisSOA Knowledge Kit, Developer Productivity  and Performance Comparison Analysis
SOA Knowledge Kit, Developer Productivity and Performance Comparison Analysis
 
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdfAstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
 
Shining a light on performance (js meetup)
Shining a light on performance (js meetup)Shining a light on performance (js meetup)
Shining a light on performance (js meetup)
 
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
 
Web Leaps Forward
Web Leaps ForwardWeb Leaps Forward
Web Leaps Forward
 
Single Page Applications – Know The Ecosystem system
Single Page Applications – Know The Ecosystem systemSingle Page Applications – Know The Ecosystem system
Single Page Applications – Know The Ecosystem system
 
Accelerating Time To Market with Sitecore & Helix
Accelerating Time To Market with Sitecore & HelixAccelerating Time To Market with Sitecore & Helix
Accelerating Time To Market with Sitecore & Helix
 
Introduction to Web Development with Ruby on Rails
Introduction to Web Development with Ruby on RailsIntroduction to Web Development with Ruby on Rails
Introduction to Web Development with Ruby on Rails
 
AFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack EncoreAFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack Encore
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontend
 

Mehr von JAX London

Everything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexityEverything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexityJAX London
 
Devops with the S for Sharing - Patrick Debois
Devops with the S for Sharing - Patrick DeboisDevops with the S for Sharing - Patrick Debois
Devops with the S for Sharing - Patrick DeboisJAX London
 
Busy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript AppsBusy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript AppsJAX London
 
It's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick DeboisIt's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick DeboisJAX London
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerJAX London
 
Worse is better, for better or for worse - Kevlin Henney
Worse is better, for better or for worse - Kevlin HenneyWorse is better, for better or for worse - Kevlin Henney
Worse is better, for better or for worse - Kevlin HenneyJAX London
 
Java performance: What's the big deal? - Trisha Gee
Java performance: What's the big deal? - Trisha GeeJava performance: What's the big deal? - Trisha Gee
Java performance: What's the big deal? - Trisha GeeJAX London
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John StevensonJAX London
 
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias WessendorfHTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias WessendorfJAX London
 
Complexity theory and software development : Tim Berglund
Complexity theory and software development : Tim BerglundComplexity theory and software development : Tim Berglund
Complexity theory and software development : Tim BerglundJAX London
 
Why FLOSS is a Java developer's best friend: Dave Gruber
Why FLOSS is a Java developer's best friend: Dave GruberWhy FLOSS is a Java developer's best friend: Dave Gruber
Why FLOSS is a Java developer's best friend: Dave GruberJAX London
 
Akka in Action: Heiko Seeburger
Akka in Action: Heiko SeeburgerAkka in Action: Heiko Seeburger
Akka in Action: Heiko SeeburgerJAX London
 
NoSQL Smackdown 2012 : Tim Berglund
NoSQL Smackdown 2012 : Tim BerglundNoSQL Smackdown 2012 : Tim Berglund
NoSQL Smackdown 2012 : Tim BerglundJAX London
 
Closures, the next "Big Thing" in Java: Russel Winder
Closures, the next "Big Thing" in Java: Russel WinderClosures, the next "Big Thing" in Java: Russel Winder
Closures, the next "Big Thing" in Java: Russel WinderJAX London
 
Java and the machine - Martijn Verburg and Kirk Pepperdine
Java and the machine - Martijn Verburg and Kirk PepperdineJava and the machine - Martijn Verburg and Kirk Pepperdine
Java and the machine - Martijn Verburg and Kirk PepperdineJAX London
 
Mongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsMongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsJAX London
 
New opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian RobinsonNew opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian RobinsonJAX London
 
HTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun GuptaHTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun GuptaJAX London
 
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian PloskerThe Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian PloskerJAX London
 
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...JAX London
 

Mehr von JAX London (20)

Everything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexityEverything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexity
 
Devops with the S for Sharing - Patrick Debois
Devops with the S for Sharing - Patrick DeboisDevops with the S for Sharing - Patrick Debois
Devops with the S for Sharing - Patrick Debois
 
Busy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript AppsBusy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript Apps
 
It's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick DeboisIt's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick Debois
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael Barker
 
Worse is better, for better or for worse - Kevlin Henney
Worse is better, for better or for worse - Kevlin HenneyWorse is better, for better or for worse - Kevlin Henney
Worse is better, for better or for worse - Kevlin Henney
 
Java performance: What's the big deal? - Trisha Gee
Java performance: What's the big deal? - Trisha GeeJava performance: What's the big deal? - Trisha Gee
Java performance: What's the big deal? - Trisha Gee
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias WessendorfHTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
 
Complexity theory and software development : Tim Berglund
Complexity theory and software development : Tim BerglundComplexity theory and software development : Tim Berglund
Complexity theory and software development : Tim Berglund
 
Why FLOSS is a Java developer's best friend: Dave Gruber
Why FLOSS is a Java developer's best friend: Dave GruberWhy FLOSS is a Java developer's best friend: Dave Gruber
Why FLOSS is a Java developer's best friend: Dave Gruber
 
Akka in Action: Heiko Seeburger
Akka in Action: Heiko SeeburgerAkka in Action: Heiko Seeburger
Akka in Action: Heiko Seeburger
 
NoSQL Smackdown 2012 : Tim Berglund
NoSQL Smackdown 2012 : Tim BerglundNoSQL Smackdown 2012 : Tim Berglund
NoSQL Smackdown 2012 : Tim Berglund
 
Closures, the next "Big Thing" in Java: Russel Winder
Closures, the next "Big Thing" in Java: Russel WinderClosures, the next "Big Thing" in Java: Russel Winder
Closures, the next "Big Thing" in Java: Russel Winder
 
Java and the machine - Martijn Verburg and Kirk Pepperdine
Java and the machine - Martijn Verburg and Kirk PepperdineJava and the machine - Martijn Verburg and Kirk Pepperdine
Java and the machine - Martijn Verburg and Kirk Pepperdine
 
Mongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsMongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdams
 
New opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian RobinsonNew opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian Robinson
 
HTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun GuptaHTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun Gupta
 
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian PloskerThe Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
 
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
 

Kürzlich hochgeladen

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 

Kürzlich hochgeladen (20)

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 

Play framework 2 : Peter Hilton

  • 1. Play  framework  2 @PeterHilton  at  #JAXLondon  on  17  October  2012
  • 2. 2 Peter  Hilton ■ (sorry, I am not Guillaume Bort) ■ Web developer and Operations Director at Lunatech Research in Rotterdam ■ Web application architecture, design and construction ■ Technical project management and functional design ■ Play framework committer since 2010 ■ Co-author of the book Play for Scala (Manning)
  • 3. 3 About  Lunatech ■ Founded  in  Ro*erdam  in  1993  as  an  IT  consul6ng,  product   research  and  development  team ■ We  build  web  applica6ons,  web  services,  large-­‐scale  document-­‐ processing  and  message-­‐processing  applica6ons,  online  products ■ Leverage  cuBng-­‐edge  open-­‐source  soCware  plaDorms ■ Invest  in  product  research  and  development ■ Play  framework;  Java  EE  -­‐  JBoss  AS,  Seam,  JPA,  jBPM,  Drools;   back-­‐end  -­‐  PostgreSQL,  Linux;  front-­‐end  -­‐  jQuery,  Backbone,  _.js ■ Agile  soCware  development  -­‐  self-­‐managing  technical  teams
  • 4. 4 “ Play  introduces  high-­‐produc6vity   type  safe  web  development Presenta6on  goal:  show  you  how  cool  Play  is
  • 5. 5 Outline ■ What Play is and why it matters (web architecture) ■ High-productivity web development (but for Java and Scala developers) ■ Developer Experience (DX) that doesn’t suck ■ Type safe compile-time checked web development ■ HTML5 front-end development
  • 6. 6 What  Play  is ■ Full-stack web framework (what you need to build an app) ■ Simple, flexible and powerful HTTP interface ■ High-productivity web development ■ High-performance scalable architecture ■ Designed by web developers for web developers ■ Play is fun
  • 9. 9 “ What  is  the  focal-­‐point  of  web   applica6on  architecture?
  • 10. 10 “ It’s  the  web  browser,  stupid
  • 11. 11 Why  Play  maCers The  Back  bu*on  works Play’s  stateless  architecture  is  based  on  HTTP.   When  a  web  framework  starts  an  architecture  fight   with  the  web,  the  framework  loses.
  • 12. 12 Why  Play  maCers Back   The  Reload  bu*on  works bu*on During   development,   just   reload   the   page   to  see  changes  in  your  Java  (or  Scala)  code. That’s  high-­‐produc6vity  web  development.
  • 13. 13 Why  Play  maCers Back   You  design  the  URL Reload   bu*on bu*on You  can  use  ‘clean’  URLs: /products /product/42 /product/42/comments
  • 14. 14 Why  Play  maCers Back   Usability  (DX) URL Reload   bu*on bu*on Convenient  HTTP  API   and  template  syntax Clear  error  messages   and  short  stack  traces
  • 15. 15 “ What’s  the  story  behind  the  heart  icon? “ There  isn’t  one. Feel  free  to  make  one  up  :) Guillaume  Bort
  • 16. 16 “ Play  doesn’t  fight  web  architecture Stateless,  HTTP-­‐centric  architecture…
  • 17.
  • 18. 18 Stateless  architecture ■ No state in the application’s web tier ■ e.g. Java Servlet API’s HTTP session (which isn’t actually part of HTTP) ■ State belongs in other tiers ■ HTTP client, server cache or database ■ Web application behaviour defined by URLs (requests) ■ Exception for identifying authenticated user by cookie
  • 19. 19 Stateless  architecture  -­‐  why ■ Simplifies application development and testing ■ (a URL is all you need for reproducability) ■ Matches the web’s stateless HTTP architecture ■ Avoids synchronising state between additional layers ■ (‘synchronisation’ should ring tech design alarm bells) ■ Enables cloud deployment and horizontal scalability ■ (search the web for “Play framework Heroku”)
  • 21. 21 “ Dear  Java  devs,  PHP  and  Rails  devs   have  been  laughing  at  you  for  years …  every  6me  they  reload  a  page’s  code  changes
  • 22. 22 Code  reloading ■ During development, reload the page to see changes in: ■ Java and Scala classes ■ configuration files ■ templates. ■ Play pre-compiles classes and templates for better performance in production mode ■ This just works out-of-the-box
  • 23. 23 “ URLs  want  to  be  loved  too REST  architecture  isn’t  just  for  web  service  APIs
  • 24. 24 h  t  t  p  :  /    a  p  p  .  e    a  m  p  l  e  .  c  o  m  /  W    r    o  o  t  D    r     / x a R i e c  t  o  r    1  /    e      l  e    s      A    l  a    e    s    s  s    o  n  I  d  =  x  8   y S rv t On P n ? e i 1  n  j  3  8  a  v    g    L  O  L  d  x  p  a    e  w  q  &  a  c  t  i  o  n  =  N  e  x  t   n j n P  a  g    &  H    n  e    B  a  d    e  r      r    s  =    a  l  s  e    e  n  t    t  y   e o y g Ca e f & i I  d    1  2  9  9  1  2  7  4  3  &  p  r  o  c  e  s  s  N    m  e  =    n  l  a  d  e  n   = a U S  w  a  l  l  o  w  C  o  m  p  u  t  a  t  i  o  n  &  r  o  l  e  =  p  e  o  n  &  d  a  t   e  =  1  4  %  2  F    2  %  2  F  2  0  1  2  &  f  l    g    e    t  i  n  g    =  0  1  0   0 a S t s 1  0  1  1  &  r  e  t  u  r  n  =  %  2  F  v  i  d  e  o  s  %  2  F  r  i  c  k  r  o  l  l  .  a  v  i
  • 26. 26 URL  design  (HTTP  rouMng) ■ Clean URLs are stable URLs: ■ http://example.com/products ■ http://example.com/product/42 ■ Read it, bookmark it, mail it, tweet it ■ URL-centric design: ■ Design the URL scheme before you start coding ■ Configure your application’s URLs in one file
  • 27. 27 URL  design  (HTTP  rouMng) ■ Designed URLs are clean URLs: ■ http://example.com/products ■ http://example.com/product/42 ■ Corresponding Play routing configuration: #  HTTP  routes  configuration  file #  method,  URL  path,  controller  action  method  (and  params) GET    /products            controllers.Products.list() GET    /product/:id      controllers.Products.details(id:Long)
  • 28. 28 #  HTTP  routes  configuraMon  file GET        /                            controllers.Application.index() GET        /products            controllers.Products.list() POST      /products            controllers.Products.add(p:  Product) GET        /product/:id      controllers.Products.details(id:  Long) DELETE  /product/:id      controllers.Products.delete(id:  Long) GET  /products.json        controllers.Products.listJSON() GET  /product/:id.json  controllers.Products.detailsJSON(id:Long)
  • 29. 29 “ You  have  to  be  a  genius  to  successfully   use  some  web  frameworks For  the  rest  of  us,  there  are  good  error  messages
  • 30. 30
  • 31. 31 Where’s  the  actual  error  message? 13:07:55,796  ERROR  [[PersonServlet]]  Servlet.service()  for  servlet   PersonServlet  threw  exception javax.ejb.EJBException:  null;  CausedByException  is:   null   at  org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:46)   at  org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:70)   at  org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:189)   at  org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)   at  org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:37)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:88)   at  $Proxy76.getAllPeople(Unknown  Source)   at  uk.co.mediaport.web.PersonServlet.showTelephones(PersonServlet.java:54)   at  uk.co.mediaport.web.PersonServlet.doPost(PersonServlet.java:45)   at  uk.co.mediaport.web.PersonServlet.doGet(PersonServlet.java:34)   at  javax.servlet.http.HttpServlet.service(HttpServlet.java:697)   at  javax.servlet.http.HttpServlet.service(HttpServlet.java:810)   at  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)   at  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)   at  org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)   at  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)   at  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)   at  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)   at  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)   at  org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)   at  org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)   at  org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)   at  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)   at  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)   at  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)   at  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)   at  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
  • 32.   at  org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)   at  org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)   at  org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112) 32   at  java.lang.Thread.run(Thread.java:595)   java.lang.NullPointerException   at  uk.co.mediaport.core.PeopleBean.getAllPeople(PeopleBean.java:33)   at  sun.reflect.NativeMethodAccessorImpl.invoke0(Native  Method)   at  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)   at  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)   at  java.lang.reflect.Method.invoke(Method.java:585)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)   at  org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:32)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)   at  org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:189)   at  org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)   at  org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:37)   at  org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)   at  org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:88)   at  $Proxy76.getAllPeople(Unknown  Source)   at  uk.co.mediaport.web.PersonServlet.showTelephones(PersonServlet.java:54)   at  uk.co.mediaport.web.PersonServlet.doPost(PersonServlet.java:45)   at  uk.co.mediaport.web.PersonServlet.doGet(PersonServlet.java:34)   at  javax.servlet.http.HttpServlet.service(HttpServlet.java:697)   at  javax.servlet.http.HttpServlet.service(HttpServlet.java:810)   at  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)   at  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)   at  org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)   at  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)   at  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)   at  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)   at  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)   at  org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)   at  org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)   at  org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)   at  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)   at  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)   at  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)   at  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  • 33. http://localhost/ 33 Parse error: syntax error, unexpected T_VARIABLE in /usr/local/www/htdocs/index.php on line 3
  • 34.
  • 35. 35 “ Play  2  con6nues  the  innova6on First-­‐class  support  for  both  Java  and  Scala Type-­‐safe  templates Compile-­‐6me  checking Asynchronous  HTTP  programming
  • 37. 37 Play  in  Java  and  Scala ■ Play 2.0 provides parallel APIs for Java and Scala, for example, a controller action: //  Java  controller  action  method public  static  Result  index(String  name)  {    return  ok("Hello"  +  name); } //  Scala  controller  action  method def  hello(name:  String)  =  Action  {    Ok("Hello  "  +  name) }
  • 38. 38 Play  2.0  Scala  implementaMon ■ Play 2.0 is itself implemented in Scala ■ Scala removes the need for so much bytecode enhancement in the Java API (which is how Play 1.x works) ■ There is less ‘magic’ and strangeness in the API ■ The code you see in the IDE is the code that runs ■ Scala source code not necessarily harder to read
  • 39. 39 “ Templates  want  to  be  beau6ful  too Type  safe  template  parameter  delcara6ons Minimal  interference  with  HTML  mark-­‐up
  • 40. 40 Type-­‐safe  template  parameters ■ Templates include type-safe parameter declarations ■ Similar to the lightweight template syntax in Play 1.x ■ Templates are compiled into class files for run-time speed @(products:  List[Product]) <ul>   @for(product  <-­‐  products)  {    <li  class="@product.type">@product.name</li> }   </ul>
  • 41. 41 Template  funcMons ■ Play 2.0’s template system is based on Scala ■ A template is a Scala function that you call from your code //  Render  the  ‘Products.list’  template  in  Java  code. Html  html  =  views.html.Products.list.render(products); //  e.g.  as  the  result  of  a  controller  action  method. public  static  Result  list()  {    final  List<Product>  products  =  Products.list();    return  ok(views.html.Products.list.render(products)); }
  • 42. Template syntax starts with @ 42 Template parameter declaration @(products:  List[Product]) @if(products.isEmpty)  {    <h1>No  products</h1> } No delimiter for the end of a template syntax section
  • 43. 43 @(products:  List[Product]) @if(products.isEmpty)  {    <h1>No  products</h1> }  else  {    <h1>@items.size  products</h1> } Output the value of an expression
  • 44. 44 Define a ‘tag’ - output a details page link @display(product:  models.Product)  =  {    <a  href="@routes.Products.details(product.id)">        @product.name    </a> } <ul> @for(product  <-­‐  products)  {    @display(product) }   </ul> Use the ‘display’ tag
  • 45. 45 <section  class="content">    … </section> @footer() Include the ‘footer’ template (i.e. call the ‘footer’ function)
  • 46. main.scala.html 46 @(title:  String)(content:  Html) <!DOCTYPE  html> <html> Two parameter lists    <head> (one parameter each)        <title>@title</title>    </head>    <body>        @content    </body> Define a page layout </html> template called ‘main’ index.scala.html @main("Home  page")  { Render the ‘main’ template,    <h1>Welcome</h1> passing two parameters }
  • 47. 47 “ Dear  PHP  and  Rails  developers,   run6me  errors  make  you  look  bad Using  unit  tests  to  find  syntax  errors  is  a  hack There  is  a  solu6on…
  • 48. 48
  • 49. 49 Compile-­‐Mme  checking ■ Not just Java and Scala classes ■ HTTP routes file (maps URLs to controller actions) ■ Templates ■ JavaScript files (using Google Closure Compiler) ■ CoffeeScript files (alternative to JavaScript) ■ LESS style sheets (alternative to CSS) ■ Fewer errors at run-time
  • 50. controllers/Products.java 50 public  class  Products  extends  Controller  {    public  static  Result  details(final  Long  id)  {        return  ok();    } } conf/routes GET  /product/:id      controllers.Products.details(id:  String)
  • 51. controllers/Products.java 50 public  class  Products  extends  Controller  {    public  static  Result  details(final  Long  id)  {        return  ok();    } } Incompatible types conf/routes GET  /product/:id      controllers.Products.details(id:  String)
  • 52. controllers/Products.java 50 public  class  Products  extends  Controller  {    public  static  Result  details(final  Long  id)  {        return  ok();    } } Incompatible types conf/routes GET  /product/:id      controllers.Products.details(id:  String)
  • 53.
  • 55.
  • 56.
  • 57.
  • 58. @rainbow:  -­‐webkit-­‐gradient(linear,  left  top,  left  bottom,    color-­‐stop(0.00,  red),    color-­‐stop(20%,  orange),    color-­‐stop(25%,  yellow),    color-­‐stop(30%,  yellow),    color-­‐stop(45%,  green),    color-­‐stop(65%,  blue),    color-­‐stop(80%,  indigo),    color-­‐stop(1.00,  violet));
  • 59. 57 “ Use  HTML5  technologies Choose  a  web  framework  that  lets  you Hire  or  become  a  front-­‐end  expert Use  HTML  ‘bricks’  instead  of  moulded  components
  • 60.
  • 61. 59
  • 62. 60 Modern  web  development ■ Play is designed to work with HTML5 technologies ■ No constraints on HTML output (front-end dev-friendly) ■ UI components belong in the client, e.g. JQuery UI ■ Built-in support for improvements to CSS and JavaScript: ■ LESS http://lesscss.org/ ■ CoffeeScript http://coffeescript.org/ ■ Closure Compiler http://code.google.com/closure/compiler
  • 63. 61 Single-­‐page  JavaScript  applicaMons ■ Server-side HTML templates are not the only game in town ■ JavaScript and mobile apps need web services ■ Play is great for building web services ■ You’ve already seen HTTP routing ■ Play has a type safe API for parsing/generating JSON ■ Play application architecture is natural fit for REST ■ Functionality is not tied to view templates
  • 64. 62 GeneraMng  a  JSON  response $  curl  -­‐i  http://localhost:9000/products/5010255079763 HTTP/1.1  200  OK Content-­‐Type:  application/json;  charset=utf-­‐8 Content-­‐Length:  88 {    "ean":5010255079763,    "name":"Paperclips  Large",    "description":"Large  Plain  Pack  of  1000" }
  • 65. 63 GeneraMng  a  JSON  response //  Value  object case  class  Product(ean:  Long,  name:  String,      description:  String) //  JSON  formatter implicit  object  ProductWrites  extends  Writes[Product]  {        def  writes(p:  Product)  =  Json.toJson(        Map(            "ean"  -­‐>  Json.toJson(p.ean),            "name"  -­‐>  Json.toJson(p.name),            "description"  -­‐>  Json.toJson(p.description)        )    ) } //  Controller  response Ok(Json.toJson(product))
  • 66. 64 Parsing  a  JSON  request implicit  object  ProductReads  extends  Reads[Product]  {    def  reads(json:  JsValue)  =  Product(        (json    "ean").as[Long],        (json    "name").as[String],        (json    "description").as[String]    ) } //  Controller  method  -­‐  using  the  parse.json  body  parser def  save(ean:  Long)  =  Action(parse.json)  {  request  =>    val  productJson  =  request.body    val  product  =  productJson.as[Product]    //  … }
  • 68. 66 Asynchronous  HTTP  programming  model ■ The future of web programming is asynchronous: ■ Perform simultaneous web service requests ■ Process streams, instead of filling up memory or disk ■ Publish real-time data ■ Predictable and minimal resource consumption ■ Play’s internal architecture uses a reactive model based on Iteratee IO (read about ‘Iteratees’ in the Play 2.0 docs)
  • 69. 67 Other  Play  2.0  features ■ Asynchronous web programming ■ Build environment based on sbt ■ Scala REPL (irb eat your heart out) ■ Designed for easy cloud deployment, e.g. Heroku ■ Persistence - use your favourite framework ■ Ebean (Java) or Anorm (Scala) included with Play ■ Test framework integration
  • 70. $  play   [info]  Loading  project  definition  from  /demo/project [info]  Set  current  project  to  demo  (in  build  file:/ Users/pedro/Documents/code/examples-­‐play/demo/)              _                        _    _  __  |  |  __  _  _    _|  | |  '_  |  |/  _'  |  ||  |_| |    __/|_|____|__  (_) |_|                        |__/                             play!  2.0.1,  http://www.playframework.org >  Type  "help"  or  "license"  for  more  information. >  Type  "exit"  or  use  Ctrl+D  to  leave  this  console. [demo-­‐app]  $
  • 71. [jfokus-­‐app]  $  console [info]  Starting  scala  interpreter... [info]   Welcome  to  Scala  version  2.9.1.final  (Java  HotSpot(TM)   64-­‐Bit  Server  VM,  Java  1.6.0_31). Type  in  expressions  to  have  them  evaluated. Type  :help  for  more  information. scala>
  • 72. scala>  views.html.rainbow.render res0:  play.api.templates.Html  =   <!DOCTYPE  html> <html>    <head>        <title>rainbow</title>        <link  rel="stylesheet"  type="text/css"  href="/ assets/colours.css">    </head>    <body>            <div  class="nyan">    <div  class="trail"></div>    <div  class="cat">insert  meme</div>    </div>    </body> </html>
  • 73. 71 Play  2  books ■ Play 2 for Scala, Peter Hilton, Erik Bakker, Francisco Canedo http://bit.ly/playforscala ■ Play 2 for Java, Nicolas Leroux, Sietse de Kaper http://bit.ly/playjava ■ Early Access (MEAP) editions now available
  • 74. @PeterHilton @PlayFramework www.lunatech.com www.playframework.org