Accessing Other Beans and Separation of Concerns
The mechanism for defining other beans in the application context is identical to what I've just described: Simply follow the format of Listing 1. In other words, the application context is extensible, and you also can add more than one application context file. A common example of the latter is an application context file for persistence classes—that is, data access objects (or DAOs, as they're usually called). It's merely a matter of creating a new XML file and loading it from the Java code as illustrated in Listing 2.
This use of multiple application context files is a good example of the way Spring helps in reinforcing good design patterns. In this case, the patterns are separation of concerns and loose coupling. When used properly, application contexts provide some degree of insurance against producing monolithic code.