SlideShare a Scribd company logo
Spring AOP
Aspect-Oriented Programming with Spring
Jeroen Rosenberg, Java Developer
jeroen.rosenberg@gmail.com
Table of Contents
Table of Contents

‣ Why Aspect-Oriented Programming?
Table of Contents

‣ Why Aspect-Oriented Programming?


‣ Basic AOP Concepts
Table of Contents

‣ Why Aspect-Oriented Programming?


‣ Basic AOP Concepts


‣ Getting Started with Spring AOP
Table of Contents

‣ Why Aspect-Oriented Programming?


‣ Basic AOP Concepts


‣ Getting Started with Spring AOP


‣ Benefits and Drawbacks
Table of Contents

‣ Why Aspect-Oriented Programming?


‣ Basic AOP Concepts


‣ Getting Started with Spring AOP


‣ Benefits and Drawbacks


‣ When to Use Spring AOP?
Aspect-Oriented Programming (AOP)
enables modularization of cross-
cutting concerns
Cross-cutting Concerns
Cross-cutting Concerns

‣ Logging
‣ Validation
‣ Transaction
  Management
‣ Security
‣ Caching
Code Tangling
Code Tangling
Coupling of different concerns
Code Scattering
Code Scattering
Same concern spread across
modules
The encouraged approach for implementing cross-cutting concerns
The encouraged approach for implementing cross-cutting concerns
1. Solve core problem




The encouraged approach for implementing cross-cutting concerns
1. Solve core problem




The encouraged approach for implementing cross-cutting concerns
1. Solve core problem




                                      2. Write aspects



The encouraged approach for implementing cross-cutting concerns
1. Solve core problem




                                      2. Write aspects



The encouraged approach for implementing cross-cutting concerns
1. Solve core problem                                             3. Weave at runtime




                                      2. Write aspects



The encouraged approach for implementing cross-cutting concerns
AOP Terminology
AOP Terminology

‣ An aspect is a module that encapsulates advice and pointcuts
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
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
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
Spring AOP   Java-based AOP framework
Spring uses dynamic proxying for aspect weaving
Calls on the object reference will be calls on the proxy and the proxy
delegates to all of the relevant advices
Regular method invocation




Calls on the object reference will be calls on the proxy and the proxy
delegates to all of the relevant advices
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
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
Configuration
Schema based aspect
configuration without AspectJ
Sample XML configuration
Demo
Benefits   No special compiler required to allow
          per-object interception
Drawbacks   Lower performance
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
Modularization of                           Schema based
cross cutting concerns                       aspect configuration




                         Auto-proxying for
                          aspect weaving

Summary

More Related Content

PPTX
Spring AOP in Nutshell
PPT
Spring AOP
PDF
Spring framework aop
PPTX
Spring Framework
PPTX
Aspect Oriented Programming
PPTX
Spring boot
PDF
Spring Framework - AOP
Spring AOP in Nutshell
Spring AOP
Spring framework aop
Spring Framework
Aspect Oriented Programming
Spring boot
Spring Framework - AOP

What's hot (20)

PPT
Spring Core
PPTX
Optional in Java 8
PDF
Spring Boot
PPTX
Spring boot
PPT
Java Persistence API (JPA) Step By Step
PPTX
Spring Boot
PPTX
Spring boot Introduction
PDF
Introduction to Spring webflux
ODP
Xke spring boot
PPTX
Spring jdbc
PDF
Spring framework Introduction
PPT
Spring ppt
PPTX
Introduction to Node.js
PDF
Arrays in Java
PPTX
Java 8 streams
PDF
Angular routing
PDF
PUC SE Day 2019 - SpringBoot
PDF
Nodejs presentation
ODP
Routing & Navigating Pages in Angular 2
PDF
Model View Controller (MVC)
Spring Core
Optional in Java 8
Spring Boot
Spring boot
Java Persistence API (JPA) Step By Step
Spring Boot
Spring boot Introduction
Introduction to Spring webflux
Xke spring boot
Spring jdbc
Spring framework Introduction
Spring ppt
Introduction to Node.js
Arrays in Java
Java 8 streams
Angular routing
PUC SE Day 2019 - SpringBoot
Nodejs presentation
Routing & Navigating Pages in Angular 2
Model View Controller (MVC)
Ad

Viewers also liked (20)

PPTX
Introduction to Aspect Oriented Programming
PPT
Aspect Oriented Programming
PDF
PPTX
Introduction to Aspect Oriented Programming
PPTX
Produce Cleaner Code with Aspect-Oriented Programming
PDF
Aspect oriented programming_with_spring
PPTX
AspectJ Android with Example
PDF
Aspect Oriented Programming and Design
PPT
Aspect Oriented Software Development
ODP
Aspect Oriented Programming (AOP) - A case study in Android
PDF
Spring AOP
PPT
IOC and AOP presentation
PDF
CoffeeScript
PPSX
Spring AOP
PDF
マルチテナントメッセージング基盤を刷新して一年運用した話
PDF
Aspect Oriented Software Development
PPT
Introduction to Aspect Oriented Software Development
PDF
Apache Solr lessons learned
PPTX
Aspect Oriented Programming
PPTX
Spring AOP Introduction
Introduction to Aspect Oriented Programming
Aspect Oriented Programming
Introduction to Aspect Oriented Programming
Produce Cleaner Code with Aspect-Oriented Programming
Aspect oriented programming_with_spring
AspectJ Android with Example
Aspect Oriented Programming and Design
Aspect Oriented Software Development
Aspect Oriented Programming (AOP) - A case study in Android
Spring AOP
IOC and AOP presentation
CoffeeScript
Spring AOP
マルチテナントメッセージング基盤を刷新して一年運用した話
Aspect Oriented Software Development
Introduction to Aspect Oriented Software Development
Apache Solr lessons learned
Aspect Oriented Programming
Spring AOP Introduction
Ad

Similar to Spring AOP (20)

PDF
01.egovFrame Training Book II
PDF
Upgrading to System Verilog for FPGA Designs, Srinivasan Venkataramanan, CVC
PPTX
Aspect Oriented Programing - Introduction
PDF
Upgrading to SystemVerilog for FPGA Designs - FPGA Camp Bangalore, 2010
PDF
A comprehensive formal verification solution for ARM based SOC design
PPTX
Dependency injection
PPTX
Spring basics for freshers
PDF
Introducing spring
PPT
Aspect oriented programming in .Net
PPTX
"Jabeklah" Cloud Based Back-End Design and Implementation
PDF
Advice weaving in AspectJ
PPTX
Advanced Silverlight
KEY
Polyglot OSGi
PPT
jVoiD - the enterprise ecommerce Java by Schogini
PPTX
JVM: A Platform for Multiple Languages
PDF
Service-Oriented Modeling Language
PDF
Aspect Orientated Programming in Ruby
PDF
Modular Java EE in the Cloud
PDF
OW2 Petals Dragon SOA Linuxtag09
PPTX
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)
01.egovFrame Training Book II
Upgrading to System Verilog for FPGA Designs, Srinivasan Venkataramanan, CVC
Aspect Oriented Programing - Introduction
Upgrading to SystemVerilog for FPGA Designs - FPGA Camp Bangalore, 2010
A comprehensive formal verification solution for ARM based SOC design
Dependency injection
Spring basics for freshers
Introducing spring
Aspect oriented programming in .Net
"Jabeklah" Cloud Based Back-End Design and Implementation
Advice weaving in AspectJ
Advanced Silverlight
Polyglot OSGi
jVoiD - the enterprise ecommerce Java by Schogini
JVM: A Platform for Multiple Languages
Service-Oriented Modeling Language
Aspect Orientated Programming in Ruby
Modular Java EE in the Cloud
OW2 Petals Dragon SOA Linuxtag09
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)

More from Jeroen Rosenberg (6)

PDF
Cooking your Ravioli "al dente" with Hexagonal Architecture
PDF
Websocket on Rails
PDF
Provisioning with Vagrant & Puppet
PDF
Dynamic System Configuration using SOA
PDF
Dynamic Lighting with OpenGL
PPSX
Git the fast version control system
Cooking your Ravioli "al dente" with Hexagonal Architecture
Websocket on Rails
Provisioning with Vagrant & Puppet
Dynamic System Configuration using SOA
Dynamic Lighting with OpenGL
Git the fast version control system

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Cloud computing and distributed systems.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
A Presentation on Artificial Intelligence
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Modernizing your data center with Dell and AMD
PDF
cuic standard and advanced reporting.pdf
Teaching material agriculture food technology
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Cloud computing and distributed systems.
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
MYSQL Presentation for SQL database connectivity
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
Machine learning based COVID-19 study performance prediction
Dropbox Q2 2025 Financial Results & Investor Presentation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
A Presentation on Artificial Intelligence
Building Integrated photovoltaic BIPV_UPV.pdf
Unlocking AI with Model Context Protocol (MCP)
Review of recent advances in non-invasive hemoglobin estimation
Modernizing your data center with Dell and AMD
cuic standard and advanced reporting.pdf

Spring AOP

Editor's Notes

  • #33: 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)?