我是AspectJ的新手,儘管我多年來一直知道這種AOP方法。 現在,這是我第一次在我的Android應用程序中使用它,並且想問幾個關於它的問題。加入AspectJ上的切入點
我有Java代碼:
private void mainView() {
... (some code)
<A>
setContentView(R.layout.main);
mView = findViewById(R.id.Main_Root);
mView.setOnTouchListener(this);
<B>
... (some code)
}
我有如下的AspectJ代碼:
public aspect mainViewTiming {
pointcut callSetContentViewTiming():
call(* android.app.Activity.setContentView(..))
&& withincode(void mainView(..))
;
pointcut callFindViewById():
call(* android.app.Activity.findViewById(..))
&& withincode(void mainView(..))
;
pointcut callSetOnTouchListener():
call (* android.view.View.setOnTouchListener(..))
&& withincode(void mainView(..))
;
}
現在我的問題是,如何我使用AspectJ和計算它從到運行的時間?
我有3個切入點,我想知道什麼是最好的方式來結合他們有這種效果?從這個鏈接我才知道,我可以用「CFLOW」: http://www.eclipse.org/aspectj/doc/released/progguide/language-joinPoints.html
before(): cflow(callSetContentViewTiming()) && cflow(callFindViewById()) && callSetOnTouchListener() {
start = System.currentTimeMillis();
}
但我不知道,如果這是正確的。我該如何計算組合切入點之間的差異。有沒有像「之後()」?
謝謝先進。