SlideShare une entreprise Scribd logo
1  sur  50
Spring AOP
Presented By
SHAKIL AKHTAR
Agenda
v What problem does AOP solve?
v Core AOP concepts.
v Quick Start.
v Defining Pointcuts.
v Implementing Advice.
© Shakil Akhtar
What are Cross-cutting Concerns?
v Generic functionality that’s needed in places in
application.
v Examples
•  Logging
•  Transaction Management
•  Security
•  Caching
•  Error Handling
•  Performance Monitoring
•  Custom Business Rules
© Shakil Akhtar
An Example Requirement
v Perform a role based security check before
every application method.
A cross cutting
concern requirement
© Shakil Akhtar
Implementing Cross-Cutting Concerns
Without Modularization
v Failing to Modularize cross-cutting concerns leads to
two things
•  Code Tangling
o  A couple of concerns
•  Code scattering
o  The same concern spread across modules
© Shakil Akhtar
Symptom #1: Tangling
v Write tangling code
© Shakil Akhtar
Symptom #2: Scattering
v Write scattering code
© Shakil Akhtar
System Evolution Without Modularization
© Shakil Akhtar
How AOP Works
v Implement your mainline application logic
•  Focusing on the core problem
v Write aspects to implement your cross-cutting
concerns
•  Spring provides many aspects
v Weave the aspects into your application
•  Adding the cross cutting concern behavior’s to the right
place
© Shakil Akhtar
Aspect Oriented Programming (AOP )
v Aspect Oriented Programming(AOP) enables
modularization of cross-cutting concerns
•  To avoid tangling
•  To avoid Scattering
© Shakil Akhtar
Aspect Oriented Programming (AOP )
© Shakil Akhtar
Object A
Object C
Object B
method
method method
method
method
method
method
…
© Shakil Akhtar
Object A Object Bmet
hod
met
hod
advice
Object Oriented Programming
Target obj=obj B
Pointcut=method B
Aspect
Join point method =
invocation
AOP
Leading AOP Technologies
v AspectJ
•  Original AOP technology (first version in 1995)
•  Offers a full blown Aspect Oriented Programming
language
•  Uses byte code modification for aspect weaving
v Spring AOP
•  Java based AOP framework with AspectJ integration
•  Uses dynamic proxies for aspect weaving
•  Focuses on using AOP to solve enterprise problems
•  The Focus of this session
© Shakil Akhtar
Core AOP Concepts
v Join Point
•  A point in the execution point such as a method call or
field assignment or handling of an exception
v Pointcut
•  An expression that selects one or more join points
v Advice
•  Code to be executed at join point that has been selected
by a pointcut
v Aspect
•  A module that encapsulates pointcuts and advice
© Shakil Akhtar
Aspect
v  A modularization of a concern that cuts across
multiple classes
v Example Transaction management
v Two flavor
•  Code XML based
•  AspectJ Annotation style
© Shakil Akhtar
JoinPoint
v  A point during the execution of a program, such as
the execution of a method or the handling of an
exception
v This represents a point in your application where you can
plug-in AOP aspect
v A place in the application where an action will be taken
using Spring AOP framework
© Shakil Akhtar
Advice
v  Action taken by an aspect at a particular join point
v Example Transaction management
v This is actual piece of code that is invoked during
program execution
v Types of advice
•  Around
•  Before
•  After returning
•  After throwing
•  After (finally)
© Shakil Akhtar
Pointcut
v  A predicate that matches join points.Advice is
associated with a pointcut expression and runs at any
join point matched by the pointcut (for example, the
execution of a method with a certain name).
v A set of one or more joinpoints where an advice
should be executed
v Spring uses the AspectJ pointcut expression language
by default
© Shakil Akhtar
Introduction or inner-type
v  Declaring additional methods or fields on behalf of a
type
v Allows you to add new methods or attributes to
existing classes
v Example, you could use an introduction to make a
bean implement an IsModified interface, to simplify
caching
© Shakil Akhtar
Target Object
v  An object being advised by one or more aspects.
v This object will always be a proxied object
v Also referred as the advised object
© Shakil Akhtar
AOP Proxy
v  An object created by the AOP framework in order to
implement the aspect contracts (advise method
executions and so on).
v In Spring ,an AOP proxy will be a JDK dynamic proxy
or a CGLIB proxy
© Shakil Akhtar
Weaving
v  Linking aspects with other application types or
objects to create an advised object.
v This can be done at compile time (using the AspectJ
compiler, for example), load time, or at runtime
v Spring AOP, like other pure Java AOP frameworks,
performs weaving at runtime
© Shakil Akhtar
Considerations
v  Field interception is not implemented, although
support for field interception could be added using
AspectJ.The same for protected/private methods and
constructors.
© Shakil Akhtar
AOP Types
v Static AOP
•  In static AOP weaving process finds another step in the
build process for an application
•  AOP is achieved by modifying byte code
•  well –performing way of achieving the weaving process,
because the end result is just java byte code.
•  Recompilation requires for very join point addition
v Dynamic AOP
•  Dynamic AOP (spring AOP)
•  Weaving process is performed dynamically at runtime
•  Less performance than static AOP
© Shakil Akhtar
AOP Quick Start
v Consider the basic requirement
•  Log a message every time a property is going to change
v How can you use AOP to meet this?
© Shakil Akhtar
An Application Object whose
properties could change
public class SimpleCache implements Cache{
int cacheSize;
public void setCacheSize(int cacheSize) {
this.cacheSize = cacheSize;
}
...
}
© Shakil Akhtar
Implement the Aspect
@Aspect
public class PropertyChangeTracker {
private static final Log logger =
LogFactory.getLog(PropertyChangeTracker.class);
@Before("execution(void set*(*))")
public void trackChange(){
logger.info("property about to change");
}
}
© Shakil Akhtar
Best Practice Use Named Pointcuts
@Aspect
public class PropertyChangeTracker {
private static final Log logger =
LogFactory.getLog( PropertyChangeTracker.class);
@Before("setterMethod()")
public void trackChange(){
logger.info("property about to change");
}
@Pointcut("execution(void set*(*))")
public void setterMethod(){
}
}
© Shakil Akhtar
Configure the Aspect as a bean
<beans>
<aop:aspectj-autoproxy>
<aop:include name="propertyChangeTracker"/>
</aop:aspectj-autoproxy>
<bean id="propertyChangeTracker"
class="com.tr.spring.aop.PropertyChangeTracker" />
</beans>
Configures spring to apply the
@Aspect to your bean
aspect-config.xml
© Shakil Akhtar
Include the Aspect Configuration
<beans>
<import resource="aspect-config.xml"/>
<bean name="cache-A" class="com.tr.spring.aop.SimpleCache"/>
<bean name="cache-B" class="com.tr.spring.aop.SimpleCache"/>
<bean name="cache-C" class="com.tr.spring.aop.SimpleCache"/>
</beans>
application-config.xml
© Shakil Akhtar
Test the application
ApplicationContext appCtx = new
ClassPathXmlApplicationContext(APP_CTX_FILE_NAME);
Cache cache = (Cache) appCtx.getBean("cache-A");
cache.setCacheSize(2500);
INFO: property about to change
© Shakil Akhtar
How Aspects are applied
© Shakil Akhtar
How Aspects are applied
© Shakil Akhtar
Tracking property changes with Context
@Aspect
public class PropertyChangeTracker {
private static final Log logger =
LogFactory.getLog(PropertyChangeTracker.class);
@Before("setterMethod()")
public void trackChange( JoinPoint point){
String name = point.getSignature().getName();
Object newValue= point.getArgs()[0];
logger.info(name +"property about to change to " +newValue
+" on object" +point.getTarget());
}
@Pointcut("execution(void set*(*))")
public void setterMethod(){
}
}
Context about the
intercepted point
INFO: setCacheSizeproperty about to change to 2500 on object…
© Shakil Akhtar
Useful JoinPoint Context
v this
•  The currently executing object that has been
intercepted(a proxy in spring AOP)
v target
•  The target of the execution(typically your object)
v args
•  The method arguments passed to the join point
v signature
•  The method signature of the join point
© Shakil Akhtar
Defining Pointcuts
v With spring AOP you write pointcuts using AspectJ’s
pointcut expression language
•  For selecting where to apply advice
v Complete expression language reference available at
•  http://www.eclipse.org/aspectj
© Shakil Akhtar
Execution Expression Example
v execution(void send*(String))
•  Any method starting with send and takes a single string
parameter and has a void return type
v execution(* send(int,..))
•  Any method named send whose first parameter is an
int(the “..” signifies 0 or more parameters may follow
v execution(void example.MessageService+.send(*))
•  Any MessageService method named send that takes a
single parameter and returns void
© Shakil Akhtar
Execution Expression Example using
Annotations
v execution(@org.springframework.transaction.annotat
ion.Transactional void*(..))
•  Any method marked with the @Transactional annotation
v execution((@privacy.Sensitive*)*(..))
•  Any method that returns a value marked with the
@Sensitive annotation
© Shakil Akhtar
Pointcut Expression Example
v @Pointcut("execution(public * *(..))")
§  It will be applied on all the public methods.
v @Pointcut("execution(public Operation.*(..))")
§  It will be applied on all the public methods of Operation class
v @Pointcut("execution(* Operation.*(..))")
§  It will be applied on all the methods of Operation class
© Shakil Akhtar
Pointcut Expression Example
v @Pointcut("execution(public * *(..))")
§  It will be applied on all the public methods.
v @Pointcut("execution(public Operation.*(..))")
§  It will be applied on all the public methods of Operation class
© Shakil Akhtar
Advice Type: Before
© Shakil Akhtar
Advice Type: After Returning
© Shakil Akhtar
Advice Type: After Throwing
© Shakil Akhtar
Advice Type: After
© Shakil Akhtar
Advice Type: Around
© Shakil Akhtar
Advice Best Practices
v Use the simplest possible advice
•  Do not use @Around unless you must
© Shakil Akhtar
Alternative Spring AOP Syntax-XML
v Annotation syntax is java 5+ only
v XML syntax works on java 1.4
v Approach
•  Aspect logic defined java
•  Aspect configuration in XML
•  Easy to learn once annotation syntax is understood
© Shakil Akhtar
More Information
v Documentation
http://www.springsource.org
v Forum
http://forum.springsource.org/
v Spring Source Consulting
http://www.springsource.com/support/professional-
services
© Shakil Akhtar
© Shakil Akhtar
© Shakil Akhtar
shakilsoz17ster@gmail.com

Contenu connexe

Tendances

Aspect-Oriented Programming
Aspect-Oriented ProgrammingAspect-Oriented Programming
Aspect-Oriented ProgrammingAndrey Bratukhin
 
DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)Hendrik Ebbers
 
Introduction to aop
Introduction to aopIntroduction to aop
Introduction to aopDror Helper
 
Ad-hoc Runtime Object Structure Visualizations with MetaLinks
Ad-hoc Runtime Object Structure Visualizations with MetaLinks Ad-hoc Runtime Object Structure Visualizations with MetaLinks
Ad-hoc Runtime Object Structure Visualizations with MetaLinks ESUG
 
Pharo Optimising JIT Internals
Pharo Optimising JIT InternalsPharo Optimising JIT Internals
Pharo Optimising JIT InternalsESUG
 
Apex Testing and Best Practices
Apex Testing and Best PracticesApex Testing and Best Practices
Apex Testing and Best PracticesJitendra Zaa
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatAEM HUB
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8javafxpert
 
JavaFX8 TestFX - CDI
JavaFX8   TestFX - CDIJavaFX8   TestFX - CDI
JavaFX8 TestFX - CDISven Ruppert
 
Dependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functionalDependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functionalMarian Wamsiedel
 
Android MvRx Framework 介紹
Android MvRx Framework 介紹Android MvRx Framework 介紹
Android MvRx Framework 介紹Kros Huang
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemAndres Almiray
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSKnoldus Inc.
 
AEM and Sling
AEM and SlingAEM and Sling
AEM and SlingLo Ki
 
Design functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleDesign functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleMarian Wamsiedel
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Adam Peller Interoperable Ajax Tools And Mashups
Adam Peller Interoperable Ajax Tools And MashupsAdam Peller Interoperable Ajax Tools And Mashups
Adam Peller Interoperable Ajax Tools And MashupsAjax Experience 2009
 
Benefits of OSGi in Practise
Benefits of OSGi in PractiseBenefits of OSGi in Practise
Benefits of OSGi in PractiseDavid Bosschaert
 
Mastering the Sling Rewriter
Mastering the Sling RewriterMastering the Sling Rewriter
Mastering the Sling RewriterJustin Edelson
 
Zend Studio Tips and Tricks
Zend Studio Tips and TricksZend Studio Tips and Tricks
Zend Studio Tips and TricksRoy Ganor
 

Tendances (20)

Aspect-Oriented Programming
Aspect-Oriented ProgrammingAspect-Oriented Programming
Aspect-Oriented Programming
 
DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)
 
Introduction to aop
Introduction to aopIntroduction to aop
Introduction to aop
 
Ad-hoc Runtime Object Structure Visualizations with MetaLinks
Ad-hoc Runtime Object Structure Visualizations with MetaLinks Ad-hoc Runtime Object Structure Visualizations with MetaLinks
Ad-hoc Runtime Object Structure Visualizations with MetaLinks
 
Pharo Optimising JIT Internals
Pharo Optimising JIT InternalsPharo Optimising JIT Internals
Pharo Optimising JIT Internals
 
Apex Testing and Best Practices
Apex Testing and Best PracticesApex Testing and Best Practices
Apex Testing and Best Practices
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak Khetawat
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8
 
JavaFX8 TestFX - CDI
JavaFX8   TestFX - CDIJavaFX8   TestFX - CDI
JavaFX8 TestFX - CDI
 
Dependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functionalDependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functional
 
Android MvRx Framework 介紹
Android MvRx Framework 介紹Android MvRx Framework 介紹
Android MvRx Framework 介紹
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
 
AEM and Sling
AEM and SlingAEM and Sling
AEM and Sling
 
Design functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleDesign functional solutions in Java, a practical example
Design functional solutions in Java, a practical example
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Adam Peller Interoperable Ajax Tools And Mashups
Adam Peller Interoperable Ajax Tools And MashupsAdam Peller Interoperable Ajax Tools And Mashups
Adam Peller Interoperable Ajax Tools And Mashups
 
Benefits of OSGi in Practise
Benefits of OSGi in PractiseBenefits of OSGi in Practise
Benefits of OSGi in Practise
 
Mastering the Sling Rewriter
Mastering the Sling RewriterMastering the Sling Rewriter
Mastering the Sling Rewriter
 
Zend Studio Tips and Tricks
Zend Studio Tips and TricksZend Studio Tips and Tricks
Zend Studio Tips and Tricks
 

En vedette

Introduction to Aspect Oriented Programming
Introduction to Aspect Oriented ProgrammingIntroduction to Aspect Oriented Programming
Introduction to Aspect Oriented ProgrammingYan Cui
 
Produce Cleaner Code with Aspect-Oriented Programming
Produce Cleaner Code with Aspect-Oriented ProgrammingProduce Cleaner Code with Aspect-Oriented Programming
Produce Cleaner Code with Aspect-Oriented ProgrammingPostSharp Technologies
 
Apache Solr lessons learned
Apache Solr lessons learnedApache Solr lessons learned
Apache Solr lessons learnedJeroen Rosenberg
 
Aspect-Oriented Programming for PHP
Aspect-Oriented Programming for PHPAspect-Oriented Programming for PHP
Aspect-Oriented Programming for PHPWilliam Candillon
 
Aspect Oriented Software Development
Aspect Oriented Software DevelopmentAspect Oriented Software Development
Aspect Oriented Software DevelopmentJignesh Patel
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented ProgrammingAnumod Kumar
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOPDzmitry Naskou
 
Algebra 2 powerpoint
Algebra 2 powerpointAlgebra 2 powerpoint
Algebra 2 powerpointroohal51
 
Hospice letter
Hospice letterHospice letter
Hospice letternm118486
 
Know Your Supplier - Rubber & Tyre Machinery World May 2016 Special
Know Your Supplier - Rubber & Tyre Machinery World May 2016 SpecialKnow Your Supplier - Rubber & Tyre Machinery World May 2016 Special
Know Your Supplier - Rubber & Tyre Machinery World May 2016 SpecialRubber & Tyre Machinery World
 
How to unlock alcatel one touch fierce 7024w by unlock code
How to unlock alcatel one touch fierce 7024w by unlock codeHow to unlock alcatel one touch fierce 7024w by unlock code
How to unlock alcatel one touch fierce 7024w by unlock coderscooldesire
 
新希望.
新希望.新希望.
新希望.sft
 
I AM HR: FIVE STRATEGIC WAYS TO BREAK STEREOTYPES AND RECLAIM HR
I AM HR: FIVE STRATEGIC WAYS TO BREAK STEREOTYPES AND RECLAIM HRI AM HR: FIVE STRATEGIC WAYS TO BREAK STEREOTYPES AND RECLAIM HR
I AM HR: FIVE STRATEGIC WAYS TO BREAK STEREOTYPES AND RECLAIM HRLaurie Ruettimann
 
Swedish Match Tobacco Export Portfolio
Swedish Match Tobacco Export PortfolioSwedish Match Tobacco Export Portfolio
Swedish Match Tobacco Export PortfolioEmiliano Rocha
 
IBM Big Data References
IBM Big Data ReferencesIBM Big Data References
IBM Big Data ReferencesRob Thomas
 
Rapport Doing Business 2015
Rapport Doing Business 2015Rapport Doing Business 2015
Rapport Doing Business 2015Franck Dasilva
 

En vedette (20)

Spring AOP
Spring AOPSpring AOP
Spring AOP
 
Introduction to Aspect Oriented Programming
Introduction to Aspect Oriented ProgrammingIntroduction to Aspect Oriented Programming
Introduction to Aspect Oriented Programming
 
Produce Cleaner Code with Aspect-Oriented Programming
Produce Cleaner Code with Aspect-Oriented ProgrammingProduce Cleaner Code with Aspect-Oriented Programming
Produce Cleaner Code with Aspect-Oriented Programming
 
Apache Solr lessons learned
Apache Solr lessons learnedApache Solr lessons learned
Apache Solr lessons learned
 
Aspect-Oriented Programming for PHP
Aspect-Oriented Programming for PHPAspect-Oriented Programming for PHP
Aspect-Oriented Programming for PHP
 
Aspect Oriented Software Development
Aspect Oriented Software DevelopmentAspect Oriented Software Development
Aspect Oriented Software Development
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Algebra 2 powerpoint
Algebra 2 powerpointAlgebra 2 powerpoint
Algebra 2 powerpoint
 
Hospice letter
Hospice letterHospice letter
Hospice letter
 
1200 j lipman
1200 j lipman1200 j lipman
1200 j lipman
 
Know Your Supplier - Rubber & Tyre Machinery World May 2016 Special
Know Your Supplier - Rubber & Tyre Machinery World May 2016 SpecialKnow Your Supplier - Rubber & Tyre Machinery World May 2016 Special
Know Your Supplier - Rubber & Tyre Machinery World May 2016 Special
 
Planejamento pms
Planejamento pmsPlanejamento pms
Planejamento pms
 
How to unlock alcatel one touch fierce 7024w by unlock code
How to unlock alcatel one touch fierce 7024w by unlock codeHow to unlock alcatel one touch fierce 7024w by unlock code
How to unlock alcatel one touch fierce 7024w by unlock code
 
新希望.
新希望.新希望.
新希望.
 
I AM HR: FIVE STRATEGIC WAYS TO BREAK STEREOTYPES AND RECLAIM HR
I AM HR: FIVE STRATEGIC WAYS TO BREAK STEREOTYPES AND RECLAIM HRI AM HR: FIVE STRATEGIC WAYS TO BREAK STEREOTYPES AND RECLAIM HR
I AM HR: FIVE STRATEGIC WAYS TO BREAK STEREOTYPES AND RECLAIM HR
 
Swedish Match Tobacco Export Portfolio
Swedish Match Tobacco Export PortfolioSwedish Match Tobacco Export Portfolio
Swedish Match Tobacco Export Portfolio
 
IBM Big Data References
IBM Big Data ReferencesIBM Big Data References
IBM Big Data References
 
Rapport Doing Business 2015
Rapport Doing Business 2015Rapport Doing Business 2015
Rapport Doing Business 2015
 
Auraplus ciuziniai
Auraplus ciuziniaiAuraplus ciuziniai
Auraplus ciuziniai
 

Similaire à Spring AOP Quick Start Guide

Scorex, the Modular Blockchain Framework
Scorex, the Modular Blockchain FrameworkScorex, the Modular Blockchain Framework
Scorex, the Modular Blockchain FrameworkAlex Chepurnoy
 
Spring - Part 3 - AOP
Spring - Part 3 - AOPSpring - Part 3 - AOP
Spring - Part 3 - AOPHitesh-Java
 
Session 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOPSession 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOPPawanMM
 
SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011David O'Dowd
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to SpringSujit Kumar
 
Integration made easy with Apache Camel
Integration made easy with Apache CamelIntegration made easy with Apache Camel
Integration made easy with Apache CamelRosen Spasov
 
Spring 1 day program
Spring 1 day programSpring 1 day program
Spring 1 day programMohit Kanwar
 
Interactive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureInteractive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureJavaDayUA
 
How to generate code coverage reports in xcode with slather
How to generate code coverage reports in xcode with slatherHow to generate code coverage reports in xcode with slather
How to generate code coverage reports in xcode with slatherallanh0526
 
SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4Jon Galloway
 
Eclipse 40 - Eclipse Summit Europe 2010
Eclipse 40 - Eclipse Summit Europe 2010Eclipse 40 - Eclipse Summit Europe 2010
Eclipse 40 - Eclipse Summit Europe 2010Lars Vogel
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Loiane Groner
 
Guidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha ProjectsGuidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha ProjectsAmitaSuri
 
Azure serverless architectures
Azure serverless architecturesAzure serverless architectures
Azure serverless architecturesBenoit Le Pichon
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework Yakov Fain
 
Introduction to Aspect Oriented Programming
Introduction to Aspect Oriented ProgrammingIntroduction to Aspect Oriented Programming
Introduction to Aspect Oriented ProgrammingAmir Kost
 

Similaire à Spring AOP Quick Start Guide (20)

Scorex, the Modular Blockchain Framework
Scorex, the Modular Blockchain FrameworkScorex, the Modular Blockchain Framework
Scorex, the Modular Blockchain Framework
 
Spring - Part 3 - AOP
Spring - Part 3 - AOPSpring - Part 3 - AOP
Spring - Part 3 - AOP
 
Session 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOPSession 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOP
 
SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to Spring
 
Integration made easy with Apache Camel
Integration made easy with Apache CamelIntegration made easy with Apache Camel
Integration made easy with Apache Camel
 
Spring 1 day program
Spring 1 day programSpring 1 day program
Spring 1 day program
 
Interactive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureInteractive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and Architecture
 
Spring aop
Spring aopSpring aop
Spring aop
 
How to generate code coverage reports in xcode with slather
How to generate code coverage reports in xcode with slatherHow to generate code coverage reports in xcode with slather
How to generate code coverage reports in xcode with slather
 
SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4
 
Eclipse 40 - Eclipse Summit Europe 2010
Eclipse 40 - Eclipse Summit Europe 2010Eclipse 40 - Eclipse Summit Europe 2010
Eclipse 40 - Eclipse Summit Europe 2010
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
 
SpringBoot
SpringBootSpringBoot
SpringBoot
 
Guidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha ProjectsGuidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha Projects
 
Azure serverless architectures
Azure serverless architecturesAzure serverless architectures
Azure serverless architectures
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Introduction to Aspect Oriented Programming
Introduction to Aspect Oriented ProgrammingIntroduction to Aspect Oriented Programming
Introduction to Aspect Oriented Programming
 
ASP.NET MVC 3
ASP.NET MVC 3ASP.NET MVC 3
ASP.NET MVC 3
 

Dernier

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Dernier (20)

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Spring AOP Quick Start Guide

  • 2. Agenda v What problem does AOP solve? v Core AOP concepts. v Quick Start. v Defining Pointcuts. v Implementing Advice. © Shakil Akhtar
  • 3. What are Cross-cutting Concerns? v Generic functionality that’s needed in places in application. v Examples •  Logging •  Transaction Management •  Security •  Caching •  Error Handling •  Performance Monitoring •  Custom Business Rules © Shakil Akhtar
  • 4. An Example Requirement v Perform a role based security check before every application method. A cross cutting concern requirement © Shakil Akhtar
  • 5. Implementing Cross-Cutting Concerns Without Modularization v Failing to Modularize cross-cutting concerns leads to two things •  Code Tangling o  A couple of concerns •  Code scattering o  The same concern spread across modules © Shakil Akhtar
  • 6. Symptom #1: Tangling v Write tangling code © Shakil Akhtar
  • 7. Symptom #2: Scattering v Write scattering code © Shakil Akhtar
  • 8. System Evolution Without Modularization © Shakil Akhtar
  • 9. How AOP Works v Implement your mainline application logic •  Focusing on the core problem v Write aspects to implement your cross-cutting concerns •  Spring provides many aspects v Weave the aspects into your application •  Adding the cross cutting concern behavior’s to the right place © Shakil Akhtar
  • 10. Aspect Oriented Programming (AOP ) v Aspect Oriented Programming(AOP) enables modularization of cross-cutting concerns •  To avoid tangling •  To avoid Scattering © Shakil Akhtar
  • 11. Aspect Oriented Programming (AOP ) © Shakil Akhtar Object A Object C Object B method method method method method method method
  • 12. … © Shakil Akhtar Object A Object Bmet hod met hod advice Object Oriented Programming Target obj=obj B Pointcut=method B Aspect Join point method = invocation AOP
  • 13. Leading AOP Technologies v AspectJ •  Original AOP technology (first version in 1995) •  Offers a full blown Aspect Oriented Programming language •  Uses byte code modification for aspect weaving v Spring AOP •  Java based AOP framework with AspectJ integration •  Uses dynamic proxies for aspect weaving •  Focuses on using AOP to solve enterprise problems •  The Focus of this session © Shakil Akhtar
  • 14. Core AOP Concepts v Join Point •  A point in the execution point such as a method call or field assignment or handling of an exception v Pointcut •  An expression that selects one or more join points v Advice •  Code to be executed at join point that has been selected by a pointcut v Aspect •  A module that encapsulates pointcuts and advice © Shakil Akhtar
  • 15. Aspect v  A modularization of a concern that cuts across multiple classes v Example Transaction management v Two flavor •  Code XML based •  AspectJ Annotation style © Shakil Akhtar
  • 16. JoinPoint v  A point during the execution of a program, such as the execution of a method or the handling of an exception v This represents a point in your application where you can plug-in AOP aspect v A place in the application where an action will be taken using Spring AOP framework © Shakil Akhtar
  • 17. Advice v  Action taken by an aspect at a particular join point v Example Transaction management v This is actual piece of code that is invoked during program execution v Types of advice •  Around •  Before •  After returning •  After throwing •  After (finally) © Shakil Akhtar
  • 18. Pointcut v  A predicate that matches join points.Advice is associated with a pointcut expression and runs at any join point matched by the pointcut (for example, the execution of a method with a certain name). v A set of one or more joinpoints where an advice should be executed v Spring uses the AspectJ pointcut expression language by default © Shakil Akhtar
  • 19. Introduction or inner-type v  Declaring additional methods or fields on behalf of a type v Allows you to add new methods or attributes to existing classes v Example, you could use an introduction to make a bean implement an IsModified interface, to simplify caching © Shakil Akhtar
  • 20. Target Object v  An object being advised by one or more aspects. v This object will always be a proxied object v Also referred as the advised object © Shakil Akhtar
  • 21. AOP Proxy v  An object created by the AOP framework in order to implement the aspect contracts (advise method executions and so on). v In Spring ,an AOP proxy will be a JDK dynamic proxy or a CGLIB proxy © Shakil Akhtar
  • 22. Weaving v  Linking aspects with other application types or objects to create an advised object. v This can be done at compile time (using the AspectJ compiler, for example), load time, or at runtime v Spring AOP, like other pure Java AOP frameworks, performs weaving at runtime © Shakil Akhtar
  • 23. Considerations v  Field interception is not implemented, although support for field interception could be added using AspectJ.The same for protected/private methods and constructors. © Shakil Akhtar
  • 24. AOP Types v Static AOP •  In static AOP weaving process finds another step in the build process for an application •  AOP is achieved by modifying byte code •  well –performing way of achieving the weaving process, because the end result is just java byte code. •  Recompilation requires for very join point addition v Dynamic AOP •  Dynamic AOP (spring AOP) •  Weaving process is performed dynamically at runtime •  Less performance than static AOP © Shakil Akhtar
  • 25. AOP Quick Start v Consider the basic requirement •  Log a message every time a property is going to change v How can you use AOP to meet this? © Shakil Akhtar
  • 26. An Application Object whose properties could change public class SimpleCache implements Cache{ int cacheSize; public void setCacheSize(int cacheSize) { this.cacheSize = cacheSize; } ... } © Shakil Akhtar
  • 27. Implement the Aspect @Aspect public class PropertyChangeTracker { private static final Log logger = LogFactory.getLog(PropertyChangeTracker.class); @Before("execution(void set*(*))") public void trackChange(){ logger.info("property about to change"); } } © Shakil Akhtar
  • 28. Best Practice Use Named Pointcuts @Aspect public class PropertyChangeTracker { private static final Log logger = LogFactory.getLog( PropertyChangeTracker.class); @Before("setterMethod()") public void trackChange(){ logger.info("property about to change"); } @Pointcut("execution(void set*(*))") public void setterMethod(){ } } © Shakil Akhtar
  • 29. Configure the Aspect as a bean <beans> <aop:aspectj-autoproxy> <aop:include name="propertyChangeTracker"/> </aop:aspectj-autoproxy> <bean id="propertyChangeTracker" class="com.tr.spring.aop.PropertyChangeTracker" /> </beans> Configures spring to apply the @Aspect to your bean aspect-config.xml © Shakil Akhtar
  • 30. Include the Aspect Configuration <beans> <import resource="aspect-config.xml"/> <bean name="cache-A" class="com.tr.spring.aop.SimpleCache"/> <bean name="cache-B" class="com.tr.spring.aop.SimpleCache"/> <bean name="cache-C" class="com.tr.spring.aop.SimpleCache"/> </beans> application-config.xml © Shakil Akhtar
  • 31. Test the application ApplicationContext appCtx = new ClassPathXmlApplicationContext(APP_CTX_FILE_NAME); Cache cache = (Cache) appCtx.getBean("cache-A"); cache.setCacheSize(2500); INFO: property about to change © Shakil Akhtar
  • 32. How Aspects are applied © Shakil Akhtar
  • 33. How Aspects are applied © Shakil Akhtar
  • 34. Tracking property changes with Context @Aspect public class PropertyChangeTracker { private static final Log logger = LogFactory.getLog(PropertyChangeTracker.class); @Before("setterMethod()") public void trackChange( JoinPoint point){ String name = point.getSignature().getName(); Object newValue= point.getArgs()[0]; logger.info(name +"property about to change to " +newValue +" on object" +point.getTarget()); } @Pointcut("execution(void set*(*))") public void setterMethod(){ } } Context about the intercepted point INFO: setCacheSizeproperty about to change to 2500 on object… © Shakil Akhtar
  • 35. Useful JoinPoint Context v this •  The currently executing object that has been intercepted(a proxy in spring AOP) v target •  The target of the execution(typically your object) v args •  The method arguments passed to the join point v signature •  The method signature of the join point © Shakil Akhtar
  • 36. Defining Pointcuts v With spring AOP you write pointcuts using AspectJ’s pointcut expression language •  For selecting where to apply advice v Complete expression language reference available at •  http://www.eclipse.org/aspectj © Shakil Akhtar
  • 37. Execution Expression Example v execution(void send*(String)) •  Any method starting with send and takes a single string parameter and has a void return type v execution(* send(int,..)) •  Any method named send whose first parameter is an int(the “..” signifies 0 or more parameters may follow v execution(void example.MessageService+.send(*)) •  Any MessageService method named send that takes a single parameter and returns void © Shakil Akhtar
  • 38. Execution Expression Example using Annotations v execution(@org.springframework.transaction.annotat ion.Transactional void*(..)) •  Any method marked with the @Transactional annotation v execution((@privacy.Sensitive*)*(..)) •  Any method that returns a value marked with the @Sensitive annotation © Shakil Akhtar
  • 39. Pointcut Expression Example v @Pointcut("execution(public * *(..))") §  It will be applied on all the public methods. v @Pointcut("execution(public Operation.*(..))") §  It will be applied on all the public methods of Operation class v @Pointcut("execution(* Operation.*(..))") §  It will be applied on all the methods of Operation class © Shakil Akhtar
  • 40. Pointcut Expression Example v @Pointcut("execution(public * *(..))") §  It will be applied on all the public methods. v @Pointcut("execution(public Operation.*(..))") §  It will be applied on all the public methods of Operation class © Shakil Akhtar
  • 41. Advice Type: Before © Shakil Akhtar
  • 42. Advice Type: After Returning © Shakil Akhtar
  • 43. Advice Type: After Throwing © Shakil Akhtar
  • 44. Advice Type: After © Shakil Akhtar
  • 45. Advice Type: Around © Shakil Akhtar
  • 46. Advice Best Practices v Use the simplest possible advice •  Do not use @Around unless you must © Shakil Akhtar
  • 47. Alternative Spring AOP Syntax-XML v Annotation syntax is java 5+ only v XML syntax works on java 1.4 v Approach •  Aspect logic defined java •  Aspect configuration in XML •  Easy to learn once annotation syntax is understood © Shakil Akhtar
  • 48. More Information v Documentation http://www.springsource.org v Forum http://forum.springsource.org/ v Spring Source Consulting http://www.springsource.com/support/professional- services © Shakil Akhtar