SlideShare a Scribd company logo
1 of 49
Download to read offline
PLAY FRAMEWORK
« JAVA IS FUN AGAIN »
Toulouse JUG – 17 novembre 2011
Le programme
   L’histoirede Play!
   Développer avec Play!
   Test, déploiement, exploitation

   L’écosystème autour de Play!

   Le futur

   Alors, Play ou pas Play?
A propos…
    Sylvain Wallez
       Architecteexpert freelance, web & Java
       2008-2010 : CTO de Goojet/Scoop.it
       2006-2008 : Backend architect Joost
       2000-2008 : cofondateur & CTO
        Anyware Technologies
       2003 : premier VP français de la fondation
        Apache
       Membre du Tetalab, hacking Kinect & Arduino


                 sylvain@bluxte.net
                 http://bluxte.net
                 Twitter: @bluxte
L’histoire de Play
C’est quoi, c’est qui, d’où ça vient ?
L’histoire de Play
    Framework web
       Orienté    REST (urls matter !)
    Framework full stack
       http,   persistance, build, test, déploiement
    Haute productivité
       TrèsDRY
       Save / reload, recompilation à la volée



    Très inspiré de Rails et Django !            J2EE
L’histoire de Play
  Créé par Guillaume Bort (cocorico !) de Zenexity
  Open source en 2008

  Licence Apache

  Actuellement : version 1.2.3 (Java + Scala)

  Bientôt : version 2.0 (Scala + Java)
L’histoire de Play
    Les frameworks web Java sont créés par des devs
     Java, et pas des développeurs web

    Java a une culture de la complexité, préférant
     l’empilement des abstractions à la résolution
     effective des problèmes

    Mais l’écosystème Java est incroyablement riche
Développer avec Play!
Hello world… et un peu plus
L’appli finale… wow!
Création du projet
Le contrôleur

            package controllers;	
            	
            import play.data.validation.Required;	                  Méthode
            import play.mvc.Controller;	
            	
                                                                    statique
Appel du    public class Application extends Controller {	
            	
template        public static void index() {	
                    render();	
                }	
            	
                public static void hello(@Required String who) {	
            	                                                       Binding et
                    if (validation.hasErrors()) {	                  validation
 Template               render("@index");	
                    } else {	
  nommé                 render(who);	
                    }	
                }	
            }	


                                                 Modèle
                                                pour la vue
Les vues
                             index.html
  Héritage de                                              Variables
                #{set title:'Bienvenue' /}	
   template     #{extends 'main.html' /}	
                	
                <form action="@{Application.hello}"	
                       method="POST">	                     Reverse
                	                                          routing
                  <p>Dire bonjour à	
                    <input name="who"/> #{error 'who'/}	
                  </p>	
                  <p>	
                    <input type="submit"/>	
                  </p>	
                </form>	
                                                           Validation

                              hello.html
                #{set title:'Bonjour' /}	
                #{extends 'main.html' /}	
    Modèle      	
                <h1>Bonjour ${who} !</h1>	
                	
                <p>	
                  <a href="@{Application.index}">	
                     Recommencer	
                  </a>	
                </p>
Les vues

                                          main.html
             <!DOCTYPE html>	
             <html>	
                 <head>	
                      <title>${title}</title>	
                      <meta charset="${_response_encoding}">	                          CSS
                      <link rel="stylesheet" media="screen”	                        spécifiques
                            href="@{'/public/stylesheets/main.css'}">	
             	
                                                                                     à la vue
                      #{get 'moreStyles' /}	
             	
                      <link rel="shortcut icon" type="image/png”	
                            href="@{'/public/images/favicon.png'}">	
                      <script src="@{'/public/javascripts/jquery-1.5.2.min.js'}”	
                              type="text/javascript"></script>	
             	
 Inclusion            #{get 'moreScripts' /}	
de la vue    	
                 </head>	
                 <body>	
             	
                      #{doLayout /}	
             	
                 </body>	
             </html>
Lancement du serveur
L’architecture de Play!
Mais comment ça marche ?
Architecture de Play
    Modèle MVC classique…

                      HTTP
                                 Routes           DB
                     server




                     Views     Controllers     Models



     … mais une implémentation iconoclaste !
Architecture : le serveur
    Serveur HTTP : ce n’est pas du Servlet !
       Serveur NIO très léger et rapide (Netty)
       Pas de session (stateless, scalabilité horizontale)



    Besoin stateful ? API cache avec EHCache &
     Memcache fournie


                                                HTTP
                                                          Routes         DB
                                               server




                                               Views    Controllers   Models
Architecture : routage des URLs
       Routes : dispatching des requêtes sur les contrôleurs
           Tout le REST est là
Méthode                                                                               Contrôleur
 HTTP        # Home page	
             GET     /                                     Application.index	
             	
             # Ignore favicon requests	
             GET     /favicon.ico                          404	
             	
             # Map static resources from the /app/public folder to the /public path	
             GET     /public/                              staticDir:public	
             	
             # Catch all	
             *       /{controller}/{action}                {controller}.{action}	




                                                                     HTTP
                                                                                Routes             DB
                                                                    server
             Pattern


                                                                    Views     Controllers    Models
Architecture : routage des URLs
              GET    /                                      Application.index	
              	
              GET    /public/                               staticDir:public	
 « mount »    GET    /imgcache/                             staticDir:imgcache	
d’un module   	
              *      /admin                                 module:crud	
              	
              GET    /villes/{name}                         Villes.showByName	
                                                                                               URLs
              GET    /boutiques/{name}                      Boutiques.showByName	         « SEO friendly »
              GET    /categories/{name}                     Categories.showByName	
              GET    /villes/{id1}/categorie/{id2}          Villes.categorie	
              GET    /{controller}/{name},{id}              {controller}.show2	
              	
              	
              POST   /{action}                              Application.{action}_post	
              GET    /{action}                              Application.{action}	
              	
              GET    /{controller}/                         {controller}.index	
              POST   /{controller}/                         {controller}.index_post	
              	
              POST   /{controller}/-{id1}/{action}/-{id2}   {controller}.{action}_post	
              GET    /{controller}/-{id1}/{action}/-{id2}   {controller}.{action}	
                                                                                             Patterns
              	                                                                             génériques
              GET    /{controller}/-{id}                    {controller}.show	
              	
              POST   /{controller}/-{id}/{action}           {controller}.{action}_post	
              GET    /{controller}/-{id}/{action}           {controller}.{action}	
              	
              POST   /{controller}/{action}                 {controller}.{action}_post	
              GET    /{controller}/{action}                 {controller}.{action}
Architecture : contrôleurs
    Contrôleurs : méthodes statiques
       Un contrôleur est sans état
       Binding et validation automatique des paramètres

       request/response ? Pas besoin 90% du temps !




                                            HTTP
                                                      Routes         DB
                                           server




                                           Views    Controllers   Models
Architecture : contrôleur
    Paramètres de la vue : bytecode analysis pour
     extraire les variables locales
       Finis   les model.addAttribute("user",                  user)    !

                     public static void hello(@Required String who) {	
                 	
                          if (validation.hasErrors()) {	
                              render("@index");	
                          } else {	
                              render(who);	
                          }	
                     }
Architecture : modèles
    Modèles
       Attributs    publics
         Ecriture
                 simplifiée : user.getName()  user.name !
         Bytecode processing : génération des getter/setter

       DAO   : méthodes statiques


    Fin du « anemic domain model »

                                                 HTTP
                                                           Routes         DB
                                                server




                                                Views    Controllers   Models
Architecture : modèles
             package models;	
             	
             import ...	
Entité JPA   	
             @Entity	
             public class UserGroup extends Model {	
             	
                 @Required	
                 public String name;	
             	
                 @Required	
                 public String accessCode;	
             	
                 @ManyToOne	
get/set          public User coach;	
             	
générés          public long getSize() {	
                      return find("select count(u) from User u where u.group = ?", this).first();	
                 }	
             	
                 // DAO methods	
             	
                 public static UserGroup findByAccessCode(String code) {	
                      return find("accessCode", code).first();	
                 }	
  DAO        	
                 public static List<UserGroup> findByCoach(User user) {	
                      return find("select g from UserGroup g where g.isActivated = true" +	
                         	           	" and g.coach = ?", user).fetch();	
                 }	
             }
Architecture : vues
    Vues : templates Groovy
       Héritage de templates
       Nombreux tags : structures de contrôle, forms, erreurs
        de validation, tables, etc.
         Un   tag est un mini template
       Escaping   HTML par défaut !
    Autres moteurs via des modules
       Scalate,   Japid, Cambridge…
                                              HTTP
                                                        Routes         DB
                                             server




                                             Views    Controllers   Models
Architecture : vues
              <p>	
                  #{if product.ratingCount != 0}	
                    <div class="rateit" data-rateit-value="${product.rating}"></div>	
                    <a href="#">Notez ce produit</a>	
                  #{/if}	
                  #{else}	
                    <div class="rateit"></div>	
                    <a href="#">Soyez le premier à noter ce produit.</a>	
                  #{/else}	
              </p>	
              	
 Iteration            	
                      	
              #{list results, as: 'product'}	
                <p class="clear">	
                  <img src="${product.thumbnailUrl}" style="float: left"/>	
                  ${product.link}<br/>	
                  Boutique ${product.shop.link} à ${product.shop.city.link}.	
                </p>	
              #{/list}	
              	
              <div class="${page.cssClass}">	
                <h1>${page.title}</h1>	
                ${page.text.textile()}	
              </div>	
              	
 Fonctions
d’extension
Les tests avec Play!
Ah bon, faut tester ?
Les tests
    Junit, Corbertura et Selenium intégrés
       Avec   des « helpers » spécialisés
           public class ApplicationTest extends FunctionalTest {	
           	
               @Test	
               public void testThatIndexPageWorks() {	
                   Response response = GET("/");	
                   assertIsOk(response);	
                   assertContentType("text/html", response);	
                   assertCharset(play.Play.defaultWebEncoding, response);	
               }	
           }	




           #{selenium}	
               // Open the home page, and check that no error occured	
               open('/')	
               assertNotTitle('Application error')	
           #{/selenium}
Les tests
    « play test »
Les tests
Déploiement, opérations
Quand le code est fini, c’est là que tout
commence !
Déploiement
    The Play! Way
       Pull   du code (taggué) et « play start »
         Tout   est précompilé au démarrage


    The J2EE way
       « play    war » crée un war
         Permet   de s’intégrer dans un environnement J2EE
Configuration
    Fichier de properties centralisé
          # i18n	
          # ~~~~~	
          # Define locales used by your application.	
          # You can then place localized messages in conf/messages.{locale} files	
          	
          # Date format	
          # ~~~~~	
          # date.format.fr=dd/MM/yyyy	
          	
          # Server configuration	
          # ~~~~~	
          # If you need to change the HTTP port, uncomment this (default is set to 9000)	
          # http.port=9000	
          #	
          # By default the server listen for HTTP on the wilcard address.	
          # You can restrict this.	
          # http.address=127.0.0.1	
          # Session configuration	
          # ~~~~~~~~~~~~~~~~~~~~~~	
          # By default, session will be written to the transient PLAY_SESSION cookie.	
          # The cookies are not secured by default, only set it to true	
          # if you're serving your pages through https.	
          # application.session.cookie=PLAY	
          # application.session.maxAge=1h	
          # application.session.secure=false	
          	
          # JVM configuration	
          # ~~~~~	
          # Define which port is used by JPDA when application is in debug mode (default is
          set to 8000)	
          # jpda.port=8000	
          #
Configuration
        Modes dev/integration/prod, etc
                # JPA Configuration (Hibernate)	
                # ~~~~~	
                #	
                # Specify the custom JPA dialect to use here (default to guess):	
                # jpa.dialect=org.hibernate.dialect.PostgreSQLDialect	
                #	
                # Specify the ddl generation pattern to use. Set to none to disable it 	
  Config        # (default to update in DEV mode, and none in PROD mode):	
                # jpa.ddl=update	
  de tests      	
                %test.application.mode=dev	
                %test.db.url=jdbc:h2:mem:play;MODE=MYSQL;LOCK_MODE=0	
                %test.jpa.ddl=create	
                %test.mail.smtp=mock	
                	
   Config       %integration.db=mysql://root@localhost/helloworld	
                %integration.jpa.ddl=none	
d’intégration
Monitoring
    « play status »
Monitoring
    Disponible en texte et en JSON
       Intégration        très simple avec munin, collectd, etc.
    Librairie JaMon pour du monitoring applicatif facile

            Monitor monitor = MonitorFactory.start("SuperAlgorithm.findTheAnswer");	
                    	
            // Do complicated stuff	
            // (should be 42 anyway...)	
                    	
            monitor.stop();	




     Monitors:	
     ~~~~~~~~	
     SuperAlgorithm.findTheAnswer, ms.   ->   1 hits;   1038,0 avg;   1038,0 min;   1038,0 max;
L’écosystème Play!
On peut être full-stack et être accueillant !
L’écosystème
    Des modules à foison
       Systèmede plugins qui apportent composants, tags,
       templates, moteurs de persistance, générateurs de
       PDF/Excel, interfaces mobiles, etc…
    Play a son repository de modules
       Gestion  des dépendances avec Ivy
       Intégration avec tout repository Maven
L’écosystème : dépendances Ivy

          require:	
              - play	
Modules       - play -> fbgraph 0.3 :	
                    transitive : false	
 Play         - play -> secure	                                                 Dépendances
          	                                                                     Maven Central
              - com.restfb -> restfb 1.6.9	
              - org.codehaus.jackson -> jackson-core-asl 1.8.0	
              - org.codehaus.jackson -> jackson-mapper-asl 1.8.0	
              - org.apache.lucene -> lucene-core 3.3.0	
              - org.apache.lucene -> lucene-spatial 3.3.0	
              - com.hazelcast -> hazelcast 1.9.4 :	
                  exclude:	
                      - org.mockito -> *	                                         Repository
          	
              - local-lib -> json-lib 2.4-jdk15	                                     local
          	
          repositories:	
              - local-lib:	
                  type: local	
                  artifact: "${application.path}/local/lib/[module]-[revision].jar"	
                  contains:	
                      - local-lib -> *
Le futur de Play!
Scala en douceur
Le futur de Play
    Play 2.0 beta sorti hier (16 nov)
       Moteur en Scala / Akka
       API Java pour « masquer » Scala

       Templates Scala avec typage fort
       Performances extrèmes
Le futur de Play
    TypeSafe s’engage sur Play 2.0
       La société du créateur de Scala
       Play pourrait bien être la « killer app » qui fait
        décoller Scala
       L’API Java permet une évolution en douceur vers Scala
Le futur de Play
    Play 1.x is dead ?
       Non, beaucoup de projets existants
       Mais entrée en mode maintenance



    Play 2.0 est compatible avec Play 1.x ?
       Lesprincipes sont les mêmes, mais les APIs changent
       Adaptation importante nécessaire
Play ou pas Play ?
Alors, on joue ou pas ?
The good
  Oubliez J2EE, (re)découvrez la simplicité
  Fin des getters et setters !

  Beaucoup moins de code

  Reload / recompil automatique

  Des messages d’erreurs parlants

  Développement high-speed et « in the flow »
The bad
    Byte code processing
       Le   debugger n’aime pas (re-attach à chaque recompil)
        Mais   on en a aussi moins besoin !
    Méthodes statiques
       Empêche    l’héritage sur les contrôleurs
        Des   « contournements » existent dans la lib Play
    Bonne doc, mais code source peu commenté
The ugly




           (void)
The ugly



               Ah si…
       le temps nécessaire pour
         convaincre votre DSI
    (mais chuuut… « play war » et hop !)
Quand choisir Play ?
  Une application web
  Adhérence sur la couche métier acceptable

       Ou   se passer de l’intégration Play dans le modèle
  Avec des développeurs calés en HTML,
   mais pas forcément experts en Java
  Quand vous êtes pressé

  Projet court/moyen terme avec Play 1.x
Merci !



          Questions ?

          Réponses !

More Related Content

What's hot

ENIB cours CAI Web - Séance 4 - Frameworks/Spring - Cours
ENIB cours CAI Web - Séance 4 - Frameworks/Spring - CoursENIB cours CAI Web - Séance 4 - Frameworks/Spring - Cours
ENIB cours CAI Web - Séance 4 - Frameworks/Spring - CoursHoracio Gonzalez
 
GWT Principes & Techniques
GWT Principes & TechniquesGWT Principes & Techniques
GWT Principes & TechniquesRachid NID SAID
 
DrupalCamp Nantes 2016 - Migrer un site Drupal 6 ou Drupal 7 vers Drupal 8
DrupalCamp Nantes 2016 - Migrer un site Drupal 6 ou Drupal 7 vers Drupal 8DrupalCamp Nantes 2016 - Migrer un site Drupal 6 ou Drupal 7 vers Drupal 8
DrupalCamp Nantes 2016 - Migrer un site Drupal 6 ou Drupal 7 vers Drupal 8Aurelien Navarre
 
Alphorm.com Formation Scripting Bash avancé pour GNU/Linux
Alphorm.com   Formation Scripting Bash avancé pour GNU/LinuxAlphorm.com   Formation Scripting Bash avancé pour GNU/Linux
Alphorm.com Formation Scripting Bash avancé pour GNU/LinuxAlphorm
 
Support : introduction à docker
Support : introduction à dockerSupport : introduction à docker
Support : introduction à dockerBoubker ABERWAG
 
Support formation vidéo : Construire et administrer vos conteneurs avec Docker
Support formation vidéo : Construire et administrer vos conteneurs avec DockerSupport formation vidéo : Construire et administrer vos conteneurs avec Docker
Support formation vidéo : Construire et administrer vos conteneurs avec DockerSmartnSkilled
 
Initiation à Express js
Initiation à Express jsInitiation à Express js
Initiation à Express jsAbdoulaye Dieng
 
Introductions Aux Servlets
Introductions Aux ServletsIntroductions Aux Servlets
Introductions Aux ServletsFrançois Charoy
 
Workshop Spring - Session 1 - L'offre Spring et les bases
Workshop Spring  - Session 1 - L'offre Spring et les basesWorkshop Spring  - Session 1 - L'offre Spring et les bases
Workshop Spring - Session 1 - L'offre Spring et les basesAntoine Rey
 
Symfony with angular.pptx
Symfony with angular.pptxSymfony with angular.pptx
Symfony with angular.pptxEsokia
 
Microbox : Ma toolbox microservices - Julien Roy
Microbox : Ma toolbox microservices - Julien RoyMicrobox : Ma toolbox microservices - Julien Roy
Microbox : Ma toolbox microservices - Julien Royekino
 
les servlets-java EE
les  servlets-java EEles  servlets-java EE
les servlets-java EEYassine Badri
 
Formation d'architecte logiciel AFCEPF
Formation d'architecte logiciel AFCEPFFormation d'architecte logiciel AFCEPF
Formation d'architecte logiciel AFCEPFBoubker ABERWAG
 
Architecture de services web de type ressource
Architecture de services web de type ressourceArchitecture de services web de type ressource
Architecture de services web de type ressourceAntoine Pouch
 
DrupalCamp Lyon 2012 - Optimiser les performances Drupal depuis les tranchées
DrupalCamp Lyon 2012 -  Optimiser les performances Drupal depuis les tranchéesDrupalCamp Lyon 2012 -  Optimiser les performances Drupal depuis les tranchées
DrupalCamp Lyon 2012 - Optimiser les performances Drupal depuis les tranchéesAurelien Navarre
 
Quoi de neuf à Devoxx France 2017 ?
Quoi de neuf à Devoxx France 2017 ?Quoi de neuf à Devoxx France 2017 ?
Quoi de neuf à Devoxx France 2017 ?Antoine Rey
 

What's hot (20)

Les Servlets et JSP
Les Servlets et JSPLes Servlets et JSP
Les Servlets et JSP
 
ENIB cours CAI Web - Séance 4 - Frameworks/Spring - Cours
ENIB cours CAI Web - Séance 4 - Frameworks/Spring - CoursENIB cours CAI Web - Séance 4 - Frameworks/Spring - Cours
ENIB cours CAI Web - Séance 4 - Frameworks/Spring - Cours
 
GWT Principes & Techniques
GWT Principes & TechniquesGWT Principes & Techniques
GWT Principes & Techniques
 
Jsp
JspJsp
Jsp
 
APACHE HTTP
APACHE HTTPAPACHE HTTP
APACHE HTTP
 
DrupalCamp Nantes 2016 - Migrer un site Drupal 6 ou Drupal 7 vers Drupal 8
DrupalCamp Nantes 2016 - Migrer un site Drupal 6 ou Drupal 7 vers Drupal 8DrupalCamp Nantes 2016 - Migrer un site Drupal 6 ou Drupal 7 vers Drupal 8
DrupalCamp Nantes 2016 - Migrer un site Drupal 6 ou Drupal 7 vers Drupal 8
 
Alphorm.com Formation Scripting Bash avancé pour GNU/Linux
Alphorm.com   Formation Scripting Bash avancé pour GNU/LinuxAlphorm.com   Formation Scripting Bash avancé pour GNU/Linux
Alphorm.com Formation Scripting Bash avancé pour GNU/Linux
 
Support : introduction à docker
Support : introduction à dockerSupport : introduction à docker
Support : introduction à docker
 
Support formation vidéo : Construire et administrer vos conteneurs avec Docker
Support formation vidéo : Construire et administrer vos conteneurs avec DockerSupport formation vidéo : Construire et administrer vos conteneurs avec Docker
Support formation vidéo : Construire et administrer vos conteneurs avec Docker
 
Initiation à Express js
Initiation à Express jsInitiation à Express js
Initiation à Express js
 
Introductions Aux Servlets
Introductions Aux ServletsIntroductions Aux Servlets
Introductions Aux Servlets
 
Workshop Spring - Session 1 - L'offre Spring et les bases
Workshop Spring  - Session 1 - L'offre Spring et les basesWorkshop Spring  - Session 1 - L'offre Spring et les bases
Workshop Spring - Session 1 - L'offre Spring et les bases
 
Symfony with angular.pptx
Symfony with angular.pptxSymfony with angular.pptx
Symfony with angular.pptx
 
Microbox : Ma toolbox microservices - Julien Roy
Microbox : Ma toolbox microservices - Julien RoyMicrobox : Ma toolbox microservices - Julien Roy
Microbox : Ma toolbox microservices - Julien Roy
 
les servlets-java EE
les  servlets-java EEles  servlets-java EE
les servlets-java EE
 
Servlets et JSP
Servlets et JSPServlets et JSP
Servlets et JSP
 
Formation d'architecte logiciel AFCEPF
Formation d'architecte logiciel AFCEPFFormation d'architecte logiciel AFCEPF
Formation d'architecte logiciel AFCEPF
 
Architecture de services web de type ressource
Architecture de services web de type ressourceArchitecture de services web de type ressource
Architecture de services web de type ressource
 
DrupalCamp Lyon 2012 - Optimiser les performances Drupal depuis les tranchées
DrupalCamp Lyon 2012 -  Optimiser les performances Drupal depuis les tranchéesDrupalCamp Lyon 2012 -  Optimiser les performances Drupal depuis les tranchées
DrupalCamp Lyon 2012 - Optimiser les performances Drupal depuis les tranchées
 
Quoi de neuf à Devoxx France 2017 ?
Quoi de neuf à Devoxx France 2017 ?Quoi de neuf à Devoxx France 2017 ?
Quoi de neuf à Devoxx France 2017 ?
 

Viewers also liked

Philips Big Data Expo
Philips Big Data ExpoPhilips Big Data Expo
Philips Big Data ExpoBigDataExpo
 
Becoming the master of disaster... with asr
Becoming the master of disaster... with asrBecoming the master of disaster... with asr
Becoming the master of disaster... with asrnj-azure
 
General physicians and the adf Heddle
General physicians and the adf HeddleGeneral physicians and the adf Heddle
General physicians and the adf HeddleLeishman Associates
 
(SEC320) Leveraging the Power of AWS to Automate Security & Compliance
(SEC320) Leveraging the Power of AWS to Automate Security & Compliance(SEC320) Leveraging the Power of AWS to Automate Security & Compliance
(SEC320) Leveraging the Power of AWS to Automate Security & ComplianceAmazon Web Services
 
Big data for cio 2015
Big data for cio 2015Big data for cio 2015
Big data for cio 2015Zohar Elkayam
 
Global Azure Bootcamp - Azure OMS
Global Azure Bootcamp - Azure OMSGlobal Azure Bootcamp - Azure OMS
Global Azure Bootcamp - Azure OMSBruno Lopes
 
“Ūdens resursi. Saglabāsim ūdeni kopā!” Pasaules lielākā mācību stunda Daugav...
“Ūdens resursi. Saglabāsim ūdeni kopā!” Pasaules lielākā mācību stunda Daugav...“Ūdens resursi. Saglabāsim ūdeni kopā!” Pasaules lielākā mācību stunda Daugav...
“Ūdens resursi. Saglabāsim ūdeni kopā!” Pasaules lielākā mācību stunda Daugav...liela_stunda
 
2011_Herbstcampus_Rapid_Cloud_Development_with_Spring_Roo
2011_Herbstcampus_Rapid_Cloud_Development_with_Spring_Roo2011_Herbstcampus_Rapid_Cloud_Development_with_Spring_Roo
2011_Herbstcampus_Rapid_Cloud_Development_with_Spring_RooKai Wähner
 
Delivering Quality Open Data by Chelsea Ursaner
Delivering Quality Open Data by Chelsea UrsanerDelivering Quality Open Data by Chelsea Ursaner
Delivering Quality Open Data by Chelsea UrsanerData Con LA
 
I1 - Securing Office 365 and Microsoft Azure like a rockstar (or like a group...
I1 - Securing Office 365 and Microsoft Azure like a rockstar (or like a group...I1 - Securing Office 365 and Microsoft Azure like a rockstar (or like a group...
I1 - Securing Office 365 and Microsoft Azure like a rockstar (or like a group...SPS Paris
 
Walmart Big Data Expo
Walmart Big Data ExpoWalmart Big Data Expo
Walmart Big Data ExpoBigDataExpo
 
100 blue mix days technical training
100 blue mix days technical training100 blue mix days technical training
100 blue mix days technical trainingAjit Yohannan
 
Docker containerization cookbook
Docker containerization cookbookDocker containerization cookbook
Docker containerization cookbookPascal Louis
 
Challenges and outlook with Big Data
Challenges and outlook with Big Data Challenges and outlook with Big Data
Challenges and outlook with Big Data IJCERT JOURNAL
 

Viewers also liked (20)

Philips Big Data Expo
Philips Big Data ExpoPhilips Big Data Expo
Philips Big Data Expo
 
Water resources
Water resourcesWater resources
Water resources
 
Oracle Cloud Café IoT 12-APR-2016
Oracle Cloud Café IoT 12-APR-2016Oracle Cloud Café IoT 12-APR-2016
Oracle Cloud Café IoT 12-APR-2016
 
Becoming the master of disaster... with asr
Becoming the master of disaster... with asrBecoming the master of disaster... with asr
Becoming the master of disaster... with asr
 
General physicians and the adf Heddle
General physicians and the adf HeddleGeneral physicians and the adf Heddle
General physicians and the adf Heddle
 
(SEC320) Leveraging the Power of AWS to Automate Security & Compliance
(SEC320) Leveraging the Power of AWS to Automate Security & Compliance(SEC320) Leveraging the Power of AWS to Automate Security & Compliance
(SEC320) Leveraging the Power of AWS to Automate Security & Compliance
 
Understanding big data
Understanding big dataUnderstanding big data
Understanding big data
 
Big data for cio 2015
Big data for cio 2015Big data for cio 2015
Big data for cio 2015
 
Global Azure Bootcamp - Azure OMS
Global Azure Bootcamp - Azure OMSGlobal Azure Bootcamp - Azure OMS
Global Azure Bootcamp - Azure OMS
 
Bol.com
Bol.comBol.com
Bol.com
 
“Ūdens resursi. Saglabāsim ūdeni kopā!” Pasaules lielākā mācību stunda Daugav...
“Ūdens resursi. Saglabāsim ūdeni kopā!” Pasaules lielākā mācību stunda Daugav...“Ūdens resursi. Saglabāsim ūdeni kopā!” Pasaules lielākā mācību stunda Daugav...
“Ūdens resursi. Saglabāsim ūdeni kopā!” Pasaules lielākā mācību stunda Daugav...
 
Gastles PXL Hogeschool 2017
Gastles PXL Hogeschool 2017Gastles PXL Hogeschool 2017
Gastles PXL Hogeschool 2017
 
Voetsporen 38
Voetsporen 38Voetsporen 38
Voetsporen 38
 
2011_Herbstcampus_Rapid_Cloud_Development_with_Spring_Roo
2011_Herbstcampus_Rapid_Cloud_Development_with_Spring_Roo2011_Herbstcampus_Rapid_Cloud_Development_with_Spring_Roo
2011_Herbstcampus_Rapid_Cloud_Development_with_Spring_Roo
 
Delivering Quality Open Data by Chelsea Ursaner
Delivering Quality Open Data by Chelsea UrsanerDelivering Quality Open Data by Chelsea Ursaner
Delivering Quality Open Data by Chelsea Ursaner
 
I1 - Securing Office 365 and Microsoft Azure like a rockstar (or like a group...
I1 - Securing Office 365 and Microsoft Azure like a rockstar (or like a group...I1 - Securing Office 365 and Microsoft Azure like a rockstar (or like a group...
I1 - Securing Office 365 and Microsoft Azure like a rockstar (or like a group...
 
Walmart Big Data Expo
Walmart Big Data ExpoWalmart Big Data Expo
Walmart Big Data Expo
 
100 blue mix days technical training
100 blue mix days technical training100 blue mix days technical training
100 blue mix days technical training
 
Docker containerization cookbook
Docker containerization cookbookDocker containerization cookbook
Docker containerization cookbook
 
Challenges and outlook with Big Data
Challenges and outlook with Big Data Challenges and outlook with Big Data
Challenges and outlook with Big Data
 

Similar to Play Framework - Toulouse JUG - nov 2011

Présentation de Ruby on Rails
Présentation de Ruby on RailsPrésentation de Ruby on Rails
Présentation de Ruby on RailsJulien Blin
 
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)Café Numérique Arlon
 
Play framework - Human Talks Grenoble - 12.02.2013
Play framework - Human Talks Grenoble - 12.02.2013Play framework - Human Talks Grenoble - 12.02.2013
Play framework - Human Talks Grenoble - 12.02.2013Xavier NOPRE
 
Java EE _ Servlet et vue (1).pdf
Java EE _ Servlet et vue (1).pdfJava EE _ Servlet et vue (1).pdf
Java EE _ Servlet et vue (1).pdfColombieColombie
 
Introduction à Sinatra
Introduction à SinatraIntroduction à Sinatra
Introduction à SinatraRémi Prévost
 
Quelle place pour le framework Rails dans le développement d'application web
Quelle place pour le framework Rails dans le développement d'application webQuelle place pour le framework Rails dans le développement d'application web
Quelle place pour le framework Rails dans le développement d'application web5pidou
 
Web dev open door
Web dev   open doorWeb dev   open door
Web dev open doorLeTesteur
 
Cours yeoman backbone box2d
Cours yeoman backbone box2dCours yeoman backbone box2d
Cours yeoman backbone box2dhugomallet
 
vue j'avais pas vu !!
vue j'avais pas vu !!vue j'avais pas vu !!
vue j'avais pas vu !!Manuel Adele
 
Vue, j’avais pas vu !
Vue, j’avais pas vu !Vue, j’avais pas vu !
Vue, j’avais pas vu !Bruno Bonnin
 
Introduction à AngularJS
Introduction à AngularJSIntroduction à AngularJS
Introduction à AngularJSAbdoulaye Dieng
 
Codedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
Codedarmor 2012 - 06/03 - HTML5, CSS3 et JavascriptCodedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
Codedarmor 2012 - 06/03 - HTML5, CSS3 et Javascriptcodedarmor
 
#J2Code2018 - Mettez du feu à vos applications avec CodeIgniter
#J2Code2018 - Mettez du feu à vos applications avec CodeIgniter#J2Code2018 - Mettez du feu à vos applications avec CodeIgniter
#J2Code2018 - Mettez du feu à vos applications avec CodeIgniterAtsé François-Xavier KOBON
 
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...Jean-Laurent de Morlhon
 
La mobilité dans Drupal
La mobilité dans DrupalLa mobilité dans Drupal
La mobilité dans DrupalAdyax
 

Similar to Play Framework - Toulouse JUG - nov 2011 (20)

Présentation de Ruby on Rails
Présentation de Ruby on RailsPrésentation de Ruby on Rails
Présentation de Ruby on Rails
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)
 
Play framework - Human Talks Grenoble - 12.02.2013
Play framework - Human Talks Grenoble - 12.02.2013Play framework - Human Talks Grenoble - 12.02.2013
Play framework - Human Talks Grenoble - 12.02.2013
 
Java EE _ Servlet et vue (1).pdf
Java EE _ Servlet et vue (1).pdfJava EE _ Servlet et vue (1).pdf
Java EE _ Servlet et vue (1).pdf
 
Introduction à Sinatra
Introduction à SinatraIntroduction à Sinatra
Introduction à Sinatra
 
Quelle place pour le framework Rails dans le développement d'application web
Quelle place pour le framework Rails dans le développement d'application webQuelle place pour le framework Rails dans le développement d'application web
Quelle place pour le framework Rails dans le développement d'application web
 
Services rest & jersey
Services rest & jerseyServices rest & jersey
Services rest & jersey
 
Web dev open door
Web dev   open doorWeb dev   open door
Web dev open door
 
Backbonejs presentation
Backbonejs presentationBackbonejs presentation
Backbonejs presentation
 
Gradle
GradleGradle
Gradle
 
Cours yeoman backbone box2d
Cours yeoman backbone box2dCours yeoman backbone box2d
Cours yeoman backbone box2d
 
vue j'avais pas vu !!
vue j'avais pas vu !!vue j'avais pas vu !!
vue j'avais pas vu !!
 
Vue, j’avais pas vu !
Vue, j’avais pas vu !Vue, j’avais pas vu !
Vue, j’avais pas vu !
 
Introduction à AngularJS
Introduction à AngularJSIntroduction à AngularJS
Introduction à AngularJS
 
Codedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
Codedarmor 2012 - 06/03 - HTML5, CSS3 et JavascriptCodedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
Codedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
 
#J2Code2018 - Mettez du feu à vos applications avec CodeIgniter
#J2Code2018 - Mettez du feu à vos applications avec CodeIgniter#J2Code2018 - Mettez du feu à vos applications avec CodeIgniter
#J2Code2018 - Mettez du feu à vos applications avec CodeIgniter
 
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...
 
Intro à angular
Intro à angularIntro à angular
Intro à angular
 
La mobilité dans Drupal
La mobilité dans DrupalLa mobilité dans Drupal
La mobilité dans Drupal
 

More from Sylvain Wallez

Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGSylvain Wallez
 
Developing web applications in Rust
Developing web applications in RustDeveloping web applications in Rust
Developing web applications in RustSylvain Wallez
 
Black friday logs - Scaling Elasticsearch
Black friday logs - Scaling ElasticsearchBlack friday logs - Scaling Elasticsearch
Black friday logs - Scaling ElasticsearchSylvain Wallez
 
Elastic - From 50 to 270, how to scale a distributed engineering team
Elastic - From 50 to 270, how to scale a distributed engineering teamElastic - From 50 to 270, how to scale a distributed engineering team
Elastic - From 50 to 270, how to scale a distributed engineering teamSylvain Wallez
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Sylvain Wallez
 
Introduction au langage Go
Introduction au langage GoIntroduction au langage Go
Introduction au langage GoSylvain Wallez
 
Kibana + timelion: time series with the elastic stack
Kibana + timelion: time series with the elastic stackKibana + timelion: time series with the elastic stack
Kibana + timelion: time series with the elastic stackSylvain Wallez
 
2016 05 iot - apero web
2016 05 iot - apero web2016 05 iot - apero web
2016 05 iot - apero webSylvain Wallez
 
Brown Bag Lunch sur Hazelcast
Brown Bag Lunch sur HazelcastBrown Bag Lunch sur Hazelcast
Brown Bag Lunch sur HazelcastSylvain Wallez
 
Lucene - 10 ans d'usages plus ou moins classiques
Lucene - 10 ans d'usages plus ou moins classiquesLucene - 10 ans d'usages plus ou moins classiques
Lucene - 10 ans d'usages plus ou moins classiquesSylvain Wallez
 
2012 11 Toulibre - Open Hardware
2012 11 Toulibre - Open Hardware2012 11 Toulibre - Open Hardware
2012 11 Toulibre - Open HardwareSylvain Wallez
 
Développement avec Java Micro Edition
Développement avec Java Micro EditionDéveloppement avec Java Micro Edition
Développement avec Java Micro EditionSylvain Wallez
 

More from Sylvain Wallez (13)

Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUG
 
Developing web applications in Rust
Developing web applications in RustDeveloping web applications in Rust
Developing web applications in Rust
 
Black friday logs - Scaling Elasticsearch
Black friday logs - Scaling ElasticsearchBlack friday logs - Scaling Elasticsearch
Black friday logs - Scaling Elasticsearch
 
Elastic - From 50 to 270, how to scale a distributed engineering team
Elastic - From 50 to 270, how to scale a distributed engineering teamElastic - From 50 to 270, how to scale a distributed engineering team
Elastic - From 50 to 270, how to scale a distributed engineering team
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
 
Introduction au langage Go
Introduction au langage GoIntroduction au langage Go
Introduction au langage Go
 
Kibana + timelion: time series with the elastic stack
Kibana + timelion: time series with the elastic stackKibana + timelion: time series with the elastic stack
Kibana + timelion: time series with the elastic stack
 
2016 05 iot - apero web
2016 05 iot - apero web2016 05 iot - apero web
2016 05 iot - apero web
 
Brown Bag Lunch sur Hazelcast
Brown Bag Lunch sur HazelcastBrown Bag Lunch sur Hazelcast
Brown Bag Lunch sur Hazelcast
 
Lucene - 10 ans d'usages plus ou moins classiques
Lucene - 10 ans d'usages plus ou moins classiquesLucene - 10 ans d'usages plus ou moins classiques
Lucene - 10 ans d'usages plus ou moins classiques
 
2012 11 Toulibre - Open Hardware
2012 11 Toulibre - Open Hardware2012 11 Toulibre - Open Hardware
2012 11 Toulibre - Open Hardware
 
Développement avec Java Micro Edition
Développement avec Java Micro EditionDéveloppement avec Java Micro Edition
Développement avec Java Micro Edition
 

Play Framework - Toulouse JUG - nov 2011

  • 1. PLAY FRAMEWORK « JAVA IS FUN AGAIN » Toulouse JUG – 17 novembre 2011
  • 2. Le programme   L’histoirede Play!   Développer avec Play!   Test, déploiement, exploitation   L’écosystème autour de Play!   Le futur   Alors, Play ou pas Play?
  • 3. A propos…   Sylvain Wallez   Architecteexpert freelance, web & Java   2008-2010 : CTO de Goojet/Scoop.it   2006-2008 : Backend architect Joost   2000-2008 : cofondateur & CTO Anyware Technologies   2003 : premier VP français de la fondation Apache   Membre du Tetalab, hacking Kinect & Arduino sylvain@bluxte.net http://bluxte.net Twitter: @bluxte
  • 4. L’histoire de Play C’est quoi, c’est qui, d’où ça vient ?
  • 5. L’histoire de Play   Framework web   Orienté REST (urls matter !)   Framework full stack   http, persistance, build, test, déploiement   Haute productivité   TrèsDRY   Save / reload, recompilation à la volée   Très inspiré de Rails et Django ! J2EE
  • 6. L’histoire de Play   Créé par Guillaume Bort (cocorico !) de Zenexity   Open source en 2008   Licence Apache   Actuellement : version 1.2.3 (Java + Scala)   Bientôt : version 2.0 (Scala + Java)
  • 7. L’histoire de Play   Les frameworks web Java sont créés par des devs Java, et pas des développeurs web   Java a une culture de la complexité, préférant l’empilement des abstractions à la résolution effective des problèmes   Mais l’écosystème Java est incroyablement riche
  • 8. Développer avec Play! Hello world… et un peu plus
  • 11. Le contrôleur package controllers; import play.data.validation.Required; Méthode import play.mvc.Controller; statique Appel du public class Application extends Controller { template public static void index() { render(); } public static void hello(@Required String who) { Binding et if (validation.hasErrors()) { validation Template render("@index"); } else { nommé render(who); } } } Modèle pour la vue
  • 12. Les vues index.html Héritage de Variables #{set title:'Bienvenue' /} template #{extends 'main.html' /} <form action="@{Application.hello}" method="POST"> Reverse routing <p>Dire bonjour à <input name="who"/> #{error 'who'/} </p> <p> <input type="submit"/> </p> </form> Validation hello.html #{set title:'Bonjour' /} #{extends 'main.html' /} Modèle <h1>Bonjour ${who} !</h1> <p> <a href="@{Application.index}"> Recommencer </a> </p>
  • 13. Les vues main.html <!DOCTYPE html> <html> <head> <title>${title}</title> <meta charset="${_response_encoding}"> CSS <link rel="stylesheet" media="screen” spécifiques href="@{'/public/stylesheets/main.css'}"> à la vue #{get 'moreStyles' /} <link rel="shortcut icon" type="image/png” href="@{'/public/images/favicon.png'}"> <script src="@{'/public/javascripts/jquery-1.5.2.min.js'}” type="text/javascript"></script> Inclusion #{get 'moreScripts' /} de la vue </head> <body> #{doLayout /} </body> </html>
  • 15. L’architecture de Play! Mais comment ça marche ?
  • 16. Architecture de Play   Modèle MVC classique… HTTP Routes DB server Views Controllers Models … mais une implémentation iconoclaste !
  • 17. Architecture : le serveur   Serveur HTTP : ce n’est pas du Servlet !   Serveur NIO très léger et rapide (Netty)   Pas de session (stateless, scalabilité horizontale)   Besoin stateful ? API cache avec EHCache & Memcache fournie HTTP Routes DB server Views Controllers Models
  • 18. Architecture : routage des URLs   Routes : dispatching des requêtes sur les contrôleurs  Tout le REST est là Méthode Contrôleur HTTP # Home page GET / Application.index # Ignore favicon requests GET /favicon.ico 404 # Map static resources from the /app/public folder to the /public path GET /public/ staticDir:public # Catch all * /{controller}/{action} {controller}.{action} HTTP Routes DB server Pattern Views Controllers Models
  • 19. Architecture : routage des URLs GET / Application.index GET /public/ staticDir:public « mount » GET /imgcache/ staticDir:imgcache d’un module * /admin module:crud GET /villes/{name} Villes.showByName URLs GET /boutiques/{name} Boutiques.showByName « SEO friendly » GET /categories/{name} Categories.showByName GET /villes/{id1}/categorie/{id2} Villes.categorie GET /{controller}/{name},{id} {controller}.show2 POST /{action} Application.{action}_post GET /{action} Application.{action} GET /{controller}/ {controller}.index POST /{controller}/ {controller}.index_post POST /{controller}/-{id1}/{action}/-{id2} {controller}.{action}_post GET /{controller}/-{id1}/{action}/-{id2} {controller}.{action} Patterns génériques GET /{controller}/-{id} {controller}.show POST /{controller}/-{id}/{action} {controller}.{action}_post GET /{controller}/-{id}/{action} {controller}.{action} POST /{controller}/{action} {controller}.{action}_post GET /{controller}/{action} {controller}.{action}
  • 20. Architecture : contrôleurs   Contrôleurs : méthodes statiques   Un contrôleur est sans état   Binding et validation automatique des paramètres   request/response ? Pas besoin 90% du temps ! HTTP Routes DB server Views Controllers Models
  • 21. Architecture : contrôleur   Paramètres de la vue : bytecode analysis pour extraire les variables locales   Finis les model.addAttribute("user", user) ! public static void hello(@Required String who) { if (validation.hasErrors()) { render("@index"); } else { render(who); } }
  • 22. Architecture : modèles   Modèles   Attributs publics   Ecriture simplifiée : user.getName()  user.name !   Bytecode processing : génération des getter/setter   DAO : méthodes statiques   Fin du « anemic domain model » HTTP Routes DB server Views Controllers Models
  • 23. Architecture : modèles package models; import ... Entité JPA @Entity public class UserGroup extends Model { @Required public String name; @Required public String accessCode; @ManyToOne get/set public User coach; générés public long getSize() { return find("select count(u) from User u where u.group = ?", this).first(); } // DAO methods public static UserGroup findByAccessCode(String code) { return find("accessCode", code).first(); } DAO public static List<UserGroup> findByCoach(User user) { return find("select g from UserGroup g where g.isActivated = true" + " and g.coach = ?", user).fetch(); } }
  • 24. Architecture : vues   Vues : templates Groovy   Héritage de templates   Nombreux tags : structures de contrôle, forms, erreurs de validation, tables, etc.   Un tag est un mini template   Escaping HTML par défaut !   Autres moteurs via des modules   Scalate, Japid, Cambridge… HTTP Routes DB server Views Controllers Models
  • 25. Architecture : vues <p> #{if product.ratingCount != 0} <div class="rateit" data-rateit-value="${product.rating}"></div> <a href="#">Notez ce produit</a> #{/if} #{else} <div class="rateit"></div> <a href="#">Soyez le premier à noter ce produit.</a> #{/else} </p> Iteration #{list results, as: 'product'} <p class="clear"> <img src="${product.thumbnailUrl}" style="float: left"/> ${product.link}<br/> Boutique ${product.shop.link} à ${product.shop.city.link}. </p> #{/list} <div class="${page.cssClass}"> <h1>${page.title}</h1> ${page.text.textile()} </div> Fonctions d’extension
  • 26. Les tests avec Play! Ah bon, faut tester ?
  • 27. Les tests   Junit, Corbertura et Selenium intégrés   Avec des « helpers » spécialisés public class ApplicationTest extends FunctionalTest { @Test public void testThatIndexPageWorks() { Response response = GET("/"); assertIsOk(response); assertContentType("text/html", response); assertCharset(play.Play.defaultWebEncoding, response); } } #{selenium} // Open the home page, and check that no error occured open('/') assertNotTitle('Application error') #{/selenium}
  • 28. Les tests   « play test »
  • 30. Déploiement, opérations Quand le code est fini, c’est là que tout commence !
  • 31. Déploiement   The Play! Way   Pull du code (taggué) et « play start »  Tout est précompilé au démarrage   The J2EE way   « play war » crée un war  Permet de s’intégrer dans un environnement J2EE
  • 32. Configuration   Fichier de properties centralisé # i18n # ~~~~~ # Define locales used by your application. # You can then place localized messages in conf/messages.{locale} files # Date format # ~~~~~ # date.format.fr=dd/MM/yyyy # Server configuration # ~~~~~ # If you need to change the HTTP port, uncomment this (default is set to 9000) # http.port=9000 # # By default the server listen for HTTP on the wilcard address. # You can restrict this. # http.address=127.0.0.1 # Session configuration # ~~~~~~~~~~~~~~~~~~~~~~ # By default, session will be written to the transient PLAY_SESSION cookie. # The cookies are not secured by default, only set it to true # if you're serving your pages through https. # application.session.cookie=PLAY # application.session.maxAge=1h # application.session.secure=false # JVM configuration # ~~~~~ # Define which port is used by JPDA when application is in debug mode (default is set to 8000) # jpda.port=8000 #
  • 33. Configuration   Modes dev/integration/prod, etc # JPA Configuration (Hibernate) # ~~~~~ # # Specify the custom JPA dialect to use here (default to guess): # jpa.dialect=org.hibernate.dialect.PostgreSQLDialect # # Specify the ddl generation pattern to use. Set to none to disable it Config # (default to update in DEV mode, and none in PROD mode): # jpa.ddl=update de tests %test.application.mode=dev %test.db.url=jdbc:h2:mem:play;MODE=MYSQL;LOCK_MODE=0 %test.jpa.ddl=create %test.mail.smtp=mock Config %integration.db=mysql://root@localhost/helloworld %integration.jpa.ddl=none d’intégration
  • 34. Monitoring   « play status »
  • 35. Monitoring   Disponible en texte et en JSON   Intégration très simple avec munin, collectd, etc.   Librairie JaMon pour du monitoring applicatif facile Monitor monitor = MonitorFactory.start("SuperAlgorithm.findTheAnswer"); // Do complicated stuff // (should be 42 anyway...) monitor.stop(); Monitors: ~~~~~~~~ SuperAlgorithm.findTheAnswer, ms. -> 1 hits; 1038,0 avg; 1038,0 min; 1038,0 max;
  • 36. L’écosystème Play! On peut être full-stack et être accueillant !
  • 37. L’écosystème   Des modules à foison   Systèmede plugins qui apportent composants, tags, templates, moteurs de persistance, générateurs de PDF/Excel, interfaces mobiles, etc…   Play a son repository de modules   Gestion des dépendances avec Ivy   Intégration avec tout repository Maven
  • 38. L’écosystème : dépendances Ivy require: - play Modules - play -> fbgraph 0.3 : transitive : false Play - play -> secure Dépendances Maven Central - com.restfb -> restfb 1.6.9 - org.codehaus.jackson -> jackson-core-asl 1.8.0 - org.codehaus.jackson -> jackson-mapper-asl 1.8.0 - org.apache.lucene -> lucene-core 3.3.0 - org.apache.lucene -> lucene-spatial 3.3.0 - com.hazelcast -> hazelcast 1.9.4 : exclude: - org.mockito -> * Repository - local-lib -> json-lib 2.4-jdk15 local repositories: - local-lib: type: local artifact: "${application.path}/local/lib/[module]-[revision].jar" contains: - local-lib -> *
  • 39. Le futur de Play! Scala en douceur
  • 40. Le futur de Play   Play 2.0 beta sorti hier (16 nov)   Moteur en Scala / Akka   API Java pour « masquer » Scala   Templates Scala avec typage fort   Performances extrèmes
  • 41. Le futur de Play   TypeSafe s’engage sur Play 2.0   La société du créateur de Scala   Play pourrait bien être la « killer app » qui fait décoller Scala   L’API Java permet une évolution en douceur vers Scala
  • 42. Le futur de Play   Play 1.x is dead ?   Non, beaucoup de projets existants   Mais entrée en mode maintenance   Play 2.0 est compatible avec Play 1.x ?   Lesprincipes sont les mêmes, mais les APIs changent   Adaptation importante nécessaire
  • 43. Play ou pas Play ? Alors, on joue ou pas ?
  • 44. The good   Oubliez J2EE, (re)découvrez la simplicité   Fin des getters et setters !   Beaucoup moins de code   Reload / recompil automatique   Des messages d’erreurs parlants   Développement high-speed et « in the flow »
  • 45. The bad   Byte code processing   Le debugger n’aime pas (re-attach à chaque recompil)  Mais on en a aussi moins besoin !   Méthodes statiques   Empêche l’héritage sur les contrôleurs  Des « contournements » existent dans la lib Play   Bonne doc, mais code source peu commenté
  • 46. The ugly (void)
  • 47. The ugly Ah si… le temps nécessaire pour convaincre votre DSI (mais chuuut… « play war » et hop !)
  • 48. Quand choisir Play ?   Une application web   Adhérence sur la couche métier acceptable   Ou se passer de l’intégration Play dans le modèle   Avec des développeurs calés en HTML, mais pas forcément experts en Java   Quand vous êtes pressé   Projet court/moyen terme avec Play 1.x
  • 49. Merci ! Questions ? Réponses !