SlideShare a Scribd company logo
1 of 63
Download to read offline
Spring est mort,Vive Spring
                                by Gildas Cuisinier
                                   @gcuisinier




                                                      1
samedi 21 avril 2012
Agenda


                  •    Episode 1 : Un nouvel espoir

                  •    Episode 2 : Le JCP contre-attaque

                  •    Episode 3 : Le retour du Printemps




                                                            2
samedi 21 avril 2012
Gildas Cuisinier


                  •    @gcuisinier

                  •    Maitre Artisan Développeur @ Sfeir Benelux

                  •    Evangéliste Spring depuis plusieurs année




                                                                    3
samedi 21 avril 2012
Episode i      ( ou iv )
                          Un nouvel espoir




                                                  4
samedi 21 avril 2012
La plateforme de la mort


                  •    Plateforme standard, définie par le JCP



                  •    Gros défauts :

                       •   Applications difficilement testables

                       •   Application non portables entre les différentes implémentations


                                                                                             5
                                                                                                  
samedi 21 avril 2012
Un nouvel espoir !

                           •   Conteneur léger, OpenSource

                           •   S'intègre avec les forces en place

                           •   Simplifie les tests



                           •   Basé sur du XML


                                                                    6
samedi 21 avril 2012
<beans>

                           <bean class="spring.Jedi" id="RodJohnson">
                               <property name="nom" value="Rod Johnson" />
                               <property name="rang" value="maitre" />

                           </bean>




                       </beans>




                                                                             7
samedi 21 avril 2012
<beans>

                           <bean class="spring.Jedi" id="RodJohnson">
                               <property name="nom" value="Rod Johnson" />
                               <property name="rang" value="maitre" />
                               <property name="arme" ref="sabreVert"/>
                           </bean>

                           <bean class="spring.arme.SabreLaser" id="sabreVert">
                               <property name="couleur" value="vert"/>
                           </bean>

                       </beans>




                                                                                  8
samedi 21 avril 2012
Premières lacunes
                       <beans>

                           <bean class="spring.Jedi" id="RodJohnson"/>

                           <bean class="spring.Jedi" id="JuergenHoeller"/>

                           <bean class="spring.arme.SabreLaser" id="sabreVert" />

                           <bean class="spring.arme.SabreLaser" id="sabreBleu" />

                           ...

                       </beans>


                                                                                    9
samedi 21 avril 2012
Première évolution

                       <beans>

                           <import resource="jedis.xml" />

                           <import resource="sabres.xml" />

                           <import resource="siths.xml" />

                       </beans>




                                                              10
samedi 21 avril 2012
">
                                                                                       Proxy
                                             xy"                          lter  Chain
                                     inPro                        il.Fi               Sourc
                                                                                             e ">
                       filt  erCha                 curi   ty.ut                ition
              an id
                    ="
                                    g.ace
                                            gise                       Defin
       1 <be                s="or                              ation
                      clas                       lter  Invoc
                                        e="fi                                            PARIS
                                                                                                ON
       2                   ert  y nam                                             E_COM
                    <prop                                           ASE_B
                                                                            EFOR
        3                      lue>                         OWERC
                          <v a                      _TO_L
                                           T_URL                     NT
        4                        C ONVER                     CHE_A
                                                   P E_APA
                                          RN_TY
         5                       PATTE                                                  er
                                                                                 nFilt
                                           n =                     nteg   ratio
          6                       /logi                    textI
                                            essi   onCon
          7                        httpS                                              lter
                                                   rm=                         ionFi
                                           in.fo                        egrat
           8                        /log                        xtInt
                                                        Conte
                                              e ssion
            9                        httpS                                               ter
                                                       =                          onFil
                                               ts/**                 Inte  grati
           10                         /asse                  ntext
                                                ess ionCo                eck=
            11                         httpS                     ty_ch                      er,
                                                         ecuri                       nFilt
                                                eg i_s                  nteg  ratio
            12                          /j_ac                   textI                      er
                                                        onCon                       gFilt
                                                 essi                  Proc  essin
             13                          httpS                 ation
                                                  uth  entic
              14                         formA                                                er,
                                                                                       nFilt
                                                                          nteg  ratio
               15                         /**=                    textI
                                                   essi   onCon                lter
               16                          httpS                       ionFi
                                                             ra nslat
                                                    tionT
                17                          excep
                                               ue>
                18                    < /v a l
                                                                                                                             r">
                 19                  roper
                                             ty>                                            lter"                      Filte
                                </p                                                  ionFi                  tegr ation
                                                                             egrat                    extIn
                  20
                                  n>                           onte   xtInt               ssio  nCont
                           </bea                       sionC                       ttpSe
                    1                          tpSes                       y...H
                  2                  id="h
                                             t                      curit
                           <bean                            egise
                   22                         ="o  rg.ac
                                      class                                                                                      Point
                                                                                                                                       ">
                   23                                                                           t"                    lter Entry
                             </bea
                                     n>                                                  yPoin                  ingFi
                    24                                                      atio  nEntr              onPr ocess
                                                                    entic                     icati
                                                      Logi  nAuth                ..Au  thent            "/>
                     25                      "form                        rity.                   login
                                     n id=                        isecu                   ue="/
                              <bea                        .aceg              mUrl"
                                                                                      val
                      26                          ="org               inFor                        e"/>
                                         class                     og                       "fals
                                                           me="l                     alue=
                      27                       erty
                                                       na                     ps" v
                                      <prop                           ceHtt
                                                        name  ="for
                       28                       erty
                                       <prop
                        29
                                          n>
                                 </bea
                        30

                                                                                                                                            11
samedi 21 avril 2012
Seconde évolution
                   1 <security:http auto-config="true">
                   2     <security:intercept-url pattern="/login*"
                   3                             access="IS_AUTHENTICATED_ANONYMOUSLY"/>
                   4     <security:intercept-url pattern="/logoutSuccess*"
                   5                             access="IS_AUTHENTICATED_ANONYMOUSLY"/>
                   6     <security:intercept-url pattern="/css/main.css"
                   7                             access="IS_AUTHENTICATED_ANONYMOUSLY"/>
                   8     <security:intercept-url pattern="/**"
                   9                             access="ROLE_JEDI"/>
                  10
                  11     <security:form-login login-page="/login.html"
                  12                          login-processing-url="/loginProcess"
                  13                          default-target-url="/index.jsp"
                  14     <security:logout logout-url="/logout"
                  15                      logout-success-url="/logoutSuccess.html"/>
                  16 </security:http>




                                                                                           12
samedi 21 avril 2012
Seconde évolution, bis
                        1 @Component
                        2 public class Jedi {
                        3
                        4     private Arme arme;
                        5
                        6     @Autowired
                        7     public void setArme(Arme arme) {
                        8         this.arme = arme;
                        9     }
                       10
                       11 }


                       1 <context:component-scan base-package="spring" />


                                                                            13
samedi 21 avril 2012
Episode ii        ( ou v )
                         Le JCP contre-attaque




                                                    14
samedi 21 avril 2012
JEE 6 à nouveau sexy
               •       Simplicité

               •       Testabilité

               •       Légèreté



                       MAIS

               •       Nécessite une migration

                                                            15
samedi 21 avril 2012
Spring 3.0
                       1 @Configuration
                       2 public class ApplicationConfig {
                       3
                       4     @Bean
                       5     public MyService myService() {
                       6         return new MyService();
                       7     }
                       8
                       9 }




                                                              16
samedi 21 avril 2012
Spring 3.0
                                      1 @Configuration   // <beans>
                                      2 public class ApplicationConfig {
                                      3
                                      4     @Bean        //<bean id="myService>
                                      5     public MyService myService() {
                                      6         return new MyService();
                                      7     }
                                      8
                                      9 }


                       1 ApplicationContext factory =
                       2         new AnnotationConfigApplicationContext(ApplicationConfig.class)



                                                                                                   17
samedi 21 avril 2012
JEE 6, la mort de Spring ?




                               cyg.be/SpringJEE
                                                    18
samedi 21 avril 2012
JEE en 2012
                          None     J2EE 14         JEE 5   JEE 6




                                         56%




                                                  27%
                                   13%
                                             4%



       cyg.be/SpringJEE
                                                                   19
samedi 21 avril 2012
Adoption JEE 6
                          1 an   6 mois         Actuellement           Ne sais pas   Jamais




                                                12%       11%


                                                                 13%




                                          42%
                                                                21%




       cyg.be/SpringJEE
                                                                                              20
samedi 21 avril 2012
Conversion des troupes actuelles
                            En partie   Ne se prononce pas   Non, nous gardons Spring   Oui




                                                       8%
                                                             19%




                                                                   22%
                                              51%




       cyg.be/SpringJEE
                                                                                              21
samedi 21 avril 2012
JEE - Nouvelle troupes
                           En partie   Ne se prononce pas         Non   Oui




                                             16%
                                                            26%




                                       37%
                                                            21%




       cyg.be/SpringJEE
                                                                              22
samedi 21 avril 2012
BILAN

                       •   Spécification fin 2009

                       •   JEE 6 commence à percer en production

                           •   25-30% actuellement

                           •   > 50% d’ici 1 an



                                                                   23
samedi 21 avril 2012
Spring en 2012
                          Aucun   Spring 2.0         Spring 2.5         Spring 3.0   Spring 3.1




                                                         50%




                                         6%
                                          2%


                                                                  23%
                                               19%




       cyg.be/SpringJEE
                                                                                                  24
samedi 21 avril 2012
Spring 3.1
                          1 an   6 mois         Actuellement          Plus d’un an   Jamais




                                                       28%



                                                                     9%


                                          29%


                                                               26%
                                                  8%



       cyg.be/SpringJEE
                                                                                              25
samedi 21 avril 2012
Reproches
                            Diffile à mettre en place   Invasif   Trop de XML   Propriétaire
                            JEE6 fait la même chose    Autres    Rien

                       40


                       30


                       20


                       10


                        0




                                                                                              26
samedi 21 avril 2012
•   Spring 3.0 - Sorti en même temps que JEE 6

                           •   Bien présent en production

                       •   Spring 3.1 - Sorti fin 2011

                           •   ~25% actuellement

                           •   > 50% d’ici 1 an



                                                                        27
samedi 21 avril 2012
Episode iii       ( ou vi )
                         Le retour du Printemps




                                                     28
samedi 21 avril 2012
Amélioration
                        NoXML


                                      29
samedi 21 avril 2012
Spring 3.0
          • JavaConfig permet de remplacer la
                configuration XML                      1 @Configuration   // <beans>
                                                      2 public class ApplicationConfig {
                                                      3
          • Ne supporte pas toute les                 4     @Bean        //<bean id="myService>
                possibilités de la configuration XML   5
                                                      6
                                                            public MyService myService() {
                                                                return new MyService();
                                                      7     }
                                                      8
                                                      9 }

          • Spring 3.1 vient combler ces
                lacunes

                                                                                                  30
samedi 21 avril 2012
@ComponentScan

                   1 <context:component-scan
                   base-package="spring"/>



                   1 @Configuration
                   2 @ComponentScan("spring")
                   3 public class ApplicationConfig



                                                      31
samedi 21 avril 2012
@EnableScheduling
                       1 public class MaTache {
                       2
                       3    @Scheduled(fixedRate = 1000)
                       4     public void execute() {
                       5         System.out.println("May the Spring be
                                                       with you");
                       6     }
                       7 }




                                                                         32
samedi 21 avril 2012
@EnableScheduling

                       1 <task:annotation-driven />



                       1   @Configuration
                       2   @EnableScheduling
                       3   public class ApplicationConfig {
                       4   }




                                                              33
samedi 21 avril 2012
@EnableScheduling

                       1   @Target(ElementType.TYPE)
                       2   @Retention(RetentionPolicy.RUNTIME)
                       3   @Import(SchedulingConfiguration.class)
                       4   @Documented
                       5   public @interface EnableScheduling {
                       6
                       7   }




                                                                    34
samedi 21 avril 2012
@EnableScheduling
        1 @Configuration
        2 public class SchedulingConfiguration {
        3
        4     @Bean(name=AnnotationConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
        5     @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
        6     public ScheduledAnnotationBeanPostProcessor scheduledAnnotationProcessor() {
        7         return new ScheduledAnnotationBeanPostProcessor();
        8     }
        9
       10 }




                                                                                             35
samedi 21 avril 2012
@EnableWebMvc
                       1 <mvc:annotation-driven />




                       1   @Configuration
                       2   @EnableWebMvc
                       3   public class WebConfig {
                       4   }



                                                      36
samedi 21 avril 2012
@EnableWebMvc

                       1 <mvc:annotation-driven/>
                       2 <mvc:interceptors>
                       3     <bean class="osf..LocaleChangeInterceptor"/>
                       4 </mvc:interceptors>




                                                                            37
samedi 21 avril 2012
@EnableWebMvc +
                                WebMvcConfigurerAdapter
                        1   @Configuration
                        2   @EnableWebMvc
                        3   public class WebConfig
                        4       extends WebMvcConfigurerAdapter{
                        5
                        6        @Override
                        7        public void addInterceptors(InterceptorRegistry registry) {
                        8            registry.addInterceptor(new LocaleChangeInterceptor());
                        9        }
                       10   }




                                                                                               38
samedi 21 avril 2012
@EnableWebMvc
                        Ajout Intercepteur

                        Configuration de ViewController

                        Ajout de ResourceHandler



                        Ne permet pas une configuration fine

                       ➡ @EnableWebMvc et étendre WebMvcConfigurationSupport

                                                                              39
samedi 21 avril 2012
@Enable*

                  <context:spring-configured/>           @EnableSpringConfigured


                  <context:load-time-weaver/>            @EnableLoadTimeWeaving


                  <tx:annotation-driven/>                @EnableTransactionManagement


                  <task:annotation-driven/>              @EnableAsync


                  <aop:aspectj-autoproxy/>               @EnableAspectJAutoProxy



                                                                                        40
samedi 21 avril 2012
Testing 3.0
                        1   @RunWith(SpringJUnit4ClassRunner.class)
                        2   @ContextConfiguration("test-config.xml")
                        3   public class MyTest {
                        4       @Autowired
                        5       MyService service;
                        6
                        7       @Test
                        8       public void myTest(){
                        9       }
                       10   }




                                                                       41
samedi 21 avril 2012
Testing 3.1
                        1   @RunWith(SpringJUnit4ClassRunner.class)
                        2   @ContextConfiguration(classes = TestConfig.class)
                        3   public class MyTest {
                        4       @Autowired
                        5       MyService service;
                        6
                        7       @Test
                        8       public void myTest(){
                        9       }
                       10   }




                                                                                42
samedi 21 avril 2012
WebApplicationInitializer
               1 public class WebInitializer implements WebApplicationInitializer {
               2
               3     @Override
               4     public void onStartup(ServletContext servletContext) throws ServletException {
               5
               6         AnnotationConfigWebApplicationContext context =
                               new AnnotationConfigWebApplicationContext();
               7         context.register(WebMvcConfig.class);
               8
               9         ServletRegistration.Dynamic servletConfig    =
                               servletContext.addServlet("dispatcher", new DispatcherServlet(context));
              10         servletConfig.setLoadOnStartup(1);
              11         servletConfig.addMapping("*.do");
              12
              13     }
              14 }



                                                                                                          43
samedi 21 avril 2012
Nouveau pouvoir :
                       Cacher des resources


                                              44
samedi 21 avril 2012
1 @Service
                        2 public class AllianceRebelle {
                        3
                        4     @Cacheable(value = "jedi")
                        5     public Jedi appellerJedi(String nomJedi) {
                        6          // attendre accord du conseil
                        7          // attendre disponibilité du Jedi
                        8          return chevaliers.getByName(nomJedi);
                        9     }
                       10
                       11 }




                                                                           45
samedi 21 avril 2012
1 @Service
                        2 public class AllianceRebelle {
                        3
                        4     @Cacheable(value = "jedi")
                        5     public Jedi appellerJedi(String nomJedi) {
                        6          // attendre accord du conseil
                        7          // attendre disponibilité du Jedi
                        8          return chevaliers.getByName(nomJedi);
                        9     }
                       10
                       11     @CacheEvict(value = "jedi")
                       12     public void libererJedi(String nomJedi){
                       13
                       14     }
                       15
                       16 }


                                                                           46
samedi 21 avril 2012
@EnableCaching
                        1   @Configuration
                        2   @EnableCaching
                        3   public class ApplicationConfig {
                        4
                        5       @Bean
                        6       CacheManager cacheManager(){
                        7           return
                        8              new ConcurrentMapCacheManager();
                        9       }
                       10   }



                                                                          47
samedi 21 avril 2012
@EnableCaching
                       1 <caching:annotation-driven />
                       2
                       3     <bean class="org.springframework.cache
                           .concurrent.ConcurrentMapCacheManager"/>
                       4




                                                                      48
samedi 21 avril 2012
Abstraction de Cache

                  •     Out of the Box

                       ✓ ConcurrentHashMap
                       ✓ EhCache
                  •     GemFire



                                                          49
samedi 21 avril 2012
Nouveau pouvoir

                       Adaptation au terrain


                                               50
samedi 21 avril 2012
JNDI


                  •    Séparation entre l’utilisation d’une ressource et sa définition

                  •    Inadapté pour une configuration différente




                                                                                        51
samedi 21 avril 2012
Import + Propriété Système
                                          1 <import resource="config-${env}.xml"/>



                                          1 System.setProperty("env", "TEST");



              1 <jdbc:embedded-database                     1 <jee:jndi-lookup jndi-name="jdbc/datasource"/>
              2          id="dataSource">                   2
              3        <jdbc:script
              4              location="schema.sql"/>
              5            <jdbc:script
              6              location="test-data.sql"/>
              7 </jdbc:embedded-database>


                                                                                                               52
samedi 21 avril 2012
@Profile
            1 @Configuration
            2
            3 public class ApplicationConfig {
            4
            5     @Bean
            6     DataSource dataSource(){
            7         JndiObjectFactoryBean result = new
                          JndiObjectFactoryBean();
            8         result.setJndiName("jdbc/dataSource");
            9         return (DataSource) result.getObject();
           10     }
           11 }

                                                                53
samedi 21 avril 2012
@Profile
            1 @Configuration
            2 @Import(ApplicationDevConfig.class)
            3 public class ApplicationConfig {
            4
            5     @Bean
            6     DataSource dataSource(){
            7         JndiObjectFactoryBean result = new
                          JndiObjectFactoryBean();
            8         result.setJndiName("jdbc/dataSource");
            9         return (DataSource) result.getObject();
           10     }
           11 }

                                                                54
samedi 21 avril 2012
@Profile
            1 @Configuration
            2 @Profile("dev")
            3 public class ApplicationDevConfig {
            4
            5     @Bean
            6     DataSource dataSource() {
            7         SingleConnectionDataSource connection = new
                              SingleConnectionDataSource(...);
            8         return connection;
            9     }
           10 }


                                                                    55
samedi 21 avril 2012
<Profile />

           1 <beans profile="dev">
           2     <jdbc:embedded-database id="dataSource">
           3          <jdbc:script location="schema.sql"/>
           4          <jdbc:script location="test-data.sql"/>
           5     </jdbc:embedded-database>
           6 </beans>




                                                                56
samedi 21 avril 2012
Activation

            1 <webapp>
            2     <context-param>
            3          <param-name>spring.profiles.active</param-name>
            4          <param-value>dev</param-value>
            5     </context-param>
            6 </webapp>




                                                                         57
samedi 21 avril 2012
Activation

            1 <servlet>
            2     <servlet-name>dispatcher</servlet-name>
            3     <servlet-class>osf.web.servlet.DispatcherServlet</servlet-class>
            4     <init-param>
            5         <param-name>spring.profiles.active</param-name>
            6         <param-value>dev</param-value>
            7     </init-param>
            8 </servlet>




                                                                                     58
samedi 21 avril 2012
Spring 3.1, c’est aussi

                  •    Support Hibernate 4

                  •    Namespace c:

                  •    JPA sans Persistence.xml

                  •    Amélioration de REST dans SpringMVC

                  •    FlashMap dans Spring MVC


                                                             59
samedi 21 avril 2012
L’Univers de Spring

                       SpringData       Batch                  SpringMobile




                                     Integration   Framework



           SpringAndroid                                       SpringSocial
                                      Security        Flex

                                                                              60
samedi 21 avril 2012
Conclusion

                  •     Spring est largement répandu

                  •     Spring continue à évoluer

                       ✓ NoXML

                       ✓ Ouvert au Cloud

                  •     Spring est un écosystème


                                                           61
samedi 21 avril 2012
cyg.be/cbeamsSpring31      cyg.be/costinlDevoxx11




                       cyg.be/SpringSourceBlog   cyg.be/MattRaibleSpring31

                                                                             62
samedi 21 avril 2012
Sources des images
            http://www.thegeekshowpodcast.com

                                                http://www.thinkgeek.com

                        http://gadgetsin.com



                                                    raven - Fotolia.com


                                                                           63
samedi 21 avril 2012

More Related Content

Featured

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
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Featured (20)

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...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Spring est mort, Vive Spring à Devoxx France

  • 1. Spring est mort,Vive Spring by Gildas Cuisinier @gcuisinier 1 samedi 21 avril 2012
  • 2. Agenda • Episode 1 : Un nouvel espoir • Episode 2 : Le JCP contre-attaque • Episode 3 : Le retour du Printemps 2 samedi 21 avril 2012
  • 3. Gildas Cuisinier • @gcuisinier • Maitre Artisan Développeur @ Sfeir Benelux • Evangéliste Spring depuis plusieurs année 3 samedi 21 avril 2012
  • 4. Episode i ( ou iv ) Un nouvel espoir 4 samedi 21 avril 2012
  • 5. La plateforme de la mort • Plateforme standard, définie par le JCP • Gros défauts : • Applications difficilement testables • Application non portables entre les différentes implémentations 5   samedi 21 avril 2012
  • 6. Un nouvel espoir ! • Conteneur léger, OpenSource • S'intègre avec les forces en place • Simplifie les tests • Basé sur du XML 6 samedi 21 avril 2012
  • 7. <beans> <bean class="spring.Jedi" id="RodJohnson"> <property name="nom" value="Rod Johnson" /> <property name="rang" value="maitre" /> </bean> </beans> 7 samedi 21 avril 2012
  • 8. <beans> <bean class="spring.Jedi" id="RodJohnson"> <property name="nom" value="Rod Johnson" /> <property name="rang" value="maitre" /> <property name="arme" ref="sabreVert"/> </bean> <bean class="spring.arme.SabreLaser" id="sabreVert"> <property name="couleur" value="vert"/> </bean> </beans> 8 samedi 21 avril 2012
  • 9. Premières lacunes <beans> <bean class="spring.Jedi" id="RodJohnson"/> <bean class="spring.Jedi" id="JuergenHoeller"/> <bean class="spring.arme.SabreLaser" id="sabreVert" /> <bean class="spring.arme.SabreLaser" id="sabreBleu" /> ... </beans> 9 samedi 21 avril 2012
  • 10. Première évolution <beans> <import resource="jedis.xml" /> <import resource="sabres.xml" /> <import resource="siths.xml" /> </beans> 10 samedi 21 avril 2012
  • 11. "> Proxy xy" lter Chain inPro il.Fi Sourc e "> filt erCha curi ty.ut ition an id =" g.ace gise Defin 1 <be s="or ation clas lter Invoc e="fi PARIS ON 2 ert y nam E_COM <prop ASE_B EFOR 3 lue> OWERC <v a _TO_L T_URL NT 4 C ONVER CHE_A P E_APA RN_TY 5 PATTE er nFilt n = nteg ratio 6 /logi textI essi onCon 7 httpS lter rm= ionFi in.fo egrat 8 /log xtInt Conte e ssion 9 httpS ter = onFil ts/** Inte grati 10 /asse ntext ess ionCo eck= 11 httpS ty_ch er, ecuri nFilt eg i_s nteg ratio 12 /j_ac textI er onCon gFilt essi Proc essin 13 httpS ation uth entic 14 formA er, nFilt nteg ratio 15 /**= textI essi onCon lter 16 httpS ionFi ra nslat tionT 17 excep ue> 18 < /v a l r"> 19 roper ty> lter" Filte </p ionFi tegr ation egrat extIn 20 n> onte xtInt ssio nCont </bea sionC ttpSe 1 tpSes y...H 2 id="h t curit <bean egise 22 ="o rg.ac class Point "> 23 t" lter Entry </bea n> yPoin ingFi 24 atio nEntr onPr ocess entic icati Logi nAuth ..Au thent "/> 25 "form rity. login n id= isecu ue="/ <bea .aceg mUrl" val 26 ="org inFor e"/> class og "fals me="l alue= 27 erty na ps" v <prop ceHtt name ="for 28 erty <prop 29 n> </bea 30 11 samedi 21 avril 2012
  • 12. Seconde évolution 1 <security:http auto-config="true"> 2 <security:intercept-url pattern="/login*" 3 access="IS_AUTHENTICATED_ANONYMOUSLY"/> 4 <security:intercept-url pattern="/logoutSuccess*" 5 access="IS_AUTHENTICATED_ANONYMOUSLY"/> 6 <security:intercept-url pattern="/css/main.css" 7 access="IS_AUTHENTICATED_ANONYMOUSLY"/> 8 <security:intercept-url pattern="/**" 9 access="ROLE_JEDI"/> 10 11 <security:form-login login-page="/login.html" 12 login-processing-url="/loginProcess" 13 default-target-url="/index.jsp" 14 <security:logout logout-url="/logout" 15 logout-success-url="/logoutSuccess.html"/> 16 </security:http> 12 samedi 21 avril 2012
  • 13. Seconde évolution, bis 1 @Component 2 public class Jedi { 3 4 private Arme arme; 5 6 @Autowired 7 public void setArme(Arme arme) { 8 this.arme = arme; 9 } 10 11 } 1 <context:component-scan base-package="spring" /> 13 samedi 21 avril 2012
  • 14. Episode ii ( ou v ) Le JCP contre-attaque 14 samedi 21 avril 2012
  • 15. JEE 6 à nouveau sexy • Simplicité • Testabilité • Légèreté MAIS • Nécessite une migration 15 samedi 21 avril 2012
  • 16. Spring 3.0 1 @Configuration 2 public class ApplicationConfig { 3 4 @Bean 5 public MyService myService() { 6 return new MyService(); 7 } 8 9 } 16 samedi 21 avril 2012
  • 17. Spring 3.0 1 @Configuration // <beans> 2 public class ApplicationConfig { 3 4 @Bean //<bean id="myService> 5 public MyService myService() { 6 return new MyService(); 7 } 8 9 } 1 ApplicationContext factory = 2 new AnnotationConfigApplicationContext(ApplicationConfig.class) 17 samedi 21 avril 2012
  • 18. JEE 6, la mort de Spring ? cyg.be/SpringJEE 18 samedi 21 avril 2012
  • 19. JEE en 2012 None J2EE 14 JEE 5 JEE 6 56% 27% 13% 4% cyg.be/SpringJEE 19 samedi 21 avril 2012
  • 20. Adoption JEE 6 1 an 6 mois Actuellement Ne sais pas Jamais 12% 11% 13% 42% 21% cyg.be/SpringJEE 20 samedi 21 avril 2012
  • 21. Conversion des troupes actuelles En partie Ne se prononce pas Non, nous gardons Spring Oui 8% 19% 22% 51% cyg.be/SpringJEE 21 samedi 21 avril 2012
  • 22. JEE - Nouvelle troupes En partie Ne se prononce pas Non Oui 16% 26% 37% 21% cyg.be/SpringJEE 22 samedi 21 avril 2012
  • 23. BILAN • Spécification fin 2009 • JEE 6 commence à percer en production • 25-30% actuellement • > 50% d’ici 1 an 23 samedi 21 avril 2012
  • 24. Spring en 2012 Aucun Spring 2.0 Spring 2.5 Spring 3.0 Spring 3.1 50% 6% 2% 23% 19% cyg.be/SpringJEE 24 samedi 21 avril 2012
  • 25. Spring 3.1 1 an 6 mois Actuellement Plus d’un an Jamais 28% 9% 29% 26% 8% cyg.be/SpringJEE 25 samedi 21 avril 2012
  • 26. Reproches Diffile à mettre en place Invasif Trop de XML Propriétaire JEE6 fait la même chose Autres Rien 40 30 20 10 0 26 samedi 21 avril 2012
  • 27. Spring 3.0 - Sorti en même temps que JEE 6 • Bien présent en production • Spring 3.1 - Sorti fin 2011 • ~25% actuellement • > 50% d’ici 1 an 27 samedi 21 avril 2012
  • 28. Episode iii ( ou vi ) Le retour du Printemps 28 samedi 21 avril 2012
  • 29. Amélioration NoXML 29 samedi 21 avril 2012
  • 30. Spring 3.0 • JavaConfig permet de remplacer la configuration XML 1 @Configuration // <beans> 2 public class ApplicationConfig { 3 • Ne supporte pas toute les 4 @Bean //<bean id="myService> possibilités de la configuration XML 5 6 public MyService myService() { return new MyService(); 7 } 8 9 } • Spring 3.1 vient combler ces lacunes 30 samedi 21 avril 2012
  • 31. @ComponentScan 1 <context:component-scan base-package="spring"/> 1 @Configuration 2 @ComponentScan("spring") 3 public class ApplicationConfig 31 samedi 21 avril 2012
  • 32. @EnableScheduling 1 public class MaTache { 2 3 @Scheduled(fixedRate = 1000) 4 public void execute() { 5 System.out.println("May the Spring be with you"); 6 } 7 } 32 samedi 21 avril 2012
  • 33. @EnableScheduling 1 <task:annotation-driven /> 1 @Configuration 2 @EnableScheduling 3 public class ApplicationConfig { 4 } 33 samedi 21 avril 2012
  • 34. @EnableScheduling 1 @Target(ElementType.TYPE) 2 @Retention(RetentionPolicy.RUNTIME) 3 @Import(SchedulingConfiguration.class) 4 @Documented 5 public @interface EnableScheduling { 6 7 } 34 samedi 21 avril 2012
  • 35. @EnableScheduling 1 @Configuration 2 public class SchedulingConfiguration { 3 4 @Bean(name=AnnotationConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME) 5 @Role(BeanDefinition.ROLE_INFRASTRUCTURE) 6 public ScheduledAnnotationBeanPostProcessor scheduledAnnotationProcessor() { 7 return new ScheduledAnnotationBeanPostProcessor(); 8 } 9 10 } 35 samedi 21 avril 2012
  • 36. @EnableWebMvc 1 <mvc:annotation-driven /> 1 @Configuration 2 @EnableWebMvc 3 public class WebConfig { 4 } 36 samedi 21 avril 2012
  • 37. @EnableWebMvc 1 <mvc:annotation-driven/> 2 <mvc:interceptors> 3 <bean class="osf..LocaleChangeInterceptor"/> 4 </mvc:interceptors> 37 samedi 21 avril 2012
  • 38. @EnableWebMvc + WebMvcConfigurerAdapter 1 @Configuration 2 @EnableWebMvc 3 public class WebConfig 4 extends WebMvcConfigurerAdapter{ 5 6 @Override 7 public void addInterceptors(InterceptorRegistry registry) { 8 registry.addInterceptor(new LocaleChangeInterceptor()); 9 } 10 } 38 samedi 21 avril 2012
  • 39. @EnableWebMvc Ajout Intercepteur Configuration de ViewController Ajout de ResourceHandler Ne permet pas une configuration fine ➡ @EnableWebMvc et étendre WebMvcConfigurationSupport 39 samedi 21 avril 2012
  • 40. @Enable* <context:spring-configured/> @EnableSpringConfigured <context:load-time-weaver/> @EnableLoadTimeWeaving <tx:annotation-driven/> @EnableTransactionManagement <task:annotation-driven/> @EnableAsync <aop:aspectj-autoproxy/> @EnableAspectJAutoProxy 40 samedi 21 avril 2012
  • 41. Testing 3.0 1 @RunWith(SpringJUnit4ClassRunner.class) 2 @ContextConfiguration("test-config.xml") 3 public class MyTest { 4 @Autowired 5 MyService service; 6 7 @Test 8 public void myTest(){ 9 } 10 } 41 samedi 21 avril 2012
  • 42. Testing 3.1 1 @RunWith(SpringJUnit4ClassRunner.class) 2 @ContextConfiguration(classes = TestConfig.class) 3 public class MyTest { 4 @Autowired 5 MyService service; 6 7 @Test 8 public void myTest(){ 9 } 10 } 42 samedi 21 avril 2012
  • 43. WebApplicationInitializer 1 public class WebInitializer implements WebApplicationInitializer { 2 3 @Override 4 public void onStartup(ServletContext servletContext) throws ServletException { 5 6 AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); 7 context.register(WebMvcConfig.class); 8 9 ServletRegistration.Dynamic servletConfig = servletContext.addServlet("dispatcher", new DispatcherServlet(context)); 10 servletConfig.setLoadOnStartup(1); 11 servletConfig.addMapping("*.do"); 12 13 } 14 } 43 samedi 21 avril 2012
  • 44. Nouveau pouvoir : Cacher des resources 44 samedi 21 avril 2012
  • 45. 1 @Service 2 public class AllianceRebelle { 3 4 @Cacheable(value = "jedi") 5 public Jedi appellerJedi(String nomJedi) { 6 // attendre accord du conseil 7 // attendre disponibilité du Jedi 8 return chevaliers.getByName(nomJedi); 9 } 10 11 } 45 samedi 21 avril 2012
  • 46. 1 @Service 2 public class AllianceRebelle { 3 4 @Cacheable(value = "jedi") 5 public Jedi appellerJedi(String nomJedi) { 6 // attendre accord du conseil 7 // attendre disponibilité du Jedi 8 return chevaliers.getByName(nomJedi); 9 } 10 11 @CacheEvict(value = "jedi") 12 public void libererJedi(String nomJedi){ 13 14 } 15 16 } 46 samedi 21 avril 2012
  • 47. @EnableCaching 1 @Configuration 2 @EnableCaching 3 public class ApplicationConfig { 4 5 @Bean 6 CacheManager cacheManager(){ 7 return 8 new ConcurrentMapCacheManager(); 9 } 10 } 47 samedi 21 avril 2012
  • 48. @EnableCaching 1 <caching:annotation-driven /> 2 3 <bean class="org.springframework.cache .concurrent.ConcurrentMapCacheManager"/> 4 48 samedi 21 avril 2012
  • 49. Abstraction de Cache • Out of the Box ✓ ConcurrentHashMap ✓ EhCache • GemFire 49 samedi 21 avril 2012
  • 50. Nouveau pouvoir Adaptation au terrain 50 samedi 21 avril 2012
  • 51. JNDI • Séparation entre l’utilisation d’une ressource et sa définition • Inadapté pour une configuration différente 51 samedi 21 avril 2012
  • 52. Import + Propriété Système 1 <import resource="config-${env}.xml"/> 1 System.setProperty("env", "TEST"); 1 <jdbc:embedded-database 1 <jee:jndi-lookup jndi-name="jdbc/datasource"/> 2 id="dataSource"> 2 3 <jdbc:script 4 location="schema.sql"/> 5 <jdbc:script 6 location="test-data.sql"/> 7 </jdbc:embedded-database> 52 samedi 21 avril 2012
  • 53. @Profile 1 @Configuration 2 3 public class ApplicationConfig { 4 5 @Bean 6 DataSource dataSource(){ 7 JndiObjectFactoryBean result = new JndiObjectFactoryBean(); 8 result.setJndiName("jdbc/dataSource"); 9 return (DataSource) result.getObject(); 10 } 11 } 53 samedi 21 avril 2012
  • 54. @Profile 1 @Configuration 2 @Import(ApplicationDevConfig.class) 3 public class ApplicationConfig { 4 5 @Bean 6 DataSource dataSource(){ 7 JndiObjectFactoryBean result = new JndiObjectFactoryBean(); 8 result.setJndiName("jdbc/dataSource"); 9 return (DataSource) result.getObject(); 10 } 11 } 54 samedi 21 avril 2012
  • 55. @Profile 1 @Configuration 2 @Profile("dev") 3 public class ApplicationDevConfig { 4 5 @Bean 6 DataSource dataSource() { 7 SingleConnectionDataSource connection = new SingleConnectionDataSource(...); 8 return connection; 9 } 10 } 55 samedi 21 avril 2012
  • 56. <Profile /> 1 <beans profile="dev"> 2 <jdbc:embedded-database id="dataSource"> 3 <jdbc:script location="schema.sql"/> 4 <jdbc:script location="test-data.sql"/> 5 </jdbc:embedded-database> 6 </beans> 56 samedi 21 avril 2012
  • 57. Activation 1 <webapp> 2 <context-param> 3 <param-name>spring.profiles.active</param-name> 4 <param-value>dev</param-value> 5 </context-param> 6 </webapp> 57 samedi 21 avril 2012
  • 58. Activation 1 <servlet> 2 <servlet-name>dispatcher</servlet-name> 3 <servlet-class>osf.web.servlet.DispatcherServlet</servlet-class> 4 <init-param> 5 <param-name>spring.profiles.active</param-name> 6 <param-value>dev</param-value> 7 </init-param> 8 </servlet> 58 samedi 21 avril 2012
  • 59. Spring 3.1, c’est aussi • Support Hibernate 4 • Namespace c: • JPA sans Persistence.xml • Amélioration de REST dans SpringMVC • FlashMap dans Spring MVC 59 samedi 21 avril 2012
  • 60. L’Univers de Spring SpringData Batch SpringMobile Integration Framework SpringAndroid SpringSocial Security Flex 60 samedi 21 avril 2012
  • 61. Conclusion • Spring est largement répandu • Spring continue à évoluer ✓ NoXML ✓ Ouvert au Cloud • Spring est un écosystème 61 samedi 21 avril 2012
  • 62. cyg.be/cbeamsSpring31 cyg.be/costinlDevoxx11 cyg.be/SpringSourceBlog cyg.be/MattRaibleSpring31 62 samedi 21 avril 2012
  • 63. Sources des images http://www.thegeekshowpodcast.com http://www.thinkgeek.com http://gadgetsin.com raven - Fotolia.com 63 samedi 21 avril 2012