Devoxx 2011 - Scaffolding with Telosys
Upcoming SlideShare
Loading in...5
×
 

Devoxx 2011 - Scaffolding with Telosys

on

  • 4,655 views

Devoxx 2011 - Telosys conference

Devoxx 2011 - Telosys conference

Statistics

Views

Total Views
4,655
Views on SlideShare
4,653
Embed Views
2

Actions

Likes
1
Downloads
19
Comments
1

1 Embed 2

http://a0.twimg.com 2

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

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

Devoxx 2011 - Scaffolding with Telosys Devoxx 2011 - Scaffolding with Telosys Presentation Transcript

  • A pragmatic scaffolding approachto build Java Web ApplicationsLaurent GuérinTelosys Project LeaderSogeti & OW2 Consortium
  • 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 : CountryDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 2
  • Introduction OUTLINE : - Code generation - Telosys approach - The framework - The tools (demo)Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 3
  • About code generation …
  • Model Driven • "Model-First" approach ( MDD, MDA, … ) • Code generation from an existing model • "Model Driven" => You need a model ! • Model => substantial initial investment • Process : keep the model up to date ! 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 TemplateDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 5
  • Scaffolding • "Database-first" approach Database • Very efficient • No customization between the database Metadata metadata and the generator TOOL • Not enough information … – Java field name Template – Java field type – Validation rules : min, max, regexp, … Code – Boolean storage values ( 1/0, "T"/"F", … ) – etc … • Cannot store/reuse further informationDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 6
  • Wizards • Code generation without model / DB “Java Model” org.eclipse.jdt.core • IDE tool => Needs user inputs Workspace files I.D.E. • Can also use existing artefacts as input – Java class  Java class – WSDL file  Java classes • Efficient only for a few kinds of targets Code • Can only be considered as Bulk generation "development accelerators"Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 7
  • The Telosys approach
  • Telosys approach • What we want … – to be able to generate code quickly for entities management (like scaffolding) with a simple tool – to add and keep specific information about entities => we need a repository to store them (kind of model) • What we don’t want … – to spend a lot of time to build a model – to input further information for each generation • What we must have … – a database (“database first”) Metadata DB + – an IDE (Eclipse) that is the developer’s daily toolDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 9
  • Telosys approach • The 3 steps … Template Database updates customizes Metadata modify & add information Code Repository Code generator generator generates Repository (Lightweight updates model) 1 2 3 Use the Customize the Generate “Database-first” “lightweight model” the code approach to build a “lightweight model”Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 10
  • The tripod of success What a Method ( agile ) development project needs… Tools Framework ( code generation ) ( global & simple ) • The framework is self-sufficient to build a complete Web application ( "global" / "full stack" framework ) • The tools are provided as Eclipse plugins in order to make the programmers life easierDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 11
  • Project’s philosophy • “Keep it simple and stupid” ( KISP ? ) – lightweight framework – small tools (easy to install & to use) • “Conform with the standards” – servlet/JSP/JSPX, JDBC, JPA, http, XML, … • “Remain open” – Open Source (hosted by OW2 consortium) – Open Format (lightweight model = XML) – Customizable templates  different targets : Telosys fwk + other Java Frameworks, Flex, PHP, …Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 12
  • The Telosys framework
  • The framework • Global framework “all in one“ • Only one jar (+ JDBC) => no "jar hell" ! • Designed for "data centric" web applications • Light (just needs a servlet container and a database) & based on simple conceptsDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 14
  • The "global effect" One framework that covers all the application layers 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” means … less “glue”, less objects (less memory footprint), less configuration, … => Coherence & Efficiency • “Modular” (modules usable separately)Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 15
  • The "client-server" paradigm • Once the screen is loaded in the browser, it converses with the server via AJAX requests ( XML / http ) 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>Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 16
  • The "Data Objects" • VO Bean (POJO = “entity record”) Code • VO List (selectable/sortable list of POJO) generator • DataSet (grid of objects) Book .java BookDAO BookConv VO Bean .java .java Data Database XML XML Access <…> VO List Layer Book </ … > Table Con- BookList verters .java DataSet Parsers FilesDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 17
  • The "Data Access Layer" • Why another persistence framework ? 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 Both are useful, Low level You have the choice …Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 18
  • "Record Persistence" examples  A "record" = a bean (POJO)  Each bean is managed by a dedicated DAO EmployeeDAO dao = getDAO(); Employee employee = new Employee(); employee.setCode( "123" ); // primary key int r = dao.load(employee, db); The developer decides… if ( r > 0 ) { // if found . What to do // update employee.setFirstName("Bill"); . How to do it dao.update(employee, db); } . When to do it else { // create employee.setLastName("Wayne"); EmployeeList list = new EmployeeList(); employee.setFirstName("John"); ListQuery query = dao.createQuery(…); employee.setEmail("jwayne@cinema.com"); int count = dao.count(query, db); dao.insert(employee, db); dao.loadList(query, list, db); } dao.updateList(list, db); if (dao.exists(employee,db)){...} dao.delete(employee, db); db.commit(); db.rollback();Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 19
  • Links or no links ? • You have the choice … • Links can be generated if an “object graph approach” is chosen (ie with JPA persistence) Bean @ManyToOne Code @OneToMany generator @ManyToMany @OneToOne • With a “record approach” : no need to manage links between beans, the framework uses “aggregations” to assemble required beans Code Bean generator Aggregation (composite) DAODevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 20
  • The screens Code 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 DataSetDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 21
  • Screen view example JSP or JSPX, but no 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 >Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 22
  • Conventions • "Framework" => "Frame" ! • "CoC" ( Conventions over Configuration ) – The developers know where the files are – The tools know where to generate files • Example : 1 Java package 1 web folder 1 screen = +Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 23
  • What is a Telosys project ? • Just a standard Java Web Application project src (server side) TelosysTools (+) deployment WebContent (client side) .war • It can be organized for Maven, or not… • In Eclipse : That’s all ! 1) Create a new "Web Dynamic project" The project is ready for development and 2) Import the "Telosys Starter Kit“ code generationDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 24
  • Demo • How to create a Telosys project … 1) Create a Dynamic Web Project 2) Import the Telosys starter kitDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 25
  • Demo (cont’d) • Test and initialize the Telosys project … 3) Test the project ( run it ) 4) Define the conventionsDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 26
  • The Telosys Tools
  • The big picture Everything can be done in Eclipse Editors Wizards Properties Repository Repository Template Database .dbrep .vm Meta-data generator ( XML ) Code .java generator Context .jsp / .jspx .js Velocity other …Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 28
  • The demo • Connection to the database • Repository generation • Repository customization • Basic objects generation (Bean, List, DAO, Conv.) • Screens generation (server side & client side) • Template customization • Links management • Beans generation for JPA & Validators • New specific template See demo screenshots at the end of this presentationDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 29
  • Conclusion
  • Conclusion Database Repository Tools Initial code and the project is on the rails…Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 31
  • In the future … • Main goals in the 2012 roadmap – Repository • Extendable/unlimited information for each entity and each Java field – Screens design • Official release of the Screen Builder plugin (WYSIWYG) Still a lot – Java Portals of work to • JSR-168 portlet to embed screen maps in a portal page improve – NoSQL the rails … • DAO for GAE/BigTable & CassandraDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 32
  • 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 listsDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 35
  • Telosys Screen Builder A visual tool to design the Telosys Screens ( beta version )Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 36
  • 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/telosysDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 37
  • The demo…
  • Demo • Use the database meta-data to generate the initial repository Database Generation rules Repository Generator Repository .dbrep ( XML )Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 39
  • Demo (cont’d) • The generated repository is editable with an Eclipse plugin editor Database Java Classes updatable Database Java Attributes O/R MappingDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 40
  • 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"Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 41
  • Demo (cont’d) • Bulk generationDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 42
  • 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 serializationDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 43
  • Demo (cont’d) • Entities links – The foreign keys can be used to generate links between entities –Useful for JPA beans generationDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 44
  • 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) #endDevoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 45
  • 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 …Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 46
  • Demo (cont’d) • Using wizards New …Devoxx 2011 – Laurent Guérin – JAVA scaffolding with Telosys ( http://www.telosys.org ) 47
  • The end