Your SlideShare is downloading. ×
  • Like
Spring AOP
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Spring AOP

  • 8,513 views
Published

This keynote provides a short introduction for using Spring AOP to modularize your cross cutting concerns and keep your code clean.

This keynote provides a short introduction for using Spring AOP to modularize your cross cutting concerns and keep your code clean.

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
8,513
On SlideShare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
530
Comments
0
Likes
10

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide































  • Crosscutting. Does the concern have a crosscutting nature?
    Aspectizability. Can the concern be resolved by AOP?
    Obliviousness. Is neither the existence nor the execution of the Aspect code apparent by examining the base code (Which allows greater Separation of Concerns)?
    Code reduction. Does it reduce code?
    Reliability. Does it reduce the chance of making mistakes?
    Modularity. Does it reduce tangling (multiple concerns intermixed) and scattering (spread of code for a concern)?
    Evolvability. Does it make it easier to modify the implementation when requirements change?
    Cost-effectiveness. Do the benefits (Code Reduction, Reliability, Modularity, Evolvability) outweigh the costs (possible increase of complexity and/or decrease of performance)?

Transcript

  • 1. Spring AOP Aspect-Oriented Programming with Spring
  • 2. Jeroen Rosenberg, Java Developer jeroen.rosenberg@gmail.com
  • 3. Table of Contents
  • 4. Table of Contents ‣ Why Aspect-Oriented Programming?
  • 5. Table of Contents ‣ Why Aspect-Oriented Programming? ‣ Basic AOP Concepts
  • 6. Table of Contents ‣ Why Aspect-Oriented Programming? ‣ Basic AOP Concepts ‣ Getting Started with Spring AOP
  • 7. Table of Contents ‣ Why Aspect-Oriented Programming? ‣ Basic AOP Concepts ‣ Getting Started with Spring AOP ‣ Benefits and Drawbacks
  • 8. Table of Contents ‣ Why Aspect-Oriented Programming? ‣ Basic AOP Concepts ‣ Getting Started with Spring AOP ‣ Benefits and Drawbacks ‣ When to Use Spring AOP?
  • 9. Aspect-Oriented Programming (AOP) enables modularization of cross- cutting concerns
  • 10. Cross-cutting Concerns
  • 11. Cross-cutting Concerns ‣ Logging ‣ Validation ‣ Transaction Management ‣ Security ‣ Caching
  • 12. Code Tangling
  • 13. Code Tangling Coupling of different concerns
  • 14. Code Scattering
  • 15. Code Scattering Same concern spread across modules
  • 16. The encouraged approach for implementing cross-cutting concerns
  • 17. The encouraged approach for implementing cross-cutting concerns
  • 18. 1. Solve core problem The encouraged approach for implementing cross-cutting concerns
  • 19. 1. Solve core problem The encouraged approach for implementing cross-cutting concerns
  • 20. 1. Solve core problem 2. Write aspects The encouraged approach for implementing cross-cutting concerns
  • 21. 1. Solve core problem 2. Write aspects The encouraged approach for implementing cross-cutting concerns
  • 22. 1. Solve core problem 3. Weave at runtime 2. Write aspects The encouraged approach for implementing cross-cutting concerns
  • 23. AOP Terminology
  • 24. AOP Terminology ‣ An aspect is a module that encapsulates advice and pointcuts
  • 25. AOP Terminology ‣ An aspect is a module that encapsulates advice and pointcuts ‣ An advice is code to be executed at a join point selected by a pointcut
  • 26. AOP Terminology ‣ An aspect is a module that encapsulates advice and pointcuts ‣ An advice is code to be executed at a join point selected by a pointcut ‣ A pointcut is an expression that selects one or more join points
  • 27. AOP Terminology ‣ An aspect is a module that encapsulates advice and pointcuts ‣ An advice is code to be executed at a join point selected by a pointcut ‣ A pointcut is an expression that selects one or more join points ‣ A join point is a point in the execution of a program
  • 28. Spring AOP Java-based AOP framework
  • 29. Spring uses dynamic proxying for aspect weaving
  • 30. Calls on the object reference will be calls on the proxy and the proxy delegates to all of the relevant advices
  • 31. Regular method invocation Calls on the object reference will be calls on the proxy and the proxy delegates to all of the relevant advices
  • 32. Regular method invocation Proxied method invocation Calls on the object reference will be calls on the proxy and the proxy delegates to all of the relevant advices
  • 33. Spring offers 3 ways to accomplish AOP support Annotation based Schema based Schema based with AspectJ with AspectJ without AspectJ Very easy to Bloated Easy to configure configure configuration Horizontal class Horizontal class Horizontal class relationships at relationships at relationships at code level deployment level deployment level Degrades Enables portability Enables portability portability
  • 34. Configuration Schema based aspect configuration without AspectJ
  • 35. Sample XML configuration
  • 36. Demo
  • 37. Benefits No special compiler required to allow per-object interception
  • 38. Drawbacks Lower performance
  • 39. AOP Suitability Cost-effectiveness Code reduction Aspectizability Obliviousness Crosscutting Concern Evolvability Modularity Reliability Logging V V V V V Validation V V V V V V V ? Transaction Management V V V V V V V V Security V V V ? V ? ? Caching V V V ? ? V ? V
  • 40. Modularization of Schema based cross cutting concerns aspect configuration Auto-proxying for aspect weaving Summary