About the Authors |
|
xxi | |
About the Technical Reviewer |
|
xxiii | |
Introduction |
|
xxv | |
Chapter 1 Introducing Spring |
|
1 | (14) |
|
|
1 | (11) |
|
Evolution of the Spring Framework |
|
|
2 | (3) |
|
Inverting Control or Injecting Dependencies? |
|
|
5 | (1) |
|
Evolution of Dependency Injection |
|
|
6 | (1) |
|
Beyond Dependency Injection |
|
|
7 | (5) |
|
|
12 | (2) |
|
|
12 | (1) |
|
|
12 | (1) |
|
|
13 | (1) |
|
The Spring Security Project |
|
|
13 | (1) |
|
Spring Batch and Integration |
|
|
13 | (1) |
|
|
13 | (1) |
|
|
14 | (1) |
|
|
14 | (1) |
|
|
14 | (1) |
|
|
14 | (1) |
|
|
14 | (1) |
|
|
14 | (1) |
Chapter 2 Getting Started |
|
15 | (12) |
|
Obtaining the Spring Framework |
|
|
16 | (1) |
|
|
16 | (1) |
|
Checking Spring Out of GitHub |
|
|
16 | (1) |
|
Understanding Spring Packaging |
|
|
16 | (3) |
|
Understanding Spring Modules |
|
|
16 | (2) |
|
Choosing Modules for Your Application |
|
|
18 | (1) |
|
Accessing Spring Modules on the Maven Repository |
|
|
19 | (1) |
|
Using Spring Documentation |
|
|
19 | (1) |
|
Putting a Spring into "Hello World!" |
|
|
19 | (7) |
|
Building the Sample "Hello World!" Application |
|
|
19 | (5) |
|
|
24 | (2) |
|
|
26 | (1) |
Chapter 3 Introducing loC and DI in Spring |
|
27 | (66) |
|
Inversion of Control and Dependency Injection |
|
|
27 | (1) |
|
Types of Inversion of Control |
|
|
28 | (7) |
|
|
28 | (1) |
|
Contextualized Dependency Lookup |
|
|
29 | (1) |
|
Constructor Dependency Injection |
|
|
30 | (1) |
|
Setter Dependency Injection |
|
|
31 | (1) |
|
|
31 | (1) |
|
Setter Injection vs. Constructor Injection |
|
|
32 | (3) |
|
Inversion of Control in Spring |
|
|
35 | (1) |
|
Dependency Injection in Spring |
|
|
35 | (3) |
|
|
35 | (1) |
|
BeanFactory Implementations |
|
|
36 | (2) |
|
|
38 | (1) |
|
Configuring ApplicationContext |
|
|
38 | (48) |
|
Setting Spring Configuration Options |
|
|
38 | (1) |
|
Basic Configuration Overview |
|
|
39 | (1) |
|
Declaring Spring Components |
|
|
40 | (4) |
|
|
44 | (2) |
|
Using Constructor Injection |
|
|
46 | (7) |
|
Using Injection Parameters |
|
|
53 | (19) |
|
|
72 | (8) |
|
Understanding Bean Naming |
|
|
80 | (2) |
|
Understanding Bean Instantiation Mode |
|
|
82 | (4) |
|
|
86 | (1) |
|
|
86 | (4) |
|
|
87 | (2) |
|
|
89 | (1) |
|
|
90 | (1) |
|
|
91 | (2) |
Chapter 4 Spring Configuration in Detail |
|
93 | (68) |
|
Spring's Impact on Application Portability |
|
|
94 | (1) |
|
Bean Life-Cycle Management |
|
|
94 | (18) |
|
Hooking into Bean Creation |
|
|
96 | (8) |
|
Hooking into Bean Destruction |
|
|
104 | (8) |
|
Making Your Beans "Spring Aware" |
|
|
112 | (5) |
|
Using the BeanNameAware Interface |
|
|
113 | (1) |
|
Using the ApplicationContextAware Interface |
|
|
114 | (3) |
|
|
117 | (6) |
|
FactoryBean Example: The MessageDigestFactoryBean |
|
|
117 | (4) |
|
Accessing a FactoryBean Directly |
|
|
121 | (1) |
|
Using the factory-bean and factory-method Attributes |
|
|
121 | (2) |
|
JavaBeans PropertyEditors |
|
|
123 | (8) |
|
Using the Built-in PropertyEditors |
|
|
123 | (5) |
|
Creating a Custom PropertyEditor |
|
|
128 | (3) |
|
More Spring ApplicationContext Configuration |
|
|
131 | (9) |
|
Internationalization with the MessageSource |
|
|
132 | (3) |
|
Using MessageSource in Stand-Alone Applications |
|
|
135 | (1) |
|
The MessageSourceResolvable Interface |
|
|
135 | (1) |
|
|
135 | (3) |
|
|
138 | (2) |
|
Configuration Using Java Classes |
|
|
140 | (5) |
|
ApplicationContext Configuration in Java |
|
|
140 | (5) |
|
Java or XML Configuration? |
|
|
145 | (1) |
|
|
145 | (5) |
|
An Example of Using the Spring Profiles Feature |
|
|
146 | (3) |
|
Considerations for Using Profiles |
|
|
149 | (1) |
|
Environment and PropertySource Abstraction |
|
|
150 | (4) |
|
Configuration Using JSR-330 Annotations |
|
|
154 | (4) |
|
Configuration Using Groovy |
|
|
158 | (2) |
|
|
160 | (1) |
Chapter 5 Introducing Spring AOP |
|
161 | (80) |
|
|
162 | (1) |
|
|
163 | (1) |
|
|
163 | (1) |
|
|
163 | (1) |
|
|
163 | (1) |
|
|
164 | (19) |
|
|
164 | (1) |
|
|
164 | (2) |
|
|
166 | (1) |
|
About the ProxyFactory Class |
|
|
167 | (1) |
|
Creating Advice in Spring |
|
|
167 | (16) |
|
Advisors and Pointcuts in Spring |
|
|
183 | (17) |
|
|
184 | (16) |
|
|
200 | (6) |
|
Using JDK Dynamic Proxies |
|
|
201 | (1) |
|
|
201 | (1) |
|
Comparing Proxy Performance |
|
|
201 | (5) |
|
|
206 | (1) |
|
Advanced Use of Pointcuts |
|
|
206 | (6) |
|
Using Control Flow Pointcuts |
|
|
206 | (3) |
|
Using a Composable Pointcut |
|
|
209 | (3) |
|
Composition and the Pointcut Interface |
|
|
212 | (1) |
|
|
212 | (1) |
|
Getting Started with Introductions |
|
|
212 | (8) |
|
|
212 | (3) |
|
Object Modification Detection with Introductions |
|
|
215 | (5) |
|
|
220 | (1) |
|
Framework Services for AOP |
|
|
220 | (16) |
|
Configuring AOP Declaratively |
|
|
220 | (1) |
|
|
221 | (5) |
|
|
226 | (5) |
|
Using ©AspectJ-Style Annotations |
|
|
231 | (4) |
|
Considerations for Declarative Spring AOP Configuration |
|
|
235 | (1) |
|
|
236 | (3) |
|
|
236 | (1) |
|
|
236 | (3) |
|
|
239 | (2) |
Chapter 6 Spring JDBC Support |
|
241 | (62) |
|
Introducing Lambda Expressions |
|
|
242 | (1) |
|
Sample Data Model for Example Code |
|
|
242 | (4) |
|
Exploring the JDBC Infrastructure |
|
|
246 | (6) |
|
Spring JDBC Infrastructure |
|
|
252 | (5) |
|
Overview and Used Packages |
|
|
252 | (1) |
|
Database Connections and DataSources |
|
|
253 | (3) |
|
Embedded Database Support |
|
|
256 | (1) |
|
Using DataSources in DAO Classes |
|
|
257 | (2) |
|
|
259 | (1) |
|
|
260 | (12) |
|
Initializing JdbcTemplate in a DAO Class |
|
|
261 | (1) |
|
Retrieving a Single-Value by Using JdbcTemplate |
|
|
261 | (2) |
|
Using Named Parameters with NamedParameterJdbcTemplate |
|
|
263 | (2) |
|
Retrieving Domain Objects with RowMapper<T> |
|
|
265 | (2) |
|
Retrieving Nested Domain Objects with ResultSetExtractor |
|
|
267 | (5) |
|
Spring Classes That Model JDBC Operations |
|
|
272 | (29) |
|
Querying Data by Using MappingSqlQuery<T> |
|
|
274 | (6) |
|
Updating Data by Using SqlUpdate |
|
|
280 | (3) |
|
Inserting Data and Retrieving the Generated Key |
|
|
283 | (4) |
|
Batching Operations with BatchSqlUpdate |
|
|
287 | (7) |
|
Calling Stored Functions by Using SqlFunction |
|
|
294 | (7) |
|
Spring Data Project: JDBC Extensions |
|
|
301 | (1) |
|
Considerations for Using JDBC |
|
|
301 | (1) |
|
|
302 | (1) |
Chapter 7 Using Hibernate in Spring |
|
303 | (42) |
|
Sample Data Model for Example Code |
|
|
304 | (2) |
|
Configuring Hibernate SessionFactory |
|
|
306 | (2) |
|
ORM Mapping Using Hibernate Annotations |
|
|
308 | (13) |
|
|
309 | (5) |
|
|
314 | (4) |
|
|
318 | (3) |
|
The Hibernate Session Interface |
|
|
321 | (1) |
|
Database Operations with Hibernate |
|
|
322 | (21) |
|
Querying Data by Using Hibernate Query Language |
|
|
323 | (12) |
|
|
335 | (3) |
|
|
338 | (2) |
|
|
340 | (3) |
|
Considerations When Using Hibernate |
|
|
343 | (1) |
|
|
343 | (2) |
Chapter 8 Data Access in Spring with JPA2 |
|
345 | (68) |
|
|
346 | (4) |
|
Using the Sample Data Model for Example Code |
|
|
346 | (1) |
|
Configuring JPA EntityManagerFactory |
|
|
346 | (2) |
|
Using JPA Annotations for ORM Mapping |
|
|
348 | (2) |
|
Performing Database Operations with JPA |
|
|
350 | (37) |
|
Using the Java Persistence Query Language to Query Data |
|
|
350 | (16) |
|
|
366 | (4) |
|
|
370 | (1) |
|
|
371 | (3) |
|
|
374 | (7) |
|
Using the JPA 2 Criteria API for a Criteria Query |
|
|
381 | (6) |
|
Introducing Spring Data JPA |
|
|
387 | (14) |
|
Adding Spring Data JPA Library Dependencies |
|
|
387 | (1) |
|
Using Spring Data JPA Repository Abstraction for Database Operations |
|
|
388 | (4) |
|
Keeping Track of Changes on the Entity Class |
|
|
392 | (9) |
|
Keeping Entity Versions by Using Hibernate Envers |
|
|
401 | (10) |
|
Adding Tables for Entity Versioning |
|
|
402 | (1) |
|
Configuring EntityManagerFactory for Entity Versioning |
|
|
403 | (2) |
|
Enabling Entity Versioning and History Retrieval |
|
|
405 | (5) |
|
Testing Entity Versioning |
|
|
410 | (1) |
|
Considerations When Using JPA |
|
|
411 | (1) |
|
|
411 | (2) |
Chapter 9 Transaction Management |
|
413 | (34) |
|
Exploring the Spring Transaction Abstraction Layer |
|
|
414 | (2) |
|
|
414 | (1) |
|
Implementations of the PlafformTransactionManager |
|
|
415 | (1) |
|
Analyzing Transaction Properties |
|
|
416 | (3) |
|
The TransactionDefinition Interface |
|
|
416 | (2) |
|
The TransactionStatus Interface |
|
|
418 | (1) |
|
Sample Data Model and Infrastructure for Example Code |
|
|
419 | (4) |
|
Creating a Simple Spring JPA Project with Dependencies |
|
|
419 | (1) |
|
Sample Data Model and Common Classes |
|
|
420 | (3) |
|
Declarative and Programmatic Transactions with Spring |
|
|
423 | (16) |
|
Using Annotations for Transaction Management |
|
|
423 | (9) |
|
Using XML Configuration for Transaction Management |
|
|
432 | (4) |
|
Using Programmatic Transactions |
|
|
436 | (3) |
|
Considerations on Transaction Management |
|
|
439 | (1) |
|
Global Transactions with Spring |
|
|
439 | (6) |
|
Infrastructure for Implementing the JTA Sample |
|
|
439 | (1) |
|
Implementing Global Transactions with JTA |
|
|
440 | (5) |
|
Considerations on Using JTA Transaction Manager |
|
|
445 | (1) |
|
|
445 | (2) |
Chapter 10 Validation with Type Conversion and Formatting |
|
447 | (26) |
|
|
447 | (1) |
|
Spring Type Conversion System |
|
|
448 | (10) |
|
Conversion from a String Using PropertyEditors |
|
|
448 | (4) |
|
Introducing Spring Type Conversion |
|
|
452 | (6) |
|
Field Formatting in Spring |
|
|
458 | (3) |
|
Implementing a Custom Formatter |
|
|
458 | (2) |
|
Configuring ConversionServiceFactoryBean |
|
|
460 | (1) |
|
|
461 | (11) |
|
Using the Spring Validator Interface |
|
|
462 | (2) |
|
Using JSR-349 Bean Validation |
|
|
464 | (8) |
|
Deciding Which Validation API to Use |
|
|
472 | (1) |
|
|
472 | (1) |
Chapter 11 Task Scheduling in Spring |
|
473 | (18) |
|
Dependencies for the Task Scheduling Samples |
|
|
473 | (1) |
|
Task Scheduling in Spring |
|
|
474 | (9) |
|
Introducing the Spring TaskScheduler Abstraction |
|
|
474 | (1) |
|
|
475 | (5) |
|
Using task-namespace for Task Scheduling |
|
|
480 | (2) |
|
Using Annotations for Task Scheduling |
|
|
482 | (1) |
|
Asynchronous Task Execution in Spring |
|
|
483 | (3) |
|
|
486 | (3) |
|
|
489 | (2) |
Chapter 12 Using Spring Remoting |
|
491 | (42) |
|
Adding Required Dependencies for the JPA Back End |
|
|
492 | (7) |
|
Using a Data Model for Samples |
|
|
493 | (1) |
|
Implementing and Configuring ContactService |
|
|
493 | (6) |
|
Using the Spring HTTP Invoker |
|
|
499 | (3) |
|
|
499 | (1) |
|
|
500 | (2) |
|
|
502 | (7) |
|
|
502 | (1) |
|
Implementing a JMS Listener in Spring |
|
|
502 | (2) |
|
Sending JMS Messages in Spring |
|
|
504 | (2) |
|
|
506 | (3) |
|
Using RESTful-WS in Spring |
|
|
509 | (20) |
|
Introducing RESTful Web Services |
|
|
510 | (1) |
|
Adding Required Dependencies for Samples |
|
|
510 | (1) |
|
Designing the Contact RESTful Web Service |
|
|
511 | (1) |
|
Using Spring MVC to Expose RESTful Web Services |
|
|
512 | (6) |
|
Using curl to Test RESTfuI-WS |
|
|
518 | (5) |
|
Using RestTemplate to Access RESTfuI-WS |
|
|
523 | (3) |
|
Securing RESTful-WS with Spring Security |
|
|
526 | (3) |
|
|
529 | (3) |
|
|
532 | (1) |
Chapter 13 Spring Testing |
|
533 | (18) |
|
Introducing an Enterprise Testing Framework |
|
|
534 | (2) |
|
Using Spring Test Annotations |
|
|
536 | (1) |
|
Implementing Logic Unit Tests |
|
|
537 | (3) |
|
Adding Required Dependencies |
|
|
537 | (1) |
|
Unit Testing Spring MVC Controllers |
|
|
537 | (3) |
|
Implementing an Integration Test |
|
|
540 | (9) |
|
Adding Required Dependencies |
|
|
540 | (1) |
|
Configuring the Profile for Service-Layer Testing |
|
|
541 | (2) |
|
Implementing the Infrastructure Classes |
|
|
543 | (3) |
|
Unit Testing the Service Layer |
|
|
546 | (3) |
|
Implementing a Front-End Unit Test |
|
|
549 | (1) |
|
|
549 | (1) |
|
|
550 | (1) |
Chapter 14 Scripting Support in Spring |
|
551 | (16) |
|
Working with Scripting Support in Java |
|
|
552 | (1) |
|
|
553 | (3) |
|
|
553 | (1) |
|
|
554 | (1) |
|
|
555 | (1) |
|
|
556 | (9) |
|
Adding Required Dependencies |
|
|
556 | (1) |
|
Developing the Contact Domain |
|
|
557 | (1) |
|
Implementing the Rule Engine |
|
|
558 | (3) |
|
Implementing the Rule Factory as a Spring Refreshable Bean |
|
|
561 | (1) |
|
Testing the Age Category Rule |
|
|
562 | (3) |
|
Inlining Dynamic Language Code |
|
|
565 | (1) |
|
|
566 | (1) |
Chapter 15 Spring Application Monitoring |
|
567 | (6) |
|
|
567 | (1) |
|
Exporting a Spring Bean to JMX |
|
|
568 | (1) |
|
Setting Up VisualVM for JMX Monitoring |
|
|
569 | (1) |
|
Monitoring Hibernate Statistics |
|
|
570 | (2) |
|
|
572 | (1) |
Chapter 16 Web Applications with Spring |
|
573 | (72) |
|
Implementing the Service Layer for Samples |
|
|
574 | (7) |
|
Using a Data Model for Samples |
|
|
574 | (1) |
|
Implementing and Configuring ContactService |
|
|
575 | (6) |
|
Introducing MVC and Spring MVC |
|
|
581 | (7) |
|
|
581 | (2) |
|
|
583 | (5) |
|
Creating the First View in Spring MVC |
|
|
588 | (3) |
|
Configuring the DispatcherServlet |
|
|
588 | (1) |
|
Implementing the ContactController |
|
|
589 | (1) |
|
Implementing the Contact List View |
|
|
590 | (1) |
|
Testing the Contact List View |
|
|
591 | (1) |
|
Understanding Spring MVC Project Structure |
|
|
591 | (1) |
|
Enabling i18n (Internationalization) |
|
|
592 | (3) |
|
Configuring i18n in DispatcherServlet Configuration |
|
|
593 | (1) |
|
Modifying the Contact List View for i18n Support |
|
|
594 | (1) |
|
Using Theming and Templating |
|
|
595 | (9) |
|
|
596 | (2) |
|
View Templating with Apache Tiles |
|
|
598 | (6) |
|
Implementing the Views for Contact Information |
|
|
604 | (16) |
|
Mapping URLs to the Views |
|
|
604 | (1) |
|
Implementing the Show Contact View |
|
|
605 | (3) |
|
Implementing the Edit Contact View |
|
|
608 | (6) |
|
Implementing the Add Contact View |
|
|
614 | (3) |
|
Enabling JSR-349 Bean Validation |
|
|
617 | (3) |
|
Using jQuery and jQuery UI |
|
|
620 | (11) |
|
Introducing jQuery and jQuery UI |
|
|
620 | (1) |
|
Enabling jQuery and jQuery UI in a View |
|
|
621 | (2) |
|
Rich-Text Editing with CKEditor |
|
|
623 | (1) |
|
Using jqGrid for a Data Grid with Pagination |
|
|
624 | (7) |
|
|
631 | (4) |
|
Configuring File Upload Support |
|
|
631 | (1) |
|
Modifying Views for File Upload Support |
|
|
632 | (2) |
|
Modifying Controller for File Upload Support |
|
|
634 | (1) |
|
Securing a Web Application with Spring Security |
|
|
635 | (6) |
|
Configuring Spring Security |
|
|
636 | (2) |
|
Adding Login Functions to the Application |
|
|
638 | (2) |
|
Using Annotations to Secure Controller Methods |
|
|
640 | (1) |
|
Supporting Servlet 3 Code-Based Configuration |
|
|
641 | (2) |
|
|
643 | (2) |
Chapter 17 WebSocket |
|
645 | (18) |
|
|
645 | (1) |
|
Using WebSocket with Spring |
|
|
646 | (15) |
|
|
646 | (5) |
|
|
651 | (4) |
|
Sending Messages with STOMP |
|
|
655 | (6) |
|
|
661 | (2) |
Chapter 18 Spring Projects: Batch, Integration, XD, and Boot |
|
663 | (22) |
|
|
663 | (10) |
|
|
670 | (3) |
|
|
673 | (5) |
|
|
678 | (2) |
|
|
680 | (3) |
|
|
683 | (2) |
Index |
|
685 | |