Chapter 11. Policy enforcement: keeping your design intact

 

This chapter covers

  • Understanding AOP policy enforcement patterns
  • Enforcing EJB programming restrictions using AspectJ
  • Enforcing Swing policies using AspectJ

Imagine that you’re convinced public access to a data member of a class isn’t a good idea. Or, imagine that you’ve realized layered architecture is the way to go. Or, suppose you’ve just finished reading the Enterprise JavaBeans (EJB) specification and realize that the specification prohibits working directly with files from an EJB. Clearly, you’d like to ensure that the projects you work on don’t violate these principles and restrictions. What are your choices? You could send emails to your team asking them to check for these violations, or you could add this information to a knowledge base. But these solutions are hard to maintain. Even if you somehow manage to detect any violations, perhaps through regular code reviews, what if you start a new project with a new team? Educate them again? OK, you get the point.

11.1. AOP-based policy enforcement overview

11.2. Policy origins and destinations

11.3. Enforcement using AOP

11.4. Comparison with code-analysis tools

11.5. Implementing flexible access control

11.6. Enforcement idiom: return-value restriction

11.7. Enforcing JPA-JDBC integration policies

11.8. Implementing EJB policies

11.9. Detecting Swing concurrency control policy violations

11.10. Summary