Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Spring<XML> est mort, vive Spring NoXML
Search
Gildas Cuisinier
November 13, 2012
Programming
150
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Spring<XML> est mort, vive Spring NoXML
Gildas Cuisinier
November 13, 2012
More Decks by Gildas Cuisinier
See All by Gildas Cuisinier
10 command line tools to improve your day !
gcuisinier
0
110
WaJUG - Introduction à Docker
gcuisinier
0
360
Other Decks in Programming
See All in Programming
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
3.1k
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
1
230
作るコストが小さくなった時代 幸せに働くために改めて考えたいこと 〜エンジニアとして価値を出し続けるために注視している二分野〜
yuppeeng
0
130
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.1k
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.3k
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
190
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
360
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
180
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
120
自作OSでスライド発表する
uyuki234
1
3.9k
yield再入門 #phpcon
o0h
PRO
0
760
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
730
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
330
40k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
GitHub's CSS Performance
jonrohan
1033
470k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.7k
Abbi's Birthday
coloredviolet
3
8.8k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4k
Why Our Code Smells
bkeepers
PRO
340
58k
Transcript
par Gildas Cuisinier @gcuisinier Spring<XML> est mort Vive Spring NoXML
jeudi 15 novembre 2012
Maître Artisan Développeur, Sfeir Benelux Initiateur de la section Spring
de @Developpez.com Relecteur de plusieurs livres sur Spring Evangéliste Spring ( JUGs, Devoxx France ) whois(@gcuisinier) jeudi 15 novembre 2012
Injection de dépendances AOP Abstraction de services Spring ? jeudi
15 novembre 2012
Retour en 2004 jeudi 15 novembre 2012
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 /> jeudi 15 novembre 2012
Spring 1.2 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"/> jeudi 15 novembre 2012
Spring 1.2 jeudi 15 novembre 2012
1 <bean id="filterChainProxy" 2 class="org.acegisecurity.util.FilterChainProxy"> 3 <property name="filterInvocationDefinitionSource"> 4 <value>
5 CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON 6 PATTERN_TYPE_APACHE_ANT 7 /login= 8 httpSessionContextIntegrationFilter 9 /login.form= 10 httpSessionContextIntegrationFilter 11 /assets/**= 12 httpSessionContextIntegrationFilter 13 /j_acegi_security_check= 14 httpSessionContextIntegrationFilter, 15 formAuthenticationProcessingFilter 16 /**= 17 httpSessionContextIntegrationFilter, 18 exceptionTranslationFilter 19 </value> 20 </property> 21 </bean> 22 <bean id="httpSessionContextIntegrationFilter" 23 class="org.acegisecurity...HttpSessionContextIntegrationFilter"> 24 </bean> 25 26 <bean id="formLoginAuthenticationEntryPoint" 27 class="org.acegisecurity...AuthenticationProcessingFilterEntryPoint"> 28 <property name="loginFormUrl" value="/login"/> 29 <property name="forceHttps" value="false"/> 30 </bean> jeudi 15 novembre 2012
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> jeudi 15 novembre 2012
1 @Controller 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 } Spring 2.5 1 <context:component-scan base-package="be.hikage" /> jeudi 15 novembre 2012
Spring 3.0 1 @Configuration 2 public class ApplicationConfig { 3
4 @Bean 5 public MyService myService() { 6 return new MyService(); 7 } 8 9 } jeudi 15 novembre 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) jeudi 15 novembre 2012
Spring 3.0 1 @Component 2 public class MyTask { 3
4 @Scheduled(cron="* * * * *") 5 public void execute() { 6 // code 7 } 8 9 } 1 <context:component-scan base-package="be.hikage" /> 2 <task:annotation-driven scheduler="myScheduler" .. /> jeudi 15 novembre 2012
Spring 3.1 @nnotations ++ jeudi 15 novembre 2012
1 <context:component-scan base-package="be.hikage"/> 1 @Configuration 2 @ComponentScan("be.hikage") 3 public class
ApplicationConfig @ComponentScan jeudi 15 novembre 2012
1 public class MaTache { 2 3 @Scheduled(fixedRate = 1000)
4 public void execute() { 5 System.out.println("Maman, je parle au ParisJUG"); 6 } 7 } @EnableScheduling jeudi 15 novembre 2012
1 @Configuration 2 @EnableScheduling 3 public class ApplicationConfig { 4
} 1 <task:annotation-driven /> @EnableScheduling jeudi 15 novembre 2012
1 @Target(ElementType.TYPE) 2 @Retention(RetentionPolicy.RUNTIME) 3 @Import(SchedulingConfiguration.class) 4 @Documented 5 public
@interface EnableScheduling { 6 7 } @EnableScheduling jeudi 15 novembre 2012
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 } @EnableScheduling jeudi 15 novembre 2012
1 @Service 2 public class CalculateurPrix { 3 4 @Cacheable(value
= "price") 5 public Double calculePrix(String reference){ 6 // calcul long et complexe 7 return 42L; 8 } 9 10 11 12 13 14 } @EnableCaching jeudi 15 novembre 2012
1 @Service 2 public class CalculateurPrix { 3 4 @Cacheable(value
= "price") 5 public Double calculePrix(String reference){ 6 // calcul long et complexe 7 return 42L; 8 } 9 10 @CacheEvict(value = "price",allEntries = true) 11 public void setRistourne(Float indice){ 12 13 } 14 } @EnableCaching jeudi 15 novembre 2012
1 <caching:annotation-driven /> 2 3 <bean class="org.springframework.cache .concurrent.ConcurrentMapCacheManager"/> 4 @EnableCaching
jeudi 15 novembre 2012
1 @Configuration 2 @EnableCaching 3 public class ApplicationConfig { 4
5 @Bean 6 CacheManager cacheManager(){ 7 return 8 new ConcurrentMapCacheManager(); 9 } 10 } @EnableCaching jeudi 15 novembre 2012
Abstraction de Cache Out of the Box ConcurrentHashMap EhCache GemFire
JCache (Spring 3.2/3.3) jeudi 15 novembre 2012
@EnableWebMvc 1 <mvc:annotation-driven /> 1 @Configuration 2 @EnableWebMvc 3 public
class WebConfig { 4 } jeudi 15 novembre 2012
@EnableWebMvc 1 <mvc:annotation-driven/> 2 <mvc:interceptors> 3 <bean class="osf..LocaleChangeInterceptor"/> 4 </mvc:interceptors>
jeudi 15 novembre 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 } jeudi 15 novembre 2012
@EnableWebMvc Ajout Intercepteur Configuration de ViewController Ajout de ResourceHandler Ne
permet pas une configuration fine ➡@EnableWebMvc et étendre WebMvcConfigurationSupport jeudi 15 novembre 2012
@Enable* EnableAsync EnableAspectJAutoProxy EnableSpringConfigured EnableLoadTimeWeaving EnableTransactionManagement jeudi 15 novembre 2012
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 } jeudi 15 novembre 2012
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 } jeudi 15 novembre 2012
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 Servlet 3.0 jeudi 15 novembre 2012
DEMO jeudi 15 novembre 2012
Spring 3.1 bis jeudi 15 novembre 2012
@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 } jeudi 15 novembre 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> jeudi 15 novembre 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> jeudi 15 novembre 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> jeudi 15 novembre 2012
Spring 3.1, c’est aussi Support Hibernate 4 Namespace c: JPA
sans Persistence.xml ... jeudi 15 novembre 2012
Spring 3.2 jeudi 15 novembre 2012
Spring 3.2 RC1 - Release début Novembre Principalement des améliorations
de l’existant Support des contrôleurs asynchrones dans WebMVC Amélioration du testing (REST, MVC) Release prévue pour le 12/12/12 ;-) Spring 3.3 JEE 7 : JPA 2.1, Bean Validation 1.1, JMS 2 Spring 3.2 jeudi 15 novembre 2012
Spring est mort ? jeudi 15 novembre 2012
Spring en 2003 Framework jeudi 15 novembre 2012
Spring en 2012 Framework Security Batch Integration Flex SpringData SpringMobile
SpringAndroid SpringSocial jeudi 15 novembre 2012
Conclusions jeudi 15 novembre 2012
Questions ? jeudi 15 novembre 2012