Java Reference
In-Depth Information
7. <bean id="bike" class="com.apress.decoupled.Bike" />
8. <bean id="vehicleService" class="com.apress.decoupled.VehicleService">
9. <property name="vehicle">
10. <ref local="car" />
11. </property>
12. </bean>
13. </beans>
You can choose any name you like for beans.xml . You have to make sure that this file is available in
CLASSPATH and use the same name in the main application while creating the application context, as
shown in the VehicleApp.java file. Figure 5-4 shows the directory structure of the application.
Figure 5-4. Directory structure
Addressing Cross-Cutting Concerns Using AOP
A separation of concerns is achieved in Spring by means of aspect-oriented programming (AOP).
AOP encapsulates the cross-cutting concerns in separate, reusable components called aspects
and adds them to the application. This process is called weaving . This results in the cohesive
components that concentrate on the business functions and are totally unaware of system services
such as logging, security, transaction, and so on. To understand how aspects can be applied in
Spring, you will now create a simple BookService that retrieves a list of all books, adding a basic
logging aspect to the BookService . The code for this application is available in a downloadable
archive on the Apress web site. Listing 5-18 illustrates the BookService .
 
Search WWH ::




Custom Search