SlideShare uma empresa Scribd logo
1 de 49
Baixar para ler offline
Spring 3.0
                            Gildas Cuisinier




vendredi 19 février 2010
Gildas Cuisinier


                   Consultant Java depuis 3 ans
                       Gam Consult Luxembourg
                       Certifié Spring

                   Responsable Spring @
                   Developpez.com
                       Article, FAQ, Forum, Compte rendu

                   Relecteur technique
                                                           2
vendredi 19 février 2010
Agenda




                   Retrospective
                   Spring 3.0
                   Spring et JEE 6



                                     3
vendredi 19 février 2010
Retrospective



vendredi 19 février 2010
Avant Spring




                   EJB 2
                       Modèle complexe
                       Difficile à tester




                                            5
vendredi 19 février 2010
Spring 1.0



                   Mars 2004
                   Fonctionnalités
                       Inversion du contrôle
                       Programmation Orienté Aspect (AOP)
                       Support de Jdbc, Hibernate, JDO
                       Framework Web


                                                            6
vendredi 19 février 2010
Instanciation




                   Dépendance directe
                   Difficile à tester
                                        7
vendredi 19 février 2010
Registre




                           8
vendredi 19 février 2010
IoC : Injection de dépendances
                                 Injecte InstanceB

                              Instancie




                             Instancie




                                                     9
vendredi 19 février 2010     Instancie
IoC : Avantages




                   POJO
                   Dépendance uniquement sur les
                   contrats
                   Plus simple à tester


                                                   10
vendredi 19 février 2010
Spring 1.0



                   Configuration xml, basée sur une
                   DTD
                       Un seul tag : <bean>

                   Possibilité de métadonnées sur les
                   classes
                       Basé sur Xdoclet



vendredi 19 février 2010
Spring 1.2



                   Mai 2005
                   Toujours basé sur une DTD
                       Alias, import



                   Premier support du JDK 5 !
                       @Transactional, …



vendredi 19 février 2010
Spring 2.0

                   Octobre 2006
                   Simplification de la configuration
                   XML
                       Basé sur XML Schema
                       Namespaces dédiés
                           JEE, Transaction, AOP, Lang, Util

                       Scope

                   Annotations AspectJ
                                                               13
vendredi 19 février 2010
Spring 2.5

                   Novembre 2007
                   Nouveaux namespaces :
                       JMS
                       Context

                   Annotations
                       Spring : IoC, Tests, Web
                       Standard JEE

                   Toujours compatible JDK 1.4
                                                  14
vendredi 19 février 2010
Spring 3.0



vendredi 19 février 2010
Spring 3.0



                   Supports, dépréciations et
                   suppressions
                   Nouveautés de Spring 3
                       Rest, Expression Languages, namespaces

                   Spring 3.1


                                                                16
vendredi 19 février 2010
Java 5 - ApplicationContext



     <T> T getBean(Class<T> requiredType) throws
     BeansException;




                                         Pas de casting

     SpeakerRepository repository =
          context.getBean(SpeakerRepository.class);
     	 	


                                                          17
vendredi 19 février 2010
Java 5 - RowMapper
     private class SpeakerMapper implements RowMapper<Speaker> {




     	 	 public Speaker mapRow(ResultSet rs, int rowNum) throws
     SQLException {
     	 	 	
     	 	 	
     	 	 	 return SpeakerBuilder.SpeakerWith()
     	 	 	 	 	 	 .id(rs.getInt(1))
     	 	 	 	 	 	 .firstName(	 rs.getString(2))
     	 	 	 	 	 	 .lastName(rs.getString(3))
     	 	 	 	 	 	 .email(rs.getString(4))
     	 	 	 	 	 	 .birthday(rs.getDate(5))
     	 	 	 	 	 	 .build();
     	 	 }
     	 }


                                                                   18
vendredi 19 février 2010
Java 5 - Varargs
              Avant
              public Integer saveOld(Speaker speaker) {
              	 	 return template.update("insert into speakers values
              (null, ?,?,?,?)",
              	 	 	 	 	 new Object[]{speaker.getFirstName(),
              	 	 	 	 	 	 	 	 speaker.getLastName(),
              	 	 	 	 	 	 	 	 speaker.getEmail(),
              	 	 	 	 	 	 	 	 speaker.getBirthday()});
              	 }

              Spring 3
              public Integer save(Speaker speaker) {
              	 	 return template.update("insert into speakers values
              (null, ?,?,?,?)",
              	 	 	 	 	 speaker.getFirstName(),
              	 	 	 	 	 speaker.getLastName(),
              	 	 	 	 	 speaker.getEmail(),
              	 	 	 	 	 speaker.getBirthday());
              	 }                                                       19
vendredi 19 février 2010
Supports

                   JDK 1.5+
                       Rupture : JDK 1.4 n’est plus supporté

                   Dépréciation
                       Hiérarchie de contrôleur Web
                       Hiérarchie de classe pour Junit 3.8
                       Le support de Struts 1.0

                   Suppression
                       Le support de Commons Attributes
                       Le support de Toplink                   20
vendredi 19 février 2010
DEMO
                           DROP IN


vendredi 19 février 2010
Spring OXM

                   Inclusion du module de mapping
                   Object / XML
                       Provient de Spring WS

                   Permet une abstraction des API
                   communes
                       JAXB, JiBX, Xstream, Castor
                       Unification des exceptions

                   Utilisation
                       Gestion des payload REST en XML
                                                         22
vendredi 19 février 2010
JavaConfig

                   Configuration par annotations
                       @Configuration, @Bean, @Lazy, @Primary, @Import,
                       @Value

                   Version XML :
                       <beans>
                       <bean name=“monBean"
                       class=“be.hikage.MonBeanImpl"/>
                        </beans>

                   Version Annotation:
                       @Configuration
                       public class AppConfig {                      23
vendredi 19 février 2010
Version Annotation



   @Configuration
   public class AppConfig {
   @Bean
   public MonBean monBean() { return new
   MonBeanImpl(); }
   }




                                           24
vendredi 19 février 2010
Expression Language



                   Syntaxe proche des Unified EL mais
                   avec des fonctionnalités
                   supplémentaires
                   Développé selon les besoins des
                   projets du portfolio
                   Indépendant

                                                     25
vendredi 19 février 2010
EL : Synthaxe	



                                 Syntaxe                    Type

                             objet.propriete       Appel des getters/setter

                           chaine.subString(2,3)    Appel d’une méthode

                                 array[2]          Accès tableau par index

                                  list[2]           Accès liste par index

                                map[‘clé’]                  Map
                                                                              26
vendredi 19 février 2010
EL : Synthaxe	



                               Syntaxe                   Type

                                2 == 2                Opérateur

                       2 == 2 and 3 == 4 (faux)
                                                   Opérateur logique
                        2 == 1 or 4 ==4 (vrai)

            5.00' matches '^-?d+(.d{2})?$'        Regex

                           prenom ?:‘inconu’        Opérateur elvis

                objet?.propriete?.proprieteFils     Safe navigation
                                                                       27
vendredi 19 février 2010
Expression Language



                   Attributs du contexte
                       systemProperties, systemEnvironnent
                       Beans
                       Web :
                           contextParameters, contextAttributes
                           request, session



                                                                  28
vendredi 19 février 2010
EL : A venir




                   Utilisation dans les projets du
                   portfolio
                   Exemple : Spring Security
                           <http use-expressions="true">
                             <intercept-url pattern="/secure/**"
                            access="hasRole('ROLE_SUPERVISOR') and hasIpAddress
                           ('192.168.1.0/24')" />
                             ...
                           </http>


                                                                                  29
vendredi 19 février 2010
Spring MVC




                   Namespace de configuration
                   Support de REST
                       Nouvelles vues : Xml, Json, RSS
                       Mécanisme de sélection de la vue selon la requête
                       API client



                                                                           30
vendredi 19 février 2010
REST



                   Intégré dans Spring @MVC
                   Fournir un support natif
                       Application visuelle Web
                       Service

                   Alternative : Utiliser JAX-RS et son
                   modèle propre

                                                          31
vendredi 19 février 2010
Exemple




                           32
vendredi 19 février 2010
REST – Limitation HTML


                   REST : Utilisation les méthodes
                   HTTP :
                       GET,POST,PUT,DELETE



                   HTML ne gère que GET / POST
                       Solution : HiddenHttpMethodFilter
                       Taglib Spring MVC utilise cette solution

                                                                  33
vendredi 19 février 2010
REST – Content Negociation



                   URL = Resource
                       Plusieurs représentations possibles

                   Solution :
                   ContentNegotiatingViewResolver
                       Délègue aux autres ViewResolver
                       Sélectionne celui qui correspond à la demande


                                                                       34
vendredi 19 février 2010
REST - Client


                   RestTemplate
                       API de haut niveau pour REST
                           Accès au méthodes GET, PUT, POST, DELETE, OPTIONS
                           Gestion des conversions des objets
                           ‣   HttpMessageConverter

                           Reste extensible par utilisation de CallBack
                           ‣   Génération de la requête

                           ‣   Traduction de la réponse


                                                                               35
vendredi 19 février 2010
Support du scheduling

                   Avant :
                       Configuration verbeuse en XML
                           Définition du Scheduler
                           Définition du Trigger
                           Définition du Job
                           Définition du Bean « métier »

                   Après :



                                                           36
vendredi 19 février 2010
Support du scheduling

                  Alternative : Annotation
                      Cron




                      Delai fixe




                      Période fixe


                                             37
vendredi 19 février 2010
Support appel asynchrone




                  Permet de rendre asynchrone
                  l’appel d’une méthode
                      Annotation @Asyn
                      Délègue l’appel à un TaskExecutor




                                                          38
vendredi 19 février 2010
Support appel asynchrone




                   Cas 1 : Méthode sans résultat



                   Cas 2 : Méthode avec résultat


                                                   39
vendredi 19 février 2010
Support des DB embarquées



                   Namespace jdbc
                       Permet de configurer des bases embarquées
                           Derby
                           H2
                           HSQLDB

                       Permet de configurer des scripts d’initialisation


                                                                           40
vendredi 19 février 2010
Support Bean Validation

                   JSR 303 – Bean Validation
                       Standardisation de Hibernate Validator
                       Permet de configurer les contraintes de validation
                       directement sur les objets métiers




                                                                            41
vendredi 19 février 2010
Support Bean Validation

                   Spring possède son propre système
                   de validation
                       org.springframework.validation.Validator



                   Propose un adapteur
                       LocalValidatorFactoryBean



                   Toutes couches
                       Validation manuelle via injection du validateur   42
vendredi 19 février 2010
Support JSR 330 - @Inject

                   JSR initiée par SpringSource et
                   Google


                   Propose un jeu d’annotations propre
                       @Inject ↔ @AutoWired mais limité
                       @Qualifier ↔ @Qualifier mais limité
                       @Named ↔ @Qualifier sur le nom du Bean
                       @Singleton
                       @Scope
                                                                43
vendredi 19 février 2010
DEMO
                           REST


vendredi 19 février 2010
Spring 3.X Roadmap




                   Spring 3.1 : Début 2010
                       Support complet de JEE 6
                       Support des conversations




                                                   45
vendredi 19 février 2010
Conclusion

                   Spring 3.0
                       Release majeure car rupture du JDK 1.4
                       Nouvelles fonctionnalités intéressantes
                           REST
                           SpEL
                           Bean Validation



                       Pas une révolution pour autant


                                                                 46
vendredi 19 février 2010
Spring 3 et JEE 6



vendredi 19 février 2010
Questions



vendredi 19 février 2010
Offert par Eyrolles




                           49
vendredi 19 février 2010

Mais conteúdo relacionado

Destaque

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

MarsJUG - Spring 3.0

  • 1. Spring 3.0 Gildas Cuisinier vendredi 19 février 2010
  • 2. Gildas Cuisinier Consultant Java depuis 3 ans Gam Consult Luxembourg Certifié Spring Responsable Spring @ Developpez.com Article, FAQ, Forum, Compte rendu Relecteur technique 2 vendredi 19 février 2010
  • 3. Agenda Retrospective Spring 3.0 Spring et JEE 6 3 vendredi 19 février 2010
  • 5. Avant Spring EJB 2 Modèle complexe Difficile à tester 5 vendredi 19 février 2010
  • 6. Spring 1.0 Mars 2004 Fonctionnalités Inversion du contrôle Programmation Orienté Aspect (AOP) Support de Jdbc, Hibernate, JDO Framework Web 6 vendredi 19 février 2010
  • 7. Instanciation Dépendance directe Difficile à tester 7 vendredi 19 février 2010
  • 8. Registre 8 vendredi 19 février 2010
  • 9. IoC : Injection de dépendances Injecte InstanceB Instancie Instancie 9 vendredi 19 février 2010 Instancie
  • 10. IoC : Avantages POJO Dépendance uniquement sur les contrats Plus simple à tester 10 vendredi 19 février 2010
  • 11. Spring 1.0 Configuration xml, basée sur une DTD Un seul tag : <bean> Possibilité de métadonnées sur les classes Basé sur Xdoclet vendredi 19 février 2010
  • 12. Spring 1.2 Mai 2005 Toujours basé sur une DTD Alias, import Premier support du JDK 5 ! @Transactional, … vendredi 19 février 2010
  • 13. Spring 2.0 Octobre 2006 Simplification de la configuration XML Basé sur XML Schema Namespaces dédiés JEE, Transaction, AOP, Lang, Util Scope Annotations AspectJ 13 vendredi 19 février 2010
  • 14. Spring 2.5 Novembre 2007 Nouveaux namespaces : JMS Context Annotations Spring : IoC, Tests, Web Standard JEE Toujours compatible JDK 1.4 14 vendredi 19 février 2010
  • 15. Spring 3.0 vendredi 19 février 2010
  • 16. Spring 3.0 Supports, dépréciations et suppressions Nouveautés de Spring 3 Rest, Expression Languages, namespaces Spring 3.1 16 vendredi 19 février 2010
  • 17. Java 5 - ApplicationContext <T> T getBean(Class<T> requiredType) throws BeansException; Pas de casting SpeakerRepository repository = context.getBean(SpeakerRepository.class); 17 vendredi 19 février 2010
  • 18. Java 5 - RowMapper private class SpeakerMapper implements RowMapper<Speaker> { public Speaker mapRow(ResultSet rs, int rowNum) throws SQLException { return SpeakerBuilder.SpeakerWith() .id(rs.getInt(1)) .firstName( rs.getString(2)) .lastName(rs.getString(3)) .email(rs.getString(4)) .birthday(rs.getDate(5)) .build(); } } 18 vendredi 19 février 2010
  • 19. Java 5 - Varargs Avant public Integer saveOld(Speaker speaker) { return template.update("insert into speakers values (null, ?,?,?,?)", new Object[]{speaker.getFirstName(), speaker.getLastName(), speaker.getEmail(), speaker.getBirthday()}); } Spring 3 public Integer save(Speaker speaker) { return template.update("insert into speakers values (null, ?,?,?,?)", speaker.getFirstName(), speaker.getLastName(), speaker.getEmail(), speaker.getBirthday()); } 19 vendredi 19 février 2010
  • 20. Supports JDK 1.5+ Rupture : JDK 1.4 n’est plus supporté Dépréciation Hiérarchie de contrôleur Web Hiérarchie de classe pour Junit 3.8 Le support de Struts 1.0 Suppression Le support de Commons Attributes Le support de Toplink 20 vendredi 19 février 2010
  • 21. DEMO DROP IN vendredi 19 février 2010
  • 22. Spring OXM Inclusion du module de mapping Object / XML Provient de Spring WS Permet une abstraction des API communes JAXB, JiBX, Xstream, Castor Unification des exceptions Utilisation Gestion des payload REST en XML 22 vendredi 19 février 2010
  • 23. JavaConfig Configuration par annotations @Configuration, @Bean, @Lazy, @Primary, @Import, @Value Version XML : <beans> <bean name=“monBean" class=“be.hikage.MonBeanImpl"/> </beans> Version Annotation: @Configuration public class AppConfig { 23 vendredi 19 février 2010
  • 24. Version Annotation @Configuration public class AppConfig { @Bean public MonBean monBean() { return new MonBeanImpl(); } } 24 vendredi 19 février 2010
  • 25. Expression Language Syntaxe proche des Unified EL mais avec des fonctionnalités supplémentaires Développé selon les besoins des projets du portfolio Indépendant 25 vendredi 19 février 2010
  • 26. EL : Synthaxe Syntaxe Type objet.propriete Appel des getters/setter chaine.subString(2,3) Appel d’une méthode array[2] Accès tableau par index list[2] Accès liste par index map[‘clé’] Map 26 vendredi 19 février 2010
  • 27. EL : Synthaxe Syntaxe Type 2 == 2 Opérateur 2 == 2 and 3 == 4 (faux) Opérateur logique 2 == 1 or 4 ==4 (vrai) 5.00' matches '^-?d+(.d{2})?$' Regex prenom ?:‘inconu’ Opérateur elvis objet?.propriete?.proprieteFils Safe navigation 27 vendredi 19 février 2010
  • 28. Expression Language Attributs du contexte systemProperties, systemEnvironnent Beans Web : contextParameters, contextAttributes request, session 28 vendredi 19 février 2010
  • 29. EL : A venir Utilisation dans les projets du portfolio Exemple : Spring Security <http use-expressions="true"> <intercept-url pattern="/secure/**" access="hasRole('ROLE_SUPERVISOR') and hasIpAddress ('192.168.1.0/24')" /> ... </http> 29 vendredi 19 février 2010
  • 30. Spring MVC Namespace de configuration Support de REST Nouvelles vues : Xml, Json, RSS Mécanisme de sélection de la vue selon la requête API client 30 vendredi 19 février 2010
  • 31. REST Intégré dans Spring @MVC Fournir un support natif Application visuelle Web Service Alternative : Utiliser JAX-RS et son modèle propre 31 vendredi 19 février 2010
  • 32. Exemple 32 vendredi 19 février 2010
  • 33. REST – Limitation HTML REST : Utilisation les méthodes HTTP : GET,POST,PUT,DELETE HTML ne gère que GET / POST Solution : HiddenHttpMethodFilter Taglib Spring MVC utilise cette solution 33 vendredi 19 février 2010
  • 34. REST – Content Negociation URL = Resource Plusieurs représentations possibles Solution : ContentNegotiatingViewResolver Délègue aux autres ViewResolver Sélectionne celui qui correspond à la demande 34 vendredi 19 février 2010
  • 35. REST - Client RestTemplate API de haut niveau pour REST Accès au méthodes GET, PUT, POST, DELETE, OPTIONS Gestion des conversions des objets ‣ HttpMessageConverter Reste extensible par utilisation de CallBack ‣ Génération de la requête ‣ Traduction de la réponse 35 vendredi 19 février 2010
  • 36. Support du scheduling Avant : Configuration verbeuse en XML Définition du Scheduler Définition du Trigger Définition du Job Définition du Bean « métier » Après : 36 vendredi 19 février 2010
  • 37. Support du scheduling Alternative : Annotation Cron Delai fixe Période fixe 37 vendredi 19 février 2010
  • 38. Support appel asynchrone Permet de rendre asynchrone l’appel d’une méthode Annotation @Asyn Délègue l’appel à un TaskExecutor 38 vendredi 19 février 2010
  • 39. Support appel asynchrone Cas 1 : Méthode sans résultat Cas 2 : Méthode avec résultat 39 vendredi 19 février 2010
  • 40. Support des DB embarquées Namespace jdbc Permet de configurer des bases embarquées Derby H2 HSQLDB Permet de configurer des scripts d’initialisation 40 vendredi 19 février 2010
  • 41. Support Bean Validation JSR 303 – Bean Validation Standardisation de Hibernate Validator Permet de configurer les contraintes de validation directement sur les objets métiers 41 vendredi 19 février 2010
  • 42. Support Bean Validation Spring possède son propre système de validation org.springframework.validation.Validator Propose un adapteur LocalValidatorFactoryBean Toutes couches Validation manuelle via injection du validateur 42 vendredi 19 février 2010
  • 43. Support JSR 330 - @Inject JSR initiée par SpringSource et Google Propose un jeu d’annotations propre @Inject ↔ @AutoWired mais limité @Qualifier ↔ @Qualifier mais limité @Named ↔ @Qualifier sur le nom du Bean @Singleton @Scope 43 vendredi 19 février 2010
  • 44. DEMO REST vendredi 19 février 2010
  • 45. Spring 3.X Roadmap Spring 3.1 : Début 2010 Support complet de JEE 6 Support des conversations 45 vendredi 19 février 2010
  • 46. Conclusion Spring 3.0 Release majeure car rupture du JDK 1.4 Nouvelles fonctionnalités intéressantes REST SpEL Bean Validation Pas une révolution pour autant 46 vendredi 19 février 2010
  • 47. Spring 3 et JEE 6 vendredi 19 février 2010
  • 49. Offert par Eyrolles 49 vendredi 19 février 2010