SlideShare a Scribd company logo
Spring est mort,Vive Spring !
          par Gildas Cuisinier
              @gcuisinier




                                 1
whois(@gcuisinier)

•   Maître Artisan Développeur, Sfeir Benelux

•   Initiateur de la section Spring de @Developpez.com

•   Relecteur de plusieurs livres sur Spring

•   Evangéliste Spring



                                                         2
Spring est mort ?
                    3
cyg.be/SpringJEE
JEE en 2012
                   None     J2EE 14   JEE 5   JEE 6




cyg.be/SpringJEE
                                                      5
JEE en 2012
                   None     J2EE 14         JEE 5   JEE 6




                                  56%




                                           27%
                            13%
                                      4%



cyg.be/SpringJEE
                                                            5
Adoption JEE 6
                   1 an   6 mois   Actuellement   Ne sais pas   Jamais




cyg.be/SpringJEE
                                                                         6
Adoption JEE 6
                   1 an   6 mois         Actuellement           Ne sais pas   Jamais




                                         12%       11%


                                                          13%




                                   42%
                                                         21%




cyg.be/SpringJEE
                                                                                       6
Migration de l’existant
                   En partie   Ne se prononce pas   Non, nous gardons Spring   Oui




cyg.be/SpringJEE
                                                                                     7
Migration de l’existant
                   En partie   Ne se prononce pas   Non, nous gardons Spring   Oui




                                              8%
                                                    19%




                                                          22%
                                     51%




cyg.be/SpringJEE
                                                                                     7
JEE - Nouveau projet
                   En partie   Ne se prononce pas   Non   Oui




cyg.be/SpringJEE
                                                                8
JEE - Nouveau projet
                   En partie   Ne se prononce pas         Non   Oui




                                     16%
                                                    26%




                               37%
                                                    21%




cyg.be/SpringJEE
                                                                      8
BILAN




        9
BILAN

•   Spécification fin 2009

•   JEE 6 commence à percer en production

    •   25-30% actuellement

    •   > 50% d’ici 1 an



                                            9
Spring en 2012
                   Aucun   Spring 2.0   Spring 2.5   Spring 3.0   Spring 3.1




cyg.be/SpringJEE
                                                                               10
Spring en 2012
                   Aucun   Spring 2.0         Spring 2.5         Spring 3.0   Spring 3.1




                                                  50%




                                  6%
                                   2%


                                                           23%
                                        19%




cyg.be/SpringJEE
                                                                                           10
Spring 3.1
                   1 an   6 mois     Actuellement   Plus d’un an   Jamais




cyg.be/SpringJEE
                                                                            11
Spring 3.1
                   1 an   6 mois         Actuellement          Plus d’un an   Jamais




                                                28%



                                                              9%


                                   29%


                                                        26%
                                           8%



cyg.be/SpringJEE
                                                                                       11
BILAN




        12
BILAN

•   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


                                                 12
Pourquoi tant de haine ?



                           13
Reproches
Diffile à mettre en place   Invasif   Trop de XML   Propriétaire
JEE6 fait la même chose    Autres    Rien




                                                                  14
Reproches
     Diffile à mettre en place   Invasif             Trop de XML   Propriétaire
     JEE6 fait la même chose    Autres              Rien

40


30


20


10


 0
                                          JEE 1.4




                                                                                 14
Flash back
   2004


             15
0 0 4
2
0 0 4
2
Spring 1.0
1 <bean id="monBean" class="be.hikage.service.MyService">
2     <property name="version" value="maVersion"/>
3 </bean>




                                                            17
Spring 1.0
 1   <bean id="monBean" class="be.hikage.service.MyService">
 2       <property name="version" value="maVersion"/>
 3   </bean>
 4
 5   <bean   />
 6   <bean   />
 7   <bean   />
 8   <bean   />
 9   <bean   />
10   <bean   />




                                                               18
Spring 1.2                                  200
                                                              We    5
                                                                 b2
                                                                 .0


1   <bean id="monBean" class="be.hikage.service.MyService">
2       <property name="version" value="maVersion"/>
3   </bean>
4
5   <import resource="service-layer.xml"/>
6   <import resource="dao-layer.xml"/>
7   <import resource="disp-layer.xml"/>




                                                                        19
">
                                                                                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

                                                                                                                                     20
Spring 2.0
 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_USER"/>
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>




                                                                         21
Spring 2.5                              200
                                                         Sar     7
                                                             koz
                                                              y

 1 @Component
 2 public class MyController {
 3
 4     private MyService myService;
 5
 6     @Autowired
 7     public void setMyService(MyService myService) {
 8         this.myService = myService;
 9     }
10
11 }




                                                                     22
Spring 2.5                              200
                                                         Sar     7
                                                             koz
                                                              y

 1 @Component
 2 public class MyController {
 3
 4     private MyService myService;
 5
 6     @Autowired
 7     public void setMyService(MyService myService) {
 8         this.myService = myService;
 9     }
10
11 }


1 <context:component-scan base-package="be.hikage" />


                                                                     22
Spring 3.0                   R
                                        200
                                       ach  9
                                           at
                                       Sun de

1 @Configuration
2 public class ApplicationConfig {
3
4     @Bean
5     public MyService myService() {
6         return new MyService();
7     }
8
9 }




                                                23
Spring 3.0                        R
                                             200
                                            ach  9
                                                at
                                            Sun de

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




                                                     24
Spring 3.0                                  R
                                                                      200
                                                                      ach 9
                                                                          at
                                                                      Sun de

               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)



                                                                               24
Spring 3.1



             25
Annotation++



               26
@ComponentScan

1 <context:component-scan
      base-package="be.hikage"/>




                                   27
@ComponentScan

1 <context:component-scan
      base-package="be.hikage"/>



1 @Configuration
2 @ComponentScan("be.hikage")
3 public class ApplicationConfig



                                   27
@EnableScheduling
1 public class MaTache {
2
3    @Scheduled(fixedRate = 1000)
4     public void execute() {
5         System.out.println("Maman, je parle
                     au MarsJUG");
6     }
7 }




                                                28
@EnableScheduling

1 <task:annotation-driven />




                                29
@EnableScheduling

1 <task:annotation-driven />



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




                                       29
@EnableScheduling

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




                                             30
@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 }




                                                                                      31
@EnableCaching
 1 @Service
 2 public class CalculateurPrix {
 3
 4     @Cacheable(value = "price")
 5     public Double calculePrix(String reference){
 6          // calcul long et complexe
 7          return new Random().nextDouble();
 8     }
 9
10
11
12
13
14 }


                                                      32
@EnableCaching
 1 @Service
 2 public class CalculateurPrix {
 3
 4     @Cacheable(value = "price")
 5     public Double calculePrix(String reference){
 6          // calcul long et complexe
 7          return new Random().nextDouble();
 8     }
 9
10     @CacheEvict(value = "price",allEntries = true)
11     public void setRistourne(Float indice){
12
13     }
14 }


                                                        33
@EnableCaching

1 <caching:annotation-driven />
2
3     <bean class="org.springframework.cache
    .concurrent.ConcurrentMapCacheManager"/>
4




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



                                                   35
Abstraction de Cache

•    Out of the Box

    ✓ ConcurrentHashMap
    ✓ EhCache
•    GemFire



                                       36
@EnableWebMvc
1 <mvc:annotation-driven />




                              37
@EnableWebMvc
1 <mvc:annotation-driven />




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



                               37
@EnableWebMvc

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




                                                     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   }




                                                                        39
@EnableWebMvc




                40
@EnableWebMvc
Ajout Intercepteur




                               40
@EnableWebMvc
Ajout Intercepteur

Configuration de ViewController




                                 40
@EnableWebMvc
Ajout Intercepteur

Configuration de ViewController

Ajout de ResourceHandler




                                 40
@EnableWebMvc
Ajout Intercepteur

Configuration de ViewController

Ajout de ResourceHandler




                                 40
@EnableWebMvc
Ajout Intercepteur

Configuration de ViewController

Ajout de ResourceHandler



Ne permet pas une configuration fine



                                     40
@EnableWebMvc
 Ajout Intercepteur

 Configuration de ViewController

 Ajout de ResourceHandler



 Ne permet pas une configuration fine

➡ @EnableWebMvc et étendre WebMvcConfigurationSupport

                                                       40
@Enable*




           41
@Enable*

•   EnableAsync




                             41
@Enable*

•   EnableAsync

•   EnableAspectJAutoProxy




                                    41
@Enable*

•   EnableAsync

•   EnableAspectJAutoProxy

•   EnableSpringConfigured




                                       41
@Enable*

•   EnableAsync

•   EnableAspectJAutoProxy

•   EnableSpringConfigured

•   EnableLoadTimeWeaving




                                       41
@Enable*

•   EnableAsync

•   EnableAspectJAutoProxy

•   EnableSpringConfigured

•   EnableLoadTimeWeaving

•   EnableTransactionManagement


                                       41
Testing 2.5
 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   }




                                                42
Testing 3.1
 1   @RunWith(SpringJUnit4ClassRunner.class)
 2   @ContextConfiguration(classes = TestConfig.class)
 3   @ActiveProfiles("test")
 4   public class MyTest {
 5       @Autowired
 6       MyService service;
 7
 8       @Test
 9       public void myTest(){
10       }
11   }




                                                         43
Servlet 3.0



              44
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 }
DEMO



       46
Profile



         47
JNDI


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

•   Inadapté pour une configuration différente




                                                                     48
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>


                                                                                             49
@Profile
 1 @Configuration

 2 public class ApplicationConfig {
 3
 4     @Bean
 5     DataSource dataSource(){
 6         JndiObjectFactoryBean result = new
               JndiObjectFactoryBean();
 7         result.setJndiName("jdbc/dataSource");
 8         return (DataSource) result.getObject();
 9     }
10 }

                                                     50
@Profile
 1   @Configuration
 2   @Profile("dev")
 3   public class DevConfig {
 4
 5       @Bean
 6       MyService monBean() {
 7           MyService tmp = new MyService();
 8           tmp.setVersion("dev");
 9           return tmp;
10       }
11
12   }

                                                51
<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>




                                                     52
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>




                                                             53
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>




                                                                         54
Spring 3.1, c’est aussi

•   Support Hibernate 4

•   Namespace c:

•   JPA sans Persistence.xml

•   ...



                                          55
Conclusions



              56
Questions ?



              57
Resources


cyg.be/cbeamsSpring31          cyg.be/costinlDevoxx11




cyg.be/SpringSourceBlog       cyg.be/MattRaibleSpring31

                                                          58
Crédits


© suzesizu - Fotolia.com   © vsurkov - Fotolia.com




                                                     © Tiler84 - Fotolia.com
© Mitarart - Fotolia.com


                           © Beboy - Fotolia.com
                                                                               59

More Related Content

Featured

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
Marius 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 ChatGPT
Expeed 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 Engineerings
Pixeldarts
 
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
ThinkNow
 
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
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
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
Neil 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 2024
Albert 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 Insights
Kurio // 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 2024
Search 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 summary
SpeakerHub
 
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 Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit 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 management
MindGenius
 
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
 

Featured (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...
 

Spring est mort, vive Spring

  • 1. Spring est mort,Vive Spring ! par Gildas Cuisinier @gcuisinier 1
  • 2. whois(@gcuisinier) • Maître Artisan Développeur, Sfeir Benelux • Initiateur de la section Spring de @Developpez.com • Relecteur de plusieurs livres sur Spring • Evangéliste Spring 2
  • 5. JEE en 2012 None J2EE 14 JEE 5 JEE 6 cyg.be/SpringJEE 5
  • 6. JEE en 2012 None J2EE 14 JEE 5 JEE 6 56% 27% 13% 4% cyg.be/SpringJEE 5
  • 7. Adoption JEE 6 1 an 6 mois Actuellement Ne sais pas Jamais cyg.be/SpringJEE 6
  • 8. Adoption JEE 6 1 an 6 mois Actuellement Ne sais pas Jamais 12% 11% 13% 42% 21% cyg.be/SpringJEE 6
  • 9. Migration de l’existant En partie Ne se prononce pas Non, nous gardons Spring Oui cyg.be/SpringJEE 7
  • 10. Migration de l’existant En partie Ne se prononce pas Non, nous gardons Spring Oui 8% 19% 22% 51% cyg.be/SpringJEE 7
  • 11. JEE - Nouveau projet En partie Ne se prononce pas Non Oui cyg.be/SpringJEE 8
  • 12. JEE - Nouveau projet En partie Ne se prononce pas Non Oui 16% 26% 37% 21% cyg.be/SpringJEE 8
  • 13. BILAN 9
  • 14. BILAN • Spécification fin 2009 • JEE 6 commence à percer en production • 25-30% actuellement • > 50% d’ici 1 an 9
  • 15. Spring en 2012 Aucun Spring 2.0 Spring 2.5 Spring 3.0 Spring 3.1 cyg.be/SpringJEE 10
  • 16. Spring en 2012 Aucun Spring 2.0 Spring 2.5 Spring 3.0 Spring 3.1 50% 6% 2% 23% 19% cyg.be/SpringJEE 10
  • 17. Spring 3.1 1 an 6 mois Actuellement Plus d’un an Jamais cyg.be/SpringJEE 11
  • 18. Spring 3.1 1 an 6 mois Actuellement Plus d’un an Jamais 28% 9% 29% 26% 8% cyg.be/SpringJEE 11
  • 19. BILAN 12
  • 20. BILAN • 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 12
  • 21. Pourquoi tant de haine ? 13
  • 22. Reproches Diffile à mettre en place Invasif Trop de XML Propriétaire JEE6 fait la même chose Autres Rien 14
  • 23. Reproches Diffile à mettre en place Invasif Trop de XML Propriétaire JEE6 fait la même chose Autres Rien 40 30 20 10 0 JEE 1.4 14
  • 24. Flash back 2004 15
  • 27. Spring 1.0 1 <bean id="monBean" class="be.hikage.service.MyService"> 2 <property name="version" value="maVersion"/> 3 </bean> 17
  • 28. Spring 1.0 1 <bean id="monBean" class="be.hikage.service.MyService"> 2 <property name="version" value="maVersion"/> 3 </bean> 4 5 <bean /> 6 <bean /> 7 <bean /> 8 <bean /> 9 <bean /> 10 <bean /> 18
  • 29. Spring 1.2 200 We 5 b2 .0 1 <bean id="monBean" class="be.hikage.service.MyService"> 2 <property name="version" value="maVersion"/> 3 </bean> 4 5 <import resource="service-layer.xml"/> 6 <import resource="dao-layer.xml"/> 7 <import resource="disp-layer.xml"/> 19
  • 30. "> 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 20
  • 31. Spring 2.0 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_USER"/> 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> 21
  • 32. Spring 2.5 200 Sar 7 koz y 1 @Component 2 public class MyController { 3 4 private MyService myService; 5 6 @Autowired 7 public void setMyService(MyService myService) { 8 this.myService = myService; 9 } 10 11 } 22
  • 33. Spring 2.5 200 Sar 7 koz y 1 @Component 2 public class MyController { 3 4 private MyService myService; 5 6 @Autowired 7 public void setMyService(MyService myService) { 8 this.myService = myService; 9 } 10 11 } 1 <context:component-scan base-package="be.hikage" /> 22
  • 34. Spring 3.0 R 200 ach 9 at Sun de 1 @Configuration 2 public class ApplicationConfig { 3 4 @Bean 5 public MyService myService() { 6 return new MyService(); 7 } 8 9 } 23
  • 35. Spring 3.0 R 200 ach 9 at Sun de 1 @Configuration // <beans> 2 public class ApplicationConfig { 3 4 @Bean //<bean id="myService> 5 public MyService myService() { 6 return new MyService(); 7 } 8 9 } 24
  • 36. Spring 3.0 R 200 ach 9 at Sun de 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) 24
  • 39. @ComponentScan 1 <context:component-scan base-package="be.hikage"/> 27
  • 40. @ComponentScan 1 <context:component-scan base-package="be.hikage"/> 1 @Configuration 2 @ComponentScan("be.hikage") 3 public class ApplicationConfig 27
  • 41. @EnableScheduling 1 public class MaTache { 2 3 @Scheduled(fixedRate = 1000) 4 public void execute() { 5 System.out.println("Maman, je parle au MarsJUG"); 6 } 7 } 28
  • 43. @EnableScheduling 1 <task:annotation-driven /> 1 @Configuration 2 @EnableScheduling 3 public class ApplicationConfig { 4 } 29
  • 44. @EnableScheduling 1 @Target(ElementType.TYPE) 2 @Retention(RetentionPolicy.RUNTIME) 3 @Import(SchedulingConfiguration.class) 4 @Documented 5 public @interface EnableScheduling { 6 7 } 30
  • 45. @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 } 31
  • 46. @EnableCaching 1 @Service 2 public class CalculateurPrix { 3 4 @Cacheable(value = "price") 5 public Double calculePrix(String reference){ 6 // calcul long et complexe 7 return new Random().nextDouble(); 8 } 9 10 11 12 13 14 } 32
  • 47. @EnableCaching 1 @Service 2 public class CalculateurPrix { 3 4 @Cacheable(value = "price") 5 public Double calculePrix(String reference){ 6 // calcul long et complexe 7 return new Random().nextDouble(); 8 } 9 10 @CacheEvict(value = "price",allEntries = true) 11 public void setRistourne(Float indice){ 12 13 } 14 } 33
  • 48. @EnableCaching 1 <caching:annotation-driven /> 2 3 <bean class="org.springframework.cache .concurrent.ConcurrentMapCacheManager"/> 4 34
  • 49. @EnableCaching 1 @Configuration 2 @EnableCaching 3 public class ApplicationConfig { 4 5 @Bean 6 CacheManager cacheManager(){ 7 return 8 new ConcurrentMapCacheManager(); 9 } 10 } 35
  • 50. Abstraction de Cache • Out of the Box ✓ ConcurrentHashMap ✓ EhCache • GemFire 36
  • 52. @EnableWebMvc 1 <mvc:annotation-driven /> 1 @Configuration 2 @EnableWebMvc 3 public class WebConfig { 4 } 37
  • 53. @EnableWebMvc 1 <mvc:annotation-driven/> 2 <mvc:interceptors> 3 <bean class="osf..LocaleChangeInterceptor"/> 4 </mvc:interceptors> 38
  • 54. @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 } 39
  • 58. @EnableWebMvc Ajout Intercepteur Configuration de ViewController Ajout de ResourceHandler 40
  • 59. @EnableWebMvc Ajout Intercepteur Configuration de ViewController Ajout de ResourceHandler 40
  • 60. @EnableWebMvc Ajout Intercepteur Configuration de ViewController Ajout de ResourceHandler Ne permet pas une configuration fine 40
  • 61. @EnableWebMvc Ajout Intercepteur Configuration de ViewController Ajout de ResourceHandler Ne permet pas une configuration fine ➡ @EnableWebMvc et étendre WebMvcConfigurationSupport 40
  • 62. @Enable* 41
  • 63. @Enable* • EnableAsync 41
  • 64. @Enable* • EnableAsync • EnableAspectJAutoProxy 41
  • 65. @Enable* • EnableAsync • EnableAspectJAutoProxy • EnableSpringConfigured 41
  • 66. @Enable* • EnableAsync • EnableAspectJAutoProxy • EnableSpringConfigured • EnableLoadTimeWeaving 41
  • 67. @Enable* • EnableAsync • EnableAspectJAutoProxy • EnableSpringConfigured • EnableLoadTimeWeaving • EnableTransactionManagement 41
  • 68. Testing 2.5 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 } 42
  • 69. Testing 3.1 1 @RunWith(SpringJUnit4ClassRunner.class) 2 @ContextConfiguration(classes = TestConfig.class) 3 @ActiveProfiles("test") 4 public class MyTest { 5 @Autowired 6 MyService service; 7 8 @Test 9 public void myTest(){ 10 } 11 } 43
  • 71. 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 }
  • 72. DEMO 46
  • 73. Profile 47
  • 74. JNDI • Séparation entre l’utilisation d’une ressource et sa définition • Inadapté pour une configuration différente 48
  • 75. 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> 49
  • 76. @Profile 1 @Configuration 2 public class ApplicationConfig { 3 4 @Bean 5 DataSource dataSource(){ 6 JndiObjectFactoryBean result = new JndiObjectFactoryBean(); 7 result.setJndiName("jdbc/dataSource"); 8 return (DataSource) result.getObject(); 9 } 10 } 50
  • 77. @Profile 1 @Configuration 2 @Profile("dev") 3 public class DevConfig { 4 5 @Bean 6 MyService monBean() { 7 MyService tmp = new MyService(); 8 tmp.setVersion("dev"); 9 return tmp; 10 } 11 12 } 51
  • 78. <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> 52
  • 79. 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> 53
  • 80. 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> 54
  • 81. Spring 3.1, c’est aussi • Support Hibernate 4 • Namespace c: • JPA sans Persistence.xml • ... 55
  • 84. Resources cyg.be/cbeamsSpring31 cyg.be/costinlDevoxx11 cyg.be/SpringSourceBlog cyg.be/MattRaibleSpring31 58
  • 85. Crédits © suzesizu - Fotolia.com © vsurkov - Fotolia.com © Tiler84 - Fotolia.com © Mitarart - Fotolia.com © Beboy - Fotolia.com 59

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. @SlowService\n@CachePut\n@Caching(@CacheEvict(&amp;#xAB;primary&amp;#xBB;), @CacheEvict(&amp;#xAB;secondary&amp;#xBB;, &amp;#xAB;otherkey&amp;#xBB;))\n\n
  75. \n
  76. \n
  77. Etendre de WebMvcConfigurer et overrider les m&amp;#xE9;thodes n&amp;#xE9;cessaires\n
  78. Etendre de WebMvcConfigurer et overrider les m&amp;#xE9;thodes n&amp;#xE9;cessaires\n
  79. Etendre de WebMvcConfigurer et overrider les m&amp;#xE9;thodes n&amp;#xE9;cessaires\n
  80. Etendre de WebMvcConfigurer et overrider les m&amp;#xE9;thodes n&amp;#xE9;cessaires\n
  81. Etendre de WebMvcConfigurer et overrider les m&amp;#xE9;thodes n&amp;#xE9;cessaires\n
  82. Etendre de WebMvcConfigurer et overrider les m&amp;#xE9;thodes n&amp;#xE9;cessaires\n
  83. Etendre de WebMvcConfigurer et overrider les m&amp;#xE9;thodes n&amp;#xE9;cessaires\n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. WebApplicationInitializer vs ServletContainerInitializer\n\n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n