SlideShare une entreprise Scribd logo
1  sur  55
Télécharger pour lire hors ligne
Génération de code
       à partir d’un « modèle léger »
                                     Laurent Guérin
                               Telosys Project Leader
                           Sogeti & OW2 Consortium
Paris - 24 novembre 2011
Introduction
                                                         Sogeti : Company                              Capgemini : Company
                                                                                          belongs to




                                                                                                            : Plateform
     Laurent Guérin : Person                              Telosys : Project
                                      leads

     laurent.guerin@sogeti.com

                                                                                                               : IDE
         located in
                                                                       hosts

                                                         OW2 : Consortium
                                                                                                             : License

           France : Country




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                      2
Contexte & Objectifs
Contexte
 • Constat :
     – Généralisation de Java :-)
     – Projet Java = projet lourd :-(
 • Génération de code ?
   Oui, mais …
     – solution légère et efficace,
      adaptée aux projets à cycle court
     – solution simple, utilisable par tous
     – environnement léger (installation en quelques
      heures/minutes)
 • Objectif « démarrage rapide »
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                4
Le projet Telosys
                                                          Method




                                 Tools                                           Framework

                        ( code generation )                                     ( global & simple )




  • Un framework global, auto-suffisant pour
    construire une application complète
  • Des outils (plugins Eclipse) pour générer le code
    initial de l’application et guider le développeur.
    Puis ouverture sur d’autres cibles…
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                5
Philosophie du projet
           “Keep it simple and stupid”                                                                 ( KISP ? )
                – framework simple et léger
                – « petits outils » (faciles à installer et à utiliser)
           “Respects des standards”
                – servlet/JSP/JSPX, JDBC, JPA, http, XML, …
           “Ouverture”
                – Open Source ( projet / OW2 consortium )
                – Format ouvert (modèle léger = XML)
                – Templates adaptables  différentes cibles :
                 Telosys fwk, autres Frameworks Java, Flex, PHP, …

                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                             6
Outillage
 • Ne pas réinventer la roue (il existe déjà de
   nombreux outils), apporter une alternative
 • Offrir une boite à outils intégrée dans Eclipse,
   immédiatement utilisable par des développeurs
   non initiés au MDD
 • La génération de code pour tous !




                   -                                                sophistication                     +
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                    7
Le framework
Le framework
 • Framework global                                                  “all in one“




 • Un seul jar    (+ JDBC) => pas de "jar hell" !
 • Basé sur des concepts simples
 • Léger (servlet container + base de données)
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                9
« Global effect »
                                             Un seul framework
                                qui couvre toutes les couches de l’application
                                                   Authenti-
                                                    cation

                         Presentation                     Application            Business   Persistence
                                                               Services
                             Screen                                          Java Beans
                              Maps                                             ( POJO )         DAO
                                             XML       conv
                                                                          "VO"                                SQL
                         JSP + taglib                           Screen
                                            AJAX               Managers
                           Framework
                                                                                 Services                 Thin persistence
                           Javascript                                                                     layer

                                                                                             Very simple objects
                                 Natively AJAX                     Commons, logging, I18N, … ( "Pure POJO" )


    • “Global” => moins de “glue”, moins d’objets
      (empreinte mémoire réduite), moins de
      configuration, … => plus homogène
    • “Modulaire” (utilisation partielle)
                                                                                      www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                      10
Le paradigme « client-serveur »
  • Une fois chargé dans le navigateur, un écran
    dialogue avec le server via des requêtes AJAX
  • Découplage ( facilite la génération de code )

      Client-side                                                      http                            Server-side
                                                     <request screen-name="Employee"
                                                       screen-id="0" action="get" >
                                                     </request>                                           Screen
                                                                                                          Manager
                                           Action



                                                     <response screen-name="Employee"
                                                        screen-id="0" action="get" >
                                                     <return code="0" message="Ok" >
                                                     </return>
                          Framework
                          JavaScript




                                                     <data>
                                                     <employee id="23" lastName="Wayne"
                                                        firstName="John" manager="0" email="" />
                                                     </data>
                                                     </response>

                                                                                                          Service
                                           Service




                                                     http://myhost:8080/.../Add.svc?p1=2&p2=6

                                                     <response service-name="Add">
                                                      <return code="0" message="Ok" />
                                                      <values> <value result="8" /> </values>
                                                      <data> </data>
                                                     </response>




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                              11
La persistance
 • Une alternative aux “ORM” classiques

                  ORM : JPA (or Hibernate) …
                  High level & "Object Oriented"
                                                                                              Java objects
                  Hides the complexity                                                    rule the persistence
                  Sometimes misunderstood by the developers
                  ( "lazy/eager" loading, cache effects,                                                DB
                  "attached/detached" entities,
                  "owning side"/"inverse side" links, … )                                      new       new


                  Telosys DAL (based on DAO pattern)
                  Intermediate level & "Record Oriented"                                   Database records
                  One Bean = One Record                                                   rule the persistence
                  The developer keeps the control
                  No links, no cache, no byte-code enhancement
                                                                                                        DB
                  Very simple API : load, save, insert, update,
                  exists, loadList, updateList, …                                              new       legacy



                  JDBC API                                                     Les deux sont utiles.
                  Low level                                                    Au choix …
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                           12
Un framework ne suffit pas…
                                                                                                       Outils
                       Framework                                                  « boilerplate »

          Plate-forme (Java EE)
                                                                              Application
               Code générique                                               Code spécifique

    • Le problème : le code technique et spécifique
    • Les outils de génération de code sont une
      réponse possible.
      Exemples :
        Ruby on Rails, Grails, Spring Roo, etc…
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                     13
Génération de code
Les différentes approches
Approche « Model First »
 • Démarche MDD classique, MDA, etc …
 • « Model - First » => concevoir un model !
      – investissement initial important
      – nécessite de respecter le process (formation)
 • Incompatible avec un démarrage rapide
                                                      MODEL                                                                                                  Split !
                                                                                                                                                 XMI
                                       Service
                                      name




                                    +port 0..n




                                                                                                                                                ( XML )
                                        Port                      Binding                Port Type
                                                                                    1
                                                      +binding                          name
                                      name                       name                                                   Param
                                                           1                    +type
                                                                                                                       name

                                   StartWithExtensions

                                +output 0..1             +operation 0..n         +operation 0..n
                                                                                                         +input    Input
                                        0..1 +input
                                                           BindingOperation                  Operation
                                                                                                           0..1




                                                                                                                                                                       Code
                                                          name                              name
                                                                                    1                                0..1 Output
                                                                                                                  +output

                                                                                                                           +message         1
                                                                 +fault 0..n            +fault    0..n
                                                                                                                                Message
                                                                                               Fault              +message
                                                                 BindingFault                                                  name
                                                                                             name
                                                                                        1                                  1

                                                                                                                               +part 0..n
                                                                                                                                  Part
                                                                                                                                name




                                                                                                                                                   TOOL
                                                           Template




Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                                                   www.telosys.org     15
Approche « scaffolding »
 • Scaffolding de type « Database - First »
 • Très efficace ( rapide )                                                                                 Database

 • Mais pas d’action possible sur l’outil
                                                                                                            Metadata
   de génération
 • Pas assez d’informations …                                                                                TOOL

      – Noms/types des attributs Java
      – Règles de validation : min, max, regexp, …                                               Template

      – Représentation des Booléens
       (1/0, "T"/"F", … )
                                                                                                              Code
      – etc …
 • Il faudrait injecter/stocker des informations
   complémentaires… un modèle ?
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                16
Les « wizards »
 • Bien intégré dans l’IDE :-)                                                                               “Java Model”
                                                                                                           org.eclipse.jdt.core


 • Informations en entrée :                                                                                       Workspace
                                                                                                                    files


     – Saisie utilisateur :-(                                                                          I.D.E.
     – Artefacts existants dans le projet
            • Java class  Java class
            • WSDL file  Java classes
 • Génération unitaire,
   non automatisable
 • Peuvent être utilisés comme         Bulk
                                                                                                             Code
                                    generation
   des « accélérateurs »
   ( après la génération de masse )
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                       17
L’approche « Telosys Tools »
Expression du besoin
 • Les souhaits :
      – générer rapidement le code initial des écrans de
                                                                                                           DB
       mise à jour des entités d’une base de données                                                    Metadata
       (notion de scaffolding / database first)
      – avec un outil simple, bien intégré dans l’IDE
       (comme les wizards)
                                                                                                       Template
      – modifier/adapter les « patrons » de
       génération (notion de templates)
      – modifier (raffiner) les informations brutes
       issues des méta-data, pouvoir y ajouter
       des informations complémentaires                                                                Modèle      ?
      – lancer des générations de masse

                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                           19
Telosys Tools : le processus
  • Un processus en 3 étapes
                                                                                                          Template
                  Database           updates                                              customizes




                  Metadata
                                                                       modify
                                                                        & add
                                                                     information                                     Code
                 Repository                                                                     Code
                 generator                                                                    generator
                                     generates
                                                        Repository
                                                         (Lightweight
                                     updates                model)



    1                                              2                                         3
              Approche                                 Adapter / enrichir                         Générer
           “Database-first”                            le “modèle léger”                          le code
          pour initialiser un                                                                      initial
            “modèle léger”

                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                     20
Telosys Tools
 • Modèle ( « léger » )
      –    seules les entités sont gérées
      –    représentation graphique inutile
      –    simple fichier XML (indépendant d’Eclipse)
      –    adhérence Eclipse : limitée à l’ IHM
 • Moteur de génération de code
   ( « templating engine » )
      –    simple
      –    connu
      –    open source
      –    utilisable avec les wizards                                                                 Basique
                                                                                                       mais suffisant

                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                 21
Editeur de modèle
                           workspace                                                      Fichier
                                                                           Repository
                                                                             (model)      .dbrep




                                                                                                             Database

                                                                                                            Java Classes




                                                                                                                           modifiable




                                          Database                                        Java Attributes
                                                             O/R Mapping



                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                                 22
Velocity ( templating engine )
    Extrait d’un template (génération d’un bean)
     public class $class.name implements Serializable {
         private static final long serialVersionUID = 1L;
                                                                                                               Repository
          //--- ATTRIBUTES
     #foreach( $field in $class.attributes )                                                                     (model)
          private $field.formatedType(10) $field.formatedName(12) ;
     #end
          //--- CONSTRUCTOR(S)
          public ${class.name}()
          {                                                                                                     Velocity
              super();
                                                                                                                Context
          }
          //--- GETTERS & SETTERS
     #foreach( $field in $class.attributes )                                                                     $class
     #if ( $field.setter )     public void ${field.setter}( $field.type value )                                   etc…
          {
              this.$field.name = value;
          }
     #end
     #if ( $field.getter )     public $field.type ${field.getter}()
          {
              return this.$field.name;
          }
     #end
     #end
                                                                                                   cf documentation
                                                                                                   sur le site Apache

                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                    23
Qu’est-ce qu’on génère ?
Les artefacts générés N fois
 •    VO Bean (POJO = “entity record”)
 •    VO List (liste de bean avec tri & sélection)                                                              Code
                                                                                                              generator
 •    DAO                       code « jetable »
 •    Convertisseurs
                                                                Book
                                                                .java
                                                                                                BookDAO
                 BookConv                                VO Bean                                 .java
                  .java
                                                                                             Data
                                                                                                          Database
      XML                XML                                                                Access
     <…>
                                                           VO List                           Layer                 Book
     </ … >
                                                                                                                   Table
                        Con-                                     BookList
                       verters                                    .java




                                                          DataSet                           Parsers
                                                                                                           Files

                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                    25
Persistance : objet ou record ?
 • Approche “graphe d’objets” : les liens peuvent
   être générés (persistance de type JPA)
                                                                                                   Bean
                                                                                     @ManyToOne               Code
                                                                                     @OneToMany             generator
                                                                                     @ManyToMany
                                                                                     @OneToOne




 • Approche “record” : les liens ne sont pas
   nécessaires, assemblage possible par
   “agrégation”
                                                                                                            Code
                                                                                          Bean            generator
                               Aggregation
                               (composite)                                                DAO




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                 26
Les artefacts générés 1 fois
 code « initial »  à reprendre
                                                                                                              Code
 (ne pas régénérer après évolution)                                                                         generator


                                      request                         BookMgr                 BookProc
           ScreenMap                                                  .java                    .java
                                      response             ScreenManager                  ScreenProcedure
   V                                                                                                        C
                                      AJAX                                                  acts on …

                                                                 BookData
                                                                  .java                   Book (bean)       M
                                                            ScreenData
                                                                                           AuthorList
               Book.jsp                                    (aggregation
               ( or .jspx)
                                                           0 .. N objects)                Shop (bean)
                Book.js                                                                     DataSet


                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                             27
Screen body (exemple)
  JSP ou JSPX, pas de HTML !
  <%@ taglib uri="/telosys/widgets" prefix="t" %>

  <t:screenbody>

    <t:label       id="L_EmpId"    x="40" y="60" txt="Employee Id : " cl="PK_field_label" />
    <t:label       id="L_LastName" x="40" y="100" txt="Last name : " />
    <t:label       id="L_FirstName" x="40" y="140" txt="First name : " />
    <t:label       id="L_Birthdate" x="40" y="180" txt="Birthdate : " />

    <t:field x="200" y="60" id="EmpId" cl="PK_field" size="6" maxlength="6" />
    <t:field x="200" y="100" id="LastName"    size="30" maxlength="30" value="Aaaa" />

    <t:button x="460" y="100" id="b1" txt="My button" onclick="b1_onClick();"                          />

    <t:field x="200" y="140" id="FirstName" size="30" maxlength="30" value="Georges" />
    <t:field x="200" y="180" id="Birthdate" size="10" maxlength="10" value="" type="Date" />

    <t:radiogroup id="Contract" x="200" y="220">
     <t:radioitem id="R_field61" x="0" y="0" value="1" txt="C.D.D. (1)" />
     <t:radioitem id="R_field62" x="0" y="20" value="2" txt="C.D.I. (2)" />
    </t:radiogroup >

    <t:checkbox id="Manager" x="340" y="220" value="1" valueoff="9" txt="Manager"                           />

  </t:screenbody >



                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                          28
Conventions
  • "Framework" => "Frame" !
  • "CoC" ( Conventions over Configuration )
       – Les développeurs savent où placer les fichiers
       – Les outils savent où générer les fichiers et n’ont pas à
        modifier les fichiers de configuration
  • Exemple :                                          Java : 1 package                         Web : 1 répertoire



                1 écran =                                                                 +

                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                              29
Qu’est-ce qu’un projet Telosys ?
 • Une application Java Web standard
                                             src (server side)

                                             TelosysTools (+)                                   déploiement

                                             WebContent (client side)                                         .war




 • Le projet peut être organisé pour Maven,
   ou pas …

                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                              30
Démo avec Eclipse
 • Création d’un nouveau projet Telosys …
 1) Création d’un projet
 « Dynamic Web Project »                                                          2) Importation du
                                                                                  « Telosys starter kit »




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                     31
Démo avec Eclipse (suite)
   3) Tester le
      projet (run)




         4) Définir les
            conventions


                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                32
Utilisation des Telosys Tools
Vue d’ensemble
 Utilisable en ligne                                                                                   Tout peut être fait
 de commande                                                                                           dans Eclipse


                                                                                   Editors   Wizards   Properties




                                Repository             Repository                Template
           Database                                    .dbrep                      .vm
           Meta-data            generator              ( XML )

                                                                       Code
                                                                                                           .java
                                                                       generator
                                                          Context                                          .jsp / .jspx

                                                                                                           .js
                                                                              Velocity

                                                                                                           other …



                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                      34
Généralisation : nouvelles cibles
 • Si ça fonctionne pour le framework Telosys …
   ça peut aussi être utilisé pour …
    d’ autres frameworks Java
                                                                         - Spring MVC
                                                                         - Vaadin
                                                                         - etc…

      d’ autres langages/plates-formes
                                                                          - Flex (MXML & Action Script)
                                                                          - PHP
                                                                          - etc …

                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                35
La démo …
  • Connexion à la base de données
  • Génération du « repository »
  • Modification/adaptation du « repository »
  • Génération des objets basiques (Bean, List, DAO,
    Conv.)
  • Génération des écrans (server side & client side)
  • Modification des template
  • Gestion des liens inter-entités
  • Génération des beans pour JPA & Validators
  • Ajout d’un nouveau template spécifique
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                36
Conclusion
Conclusion
   Base de                                Modèle                                          Outils       Code initial
   données                                 léger




                                                           et le projet est
                                                           sur les rails…


                                                                                 Gain (J/H)
                                                                           Temps de mise en œuvre
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                           38
Le future
   • Roadmap 2012 / principales évolutions
        – Repository
             • Extension (sans limite) des informations pour chaque
               entité et chaque champ
             • Templates pour des collections d’entités
        – Screens design
             • Release officielle du plugin Screen Builder (WYSIWYG)
        –Portails
             • Portlet JSR-168 pour embarquer des écrans Telosys
               dans une page de portail
        – NoSQL
             • DAO pour GAE/BigTable & Cassandra
        – etc …
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                39
Questions ?
Appendix
Framework features
   Screen Maps
                                                                                          Widgets TagLib
                                              DataSet
             Services
                          JavaScript framework
         Commons/util classes                SQL DAO
                                   Logging
           Authentication
          XML converters      File upload/download

                      Text/CSV files parser                                               Selectable/Sortable
            Internationalization                                                          beans lists

                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                     42
Telosys Screen Builder
     A visual tool to design the Telosys Screens
     ( beta version )




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                43
Follow the project …
• Web site : http://www.telosys.org


•         LinkedIN
    http://www.linkedin.com/groups?gid=1340197

•         Twitter
    http://twitter.com/telosys

•         Viadeo (in french)
    http://www.viadeo.com/hu03/0024uydjnnwew6j/telosys
                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                44
The demo…
Demo
 • Use the database meta-data to generate the
   initial repository

             Database
                             Generation
                               rules


                        Repository
                        Generator




          Repository
          .dbrep
          ( XML )




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                46
Demo (cont’d)
 • The generated repository is editable
   with an Eclipse plugin editor


                                                                                                  Database

                                                                                                 Java Classes




                                                                                                                updatable




                             Database                                          Java Attributes
                                                O/R Mapping




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                     47
Demo (cont’d)
 • Java fields :
     – Each Java field can have additional information
     – Useful for
           • JSP/TagLib user input validation
           • "Bean Validation " annotations ( JSR 303 )
             or "Hibernate Validators"




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                48
Demo (cont’d)
 • Bulk generation




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                49
Demo (cont’d)
 • Generator templates
     – The generator is based on "Velocity"
     – The templates ( ".vm" files ) can be modified in order
      to conform with each project requirements
            • coding style
            • comments
            • etc…
                                                                                                       i.e. :
                                                                                                       add/remove
                                                                                                       serialization




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                                50
Demo (cont’d)
  • Entities links
       – The foreign keys can be used to generate
        links between entities
       –Useful for JPA beans generation




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                51
Demo (cont’d)
  • Generator project’s variables
       – Each project can
        define its own
        specific variables…


          … and use them
          in the templates
      #if ( $bean_jpa == "1" )
      $link.jpaAnnotations(4)
      #end




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                52
Demo (cont’d)
 • Adding a new specific template
      – 1) create the new “.vm” file                                                                    vo_doc_html.vm
      – 2) add it in the “templates.cfg” file
          HTML documentation ;                   ${BEANNAME}.html ;              doc/html ;       vo_doc_html.vm

             Title                                 File                           Folder           Template

      –3) use it in the tool …




                                                                                                                         53
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys                          www.telosys.org
                                                               ( http://www.telosys.org )
Demo (cont’d)
  • Using wizards

          New …




                                                                                     www.telosys.org
Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org )                54
The end

Contenu connexe

En vedette

Presentation1
Presentation1Presentation1
Presentation1954451
 
Evaluation q4
Evaluation q4Evaluation q4
Evaluation q4954451
 
W4 ucl@md day2011
W4 ucl@md day2011W4 ucl@md day2011
W4 ucl@md day2011MDDAY11
 
Evaluation q4
Evaluation q4Evaluation q4
Evaluation q4954451
 
Front cover analysis [autosaved]
Front cover analysis [autosaved]Front cover analysis [autosaved]
Front cover analysis [autosaved]954451
 
Audience research
Audience researchAudience research
Audience research954451
 
Drafting for masthead
Drafting for mastheadDrafting for masthead
Drafting for masthead954451
 
No magic@md day2011
No magic@md day2011No magic@md day2011
No magic@md day2011MDDAY11
 
Evaluation Q4
Evaluation Q4Evaluation Q4
Evaluation Q4954451
 
Yves caseau@md day2011
Yves caseau@md day2011Yves caseau@md day2011
Yves caseau@md day2011MDDAY11
 
Flat plan
Flat planFlat plan
Flat plan954451
 
What Can Be Gained from Listening to Children Living in Poverty? And How to A...
What Can Be Gained from Listening to Children Living in Poverty? And How to A...What Can Be Gained from Listening to Children Living in Poverty? And How to A...
What Can Be Gained from Listening to Children Living in Poverty? And How to A...Ministère de la Communauté française
 
Obeo thales@md day2011
Obeo thales@md day2011Obeo thales@md day2011
Obeo thales@md day2011MDDAY11
 
Target audience
Target audienceTarget audience
Target audience954451
 
Analysing magazine front covers
Analysing magazine front coversAnalysing magazine front covers
Analysing magazine front covers954451
 

En vedette (20)

Q5
Q5Q5
Q5
 
Presentation1
Presentation1Presentation1
Presentation1
 
Neets&parcours improbables gdl_tacklingearlyschoolleaving_20150709
Neets&parcours improbables gdl_tacklingearlyschoolleaving_20150709Neets&parcours improbables gdl_tacklingearlyschoolleaving_20150709
Neets&parcours improbables gdl_tacklingearlyschoolleaving_20150709
 
Evaluation q4
Evaluation q4Evaluation q4
Evaluation q4
 
W4 ucl@md day2011
W4 ucl@md day2011W4 ucl@md day2011
W4 ucl@md day2011
 
Evaluation q4
Evaluation q4Evaluation q4
Evaluation q4
 
Front cover analysis [autosaved]
Front cover analysis [autosaved]Front cover analysis [autosaved]
Front cover analysis [autosaved]
 
Audience research
Audience researchAudience research
Audience research
 
Drafting for masthead
Drafting for mastheadDrafting for masthead
Drafting for masthead
 
Q6
Q6Q6
Q6
 
No magic@md day2011
No magic@md day2011No magic@md day2011
No magic@md day2011
 
Evaluation Q4
Evaluation Q4Evaluation Q4
Evaluation Q4
 
Yves caseau@md day2011
Yves caseau@md day2011Yves caseau@md day2011
Yves caseau@md day2011
 
Flat plan
Flat planFlat plan
Flat plan
 
What Can Be Gained from Listening to Children Living in Poverty? And How to A...
What Can Be Gained from Listening to Children Living in Poverty? And How to A...What Can Be Gained from Listening to Children Living in Poverty? And How to A...
What Can Be Gained from Listening to Children Living in Poverty? And How to A...
 
Obeo thales@md day2011
Obeo thales@md day2011Obeo thales@md day2011
Obeo thales@md day2011
 
Target audience
Target audienceTarget audience
Target audience
 
Analysing magazine front covers
Analysing magazine front coversAnalysing magazine front covers
Analysing magazine front covers
 
Mirgawati (animals)
Mirgawati (animals)Mirgawati (animals)
Mirgawati (animals)
 
Lesson 2
Lesson 2Lesson 2
Lesson 2
 

Similaire à Sogeti telosys@md day2011

La plateforme de services dynamiques OSGi
La plateforme de services dynamiques OSGiLa plateforme de services dynamiques OSGi
La plateforme de services dynamiques OSGiDidier Donsez
 
Agile lille 2015 devops etapres
Agile lille 2015 devops etapresAgile lille 2015 devops etapres
Agile lille 2015 devops etapresLaurent Tardif
 
Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et ...
Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et  ...Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et  ...
Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et ...Jasmine Conseil
 
08 jus 20101123_cae_linux_presentation
08 jus 20101123_cae_linux_presentation08 jus 20101123_cae_linux_presentation
08 jus 20101123_cae_linux_presentationOpenCascade
 
Devoxx 2017 : toutes les actualités technologiques à surveiller !
Devoxx 2017 : toutes les actualités technologiques à surveiller !Devoxx 2017 : toutes les actualités technologiques à surveiller !
Devoxx 2017 : toutes les actualités technologiques à surveiller !Société ELOSI
 
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-gr__ce-__-Docker.pptx
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-gr__ce-__-Docker.pptxJFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-gr__ce-__-Docker.pptx
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-gr__ce-__-Docker.pptxAnisSalhi3
 
Meetup DevOps Aix-Marseille - théorie du chaos et architectures résilientes
Meetup DevOps Aix-Marseille - théorie du chaos et architectures résilientesMeetup DevOps Aix-Marseille - théorie du chaos et architectures résilientes
Meetup DevOps Aix-Marseille - théorie du chaos et architectures résilientesFrederic Leger
 
OpenStack & DevOps, l'Open Source au service du Cloud
OpenStack & DevOps, l'Open Source au service du CloudOpenStack & DevOps, l'Open Source au service du Cloud
OpenStack & DevOps, l'Open Source au service du CloudMichel-Marie Maudet
 
DevOps - Retour d’expérience - AlpesJug du 20 Septembre 2011
DevOps - Retour d’expérience - AlpesJug du 20 Septembre 2011DevOps - Retour d’expérience - AlpesJug du 20 Septembre 2011
DevOps - Retour d’expérience - AlpesJug du 20 Septembre 2011Henri Gomez
 
CompatibleOne OSCi OW2 Workshop July 11
CompatibleOne  OSCi OW2 Workshop July 11CompatibleOne  OSCi OW2 Workshop July 11
CompatibleOne OSCi OW2 Workshop July 11CompatibleOne
 
Microservices-DDD-Telosys-Devoxx-FR-2022
Microservices-DDD-Telosys-Devoxx-FR-2022Microservices-DDD-Telosys-Devoxx-FR-2022
Microservices-DDD-Telosys-Devoxx-FR-2022Laurent Guérin
 
Apéro techno node.js + AngularJS @Omnilog 2014
Apéro techno node.js + AngularJS @Omnilog 2014Apéro techno node.js + AngularJS @Omnilog 2014
Apéro techno node.js + AngularJS @Omnilog 2014Yves-Emmanuel Jutard
 
OpenStack - open source au service du Cloud
OpenStack - open source au service du CloudOpenStack - open source au service du Cloud
OpenStack - open source au service du CloudLINAGORA
 
20111205 breizh jug-devops
20111205 breizh jug-devops20111205 breizh jug-devops
20111205 breizh jug-devopsHenri Gomez
 
CDI mis en pratique avec Seam Social et Weld OSGI
CDI mis en pratique avec Seam Social et Weld OSGICDI mis en pratique avec Seam Social et Weld OSGI
CDI mis en pratique avec Seam Social et Weld OSGIAntoine Sabot-Durand
 
CDI par la pratique
CDI par la pratiqueCDI par la pratique
CDI par la pratiqueIppon
 
Capitole du Libre 2018 - Déployer des applications python dans un cluster Ope...
Capitole du Libre 2018 - Déployer des applications python dans un cluster Ope...Capitole du Libre 2018 - Déployer des applications python dans un cluster Ope...
Capitole du Libre 2018 - Déployer des applications python dans un cluster Ope...Arthur Lutz
 
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-grâce-à-Docker.pdf
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-grâce-à-Docker.pdfJFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-grâce-à-Docker.pdf
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-grâce-à-Docker.pdfqsdqsd4
 

Similaire à Sogeti telosys@md day2011 (20)

La plateforme de services dynamiques OSGi
La plateforme de services dynamiques OSGiLa plateforme de services dynamiques OSGi
La plateforme de services dynamiques OSGi
 
Agile lille 2015 devops etapres
Agile lille 2015 devops etapresAgile lille 2015 devops etapres
Agile lille 2015 devops etapres
 
Javavs net
Javavs netJavavs net
Javavs net
 
Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et ...
Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et  ...Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et  ...
Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et ...
 
08 jus 20101123_cae_linux_presentation
08 jus 20101123_cae_linux_presentation08 jus 20101123_cae_linux_presentation
08 jus 20101123_cae_linux_presentation
 
Devoxx 2017 : toutes les actualités technologiques à surveiller !
Devoxx 2017 : toutes les actualités technologiques à surveiller !Devoxx 2017 : toutes les actualités technologiques à surveiller !
Devoxx 2017 : toutes les actualités technologiques à surveiller !
 
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-gr__ce-__-Docker.pptx
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-gr__ce-__-Docker.pptxJFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-gr__ce-__-Docker.pptx
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-gr__ce-__-Docker.pptx
 
Meetup DevOps Aix-Marseille - théorie du chaos et architectures résilientes
Meetup DevOps Aix-Marseille - théorie du chaos et architectures résilientesMeetup DevOps Aix-Marseille - théorie du chaos et architectures résilientes
Meetup DevOps Aix-Marseille - théorie du chaos et architectures résilientes
 
OpenStack & DevOps, l'Open Source au service du Cloud
OpenStack & DevOps, l'Open Source au service du CloudOpenStack & DevOps, l'Open Source au service du Cloud
OpenStack & DevOps, l'Open Source au service du Cloud
 
DevOps - Retour d’expérience - AlpesJug du 20 Septembre 2011
DevOps - Retour d’expérience - AlpesJug du 20 Septembre 2011DevOps - Retour d’expérience - AlpesJug du 20 Septembre 2011
DevOps - Retour d’expérience - AlpesJug du 20 Septembre 2011
 
CompatibleOne OSCi OW2 Workshop July 11
CompatibleOne  OSCi OW2 Workshop July 11CompatibleOne  OSCi OW2 Workshop July 11
CompatibleOne OSCi OW2 Workshop July 11
 
Microservices-DDD-Telosys-Devoxx-FR-2022
Microservices-DDD-Telosys-Devoxx-FR-2022Microservices-DDD-Telosys-Devoxx-FR-2022
Microservices-DDD-Telosys-Devoxx-FR-2022
 
Apéro techno node.js + AngularJS @Omnilog 2014
Apéro techno node.js + AngularJS @Omnilog 2014Apéro techno node.js + AngularJS @Omnilog 2014
Apéro techno node.js + AngularJS @Omnilog 2014
 
OpenStack - open source au service du Cloud
OpenStack - open source au service du CloudOpenStack - open source au service du Cloud
OpenStack - open source au service du Cloud
 
Gradle_LyonJUG
Gradle_LyonJUGGradle_LyonJUG
Gradle_LyonJUG
 
20111205 breizh jug-devops
20111205 breizh jug-devops20111205 breizh jug-devops
20111205 breizh jug-devops
 
CDI mis en pratique avec Seam Social et Weld OSGI
CDI mis en pratique avec Seam Social et Weld OSGICDI mis en pratique avec Seam Social et Weld OSGI
CDI mis en pratique avec Seam Social et Weld OSGI
 
CDI par la pratique
CDI par la pratiqueCDI par la pratique
CDI par la pratique
 
Capitole du Libre 2018 - Déployer des applications python dans un cluster Ope...
Capitole du Libre 2018 - Déployer des applications python dans un cluster Ope...Capitole du Libre 2018 - Déployer des applications python dans un cluster Ope...
Capitole du Libre 2018 - Déployer des applications python dans un cluster Ope...
 
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-grâce-à-Docker.pdf
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-grâce-à-Docker.pdfJFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-grâce-à-Docker.pdf
JFTL-2018-Comment-mettre-en-place-des-plateformes-de-test-grâce-à-Docker.pdf
 

Plus de MDDAY11

W4@md day2011
W4@md day2011W4@md day2011
W4@md day2011MDDAY11
 
Soft fluent@md day2011
Soft fluent@md day2011Soft fluent@md day2011
Soft fluent@md day2011MDDAY11
 
Objet direct@md day2011
Objet direct@md day2011Objet direct@md day2011
Objet direct@md day2011MDDAY11
 
Modeliosoft@md day2011
Modeliosoft@md day2011Modeliosoft@md day2011
Modeliosoft@md day2011MDDAY11
 
Modelio praxeme@md day2011
Modelio praxeme@md day2011Modelio praxeme@md day2011
Modelio praxeme@md day2011MDDAY11
 
Mia software@md day2011
Mia software@md day2011Mia software@md day2011
Mia software@md day2011MDDAY11
 
Blu age@md day2011
Blu age@md day2011Blu age@md day2011
Blu age@md day2011MDDAY11
 
Axel uhl sap@md-day2011
Axel uhl sap@md-day2011Axel uhl sap@md-day2011
Axel uhl sap@md-day2011MDDAY11
 

Plus de MDDAY11 (8)

W4@md day2011
W4@md day2011W4@md day2011
W4@md day2011
 
Soft fluent@md day2011
Soft fluent@md day2011Soft fluent@md day2011
Soft fluent@md day2011
 
Objet direct@md day2011
Objet direct@md day2011Objet direct@md day2011
Objet direct@md day2011
 
Modeliosoft@md day2011
Modeliosoft@md day2011Modeliosoft@md day2011
Modeliosoft@md day2011
 
Modelio praxeme@md day2011
Modelio praxeme@md day2011Modelio praxeme@md day2011
Modelio praxeme@md day2011
 
Mia software@md day2011
Mia software@md day2011Mia software@md day2011
Mia software@md day2011
 
Blu age@md day2011
Blu age@md day2011Blu age@md day2011
Blu age@md day2011
 
Axel uhl sap@md-day2011
Axel uhl sap@md-day2011Axel uhl sap@md-day2011
Axel uhl sap@md-day2011
 

Sogeti telosys@md day2011

  • 1. Génération de code à partir d’un « modèle léger » Laurent Guérin Telosys Project Leader Sogeti & OW2 Consortium Paris - 24 novembre 2011
  • 2. Introduction Sogeti : Company Capgemini : Company belongs to : Plateform Laurent Guérin : Person Telosys : Project leads laurent.guerin@sogeti.com : IDE located in hosts OW2 : Consortium : License France : Country www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 2
  • 4. Contexte • Constat : – Généralisation de Java :-) – Projet Java = projet lourd :-( • Génération de code ? Oui, mais … – solution légère et efficace, adaptée aux projets à cycle court – solution simple, utilisable par tous – environnement léger (installation en quelques heures/minutes) • Objectif « démarrage rapide » www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 4
  • 5. Le projet Telosys Method Tools Framework ( code generation ) ( global & simple ) • Un framework global, auto-suffisant pour construire une application complète • Des outils (plugins Eclipse) pour générer le code initial de l’application et guider le développeur. Puis ouverture sur d’autres cibles… www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 5
  • 6. Philosophie du projet “Keep it simple and stupid” ( KISP ? ) – framework simple et léger – « petits outils » (faciles à installer et à utiliser) “Respects des standards” – servlet/JSP/JSPX, JDBC, JPA, http, XML, … “Ouverture” – Open Source ( projet / OW2 consortium ) – Format ouvert (modèle léger = XML) – Templates adaptables  différentes cibles : Telosys fwk, autres Frameworks Java, Flex, PHP, … www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 6
  • 7. Outillage • Ne pas réinventer la roue (il existe déjà de nombreux outils), apporter une alternative • Offrir une boite à outils intégrée dans Eclipse, immédiatement utilisable par des développeurs non initiés au MDD • La génération de code pour tous ! - sophistication + www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 7
  • 9. Le framework • Framework global “all in one“ • Un seul jar (+ JDBC) => pas de "jar hell" ! • Basé sur des concepts simples • Léger (servlet container + base de données) www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 9
  • 10. « Global effect » Un seul framework qui couvre toutes les couches de l’application Authenti- cation Presentation Application Business Persistence Services Screen Java Beans Maps ( POJO ) DAO XML conv "VO" SQL JSP + taglib Screen AJAX Managers Framework Services Thin persistence Javascript layer Very simple objects Natively AJAX Commons, logging, I18N, … ( "Pure POJO" ) • “Global” => moins de “glue”, moins d’objets (empreinte mémoire réduite), moins de configuration, … => plus homogène • “Modulaire” (utilisation partielle) www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 10
  • 11. Le paradigme « client-serveur » • Une fois chargé dans le navigateur, un écran dialogue avec le server via des requêtes AJAX • Découplage ( facilite la génération de code ) Client-side http Server-side <request screen-name="Employee" screen-id="0" action="get" > </request> Screen Manager Action <response screen-name="Employee" screen-id="0" action="get" > <return code="0" message="Ok" > </return> Framework JavaScript <data> <employee id="23" lastName="Wayne" firstName="John" manager="0" email="" /> </data> </response> Service Service http://myhost:8080/.../Add.svc?p1=2&p2=6 <response service-name="Add"> <return code="0" message="Ok" /> <values> <value result="8" /> </values> <data> </data> </response> www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 11
  • 12. La persistance • Une alternative aux “ORM” classiques ORM : JPA (or Hibernate) … High level & "Object Oriented" Java objects Hides the complexity rule the persistence Sometimes misunderstood by the developers ( "lazy/eager" loading, cache effects, DB "attached/detached" entities, "owning side"/"inverse side" links, … ) new new Telosys DAL (based on DAO pattern) Intermediate level & "Record Oriented" Database records One Bean = One Record rule the persistence The developer keeps the control No links, no cache, no byte-code enhancement DB Very simple API : load, save, insert, update, exists, loadList, updateList, … new legacy JDBC API Les deux sont utiles. Low level Au choix … www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 12
  • 13. Un framework ne suffit pas… Outils Framework « boilerplate » Plate-forme (Java EE) Application Code générique Code spécifique • Le problème : le code technique et spécifique • Les outils de génération de code sont une réponse possible. Exemples : Ruby on Rails, Grails, Spring Roo, etc… www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 13
  • 14. Génération de code Les différentes approches
  • 15. Approche « Model First » • Démarche MDD classique, MDA, etc … • « Model - First » => concevoir un model ! – investissement initial important – nécessite de respecter le process (formation) • Incompatible avec un démarrage rapide MODEL Split ! XMI Service name +port 0..n ( XML ) Port Binding Port Type 1 +binding name name name Param 1 +type name StartWithExtensions +output 0..1 +operation 0..n +operation 0..n +input Input 0..1 +input BindingOperation Operation 0..1 Code name name 1 0..1 Output +output +message 1 +fault 0..n +fault 0..n Message Fault +message BindingFault name name 1 1 +part 0..n Part name TOOL Template Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) www.telosys.org 15
  • 16. Approche « scaffolding » • Scaffolding de type « Database - First » • Très efficace ( rapide ) Database • Mais pas d’action possible sur l’outil Metadata de génération • Pas assez d’informations … TOOL – Noms/types des attributs Java – Règles de validation : min, max, regexp, … Template – Représentation des Booléens (1/0, "T"/"F", … ) Code – etc … • Il faudrait injecter/stocker des informations complémentaires… un modèle ? www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 16
  • 17. Les « wizards » • Bien intégré dans l’IDE :-) “Java Model” org.eclipse.jdt.core • Informations en entrée : Workspace files – Saisie utilisateur :-( I.D.E. – Artefacts existants dans le projet • Java class  Java class • WSDL file  Java classes • Génération unitaire, non automatisable • Peuvent être utilisés comme Bulk Code generation des « accélérateurs » ( après la génération de masse ) www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 17
  • 19. Expression du besoin • Les souhaits : – générer rapidement le code initial des écrans de DB mise à jour des entités d’une base de données Metadata (notion de scaffolding / database first) – avec un outil simple, bien intégré dans l’IDE (comme les wizards) Template – modifier/adapter les « patrons » de génération (notion de templates) – modifier (raffiner) les informations brutes issues des méta-data, pouvoir y ajouter des informations complémentaires Modèle ? – lancer des générations de masse www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 19
  • 20. Telosys Tools : le processus • Un processus en 3 étapes Template Database updates customizes Metadata modify & add information Code Repository Code generator generator generates Repository (Lightweight updates model) 1 2 3 Approche Adapter / enrichir Générer “Database-first” le “modèle léger” le code pour initialiser un initial “modèle léger” www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 20
  • 21. Telosys Tools • Modèle ( « léger » ) – seules les entités sont gérées – représentation graphique inutile – simple fichier XML (indépendant d’Eclipse) – adhérence Eclipse : limitée à l’ IHM • Moteur de génération de code ( « templating engine » ) – simple – connu – open source – utilisable avec les wizards Basique mais suffisant www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 21
  • 22. Editeur de modèle workspace Fichier Repository (model) .dbrep Database Java Classes modifiable Database Java Attributes O/R Mapping www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 22
  • 23. Velocity ( templating engine ) Extrait d’un template (génération d’un bean) public class $class.name implements Serializable { private static final long serialVersionUID = 1L; Repository //--- ATTRIBUTES #foreach( $field in $class.attributes ) (model) private $field.formatedType(10) $field.formatedName(12) ; #end //--- CONSTRUCTOR(S) public ${class.name}() { Velocity super(); Context } //--- GETTERS & SETTERS #foreach( $field in $class.attributes ) $class #if ( $field.setter ) public void ${field.setter}( $field.type value ) etc… { this.$field.name = value; } #end #if ( $field.getter ) public $field.type ${field.getter}() { return this.$field.name; } #end #end cf documentation sur le site Apache www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 23
  • 25. Les artefacts générés N fois • VO Bean (POJO = “entity record”) • VO List (liste de bean avec tri & sélection) Code generator • DAO code « jetable » • Convertisseurs Book .java BookDAO BookConv VO Bean .java .java Data Database XML XML Access <…> VO List Layer Book </ … > Table Con- BookList verters .java DataSet Parsers Files www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 25
  • 26. Persistance : objet ou record ? • Approche “graphe d’objets” : les liens peuvent être générés (persistance de type JPA) Bean @ManyToOne Code @OneToMany generator @ManyToMany @OneToOne • Approche “record” : les liens ne sont pas nécessaires, assemblage possible par “agrégation” Code Bean generator Aggregation (composite) DAO www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 26
  • 27. Les artefacts générés 1 fois code « initial »  à reprendre Code (ne pas régénérer après évolution) generator request BookMgr BookProc ScreenMap .java .java response ScreenManager ScreenProcedure V C AJAX acts on … BookData .java Book (bean) M ScreenData AuthorList Book.jsp (aggregation ( or .jspx) 0 .. N objects) Shop (bean) Book.js DataSet www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 27
  • 28. Screen body (exemple) JSP ou JSPX, pas de HTML ! <%@ taglib uri="/telosys/widgets" prefix="t" %> <t:screenbody> <t:label id="L_EmpId" x="40" y="60" txt="Employee Id : " cl="PK_field_label" /> <t:label id="L_LastName" x="40" y="100" txt="Last name : " /> <t:label id="L_FirstName" x="40" y="140" txt="First name : " /> <t:label id="L_Birthdate" x="40" y="180" txt="Birthdate : " /> <t:field x="200" y="60" id="EmpId" cl="PK_field" size="6" maxlength="6" /> <t:field x="200" y="100" id="LastName" size="30" maxlength="30" value="Aaaa" /> <t:button x="460" y="100" id="b1" txt="My button" onclick="b1_onClick();" /> <t:field x="200" y="140" id="FirstName" size="30" maxlength="30" value="Georges" /> <t:field x="200" y="180" id="Birthdate" size="10" maxlength="10" value="" type="Date" /> <t:radiogroup id="Contract" x="200" y="220"> <t:radioitem id="R_field61" x="0" y="0" value="1" txt="C.D.D. (1)" /> <t:radioitem id="R_field62" x="0" y="20" value="2" txt="C.D.I. (2)" /> </t:radiogroup > <t:checkbox id="Manager" x="340" y="220" value="1" valueoff="9" txt="Manager" /> </t:screenbody > www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 28
  • 29. Conventions • "Framework" => "Frame" ! • "CoC" ( Conventions over Configuration ) – Les développeurs savent où placer les fichiers – Les outils savent où générer les fichiers et n’ont pas à modifier les fichiers de configuration • Exemple : Java : 1 package Web : 1 répertoire 1 écran = + www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 29
  • 30. Qu’est-ce qu’un projet Telosys ? • Une application Java Web standard src (server side) TelosysTools (+) déploiement WebContent (client side) .war • Le projet peut être organisé pour Maven, ou pas … www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 30
  • 31. Démo avec Eclipse • Création d’un nouveau projet Telosys … 1) Création d’un projet « Dynamic Web Project » 2) Importation du « Telosys starter kit » www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 31
  • 32. Démo avec Eclipse (suite) 3) Tester le projet (run) 4) Définir les conventions www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 32
  • 34. Vue d’ensemble Utilisable en ligne Tout peut être fait de commande dans Eclipse Editors Wizards Properties Repository Repository Template Database .dbrep .vm Meta-data generator ( XML ) Code .java generator Context .jsp / .jspx .js Velocity other … www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 34
  • 35. Généralisation : nouvelles cibles • Si ça fonctionne pour le framework Telosys … ça peut aussi être utilisé pour …  d’ autres frameworks Java - Spring MVC - Vaadin - etc…  d’ autres langages/plates-formes - Flex (MXML & Action Script) - PHP - etc … www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 35
  • 36. La démo … • Connexion à la base de données • Génération du « repository » • Modification/adaptation du « repository » • Génération des objets basiques (Bean, List, DAO, Conv.) • Génération des écrans (server side & client side) • Modification des template • Gestion des liens inter-entités • Génération des beans pour JPA & Validators • Ajout d’un nouveau template spécifique www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 36
  • 38. Conclusion Base de Modèle Outils Code initial données léger et le projet est sur les rails… Gain (J/H) Temps de mise en œuvre www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 38
  • 39. Le future • Roadmap 2012 / principales évolutions – Repository • Extension (sans limite) des informations pour chaque entité et chaque champ • Templates pour des collections d’entités – Screens design • Release officielle du plugin Screen Builder (WYSIWYG) –Portails • Portlet JSR-168 pour embarquer des écrans Telosys dans une page de portail – NoSQL • DAO pour GAE/BigTable & Cassandra – etc … www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 39
  • 42. Framework features Screen Maps Widgets TagLib DataSet Services JavaScript framework Commons/util classes SQL DAO Logging Authentication XML converters File upload/download Text/CSV files parser Selectable/Sortable Internationalization beans lists www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 42
  • 43. Telosys Screen Builder A visual tool to design the Telosys Screens ( beta version ) www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 43
  • 44. Follow the project … • Web site : http://www.telosys.org • LinkedIN http://www.linkedin.com/groups?gid=1340197 • Twitter http://twitter.com/telosys • Viadeo (in french) http://www.viadeo.com/hu03/0024uydjnnwew6j/telosys www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 44
  • 46. Demo • Use the database meta-data to generate the initial repository Database Generation rules Repository Generator Repository .dbrep ( XML ) www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 46
  • 47. Demo (cont’d) • The generated repository is editable with an Eclipse plugin editor Database Java Classes updatable Database Java Attributes O/R Mapping www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 47
  • 48. Demo (cont’d) • Java fields : – Each Java field can have additional information – Useful for • JSP/TagLib user input validation • "Bean Validation " annotations ( JSR 303 ) or "Hibernate Validators" www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 48
  • 49. Demo (cont’d) • Bulk generation www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 49
  • 50. Demo (cont’d) • Generator templates – The generator is based on "Velocity" – The templates ( ".vm" files ) can be modified in order to conform with each project requirements • coding style • comments • etc… i.e. : add/remove serialization www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 50
  • 51. Demo (cont’d) • Entities links – The foreign keys can be used to generate links between entities –Useful for JPA beans generation www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 51
  • 52. Demo (cont’d) • Generator project’s variables – Each project can define its own specific variables… … and use them in the templates #if ( $bean_jpa == "1" ) $link.jpaAnnotations(4) #end www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 52
  • 53. Demo (cont’d) • Adding a new specific template – 1) create the new “.vm” file vo_doc_html.vm – 2) add it in the “templates.cfg” file HTML documentation ; ${BEANNAME}.html ; doc/html ; vo_doc_html.vm Title File Folder Template –3) use it in the tool … 53 Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys www.telosys.org ( http://www.telosys.org )
  • 54. Demo (cont’d) • Using wizards New … www.telosys.org Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 54