Course (2-12-1) Spring Framework Part 1
- I. Overview of Spring Framework
- 1. Introduction to Spring Framework
- 1.1. Dependency Injection and Inversion of Control
- 1.2. Modules
- 1.2.1. Core Container
- 1.2.2. Data Access/Integration
- 1.2.3. Web
- 1.2.4. AOP and Instrumentation
- 1.2.5. Test
- 1.3. Usage scenarios
- 1.3.1. Dependency Management and Naming Conventions
- Spring Dependencies and Depending on Spring
- Maven Dependency Management
- Ivy Dependency Management
- 1.3.2. Logging
- Not Using Commons Logging
- Using SLF4J
- Using Log4J
- 1.3.1. Dependency Management and Naming Conventions
- 1. Introduction to Spring Framework
- II. What's New in Spring 3
- 2. New Features and Enhancements in Spring Framework 3.0
- 2.1. Java 5
- 2.2. Improved documentation
- 2.3. New articles and tutorials
- 2.4. New module organization and build system
- 2.5. Overview of new features
- 2.5.1. Core APIs updated for Java 5
- 2.5.2. Spring Expression Language
- 2.5.3. The Inversion of Control (IoC) container
- Java based bean metadata
- Defining bean metadata within components
- 2.5.4. General purpose type conversion system and field formatting system
- 2.5.5. The Data Tier
- 2.5.6. The Web Tier
- Comprehensive REST support
- @MVC additions
- 2.5.7. Declarative model validation
- 2.5.8. Early support for Java EE 6
- 2.5.9. Support for embedded databases
- 3. New Features and Enhancements in Spring Framework 3.1
- 3.1. Cache Abstraction
- 3.2. Bean Definition Profiles
- 3.3. Environment Abstraction
- 3.4. PropertySource Abstraction
- 3.5. Code equivalents for Spring's XML namespaces
- 3.6. Support for Hibernate 4.x
- 3.7. TestContext framework support for @Configuration classes and bean definition profiles
- 3.8. c: namespace for more concise constructor injection
- 3.9. Support for injection against non-standard JavaBeans setters
- 3.10. Support for Servlet 3 code-based configuration of Servlet Container
- 3.11. Support for Servlet 3 MultipartResolver
- 3.12. JPA EntityManagerFactory bootstrapping without persistence.xml
- 3.13. New HandlerMethod-based Support Classes For Annotated Controller Processing
- 3.14. "consumes" and "produces" conditions in @RequestMapping
- 3.15. Flash Attributes and RedirectAttributes
- 3.16. URI Template Variable Enhancements
- 3.17. @Valid On @RequestBody Controller Method Arguments
- 3.18. @RequestPart Annotation On Controller Method Arguments
- 3.19. UriComponentsBuilder and UriComponents
- 4. New Features and Enhancements in Spring Framework 3.2
- 4.1. Support for Servlet 3 based asynchronous request processing
- 4.2. Spring MVC Test framework
- 4.3. Content negotiation improvements
- 4.4. @ControllerAdvice annotation
- 4.5. Matrix variables
- 4.6. Abstract base class for code-based Servlet 3+ container initialization
- 4.7. ResponseEntityExceptionHandler class
- 4.8. Support for generic types in the RestTemplate and in @RequestBody arguments
- 4.9. Jackson JSON 2 and related improvements
- 4.10. Tiles 3
- 4.11. @RequestBody improvements
- 4.12. HTTP PATCH method
- 4.13. Excluded patterns in mapped interceptors
- 4.14. Using meta-annotations for injection points and for bean definition methods
- 4.15. Initial support for JCache 0.5
- 4.16. Support for @DateTimeFormat without Joda Time
- 4.17. Global date & time formatting
- 4.18. New Testing Features
- 4.19. Concurrency refinements across the framework
- 4.20. New Gradle-based build and move to GitHub
- 4.21. Refined Java SE 7 / OpenJDK 7 support
- 2. New Features and Enhancements in Spring Framework 3.0
- III. Core Technologies
- 5. The IoC container
- 5.1. Introduction to the Spring IoC container and beans
- 5.2. Container overview
- 5.2.1. Configuration metadata
- 5.2.2. Instantiating a container
- Composing XML-based configuration metadata
- 5.2.3. Using the container
- 5.3. Bean overview
- 5.3.1. Naming beans
- Aliasing a bean outside the bean definition
- 5.3.2. Instantiating beans
- Instantiation with a constructor
- Instantiation with a static factory method
- Instantiation using an instance factory method
- 5.3.1. Naming beans
- 5.4. Dependencies
- 5.4.1. Dependency injection
- Constructor-based dependency injection
- Setter-based dependency injection
- Dependency resolution process
- Examples of dependency injection
- 5.4.2. Dependencies and configuration in detail
- Straight values (primitives, Strings, and so on)
- References to other beans (collaborators)
- Inner beans
- Collections
- Null and empty string values
- XML shortcut with the p-namespace
- XML shortcut with the c-namespace
- Compound property names
- 5.4.3. Using depends-on
- 5.4.4. Lazy-initialized beans
- 5.4.5. Autowiring collaborators
- Limitations and disadvantages of autowiring
- Excluding a bean from autowiring
- 5.4.6. Method injection
- Lookup method injection
- Arbitrary method replacement
- 5.4.1. Dependency injection
- 5.5. Bean scopes
- 5.5.1. The singleton scope
- 5.5.2. The prototype scope
- 5.5.3. Singleton beans with prototype-bean dependencies
- 5.5.4. Request, session, and global session scopes
- Initial web configuration
- Request scope
- Session scope
- Global session scope
- Scoped beans as dependencies
- 5.5.5. Custom scopes
- Creating a custom scope
- Using a custom scope
- 5.6. Customizing the nature of a bean
- 5.6.1. Lifecycle callbacks
- Initialization callbacks
- Destruction callbacks
- Default initialization and destroy methods
- Combining lifecycle mechanisms
- Startup and shutdown callbacks
- Shutting down the Spring IoC container gracefully in non-web applications
- 5.6.2. ApplicationContextAware and BeanNameAware
- 5.6.3. Other Aware interfaces
- 5.6.1. Lifecycle callbacks
- 5.7. Bean definition inheritance
- 5.8. Container Extension Points
- 5.8.1. Customizing beans using a BeanPostProcessor
- Example: Hello World, BeanPostProcessor-style
- Example: The RequiredAnnotationBeanPostProcessor
- 5.8.2. Customizing configuration metadata with a BeanFactoryPostProcessor
- Example: the PropertyPlaceholderConfigurer
- Example: the PropertyOverrideConfigurer
- 5.8.3. Customizing instantiation logic with a FactoryBean
- 5.8.1. Customizing beans using a BeanPostProcessor
- 5.9. Annotation-based container configuration
- 5.9.1. @Required
- 5.9.2. @Autowired
- 5.9.3. Fine-tuning annotation-based autowiring with qualifiers
- 5.9.4. CustomAutowireConfigurer
- 5.9.5. @Resource
- 5.9.6. @PostConstruct and @PreDestroy
- 5.10. Classpath scanning and managed components
- 5.10.1. @Component and further stereotype annotations
- 5.10.2. Automatically detecting classes and registering bean definitions
- 5.10.3. Using filters to customize scanning
- 5.10.4. Defining bean metadata within components
- 5.10.5. Naming autodetected components
- 5.10.6. Providing a scope for autodetected components
- 5.10.7. Providing qualifier metadata with annotations
- 5.11. Using JSR 330 Standard Annotations
- 5.11.1. Dependency Injection with @Inject and @Named
- 5.11.2. @Named: a standard equivalent to the @Component annotation
- 5.11.3. Limitations of the standard approach
- 5.12. Java-based container configuration
- 5.12.1. Basic concepts: @Bean and @Configuration
- 5.12.2. Instantiating the Spring container using AnnotationConfigApplicationContext
- Simple construction
- Building the container programmatically using register(Class<?>...)
- Enabling component scanning with scan(String...)
- Support for web applications with AnnotationConfigWebApplicationContext
- 5.12.3. Using the @Bean annotation
- Declaring a bean
- Receiving lifecycle callbacks
- Specifying bean scope
- Customizing bean naming
- Bean aliasing
- 5.12.4. Using the @Configuration annotation
- Injecting inter-bean dependencies
- Lookup method injection
- Further information about how Java-based configuration works internally
- 5.12.5. Composing Java-based configurations
- Using the @Import annotation
- Combining Java and XML configuration
- 5.13. Registering a LoadTimeWeaver
- 5.14. Additional Capabilities of the ApplicationContext
- 5.14.1. Internationalization using MessageSource
- 5.14.2. Standard and Custom Events
- 5.14.3. Convenient access to low-level resources
- 5.14.4. Convenient ApplicationContext instantiation for web applications
- 5.14.5. Deploying a Spring ApplicationContext as a J2EE RAR file
- 5.15. The BeanFactory
- 5.15.1. BeanFactory or ApplicationContext?
- 5.15.2. Glue code and the evil singleton
- 6. Resources
- 6.1. Introduction
- 6.2. The Resource interface
- 6.3. Built-in Resource implementations
- 6.3.1. UrlResource
- 6.3.2. ClassPathResource
- 6.3.3. FileSystemResource
- 6.3.4. ServletContextResource
- 6.3.5. InputStreamResource
- 6.3.6. ByteArrayResource
- 6.4. The ResourceLoader
- 6.5. The ResourceLoaderAware interface
- 6.6. Resources as dependencies
- 6.7. Application contexts and Resource paths
- 6.7.1. Constructing application contexts
- Constructing ClassPathXmlApplicationContext instances - shortcuts
- 6.7.2. Wildcards in application context constructor resource paths
- Ant-style Patterns
- The classpath*: prefix
- Other notes relating to wildcards
- 6.7.3. FileSystemResource caveats
- 6.7.1. Constructing application contexts
- 7. Validation, Data Binding, and Type Conversion
- 7.1. Introduction
- 7.2. Validation using Spring's Validator interface
- 7.3. Resolving codes to error messages
- 7.4. Bean manipulation and the BeanWrapper
- 7.4.1. Setting and getting basic and nested properties
- 7.4.2. Built-in PropertyEditor implementations
- Registering additional custom PropertyEditors
- 7.5. Spring 3 Type Conversion
- 7.5.1. Converter SPI
- 7.5.2. ConverterFactory
- 7.5.3. GenericConverter
- ConditionalGenericConverter
- 7.5.4. ConversionService API
- 7.5.5. Configuring a ConversionService
- 7.5.6. Using a ConversionService programmatically
- 7.6. Spring 3 Field Formatting
- 7.6.1. Formatter SPI
- 7.6.2. Annotation-driven Formatting
- Format Annotation API
- 7.6.3. FormatterRegistry SPI
- 7.6.4. FormatterRegistrar SPI
- 7.6.5. Configuring Formatting in Spring MVC
- 7.7. Configuring a global date & time format
- 7.8. Spring 3 Validation
- 7.8.1. Overview of the JSR-303 Bean Validation API
- 7.8.2. Configuring a Bean Validation Implementation
- Injecting a Validator
- Configuring Custom Constraints
- Additional Configuration Options
- 7.8.3. Configuring a DataBinder
- 7.8.4. Spring MVC 3 Validation
- Triggering @Controller Input Validation
- Configuring a Validator for use by Spring MVC
- Configuring a JSR-303 Validator for use by Spring MVC
- 8. Spring Expression Language (SpEL)
- 8.1. Introduction
- 8.2. Feature Overview
- 8.3. Expression Evaluation using Spring's Expression Interface
- 8.3.1. The EvaluationContext interface
- Type Conversion
- 8.3.1. The EvaluationContext interface
- 8.4. Expression support for defining bean definitions
- 8.4.1. XML based configuration
- 8.4.2. Annotation-based configuration
- 8.5. Language Reference
- 8.5.1. Literal expressions
- 8.5.2. Properties, Arrays, Lists, Maps, Indexers
- 8.5.3. Inline lists
- 8.5.4. Array construction
- 8.5.5. Methods
- 8.5.6. Operators
- Relational operators
- Logical operators
- Mathematical operators
- 8.5.7. Assignment
- 8.5.8. Types
- 8.5.9. Constructors
- 8.5.10. Variables
- The #this and #root variables
- 8.5.11. Functions
- 8.5.12. Bean references
- 8.5.13. Ternary Operator (If-Then-Else)
- 8.5.14. The Elvis Operator
- 8.5.15. Safe Navigation operator
- 8.5.16. Collection Selection
- 8.5.17. Collection Projection
- 8.5.18. Expression templating
- 8.6. Classes used in the examples
- 9. Aspect Oriented Programming with Spring
- 9.1. Introduction
- 9.1.1. AOP concepts
- 9.1.2. Spring AOP capabilities and goals
- 9.1.3. AOP Proxies
- 9.2. @AspectJ support
- 9.2.1. Enabling @AspectJ Support
- Enabling @AspectJ Support with Java configuration
- Enabling @AspectJ Support with XML configuration
- 9.2.2. Declaring an aspect
- 9.2.3. Declaring a pointcut
- Supported Pointcut Designators
- Combining pointcut expressions
- Sharing common pointcut definitions
- Examples
- Writing good pointcuts
- 9.2.4. Declaring advice
- Before advice
- After returning advice
- After throwing advice
- After (finally) advice
- Around advice
- Advice parameters
- Advice ordering
- 9.2.5. Introductions
- 9.2.6. Aspect instantiation models
- 9.2.7. Example
- 9.2.1. Enabling @AspectJ Support
- 9.3. Schema-based AOP support
- 9.3.1. Declaring an aspect
- 9.3.2. Declaring a pointcut
- 9.3.3. Declaring advice
- Before advice
- After returning advice
- After throwing advice
- After (finally) advice
- Around advice
- Advice parameters
- Advice ordering
- 9.3.4. Introductions
- 9.3.5. Aspect instantiation models
- 9.3.6. Advisors
- 9.3.7. Example
- 9.4. Choosing which AOP declaration style to use
- 9.4.1. Spring AOP or full AspectJ?
- 9.4.2. @AspectJ or XML for Spring AOP?
- 9.5. Mixing aspect types
- 9.6. Proxying mechanisms
- 9.6.1. Understanding AOP proxies
- 9.7. Programmatic creation of @AspectJ Proxies
- 9.8. Using AspectJ with Spring applications
- 9.8.1. Using AspectJ to dependency inject domain objects with Spring
- Unit testing @Configurable objects
- Working with multiple application contexts
- 9.8.2. Other Spring aspects for AspectJ
- 9.8.3. Configuring AspectJ aspects using Spring IoC
- 9.8.4. Load-time weaving with AspectJ in the Spring Framework
- A first example
- Aspects
- 'META-INF/aop.xml'
- Required libraries (JARS)
- Spring configuration
- Environment-specific configuration
- 9.8.1. Using AspectJ to dependency inject domain objects with Spring
- 9.9. Further Resources
- 9.1. Introduction
- 10. Spring AOP APIs
- 10.1. Introduction
- 10.2. Pointcut API in Spring
- 10.2.1. Concepts
- 10.2.2. Operations on pointcuts
- 10.2.3. AspectJ expression pointcuts
- 10.2.4. Convenience pointcut implementations
- Static pointcuts
- Dynamic pointcuts
- 10.2.5. Pointcut superclasses
- 10.2.6. Custom pointcuts
- 10.3. Advice API in Spring
- 10.3.1. Advice lifecycles
- 10.3.2. Advice types in Spring
- Interception around advice
- Before advice
- Throws advice
- After Returning advice
- Introduction advice
- 10.4. Advisor API in Spring
- 10.5. Using the ProxyFactoryBean to create AOP proxies
- 10.5.1. Basics
- 10.5.2. JavaBean properties
- 10.5.3. JDK- and CGLIB-based proxies
- 10.5.4. Proxying interfaces
- 10.5.5. Proxying classes
- 10.5.6. Using 'global' advisors
- 10.6. Concise proxy definitions
- 10.7. Creating AOP proxies programmatically with the ProxyFactory
- 10.8. Manipulating advised objects
- 10.9. Using the "auto-proxy" facility
- 10.9.1. Autoproxy bean definitions
- BeanNameAutoProxyCreator
- DefaultAdvisorAutoProxyCreator
- AbstractAdvisorAutoProxyCreator
- 10.9.2. Using metadata-driven auto-proxying
- 10.9.1. Autoproxy bean definitions
- 10.10. Using TargetSources
- 10.10.1. Hot swappable target sources
- 10.10.2. Pooling target sources
- 10.10.3. Prototype target sources
- 10.10.4. ThreadLocal target sources
- 10.11. Defining new Advice types
- 10.12. Further resources
- 11. Testing
- 11.1. Introduction to Spring Testing
- 11.2. Unit Testing
- 11.2.1. Mock Objects
- Environment
- JNDI
- Servlet API
- Portlet API
- 11.2.2. Unit Testing support Classes
- General utilities
- Spring MVC
- 11.2.1. Mock Objects
- 11.3. Integration Testing
- 11.3.1. Overview
- 11.3.2. Goals of Integration Testing
- Context management and caching
- Dependency Injection of test fixtures
- Transaction management
- Support classes for integration testing
- 11.3.3. JDBC Testing Support
- 11.3.4. Annotations
- Spring Testing Annotations
- Standard Annotation Support
- Spring JUnit Testing Annotations
- 11.3.5. Spring TestContext Framework
- Key abstractions
- Context management
- Dependency injection of test fixtures
- Testing request and session scoped beans
- Transaction management
- TestContext Framework support classes
- 11.3.6. Spring MVC Test Framework
- Server-Side Tests
- Client-Side REST Tests
- 11.3.7. PetClinic Example
- 11.4. Further Resources
- 5. The IoC container
- IV. Data Access
- 12. Transaction Management
- 12.1. Introduction to Spring Framework transaction management
- 12.2. Advantages of the Spring Framework's transaction support model
- 12.2.1. Global transactions
- 12.2.2. Local transactions
- 12.2.3. Spring Framework's consistent programming model
- 12.3. Understanding the Spring Framework transaction abstraction
- 12.4. Synchronizing resources with transactions
- 12.4.1. High-level synchronization approach
- 12.4.2. Low-level synchronization approach
- 12.4.3. TransactionAwareDataSourceProxy
- 12.5. Declarative transaction management
- 12.5.1. Understanding the Spring Framework's declarative transaction implementation
- 12.5.2. Example of declarative transaction implementation
- 12.5.3. Rolling back a declarative transaction
- 12.5.4. Configuring different transactional semantics for different beans
- 12.5.5. <tx:advice/> settings
- 12.5.6. Using @Transactional
- @Transactional settings
- Multiple Transaction Managers with @Transactional
- Custom shortcut annotations
- 12.5.7. Transaction propagation
- Required
- RequiresNew
- Nested
- 12.5.8. Advising transactional operations
- 12.5.9. Using @Transactional with AspectJ
- 12.6. Programmatic transaction management
- 12.6.1. Using the TransactionTemplate
- Specifying transaction settings
- 12.6.2. Using the PlatformTransactionManager
- 12.6.1. Using the TransactionTemplate
- 12.7. Choosing between programmatic and declarative transaction management
- 12.8. Application server-specific integration
- 12.8.1. IBM WebSphere
- 12.8.2. BEA WebLogic Server
- 12.8.3. Oracle OC4J
- 12.9. Solutions to common problems
- 12.9.1. Use of the wrong transaction manager for a specific DataSource
- 12.10. Further Resources
- 13. DAO support
- 13.1. Introduction
- 13.2. Consistent exception hierarchy
- 13.3. Annotations used for configuring DAO or Repository classes
- 12. Transaction Management