Download presentation
Presentation is loading. Please wait.
Published byMonica Fowler Modified over 8 years ago
2
Is a programming paradigm Extends OOP Enables modularization of cross cutting concerns
3
Dependency Injection Target code depends on the behavior to be applied AOP Applying a common behavior to large number of elements of code. Raise your hand if you want a Pizza ! Monday 9 AM
5
Interception Introduction Inspection Modularization / Encapsulation Open classes – extend classes Reflection – query meta data YES
6
Meta Programming Program as Data Read, generate, modify, analyze or transform other programs (itself) Code modified at run time Can we use it to do AOP? Is it effective? AOP Uses meta programming as a Vehicle. Uses the meta programming concepts Frameworks :- Aquarium AspectR
7
Aspect Advice Pointcut Join Point Weaver
8
Pointcut execution – applied to methods Within – applied to class level Args – applied based on the parameters to methods Advice @Before @AfterThrowing @AfterReturning @After @Around
9
Any public method execution(public * * (..)) any method with a name beginning with “get“ execution(* get*(..)) Any method with a name beginging with “set” and has more than one parameter execution(* set*(*)) Any method defined in the appropriate package execution(* edu.diging.controller.*.*(..))
10
@Aspect public class EmployeeAspectPointcut { @Before("getNamePointcut()") public void transactionAdvice(JointPoint jointPoint){ System.out.println("Executing firstAdvice on ="+joinPoint.toString()); System.out.println("Agruments Passed=" + Arrays.toString(joinPoint.getArgs())); } @Before("getNamePointcut()") public void customAdvice(){ System.out.println("Executing secondAdvice on getName()"); } @Pointcut("execution(public String getName(*))") public void getNamePointcut(){} }
13
A standardized AOP framework has never really taken off in Ruby because the language itself already supports most of the desirable functionality of AOP. David Heinemeier Hansson of Rails fame
18
Aquarium can run on Jruby Ruby Aspects can advise Java Java aspects can advise Ruby
19
Promotes separation of concerns Code reuse and modularization Loose coupling
20
Thank you
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.