SlideShare une entreprise Scribd logo
1  sur  15
Télécharger pour lire hors ligne
GRENOBLE

              Play framework (V1) :
     simplicité et productivité au service du
                développement WEB en Java

                 Xavier NOPRE – 12/02/2013
Préambule > Sondage

    Développeur Java ?

    Qui connait Play Framework ?
    Qui utilise Play Framework ?
        V1 ?
        V2 ?


    Précision …



    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Introduction
    Framework WEB complet
    Pour des développeurs pour des développeurs
    Pour une approche + simple et + rapide (vs JEE ou Spring)
    Constitué de composants choisis (JPA, Hibernate, …)
    Architecture Model View Controller
    Rechargement à chaud en mode "dev"
    Présentation des erreurs "serveur" dans la page HTML
     (explication et extrait de code)
    Stateless & REST
    Basé sur des conventions
                          Productivité !
    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Installation & démarrage
    Téléchargement play-1.2.5.zip :
     http://downloads.typesafe.com/releases/play-1.2.4.zip
    Extraction et ajout au PATH
    Création d'une nouvelle application :
          > play new demo-human-talks
    Préparation pour Eclipse :
          > play eclipsify
    Exécution :
          > play run
    Accès :
          http://localhost:9000/
           Principes, documentation local, API



    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Installation & démarrage




Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Structure
    Répertoires :
        config/  fichiers de configuration
        app/
          models/  classes pour les modèles objet (mapping JPA)
          controllers/  classes pour les contrôleurs
          views/  fichier HTML de templating pour les vues

        test/  tests unitaires et tests fonctionnels
        public/  ressources statiques (images, CSS, Javascript)




    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Configuration
    Répertoire "conf":
        application.conf : configuration générale de l'application :
          Nom, mode (dev / prod), langs
          Serveur HTTP et sessions
          Logs
          Base de donnée : mémoire, fichier, MySQL, PostgreSQL, JDBC, …
          JPA, memcached, proxy, mail, …
        dependencies.yml
          Dépendances (artefacts type Maven ou Ivy)
        routes
          Routages : URL  controller.action
        messages
          Internationalisation i18n (multi-langue)



    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Configuration > dépendances
    Artefacts disponibles sur des repositories publiques :
            conf/dependencies.yml
            # Application dependencies

            require:
                - play
                - play -> crud
                - play -> secure
                - org.apache.commons -> commons-lang3 3.1
                - org.mockito -> mockito-all 1.9.5
                - org.easytesting -> fest-assert 1.4


    Mise à jour des dépendances :
          > play dependencies

    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Configuration > routage URLs
    Définitions des routages entre URL et actions des
     contrôleurs, et inversement
     conf/routes
     GET     /                                    Application.index
     GET     /public/                             staticDir:public
     *       /{controller}/{action}               {controller}.{action}
     # Backbone
     GET     /bb/projects                         BBProjects.getProjects
     GET     /bb/project/{id}                     BBProjects.getProject
     POST    /bb/project                          BBProjects.createProject
     PUT     /bb/project/{id}                     BBProjects.updateProject
     DELETE /bb/project/{id}                      BBProjects.deleteProject
     POST    /bb/project/public/{id}/{isPublic}   BBProjects.postPublicProject



    Utilisation dans une vue pour faire un lien :
          <a href="@{Clients.show(client.id)}">Show</a>


    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Models
    Play utilise Hibernate à travers JPA (Java Persistance Api)
    Les objets sont annotés @Entity et dérivent de Model
    Model fournit des méthodes utilitaires statiques :
        post.save(), post.delete(), Post.findAll(), Post.findById(5L),
         Post.find("byTitle", "My first post").fetch() …
                          @Entity
                          public class Post extends Model {

                              public String title;
                              public String content;
                              public Date postDate;

                              @ManyToOne
                              public Author author;

                              @OneToMany
                              public List<Comment> comments;
                          }

    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Controllers
    Traitent les requêtes
    Dérivent de play.mvc.Controller
    Méthodes statiques
    Récupération automatique des paramètres de requête
    Binding automatique de ces paramètres en objets, selon la
     signature de la méthode
        + Dates selon différents formats
        + Uploads POST "multipart/form-data" de fichiers  File
    Actions :
        Rendu : render(), renderJSON(), renderXML(), renderBinary()
        Autre : redirect() ou appel d'une autre méthode (chainage)

    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Controllers > Exemple
public class Clients extends Controller {

      public static void list() {
          List<Client> clients = Client.findAll();
          render(clients);                                app/views/Clients/list.html
      }

      public static void show(Long id) {
          Client client = Client.findById(id);
          renderTemplate("Clients/showClient.html", client);
      }                                         app/views/Clients/showClient.html
      public static void create(String name) {
          Client client = new Client(name);
          client.save();
          show(client.id);                                       chainage
      }
             public static void getUnreadMessages() {
}
                 List<Message> unreadMessages = MessagesBox.unreadMessages();
                 renderJSON(unreadMessages);
             }
    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Vues
    Templating Groovy
        Variable : ${client.name}
        Tags : #{script 'jquery.js' /} ou #{list items:clients, as:'client' }
            Tags personnalisés dans app/views/tags
        Actions : <a href="@{Clients.show(client.id)}">Show</a>
        Textes internationalisés : &{'clientName', client.name}
        Script Java : %{ fullName = "Name : "+client.getName(); }


    Système de "decorators" (= template parent, héritage)
        Tags #{extends 'main.html' /} et #{doLayout /}



    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
Mais encore …
    Gestion d'ID pour différents déploiements (dev, test,…)
    Tests unitaires et fonctionnels
    Gestion de modules
        Personnels
        Public, grand nombre sur http://www.playframework.com/modules
        Notamment modules Secure, CRUD, …
    Déploiement
        En "natif" avec le moteur Play
        WAR déployé sur serveur d'application (Tomcat, …)
    Macro (tags) pour le templating des vues
    …
    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
MERCI
    Xavier NOPRE :

        Développeur Java & Web

        Formation et accompagnement en ingénierie agile (tests unitaires,
         TDD, intégration continue, industrialisation Maven, etc…)
         et technos Java-WEB



            @xnopre                xnopre.blogspot.com


    Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013

Contenu connexe

Tendances

20081113 - Nantes Jug - Apache Maven
20081113 - Nantes Jug - Apache Maven20081113 - Nantes Jug - Apache Maven
20081113 - Nantes Jug - Apache MavenArnaud Héritier
 
Concevoir, développer et sécuriser des micro-services avec Spring Boot
Concevoir, développer et sécuriser des micro-services avec Spring BootConcevoir, développer et sécuriser des micro-services avec Spring Boot
Concevoir, développer et sécuriser des micro-services avec Spring BootDNG Consulting
 
Workshop Spring 3 - Tests et techniques avancées du conteneur Spring
Workshop Spring  3 - Tests et techniques avancées du conteneur SpringWorkshop Spring  3 - Tests et techniques avancées du conteneur Spring
Workshop Spring 3 - Tests et techniques avancées du conteneur SpringAntoine Rey
 
Presentation JEE et son écossystéme
Presentation JEE et son écossystémePresentation JEE et son écossystéme
Presentation JEE et son écossystémeAlgeria JUG
 
GWT Principes & Techniques
GWT Principes & TechniquesGWT Principes & Techniques
GWT Principes & TechniquesRachid NID SAID
 
JCertif 2012 : Maven par la pratique
JCertif 2012 : Maven par la pratiqueJCertif 2012 : Maven par la pratique
JCertif 2012 : Maven par la pratiqueRossi Oddet
 
Jsf 110530152515-phpapp01
Jsf 110530152515-phpapp01Jsf 110530152515-phpapp01
Jsf 110530152515-phpapp01Eric Bourdet
 
20090615 - Ch'ti JUG - Apache Maven
20090615 - Ch'ti JUG - Apache Maven20090615 - Ch'ti JUG - Apache Maven
20090615 - Ch'ti JUG - Apache MavenArnaud Héritier
 
JBoss - chapitre JMX
JBoss - chapitre JMXJBoss - chapitre JMX
JBoss - chapitre JMXFranck SIMON
 
Présentation Maven
Présentation MavenPrésentation Maven
Présentation MavenSOAT
 
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
 
Workshop spring session 2 - La persistance au sein des applications Java
Workshop spring   session 2 - La persistance au sein des applications JavaWorkshop spring   session 2 - La persistance au sein des applications Java
Workshop spring session 2 - La persistance au sein des applications JavaAntoine Rey
 
Introduction à spring boot
Introduction à spring bootIntroduction à spring boot
Introduction à spring bootAntoine Rey
 

Tendances (20)

20081113 - Nantes Jug - Apache Maven
20081113 - Nantes Jug - Apache Maven20081113 - Nantes Jug - Apache Maven
20081113 - Nantes Jug - Apache Maven
 
Concevoir, développer et sécuriser des micro-services avec Spring Boot
Concevoir, développer et sécuriser des micro-services avec Spring BootConcevoir, développer et sécuriser des micro-services avec Spring Boot
Concevoir, développer et sécuriser des micro-services avec Spring Boot
 
Workshop Spring 3 - Tests et techniques avancées du conteneur Spring
Workshop Spring  3 - Tests et techniques avancées du conteneur SpringWorkshop Spring  3 - Tests et techniques avancées du conteneur Spring
Workshop Spring 3 - Tests et techniques avancées du conteneur Spring
 
Presentation JEE et son écossystéme
Presentation JEE et son écossystémePresentation JEE et son écossystéme
Presentation JEE et son écossystéme
 
GWT Principes & Techniques
GWT Principes & TechniquesGWT Principes & Techniques
GWT Principes & Techniques
 
JCertif 2012 : Maven par la pratique
JCertif 2012 : Maven par la pratiqueJCertif 2012 : Maven par la pratique
JCertif 2012 : Maven par la pratique
 
ParisJUG Spring Boot
ParisJUG Spring BootParisJUG Spring Boot
ParisJUG Spring Boot
 
Jsf 110530152515-phpapp01
Jsf 110530152515-phpapp01Jsf 110530152515-phpapp01
Jsf 110530152515-phpapp01
 
20090615 - Ch'ti JUG - Apache Maven
20090615 - Ch'ti JUG - Apache Maven20090615 - Ch'ti JUG - Apache Maven
20090615 - Ch'ti JUG - Apache Maven
 
JBoss - chapitre JMX
JBoss - chapitre JMXJBoss - chapitre JMX
JBoss - chapitre JMX
 
Présentation Maven
Présentation MavenPrésentation Maven
Présentation Maven
 
Cours jee 1
Cours jee 1Cours jee 1
Cours jee 1
 
Tp java ee.pptx
Tp java ee.pptxTp java ee.pptx
Tp java ee.pptx
 
Les Servlets et JSP
Les Servlets et JSPLes Servlets et JSP
Les Servlets et JSP
 
Sonar-Hodson-Maven
Sonar-Hodson-MavenSonar-Hodson-Maven
Sonar-Hodson-Maven
 
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
 
Support JEE Servlet Jsp MVC M.Youssfi
Support JEE Servlet Jsp MVC M.YoussfiSupport JEE Servlet Jsp MVC M.Youssfi
Support JEE Servlet Jsp MVC M.Youssfi
 
Workshop spring session 2 - La persistance au sein des applications Java
Workshop spring   session 2 - La persistance au sein des applications JavaWorkshop spring   session 2 - La persistance au sein des applications Java
Workshop spring session 2 - La persistance au sein des applications Java
 
Gradle
GradleGradle
Gradle
 
Introduction à spring boot
Introduction à spring bootIntroduction à spring boot
Introduction à spring boot
 

En vedette

Enib cours c.a.i. web - séance #5 : scala play! framework
Enib   cours c.a.i. web - séance #5 : scala play! frameworkEnib   cours c.a.i. web - séance #5 : scala play! framework
Enib cours c.a.i. web - séance #5 : scala play! frameworkHoracio Gonzalez
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Saeed Zarinfam
 
Play! Framework for JavaEE Developers
Play! Framework for JavaEE DevelopersPlay! Framework for JavaEE Developers
Play! Framework for JavaEE DevelopersTeng Shiu Huang
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in productionChristian Papauschek
 
Open Source Software and GitHub
Open Source Software and GitHubOpen Source Software and GitHub
Open Source Software and GitHubSamy Dindane
 
Marquette Social Listening presentation
Marquette Social Listening presentationMarquette Social Listening presentation
Marquette Social Listening presentation7Summits
 
807 103康八上 my comic book
807 103康八上 my comic book807 103康八上 my comic book
807 103康八上 my comic bookAlly Lin
 
อุปกรณ์เครือข่ายงคอมพิวเตอร์
อุปกรณ์เครือข่ายงคอมพิวเตอร์อุปกรณ์เครือข่ายงคอมพิวเตอร์
อุปกรณ์เครือข่ายงคอมพิวเตอร์ooh Pongtorn
 
Scala play-framework
Scala play-frameworkScala play-framework
Scala play-frameworkAbdhesh Kumar
 
Reclaiming the idea of the University
Reclaiming the idea of the UniversityReclaiming the idea of the University
Reclaiming the idea of the UniversityRichard Hall
 
4º básico a semana 03 de junio al 10 de junio
4º básico a  semana  03 de junio al 10 de junio4º básico a  semana  03 de junio al 10 de junio
4º básico a semana 03 de junio al 10 de junioColegio Camilo Henríquez
 
Postavte zeď mezi svoje vývojáře
Postavte zeď mezi svoje vývojářePostavte zeď mezi svoje vývojáře
Postavte zeď mezi svoje vývojářeLadislav Prskavec
 
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...Doug Oldfield
 

En vedette (20)

Enib cours c.a.i. web - séance #5 : scala play! framework
Enib   cours c.a.i. web - séance #5 : scala play! frameworkEnib   cours c.a.i. web - séance #5 : scala play! framework
Enib cours c.a.i. web - séance #5 : scala play! framework
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
 
Play! Framework for JavaEE Developers
Play! Framework for JavaEE DevelopersPlay! Framework for JavaEE Developers
Play! Framework for JavaEE Developers
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in production
 
Open Source Software and GitHub
Open Source Software and GitHubOpen Source Software and GitHub
Open Source Software and GitHub
 
Tp switch
Tp switchTp switch
Tp switch
 
Gamification review 1
Gamification review 1Gamification review 1
Gamification review 1
 
Ingles
InglesIngles
Ingles
 
Frede space up paris 2013
Frede space up paris 2013Frede space up paris 2013
Frede space up paris 2013
 
Marquette Social Listening presentation
Marquette Social Listening presentationMarquette Social Listening presentation
Marquette Social Listening presentation
 
User experience eBay
User experience eBayUser experience eBay
User experience eBay
 
807 103康八上 my comic book
807 103康八上 my comic book807 103康八上 my comic book
807 103康八上 my comic book
 
อุปกรณ์เครือข่ายงคอมพิวเตอร์
อุปกรณ์เครือข่ายงคอมพิวเตอร์อุปกรณ์เครือข่ายงคอมพิวเตอร์
อุปกรณ์เครือข่ายงคอมพิวเตอร์
 
Scala play-framework
Scala play-frameworkScala play-framework
Scala play-framework
 
Reclaiming the idea of the University
Reclaiming the idea of the UniversityReclaiming the idea of the University
Reclaiming the idea of the University
 
6º básico a semana 09 al 13 de mayo (1)
6º básico a semana 09  al 13 de  mayo (1)6º básico a semana 09  al 13 de  mayo (1)
6º básico a semana 09 al 13 de mayo (1)
 
4º básico a semana 03 de junio al 10 de junio
4º básico a  semana  03 de junio al 10 de junio4º básico a  semana  03 de junio al 10 de junio
4º básico a semana 03 de junio al 10 de junio
 
Postavte zeď mezi svoje vývojáře
Postavte zeď mezi svoje vývojářePostavte zeď mezi svoje vývojáře
Postavte zeď mezi svoje vývojáře
 
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...
 
Giveandget.com
Giveandget.comGiveandget.com
Giveandget.com
 

Similaire à Play framework - Human Talks Grenoble - 12.02.2013

Java dans Windows Azure, l'exemple de JOnAS
Java dans Windows Azure, l'exemple de JOnASJava dans Windows Azure, l'exemple de JOnAS
Java dans Windows Azure, l'exemple de JOnASGuillaume Sauthier
 
Rich Desktop Applications
Rich Desktop ApplicationsRich Desktop Applications
Rich Desktop Applicationsgoldoraf
 
Java dans Windows Azure: l'exemple de Jonas
Java dans Windows Azure: l'exemple de JonasJava dans Windows Azure: l'exemple de Jonas
Java dans Windows Azure: l'exemple de JonasMicrosoft
 
Présentation Gradle au LyonJUG par Grégory Boissinot - Zenika
Présentation Gradle au LyonJUG par Grégory Boissinot - ZenikaPrésentation Gradle au LyonJUG par Grégory Boissinot - Zenika
Présentation Gradle au LyonJUG par Grégory Boissinot - ZenikaZenika
 
La mobilité dans Drupal
La mobilité dans DrupalLa mobilité dans Drupal
La mobilité dans DrupalAdyax
 
Comment réussir son projet en Angular 1.5 ?
Comment réussir son projet en Angular 1.5 ?Comment réussir son projet en Angular 1.5 ?
Comment réussir son projet en Angular 1.5 ?Maxime Bernard
 
Play Framework - Toulouse JUG - nov 2011
Play Framework - Toulouse JUG - nov 2011Play Framework - Toulouse JUG - nov 2011
Play Framework - Toulouse JUG - nov 2011Sylvain Wallez
 
Presentation of GWT 2.4 (PDF version)
Presentation of GWT 2.4 (PDF version)Presentation of GWT 2.4 (PDF version)
Presentation of GWT 2.4 (PDF version)Celinio Fernandes
 
Apache flink - prise en main rapide
Apache flink - prise en main rapideApache flink - prise en main rapide
Apache flink - prise en main rapideBilal Baltagi
 
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
 
Soutenance Zend Framework vs Symfony
Soutenance Zend Framework vs SymfonySoutenance Zend Framework vs Symfony
Soutenance Zend Framework vs SymfonyVincent Composieux
 
Aspect avec AspectJ
Aspect avec AspectJAspect avec AspectJ
Aspect avec AspectJsimeon
 
Silverlight 3.MSDays EPITA 11/06/2009
Silverlight 3.MSDays EPITA 11/06/2009Silverlight 3.MSDays EPITA 11/06/2009
Silverlight 3.MSDays EPITA 11/06/2009Frédéric Queudret
 
vuejs.ppt
vuejs.pptvuejs.ppt
vuejs.pptlordeco
 

Similaire à Play framework - Human Talks Grenoble - 12.02.2013 (20)

Java dans Windows Azure, l'exemple de JOnAS
Java dans Windows Azure, l'exemple de JOnASJava dans Windows Azure, l'exemple de JOnAS
Java dans Windows Azure, l'exemple de JOnAS
 
Rich Desktop Applications
Rich Desktop ApplicationsRich Desktop Applications
Rich Desktop Applications
 
Java dans Windows Azure: l'exemple de Jonas
Java dans Windows Azure: l'exemple de JonasJava dans Windows Azure: l'exemple de Jonas
Java dans Windows Azure: l'exemple de Jonas
 
HTML5 en projet
HTML5 en projetHTML5 en projet
HTML5 en projet
 
Présentation Gradle au LyonJUG par Grégory Boissinot - Zenika
Présentation Gradle au LyonJUG par Grégory Boissinot - ZenikaPrésentation Gradle au LyonJUG par Grégory Boissinot - Zenika
Présentation Gradle au LyonJUG par Grégory Boissinot - Zenika
 
La mobilité dans Drupal
La mobilité dans DrupalLa mobilité dans Drupal
La mobilité dans Drupal
 
Comment réussir son projet en Angular 1.5 ?
Comment réussir son projet en Angular 1.5 ?Comment réussir son projet en Angular 1.5 ?
Comment réussir son projet en Angular 1.5 ?
 
Play Framework - Toulouse JUG - nov 2011
Play Framework - Toulouse JUG - nov 2011Play Framework - Toulouse JUG - nov 2011
Play Framework - Toulouse JUG - nov 2011
 
Presentation of GWT 2.4 (PDF version)
Presentation of GWT 2.4 (PDF version)Presentation of GWT 2.4 (PDF version)
Presentation of GWT 2.4 (PDF version)
 
Apache flink - prise en main rapide
Apache flink - prise en main rapideApache flink - prise en main rapide
Apache flink - prise en main rapide
 
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
 
Backbonejs presentation
Backbonejs presentationBackbonejs presentation
Backbonejs presentation
 
Gradle_LyonJUG
Gradle_LyonJUGGradle_LyonJUG
Gradle_LyonJUG
 
Silverlight 4
Silverlight 4Silverlight 4
Silverlight 4
 
Springioc
SpringiocSpringioc
Springioc
 
Soutenance Zend Framework vs Symfony
Soutenance Zend Framework vs SymfonySoutenance Zend Framework vs Symfony
Soutenance Zend Framework vs Symfony
 
Aspect avec AspectJ
Aspect avec AspectJAspect avec AspectJ
Aspect avec AspectJ
 
Silverlight 3.MSDays EPITA 11/06/2009
Silverlight 3.MSDays EPITA 11/06/2009Silverlight 3.MSDays EPITA 11/06/2009
Silverlight 3.MSDays EPITA 11/06/2009
 
vuejs.ppt
vuejs.pptvuejs.ppt
vuejs.ppt
 
iTunes Stats
iTunes StatsiTunes Stats
iTunes Stats
 

Plus de Xavier NOPRE

Human Talks Grenoble 08/09/2015 - AngularJS et Cordova = applications WEB et ...
Human Talks Grenoble 08/09/2015 - AngularJS et Cordova = applications WEB et ...Human Talks Grenoble 08/09/2015 - AngularJS et Cordova = applications WEB et ...
Human Talks Grenoble 08/09/2015 - AngularJS et Cordova = applications WEB et ...Xavier NOPRE
 
Agilistes : n'oubliez pas la technique ! - Agile France - 23/05/2013
Agilistes : n'oubliez pas la technique ! - Agile France - 23/05/2013Agilistes : n'oubliez pas la technique ! - Agile France - 23/05/2013
Agilistes : n'oubliez pas la technique ! - Agile France - 23/05/2013Xavier NOPRE
 
Jasmine : tests unitaires en JavaScript - Human Talks Grenoble 14.05.2013
Jasmine : tests unitaires en JavaScript - Human Talks Grenoble 14.05.2013Jasmine : tests unitaires en JavaScript - Human Talks Grenoble 14.05.2013
Jasmine : tests unitaires en JavaScript - Human Talks Grenoble 14.05.2013Xavier NOPRE
 
Mix-IT 2013 - Agilistes : n'oubliez pas la technique - mix-it 2013
Mix-IT 2013 - Agilistes : n'oubliez pas la technique - mix-it 2013Mix-IT 2013 - Agilistes : n'oubliez pas la technique - mix-it 2013
Mix-IT 2013 - Agilistes : n'oubliez pas la technique - mix-it 2013Xavier NOPRE
 
Human Talks Grenoble - 11/12/2012 - TDD
Human Talks Grenoble - 11/12/2012 - TDDHuman Talks Grenoble - 11/12/2012 - TDD
Human Talks Grenoble - 11/12/2012 - TDDXavier NOPRE
 
Ingénierie agile : N&rsquo;oubliez pas vos développeurs
Ingénierie agile : N&rsquo;oubliez pas vos développeursIngénierie agile : N&rsquo;oubliez pas vos développeurs
Ingénierie agile : N&rsquo;oubliez pas vos développeursXavier NOPRE
 

Plus de Xavier NOPRE (6)

Human Talks Grenoble 08/09/2015 - AngularJS et Cordova = applications WEB et ...
Human Talks Grenoble 08/09/2015 - AngularJS et Cordova = applications WEB et ...Human Talks Grenoble 08/09/2015 - AngularJS et Cordova = applications WEB et ...
Human Talks Grenoble 08/09/2015 - AngularJS et Cordova = applications WEB et ...
 
Agilistes : n'oubliez pas la technique ! - Agile France - 23/05/2013
Agilistes : n'oubliez pas la technique ! - Agile France - 23/05/2013Agilistes : n'oubliez pas la technique ! - Agile France - 23/05/2013
Agilistes : n'oubliez pas la technique ! - Agile France - 23/05/2013
 
Jasmine : tests unitaires en JavaScript - Human Talks Grenoble 14.05.2013
Jasmine : tests unitaires en JavaScript - Human Talks Grenoble 14.05.2013Jasmine : tests unitaires en JavaScript - Human Talks Grenoble 14.05.2013
Jasmine : tests unitaires en JavaScript - Human Talks Grenoble 14.05.2013
 
Mix-IT 2013 - Agilistes : n'oubliez pas la technique - mix-it 2013
Mix-IT 2013 - Agilistes : n'oubliez pas la technique - mix-it 2013Mix-IT 2013 - Agilistes : n'oubliez pas la technique - mix-it 2013
Mix-IT 2013 - Agilistes : n'oubliez pas la technique - mix-it 2013
 
Human Talks Grenoble - 11/12/2012 - TDD
Human Talks Grenoble - 11/12/2012 - TDDHuman Talks Grenoble - 11/12/2012 - TDD
Human Talks Grenoble - 11/12/2012 - TDD
 
Ingénierie agile : N&rsquo;oubliez pas vos développeurs
Ingénierie agile : N&rsquo;oubliez pas vos développeursIngénierie agile : N&rsquo;oubliez pas vos développeurs
Ingénierie agile : N&rsquo;oubliez pas vos développeurs
 

Play framework - Human Talks Grenoble - 12.02.2013

  • 1. GRENOBLE Play framework (V1) : simplicité et productivité au service du développement WEB en Java Xavier NOPRE – 12/02/2013
  • 2. Préambule > Sondage  Développeur Java ?  Qui connait Play Framework ?  Qui utilise Play Framework ?  V1 ?  V2 ?  Précision … Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 3. Introduction  Framework WEB complet  Pour des développeurs pour des développeurs  Pour une approche + simple et + rapide (vs JEE ou Spring)  Constitué de composants choisis (JPA, Hibernate, …)  Architecture Model View Controller  Rechargement à chaud en mode "dev"  Présentation des erreurs "serveur" dans la page HTML (explication et extrait de code)  Stateless & REST  Basé sur des conventions  Productivité ! Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 4. Installation & démarrage  Téléchargement play-1.2.5.zip : http://downloads.typesafe.com/releases/play-1.2.4.zip  Extraction et ajout au PATH  Création d'une nouvelle application : > play new demo-human-talks  Préparation pour Eclipse : > play eclipsify  Exécution : > play run  Accès : http://localhost:9000/  Principes, documentation local, API Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 5. Installation & démarrage Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 6. Structure  Répertoires :  config/  fichiers de configuration  app/  models/  classes pour les modèles objet (mapping JPA)  controllers/  classes pour les contrôleurs  views/  fichier HTML de templating pour les vues  test/  tests unitaires et tests fonctionnels  public/  ressources statiques (images, CSS, Javascript) Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 7. Configuration  Répertoire "conf":  application.conf : configuration générale de l'application :  Nom, mode (dev / prod), langs  Serveur HTTP et sessions  Logs  Base de donnée : mémoire, fichier, MySQL, PostgreSQL, JDBC, …  JPA, memcached, proxy, mail, …  dependencies.yml  Dépendances (artefacts type Maven ou Ivy)  routes  Routages : URL  controller.action  messages  Internationalisation i18n (multi-langue) Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 8. Configuration > dépendances  Artefacts disponibles sur des repositories publiques : conf/dependencies.yml # Application dependencies require: - play - play -> crud - play -> secure - org.apache.commons -> commons-lang3 3.1 - org.mockito -> mockito-all 1.9.5 - org.easytesting -> fest-assert 1.4  Mise à jour des dépendances : > play dependencies Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 9. Configuration > routage URLs  Définitions des routages entre URL et actions des contrôleurs, et inversement conf/routes GET / Application.index GET /public/ staticDir:public * /{controller}/{action} {controller}.{action} # Backbone GET /bb/projects BBProjects.getProjects GET /bb/project/{id} BBProjects.getProject POST /bb/project BBProjects.createProject PUT /bb/project/{id} BBProjects.updateProject DELETE /bb/project/{id} BBProjects.deleteProject POST /bb/project/public/{id}/{isPublic} BBProjects.postPublicProject  Utilisation dans une vue pour faire un lien : <a href="@{Clients.show(client.id)}">Show</a> Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 10. Models  Play utilise Hibernate à travers JPA (Java Persistance Api)  Les objets sont annotés @Entity et dérivent de Model  Model fournit des méthodes utilitaires statiques :  post.save(), post.delete(), Post.findAll(), Post.findById(5L), Post.find("byTitle", "My first post").fetch() … @Entity public class Post extends Model { public String title; public String content; public Date postDate; @ManyToOne public Author author; @OneToMany public List<Comment> comments; } Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 11. Controllers  Traitent les requêtes  Dérivent de play.mvc.Controller  Méthodes statiques  Récupération automatique des paramètres de requête  Binding automatique de ces paramètres en objets, selon la signature de la méthode  + Dates selon différents formats  + Uploads POST "multipart/form-data" de fichiers  File  Actions :  Rendu : render(), renderJSON(), renderXML(), renderBinary()  Autre : redirect() ou appel d'une autre méthode (chainage) Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 12. Controllers > Exemple public class Clients extends Controller { public static void list() { List<Client> clients = Client.findAll(); render(clients);  app/views/Clients/list.html } public static void show(Long id) { Client client = Client.findById(id); renderTemplate("Clients/showClient.html", client); }  app/views/Clients/showClient.html public static void create(String name) { Client client = new Client(name); client.save(); show(client.id);  chainage } public static void getUnreadMessages() { } List<Message> unreadMessages = MessagesBox.unreadMessages(); renderJSON(unreadMessages); } Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 13. Vues  Templating Groovy  Variable : ${client.name}  Tags : #{script 'jquery.js' /} ou #{list items:clients, as:'client' }  Tags personnalisés dans app/views/tags  Actions : <a href="@{Clients.show(client.id)}">Show</a>  Textes internationalisés : &{'clientName', client.name}  Script Java : %{ fullName = "Name : "+client.getName(); }  Système de "decorators" (= template parent, héritage)  Tags #{extends 'main.html' /} et #{doLayout /} Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 14. Mais encore …  Gestion d'ID pour différents déploiements (dev, test,…)  Tests unitaires et fonctionnels  Gestion de modules  Personnels  Public, grand nombre sur http://www.playframework.com/modules  Notamment modules Secure, CRUD, …  Déploiement  En "natif" avec le moteur Play  WAR déployé sur serveur d'application (Tomcat, …)  Macro (tags) pour le templating des vues  … Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013
  • 15. MERCI  Xavier NOPRE :  Développeur Java & Web  Formation et accompagnement en ingénierie agile (tests unitaires, TDD, intégration continue, industrialisation Maven, etc…) et technos Java-WEB @xnopre xnopre.blogspot.com Play Framework 1.2.5 - http://www.playframework.com/ - Xavier NOPRE – 12/02/2013