Spring est mort, Vive Spring à Devoxx France
-
Author
gildas-cuisinier -
Category
Technology
-
view
4.421 -
download
1
Embed Size (px)
description
Transcript of Spring est mort, Vive Spring à Devoxx France
- 1. Spring est mort,Vive Springby Gildas Cuisinier @gcuisinier1samedi 21 avril 2012
2. AgendaEpisode 1 : Un nouvel espoirEpisode 2 : Le JCP contre-attaqueEpisode 3 : Le retour du Printemps2samedi 21 avril 2012 3. Gildas [email protected] Artisan Dveloppeur @ Sfeir BeneluxEvangliste Spring depuis plusieurs anne3samedi 21 avril 2012 4. Episode i( ou iv )Un nouvel espoir4samedi 21 avril 2012 5. La plateforme de la mortPlateforme standard, dnie par le JCPGros dfauts : Applications difcilement testables Application non portables entre les diffrentes implmentations 5 samedi 21 avril 2012 6. Un nouvel espoir ! Conteneur lger, OpenSource Sintgre avec les forces en place Simplie les tests Bas sur du XML6samedi 21 avril 2012 7. 7samedi 21 avril 2012 8. 8samedi 21 avril 2012 9. Premires lacunes ... 9samedi 21 avril 2012 10. Premire volution 10samedi 21 avril 2012 11. "> Proxy xy"lterChain inProil.Fi Sourc e "> filterCha curi ty.utitionan id="g.acegise Defin 1 19roper ty>lter"Filteation egratextIn20n> onte xtInt ssionCont sionC ttpSe1tpSes y...H2id="h tcurit 23 t"lter Entry n>yPoiningFi24ationEntronPr ocessentic icatiLoginAuth..Authent"/> 25"formrity. login n id=isecu ue="/ class og "fals me="l alue=27 erty na ps" v 2 4 6 8 1011 16 12samedi 21 avril 2012 13. Seconde volution, bis1 @Component2 public class Jedi {34 private Arme arme;56 @Autowired7 public void setArme(Arme arme) {8 this.arme = arme;9 } 10 11 } 1 13samedi 21 avril 2012 14. Episode ii( ou v ) Le JCP contre-attaque14samedi 21 avril 2012 15. JEE 6 nouveau sexy Simplicit Testabilit Lgret MAIS Ncessite une migration15samedi 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 }16samedi 21 avril 2012 17. Spring 3.01 @Configuration // 2 public class ApplicationConfig {34 @Bean//possibilits de la conguration XML 56public MyService myService() {return new MyService();7 }89 } Spring 3.1 vient combler ceslacunes30samedi 21 avril 2012 31. @ComponentScan 1 1 @Configuration 2 @ComponentScan("spring") 3 public class ApplicationConfig31samedi 21 avril 2012 32. @EnableScheduling 1 public class MaTache { 2 [email protected](fixedRate = 1000) 4 public void execute() { 5 System.out.println("May the Spring be with you"); 6 } 7 } 32samedi 21 avril 2012 33. @EnableScheduling 1 1 @Configuration 2 @EnableScheduling 3 public class ApplicationConfig { 4 }33samedi 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 }34samedi 21 avril 2012 35. @EnableScheduling1 @Configuration2 public class SchedulingConfiguration {34 @Bean(name=AnnotationConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)5 @Role(BeanDefinition.ROLE_INFRASTRUCTURE)6 public ScheduledAnnotationBeanPostProcessor scheduledAnnotationProcessor() {7 return new ScheduledAnnotationBeanPostProcessor();8 }9 10 } 35samedi 21 avril 2012 36. @EnableWebMvc 1 1 @Configuration 2 @EnableWebMvc 3 public class WebConfig { 4 }36samedi 21 avril 2012 37. @EnableWebMvc 1 2 3 4 37samedi 21 avril 2012 38. @EnableWebMvc +WebMvcCongurerAdapter1 @Configuration2 @EnableWebMvc3 public class WebConfig4 extends WebMvcConfigurerAdapter{[email protected] void addInterceptors(InterceptorRegistry registry) {8registry.addInterceptor(new LocaleChangeInterceptor());9} 10 } 38samedi 21 avril 2012 39. @EnableWebMvcAjout IntercepteurConguration de ViewControllerAjout de ResourceHandlerNe permet pas une conguration ne @EnableWebMvc et tendre WebMvcCongurationSupport39samedi 21 avril 2012 40. @Enable* @[email protected]@[email protected] @EnableAspectJAutoProxy40samedi 21 avril 2012 41. Testing 3.01 @RunWith(SpringJUnit4ClassRunner.class)2 @ContextConfiguration("test-config.xml")3 public class MyTest {4 @Autowired5 MyService service;67 @Test8 public void myTest(){9 } 10 } 41samedi 21 avril 2012 42. Testing 3.11 @RunWith(SpringJUnit4ClassRunner.class)2 @ContextConfiguration(classes = TestConfig.class)3 public class MyTest {4 @Autowired5 MyService service;67 @Test8 public void myTest(){9 } 10 }42samedi 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");1213 }14 }43samedi 21 avril 2012 44. Nouveau pouvoir : Cacher des resources44samedi 21 avril 2012 45. 1 @Service2 public class AllianceRebelle {34 @Cacheable(value = "jedi")5 public Jedi appellerJedi(String nomJedi) {6// attendre accord du conseil7// attendre disponibilit du Jedi8return chevaliers.getByName(nomJedi);9 } 10 11 } 45samedi 21 avril 2012 46. 1 @Service2 public class AllianceRebelle {34 @Cacheable(value = "jedi")5 public Jedi appellerJedi(String nomJedi) {6// attendre accord du conseil7// attendre disponibilit du Jedi8return chevaliers.getByName(nomJedi);9 } 10 11 @CacheEvict(value = "jedi") 12 public void libererJedi(String nomJedi){ 13 14 } 15 16 } 46samedi 21 avril 2012 47. @EnableCaching1 @Configuration2 @EnableCaching3 public class ApplicationConfig {45 @Bean6 CacheManager cacheManager(){7 return8new ConcurrentMapCacheManager();9 } 10 }47samedi 21 avril 2012 48. @EnableCaching 1 2 3 448samedi 21 avril 2012 49. Abstraction de Cache Out of the Box ConcurrentHashMap EhCache GemFire49samedi 21 avril 2012 50. Nouveau pouvoir Adaptation au terrain 50samedi 21 avril 2012 51. JNDISparation entre lutilisation dune ressource et sa dnitionInadapt pour une conguration diffrente51samedi 21 avril 2012 52. Import + Proprit Systme1 1 System.setProperty("env", "TEST");1 2id="dataSource"> 2357 52samedi 21 avril 2012 53. @Prole1 @Configuration23 public class ApplicationConfig {45 @Bean6 DataSource dataSource(){7 JndiObjectFactoryBean result = newJndiObjectFactoryBean();8 result.setJndiName("jdbc/dataSource");9 return (DataSource) result.getObject(); 10 } 11 }53samedi 21 avril 2012 54. @Prole1 @Configuration2 @Import(ApplicationDevConfig.class)3 public class ApplicationConfig {45 @Bean6 DataSource dataSource(){7 JndiObjectFactoryBean result = newJndiObjectFactoryBean();8 result.setJndiName("jdbc/dataSource");9 return (DataSource) result.getObject(); 10 } 11 }54samedi 21 avril 2012 55. @Prole1 @Configuration2 @Profile("dev")3 public class ApplicationDevConfig {45 @Bean6 DataSource dataSource() {7 SingleConnectionDataSource connection = newSingleConnectionDataSource(...);8 return connection;9 } 10 }55samedi 21 avril 2012 56. 1 2 3 4 5 6 56samedi 21 avril 2012 57. Activation1 2 3spring.profiles.active4dev5 6 57samedi 21 avril 2012 58. Activation1 2 dispatcher3 osf.web.servlet.DispatcherServlet4 5 spring.profiles.active6 dev7 8 58samedi 21 avril 2012 59. Spring 3.1, cest aussiSupport Hibernate 4Namespace c:JPA sans Persistence.xmlAmlioration de REST dans SpringMVCFlashMap dans Spring MVC 59samedi 21 avril 2012 60. LUnivers de Spring SpringData BatchSpringMobile Integration Framework SpringAndroid SpringSocialSecurityFlex60samedi 21 avril 2012 61. Conclusion Spring est largement rpandu Spring continue voluer NoXML Ouvert au Cloud Spring est un cosystme 61samedi 21 avril 2012 62. cyg.be/cbeamsSpring31cyg.be/costinlDevoxx11 cyg.be/SpringSourceBlog cyg.be/MattRaibleSpring31 62samedi 21 avril 2012 63. Sources des imageshttp://www.thegeekshowpodcast.comhttp://www.thinkgeek.comhttp://gadgetsin.comraven - Fotolia.com 63samedi 21 avril 2012