Download - AspectJ Android with Example
![Page 1: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/1.jpg)
Introduction to AspectJ
Erol KOCAMAN
GDG Istanbul
25/10/2014
![Page 2: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/2.jpg)
Peak Games
![Page 3: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/3.jpg)
Peak Games
![Page 4: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/4.jpg)
Agenda
● Why we use AOP ?● Cross Cutting Concerns● Aspect Implementations in Java● AOP with OOP● AspectJ Compiler● Demo Project
![Page 5: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/5.jpg)
Why do we use AOP ?
GAME 1
Module 1
Module 2
Module 3
GAME 2
Module 4
Android
IOS
Desktop
![Page 6: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/6.jpg)
Cross Cutting Concerns
In App Billing Networking Game
Logging Analytics Profiling
![Page 7: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/7.jpg)
After Aspect
In App Billing Networking Game
Logging
Aspect
Analytics
Aspect
Profiling
Aspect
![Page 8: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/8.jpg)
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
![Page 9: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/9.jpg)
Aspect Implementations
● AspectJ● Spring AOP● JBossAOP● JAC● Colt● PROSE
![Page 10: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/10.jpg)
Java & Aspect
Source Files
AspectJ Compiler
Java & Aspect
Archive Files
(.jar)
Java & Aspect
Archive Files
(.jar)
Java & Aspect
Archive Files
(.jar)
AspectJ
Compiler
(ajc)
Woven system
(.class files)
Java & Aspect
Source FilesJava & Aspect
Source Files
(.java)
![Page 11: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/11.jpg)
Program Execution
Terminology
Join Points
Pointcut
// aspect codeif (...) {
...} else {
...}
Advice
![Page 12: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/12.jpg)
JoinPoint Types
● Method● call● execution
execution(* android.mobile.peakgames.net.aspectjandroid.AspectActivity.fetchImage(..))
● Constructorexecution(* android.mobile.peakgames.net.aspectjandroid.AspectActivity.new(..))
● Field Access ● Exception Handler Execution● Class Initialization
![Page 13: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/13.jpg)
Call / Execution Aspect Difference
ATM Account
debit(...)
Call Execution
Aspect
Aspect
![Page 14: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/14.jpg)
AspectJ Annotations
@Aspect@Pointcut@Before@After@AfterReturning@AfterThrowing@Around
![Page 15: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/15.jpg)
https://github.com/firstthumb/AspectJ-Android-Example
Code with sample
![Page 16: AspectJ Android with Example](https://reader034.vdocuments.us/reader034/viewer/2022052304/5594195b1a28ab7a0d8b4619/html5/thumbnails/16.jpg)
We are Hiring!www.peakgames.net
Thank You!