Spring JavaConfig Reference Guide - Spring Web Services - Parent ...

Spring JavaConfig Reference Guide - Spring Web Services - Parent ... Spring JavaConfig Reference Guide - Spring Web Services - Parent ...

static.springsource.org
from static.springsource.org More from this publisher
13.07.2015 Views

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

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

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!