Expert Spring MVC and Web Flow

(Dana P.) #1
Figure 2-1 illustrates the sequence of calls when a BankAccountis closed out, using proxy-
based AOP to perform the security checks.

Figure 2-1.Call sequence with AOP SecurityManager

As you can see from the preceding diagram, the SecurityManagercalls are handled by the
proxy before it delegates to the real BankAccountclass.
For more information on aspect-oriented programming, we recommend Ramnivas
Laddad’s AspectJ in Action (Manning Publications, 2003) or Adrian Colyer’s Eclipse AspectJ:
Aspect-Oriented Programming with AspectJ and the Eclipse AspectJ Development Tools(Eclipse/
Addison-Wesley, 2004). For more information on how Spring supports and implements AOP,
consult Pro Spring.

Summary


When you apply an AOP solution to your system, you are actually applying a form of IoC. For
instance, introducing security aspects to your object model is merely inverting the responsi-
bility from the object layer to the framework layer.
The Spring Framework provides a robust implementation of AOP. Every time you use the
declarative transaction management, you are using AOP. Thus, you are using another form of
IoC. In this form, the object model becomes a passive participant in transaction management,
relinquishing control over when to commit or roll back to the framework.
To summarize, Inversion of Control is the broad concept of giving control back to the
framework. This control can be control over creating new objects, control over transactions, or
control over the security implementation. Aspect-oriented programming is one technique to

Customer BankTeller BankAccountProxy

3: hasPermission

4: closeOut

2: closeOut

1: close account

Implements
BankAccount

SecurityManager Bank Account

10 CHAPTER 2 ■SPRING FUNDAMENTALS

Free download pdf