Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

AspectJ Android with Example

3,401 views

Published on

AspectJ Android with Example

Published in: Engineering
  • Be the first to comment

AspectJ Android with Example

  1. 1. Introduction to AspectJ Erol KOCAMAN GDG Istanbul 25/10/2014
  2. 2. Peak Games
  3. 3. Peak Games
  4. 4. Agenda ● Why we use AOP ? ● Cross Cutting Concerns ● Aspect Implementations in Java ● AOP with OOP ● AspectJ Compiler ● Demo Project
  5. 5. Why do we use AOP ? GAME 1 Module 1 Module 2 Module 3 GAME 2 Module 4 Android IOS Desktop
  6. 6. Cross Cutting Concerns In App Billing Networking Game Logging Analytics Profiling
  7. 7. After Aspect In App Billing Networking Game Logging Aspect Analytics Aspect Profiling Aspect
  8. 8. AOP / OOP ● OOP is encapsulation of module for better understanding ● You can even do the same thing with OOP by coding more ● AOP is valid for all programming paradigms
  9. 9. Aspect Implementations ● AspectJ ● Spring AOP ● JBossAOP ● JAC ● Colt ● PROSE
  10. 10. AspectJ Compiler Java & Aspect Source Files Java & Aspect Archive Files Java & Aspect Archive Files Java (.jar) & Aspect Archive Files (.jar) (.jar) AspectJ Compiler (ajc) Woven system (.class files) Java & Aspect Source Files Java & Aspect Source Files (.java)
  11. 11. Program Execution Terminology Advice // aspect code if (...) { ... } else { ... } Pointcut Join Points
  12. 12. JoinPoint Types ● Method ● call ● execution execution(* android.mobile.peakgames.net.aspectjandroid.AspectActivity.fetchImage(..)) ● Constructor execution(* android.mobile.peakgames.net.aspectjandroid.AspectActivity.new(..)) ● Field Access ● Exception Handler Execution ● Class Initialization
  13. 13. Call / Execution Aspect Difference ATM Account debit(...) Aspect Call Execution Aspect
  14. 14. AspectJ Annotations @Aspect @Pointcut @Before @After @AfterReturning @AfterThrowing @Around
  15. 15. Code with sample https://github.com/firstthumb/AspectJ-Android-Example
  16. 16. Thank You! We are Hiring! www.peakgames.net

×