Spring JavaConfig Reference Guide - Spring Web Services - Parent ...
Spring JavaConfig Reference Guide - Spring Web Services - Parent ... Spring JavaConfig Reference Guide - Spring Web Services - Parent ...
Overviewconfigurations, the dependencies are limited to CGLIB, commons-logging, spring-core, spring-beans, andspring-context. If you use more advanced features such as AOP, you'll need aspectj, spring-aop, etc. Maven2use is recommended, as it helps greatly in reducing the burden of dependency management.See also: Appendix C, Maven2 POM configurations1.4. HistoryJavaConfig was first conceived in 2005, at which time initial code was laid down. While it has remained inpre-1.0 status since that time, it has enjoyed a fair bit of use and positive user feedback. JavaConfig is now afully supported effort and is moving toward 1.0 release.Spring JavaConfig 3
Chapter 2. New & Noteworthy in 1.0.0.m32.1. AnnotationApplicationContext deprecatedAnnotationApplicationContext presented a naming conflict with Spring 2.5's Annotation-DrivenConfiguration. To avoid this problem it has been renamed to JavaConfigApplicationContext. Beyond therenaming, JavaConfigApplicationContext has several new features worth discussing. See below for details.AnnotationApplicationContext will be removed entirely in JavaConfig 1.0.0.rc1See Section 4.3, “ JavaConfigApplicationContext ”2.2. Type-safety improvementsJavaConfigApplicationContext, JavaConfigWebApplicationContext and the ConfigurationSupport baseclass now all expose type-safe getBean methods, allowing for looking up beans by type, rather than by name.@Configurationpublic class AppConfig {@Beanpublic TransferService transferService() {return new TransferServiceImpl();}}@Beanpublic NotificationService notificationService() {return new NotificationServiceImpl();}public class SimpleApp {public static void main(String... args) {JavaConfigApplicationContext context = new JavaConfigApplicationContext(AppConfig.class);// use the type-safe getBean method to avoid casting and string-based lookupsTransferService transferService = context.getBean(TransferService.class);TransferService notificationService = context.getBean(NotificationService.class);}}// ...See Section 4.3.2.1, “Type-safe access” for details.2.3. First-class support for JavaConfig in the web tierBy popular demand, a WebApplicationContext variant of JavaConfigApplicationContext has been created.This allows for seamless bootstrapping of JavaConfig bean definitions within web.xml requiring no SpringXML whatsoever.org.springframework.web.context.ContextLoaderListenercontextClassorg.springframework.config.java.JavaConfigWebApplicationContextSpring JavaConfig 4
- Page 2 and 3: About this document ...............
- Page 4 and 5: About this document1. Document stru
- Page 6 and 7: Part I. IntroductionIn Part I we ex
- Page 10 and 11: New & Noteworthy in 1.0.0.m3context
- Page 12 and 13: New & Noteworthy in 1.0.0.m3dataSou
- Page 14 and 15: Quick start3.2. Create bean definit
- Page 16 and 17: Chapter 4. Creating and using bean
- Page 18 and 19: Creating and using bean definitions
- Page 20: Creating and using bean definitions
- Page 23 and 24: Chapter 5. Modularizing configurati
- Page 25: Modularizing configurations5.4. Con
- Page 28 and 29: Using aspects}}...JavaConfigApplica
- Page 30 and 31: Chapter 8. Combining configuration
- Page 32 and 33: Appendix A. RoadmapSee the JavaConf
- Page 34 and 35: Appendix C. Maven2 POM configuratio
- Page 36: Appendix D. Additional resourcesD.1
Chapter 2. New & Noteworthy in 1.0.0.m32.1. AnnotationApplicationContext deprecatedAnnotationApplicationContext presented a naming conflict with <strong>Spring</strong> 2.5's Annotation-DrivenConfiguration. To avoid this problem it has been renamed to <strong>JavaConfig</strong>ApplicationContext. Beyond therenaming, <strong>JavaConfig</strong>ApplicationContext has several new features worth discussing. See below for details.AnnotationApplicationContext will be removed entirely in <strong>JavaConfig</strong> 1.0.0.rc1See Section 4.3, “ <strong>JavaConfig</strong>ApplicationContext ”2.2. Type-safety improvements<strong>JavaConfig</strong>ApplicationContext, <strong>JavaConfig</strong><strong>Web</strong>ApplicationContext and the ConfigurationSupport baseclass now all expose type-safe getBean methods, allowing for looking up beans by type, rather than by name.@Configurationpublic class AppConfig {@Beanpublic TransferService transferService() {return new TransferServiceImpl();}}@Beanpublic NotificationService notificationService() {return new NotificationServiceImpl();}public class SimpleApp {public static void main(String... args) {<strong>JavaConfig</strong>ApplicationContext context = new <strong>JavaConfig</strong>ApplicationContext(AppConfig.class);// use the type-safe getBean method to avoid casting and string-based lookupsTransferService transferService = context.getBean(TransferService.class);TransferService notificationService = context.getBean(NotificationService.class);}}// ...See Section 4.3.2.1, “Type-safe access” for details.2.3. First-class support for <strong>JavaConfig</strong> in the web tierBy popular demand, a <strong>Web</strong>ApplicationContext variant of <strong>JavaConfig</strong>ApplicationContext has been created.This allows for seamless bootstrapping of <strong>JavaConfig</strong> bean definitions within web.xml requiring no <strong>Spring</strong>XML whatsoever.org.springframework.web.context.ContextLoaderListenercontextClassorg.springframework.config.java.<strong>JavaConfig</strong><strong>Web</strong>ApplicationContext<strong>Spring</strong> <strong>JavaConfig</strong> 4