Book description
With over 3 Million users/developers, Spring Framework is the leading "out of the box" Java framework. Spring addresses and offers simple solutions for most aspects of your Java/Java EE application development, and guides you to use industry best practices to design and implement your applications.
The release of Spring Framework 3 has ushered in many improvements and new features. Spring Recipes: A Problem-Solution Approach, Second Edition continues upon the bestselling success of the previous edition but focuses on the latest Spring 3 features for building enterprise Java applications. This book provides elementary to advanced code recipes to account for the following, found in the new Spring 3:
Spring fundamentals: Spring IoC container, Spring AOP/ AspectJ, and more
Spring enterprise: Spring Java EE integration, Spring Integration, Spring Batch, jBPM with Spring, Spring Remoting, messaging, transactions, scaling using Terracotta and GridGrain, and more.
Spring web: Spring MVC, Spring Web Flow 2, Spring Roo, other dynamic scripting, integration with popular Grails Framework (and Groovy), REST/web services, and more.
This book guides you step by step through topics using complete and real-world code examples. Instead of abstract descriptions on complex concepts, you will find live examples in this book. When you start a new project, you can consider copying the code and configuration files from this book, and then modifying them for your needs. This can save you a great deal of work over creating a project from scratch!
Table of contents
- Copyright
- About the Authors
- About the Technical Reviewers
- Acknowledgments
- Introduction
-
1. Introduction to Spring
- 1.1. Instantiating the Spring IoC Container
-
1.2. Configuring Beans in the Spring IoC Container
- 1.2.1. Problem
- 1.2.2. Solution
- 1.2.3. How It Works
- 1.3. Creating Beans by Invoking a Constructor
- 1.4. Resolving Constructor Ambiguity
- 1.5. Specifying Bean References
- 1.6. Specifying the Data Type for Collection Elements
- 1.7. Creating Beans Using Spring's FactoryBean
- 1.8. Defining Collections Using Factory Beans and the Utility Schema
- 1.9. Checking Properties with Dependency Checking
- 1.10. Checking Properties with the @Required Annotation
- 1.11. Auto-Wiring Beans with XML Configuration
- 1.12. Auto-Wiring Beans with @Autowired and @Resource
- 1.13. Inheriting Bean Configuration
- 1.14. Scanning Components from the Classpath
- 1.15. Summary
-
2. Advanced Spring IoC Container
- 2.1. Creating Beans by Invoking a Static Factory Method
- 2.2. Creating Beans by Invoking an Instance Factory Method
- 2.3. Declaring Beans from Static Fields
- 2.4. Declaring Beans from Object Properties
- 2.5. Using the Spring Expression Language
- 2.6. Setting Bean Scopes
- 2.7. Customizing Bean Initialization and Destruction
- 2.8. Reducing XML Configuration with Java Config
- 2.9. Making Beans Aware of the Container
- 2.10. Loading External Resources
- 2.11. Creating Bean Post Processors
- 2.12. Externalizing Bean Configurations
- 2.13. Resolving Text Messages
- 2.14. Communicating with Application Events
- 2.15. Registering Property Editors in Spring
- 2.16. Creating Custom Property Editors
- 2.17. Concurrency with TaskExecutors
- 2.18. Summary
-
3. Spring AOP and AspectJ Support
- 3.1. Enabling AspectJ Annotation Support in Spring
- 3.2. Declaring Aspects with AspectJ Annotations
- 3.3. Accessing the Join Point Information
- 3.4. Specifying Aspect Precedence
- 3.5. Reusing Pointcut Definitions
- 3.6. Writing AspectJ Pointcut Expressions
- 3.7. Introducing Behaviors to Your Beans
- 3.8. Introducing States to Your Beans
- 3.9. Declaring Aspects with XML-Based Configurations
- 3.10. Load-Time Weaving AspectJ Aspects in Spring
- 3.11. Configuring AspectJ Aspects in Spring
- 3.12. Injecting Spring Beans into Domain Objects
- 3.13. Summary
- 4. Scripting in Spring
- 5. Spring Security
- 6. Integrating Spring with Other Web Frameworks
- 7. Spring Web Flow
-
8. Spring @MVC
- 8.1. Developing a Simple Web Application with Spring MVC
- 8.2. Mapping requests with @RequestMapping
- 8.3. Intercepting Requests with Handler Interceptors
- 8.4. Resolving User Locales
- 8.5. Externalizing Locale-Sensitive Text Messages
- 8.6. Resolving Views by Names
- 8.7. Views and Content Negotiation
- 8.8. Mapping Exceptions to Views
- 8.9. Assigning values in a Controller with @Value
-
8.10. Handling Forms with Controllers
- 8.10.1. Problem
- 8.10.2. Solution
-
8.10.3. How It Works
- 8.10.3.1. Creating a form's views
- 8.10.3.2. Creating a form's service processing
- 8.10.3.3. Creating a form's controller
- 8.10.3.4. Initializing a model attribute object and pre-populating a form with values
- 8.10.3.5. Providing form Reference Data
- 8.10.3.6. Binding Properties of Custom Types
- 8.10.3.7. Validating Form Data
- 8.10.3.8. Expiring a controller's Session Data
- 8.11. Handling Multipage Forms with Wizard Form Controllers
- 8.12. Bean validation with Annotations (JSR-303)
- 8.13. Creating Excel and PDF Views
- 8.14. Summary
- 9. Spring REST
-
10. Spring and Flex
- 10.1. Getting started with Flex
- 10.2. Leaving the Sandbox
- 10.3. Adding the Spring BlazeDS support to an application
- 10.4. Exposing Services Through BlazeDS / Spring
- 10.5. Working With Server-Side Objects
- 10.6. Consuming Message-Oriented Services Using BlazeDS and Spring
- 10.7. Bringing Dependency Injection to your ActionScript Client
- 10.8. Summary
-
11. Grails
- 11.1. Getting and Installing Grails
- 11.2. Creating a Grails Application
- 11.3. Grails Plug-Ins
- 11.4. Developing, Producing, and Testing in Grails Environments
- 11.5. Creating an Application's Domain Classes
- 11.6. Generating CRUD Controllers and Views for an Application's Domain Classes
- 11.7. Internationalization (I18n) Message Properties
- 11.8. Changing Permanent Storage Systems
- 11.9. Logging
- 11.10. Running Unit and Integration Tests
- 11.11. Using Custom Layouts and Templates
- 11.12. Using GORM Queries
- 11.13. Creating Custom Tags
- 11.14. Summary
- 12. Spring Roo
-
13. Spring Testing
- 13.1. Creating Tests with JUnit and TestNG
- 13.2. Creating Unit Tests and Integration Tests
- 13.3. Unit Testing Spring MVC Controllers
- 13.4. Managing Application Contexts in Integration Tests
- 13.5. Injecting Test Fixtures into Integration Tests
- 13.6. Managing Transactions in Integration Tests
- 13.7. Accessing a Database in Integration Tests
- 13.8. Using Spring's Common Testing Annotations
- 13.9. Summary
- 14. Spring Portlet MVC Framework
-
15. Data Access
- 15.1. Problems with Direct JDBC
- 15.2. Using a JDBC Template to Update a Database
- 15.3. Using a JDBC Template to Query a Database
- 15.4. Simplifying JDBC Template Creation
- 15.5. Using the Simple JDBC Template with Java 1.5
- 15.6. Using Named Parameters in a JDBC Template
- 15.7. Handling Exceptions in the Spring JDBC Framework
- 15.8. Problems with Using ORM Frameworks Directly
- 15.9. Configuring ORM Resource Factories in Spring
- 15.10. Persisting Objects with Spring's ORM Templates
- 15.11. Persisting Objects with Hibernate's Contextual Sessions
- 15.12. Persisting Objects with JPA's Context Injection
- 15.13. Summary
-
16. Transaction Management in Spring
- 16.1. Problems with Transaction Management
- 16.2. Choosing a Transaction Manager Implementation
- 16.3. Managing Transactions Programmatically with the Transaction Manager API
- 16.4. Managing Transactions Programmatically with a Transaction Template
- 16.5. Managing Transactions Declaratively with Transaction Advices
- 16.6. Managing Transactions Declaratively with the @Transactional Annotation
- 16.7. Setting the Propagation Transaction Attribute
- 16.8. Setting the Isolation Transaction Attribute
- 16.9. Setting the Rollback Transaction Attribute
- 16.10. Setting the Timeout and Read-Only Transaction Attributes
- 16.11. Managing Transactions with Load-Time Weaving
- 16.12. Summary
-
17. EJB, Spring Remoting, and Web Services
- 17.1. Exposing and Invoking Services Through RMI
- 17.2. Creating EJB 2.x Components with Spring
- 17.3. Accessing Legacy EJB 2.x Components in Spring
- 17.4. Creating EJB 3.0 Components in Spring
- 17.5. Accessing EJB 3.0 Components in Spring
- 17.6. Exposing and Invoking Services Through HTTP
- 17.7. Choosing a SOAP Web Service Development Approach
- 17.8. Exposing and Invoking a Contract-Last SOAP Web Services Using JAX-WS
- 17.9. Defining the Contract of a Web Service
- 17.10. Implementing Web Services Using Spring-WS
- 17.11. Invoking Web Services Using Spring-WS
- 17.12. Developing Web Services with XML Marshalling
- 17.13. Creating Service Endpoints with Annotations
- 17.14. Summary
-
18. Spring in the Enterprise
- 18.1. Exporting Spring Beans as JMX MBeans
- 18.2. Publishing and Listening to JMX Notifications
- 18.3. Accessing Remote JMX MBeans in Spring
- 18.4. Sending E-mail with Spring's E-mail Support
- 18.5. Scheduling with Spring's Quartz Support
- 18.6. Scheduling With Spring 3.0's Scheduling Namespace
- 18.7. Summary
- 19. Messaging
-
20. Spring Integration
- 20.1. Integrating One System with Another Using EAI
- 20.2. Integrating Two Systems Using JMS
- 20.3. Interrogating Spring Integration Messages for Context Information
- 20.4. Integrating Two Systems Using a File System
- 20.5. Transforming a Message from One Type to Another
- 20.6. Error Handling Using Spring Integration
- 20.7. Forking Integration Control: Splitters and Aggregators
- 20.8. Conditional Routing with Routers
- 20.9. Adapting External Systems to the Bus
- 20.10. Staging Events Using Spring Batch
- 20.11. Using Gateways
- 20.12. Summary
-
21. Spring Batch
- 21.1. Runtime Metadata Model
- 21.2. Setting Up Spring Batch's Infrastructure
- 21.3. Reading and Writing (but No Arithmetic)
- 21.4. Writing a Custom ItemWriter and ItemReader
- 21.5. Processing Input Before Writing
- 21.6. Better Living through Transactions
- 21.7. Retrying
- 21.8. Controlling Step Execution
- 21.9. Launching a Job
- 21.10. Parameterizing a Job
- 21.11. Summary
- 22. Spring on the Grid
- 23. jBPM and Spring
-
24. OSGi and Spring
- 24.1. Getting Started with OSGi
- 24.2. Getting Started Using Spring Dynamic Modules
- 24.3. Exporting a Service Using Spring Dynamic Modules
- 24.4. Finding a Specific Service in the OSGi Registry
- 24.5. Publishing a Service Under Multiple Interfaces
- 24.6. Customizing Spring Dynamic Modules
- 24.7. Using SpringSource dm Server
- 24.8. SpringSource's Tooling
- 24.9. Summary
Product information
- Title: Spring Recipes, Second Edition
- Author(s):
- Release date: August 2010
- Publisher(s): Apress
- ISBN: 9781430224990
You might also like
book
Spring Recipes: A Problem-Solution Approach, Third Edition
Spring Recipes: A Problem-Solution Approach, Third Edition builds upon the best-selling success of the previous editions …
book
Spring 5 Recipes: A Problem-Solution Approach
Solve all your Spring 5 problems using complete and real-world code examples. When you start a …
book
Building Applications with Spring 5 and Vue.js 2
Become efficient in both frontend and backend web development with Spring and Vue Key Features Connect …
book
Full Stack Development with JHipster - Second Edition
Written by the core development team of JHipster and fully updated for JHipster 6, Java 11, …