AspectJ Android with Example
-
Upload
firstthumb -
Category
Engineering
-
view
895 -
download
3
description
Transcript of AspectJ Android with Example
Introduction to AspectJ
Erol KOCAMAN
GDG Istanbul
25/10/2014
Peak Games
Peak Games
Agenda
● Why we use AOP ?● Cross Cutting Concerns● Aspect Implementations in Java● AOP with OOP● AspectJ Compiler● Demo Project
Why do we use AOP ?
GAME 1
Module 1
Module 2
Module 3
GAME 2
Module 4
Android
IOS
Desktop
Cross Cutting Concerns
In App Billing Networking Game
Logging Analytics Profiling
After Aspect
In App Billing Networking Game
Logging
Aspect
Analytics
Aspect
Profiling
Aspect
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
Aspect Implementations
● AspectJ● Spring AOP● JBossAOP● JAC● Colt● PROSE
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)
Program Execution
Terminology
Join Points
Pointcut
// aspect codeif (...) {
...} else {
...}
Advice
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
Call / Execution Aspect Difference
ATM Account
debit(...)
Call Execution
Aspect
Aspect
AspectJ Annotations
@Aspect@Pointcut@Before@After@AfterReturning@AfterThrowing@Around
https://github.com/firstthumb/AspectJ-Android-Example
Code with sample
We are Hiring!www.peakgames.net
Thank You!