Overview
This course enables the experienced Java developer to use the Spring application framework to manage objects in a lightweight, inversion-of-control container, and to build persistence components and application tiers using Spring's support for relational databases and transaction control.
Spring's core module gives the developer declarative control over object creation and assembly; this is useful for any tier of any Java application, so we study it in some depth to begin the course. Then students build persistence code using the Spring DAO and ORM modules, using both JDBC and JPA, with Hibernate as the provider. We study both programmatic and declarative transaction control. The course concludes with a chapter on Spring's testing framework, with a focus on test-managed transactions.
Prerequisites
- Java programming is required
- Basic knowledge of XML is recommended
- For the final chapter some undersatnding of JUnit is required
Learning Objectives
- Understand the scope, purpose, and architecture of Spring
- Use Spring application contexts to declare application components, rather than hard-coding their states and lifecycles
- Use dependency injection to further control object relationships from outside the Java code base
- Use annotations to take advantage of Spring post-processors for automated bean instantiation and wiring
- Connect business objects to persistent stores using Spring's DAO and ORM modules
- Simplify JDBC code using Spring templates
- Integrate JPA entities and DAOs into Spring applications
- Control transactions using Spring, either programmatically or declaratively
- Develop effective unit tests using Spring's test framework
Course Duration
3 Days
Course outline
IDE Support: Eclipse Luna or higher
- In addition to the primary lab files, an optional overlay is available that adds support for Eclipse Luna or higher. Students can code, build, deploy, and test all exercises from within Eclipse, and take advantage of Eclipse's built-in editors and wizards for web applications, XML files, JSPs, and more
Chapter 1. Overview of Spring
- Java EE: The Good, The Bad, and the Ugly
- Enter the Framework
- Spring Value Proposition
- The Spring Container
- Web Applications
- Persistence Support
- Aspect-Oriented Programming
- The Java EE Module(s)
Chapter 2. The Container
- JavaBeans, Reconsidered
- The Factory Pattern
- Inversion of Control
- XML View: Declaring Beans
- Java View: Using Beans
- Singletons and Prototypes
Chapter 3. Instantiation and Configuration
- Configuring Through Properties
- Configuration Namespaces
- The p: Notation
- Bean (Configuration) Inheritance
- Configuring Through Constructors
- Bean Post-Processors
- Lifecycle Hooks
- Integrating Existing Factory Code
- Awareness Interfaces
Chapter 4. Dependency Injection
- Assembling Object Graphs
- Dependency Injection
- Single and Multiple Relationships
- The Utility Schema
- Using Spring Expression Language (SpEL)
- Inner Beans
- Autowiring
- @Component, @Service, & Company
- @Autowired Properties
- Best Practices with Spring Annotations
- Java Classes as @Configurations
- AnnotationConfigApplicationContext
- Capabilities and Limitations
- Mixing and Importing XML and Java Configurations
Chapter 5. Assembling Object Models
- Collections and Maps
- Support for Generics
- The Spring Utility Schema (util:)
- Autowiring to Multiple Beans
- Order of Instantiation
- Bean Factory vs. Application Context
Chapter 6. Persistence with JDBC
- Reducing Code Complexity
- The DataAccessException Hierarchy
- JdbcTemplate
- RowMapper<T> and ResultSetExtractor<T>
- The DaoSupport Hierarchy
- Capturing Generated Keys
- Transaction Control
- PlatformTransactionManager
- TransactionTemplate
- Isolation Levels
- Transaction Propagation
Chapter 7. Persistence with JPA
- Object/Relational Mapping
- The Java Persistence API
- JpaDaoSupport and JpaTemplate
- @PersistenceUnit and @PersistenceContext
- Shared Entity Managers
- Using <tx:annotation-driven>
- The @Transactional Annotation
- Isolation and Propagation
- A Limitation of @Transactional
- Understanding Entity States
- Configuring JPA Without persistence.xml
- Bean Validation in JPA
- Optimistic Locking
Chapter 8. Testing
- Testability of Spring Applications
- Dependency Injection
- Mocking
- SpringJUnit4ClassRunner
- TestContext
- @ContextConfiguration
- Preserving Test Isolation
- @DirtiesContext
- AbstractTransactionalJUnit4SpringContextTests
- Testing JPA Components
- Mixing JPA and JDBC
- TestTransaction
- Profiles
System Requirements
Hardware Requirements (Minimum)
- Core i5, 1.8 GHz, 4 gig RAM, 1 gig disk space
Hardware Requirements (Recommended)
- Core i5, 2.5 GHz GHz, 8 gig RAM, 1 gig disk space.
Operating System
- Tested on Windows 7/8, Mac OS 10.8.5.
Network and Security
- Limited privileges required
Software Requirements
- All free downloadable tools.