6. Measuring Performance
public void convertToFixedDeposit() throws Exception {
//Your Business Logic
Thread.sleep(DEFAULT_SLEEP_INTERVAL);
log.debug("convertToFixedDeposit Complete");
}
7. Measuring Performance
public void convertToFixedDeposit() throws Exception {
StopWatch monitor = new StopWatch();
monitor.start("convertToFixedDeposit");
//Your Business Logic
Thread.sleep(DEFAULT_SLEEP_INTERVAL);
log.debug("convertToFixedDeposit Complete");
monitor.stop();
log.debug(monitor.prettyPrint());
}
8. Challenges
What If it has to be done across 10 classes and 10 methods
•Not DRY Code
•Testing Involved
•Complexity Increases with Number Of Methods
•Code change is permanent
•Invasive
•Time Consuming
16. Within & Bean Expression
within(“< filter>“); //Applies to all the methods of the classes matching filter
within(com.aspects.blog.package.*)
within(com.aspects.blog.package..*)
within(com.aspects.blog.package.DemoClass)
within(DemoClass)
within(DemoInterface+)
within(DemoInterface1+) || within(DemoInterface2+)
bean(*Service)
17. Advice Types
• Before Advice
• After Returning Advice
• After Throwing Advice
• Around Advice
18. Declaring AOP
• AspectJ Annotation Based
– More Flexible, Such as Combined named Pointcuts
– Encapsulation
• Spring XML Based
– Any JDK Version is Good
– Good Choice to configure enterprise services
22. Weaver
Spring AOP
• No Special Compilation
• Supports Only Method
Pointcuts
• Advise execution on Spring
Beans
AspectJ
• Needs AspectJ Compiler
• Support All Pointcuts
• Advice all domain objects