Spring is the framework of choice to wire Enterprise Java applications. It has solved a number of problems that Enterprise Java applications have faced since the complexity associated with EJB2. A few of them are listed as follows:
- Loose coupling and testability
- Plumbing code
- Lightweight architecture
- Architectural flexibility
- Simplified implementation of cross-cutting concerns
- Best design patterns for free
Through dependency injection, Spring brings loose coupling between classes. While loose coupling is beneficial to application maintainability in the long run, the first benefits are realized with the testability that it brings in.
Testability was not a forte of Java EE (or J2EE, as it was called then) before Spring. The only way to test EJB2 applications was to run them in the container. Unit testing them was incredibly difficult.
That's exactly the problem Spring Framework set out to solve. As we saw in the earlier chapters, if objects are...