0
在我目前的Android應用程序,我調查使用的@AspectJ
的Android AspectJ的@Around與方法ARGS不工作
我試圖「捕捉」所有執行到的簽名方法類似: -
public void onMethodClicked(com.example.CustomType customType) {}
我有以下POINTCUTS
1)忽略我的看點類:
@Pointcut("!within(com.example.aspect)")
public void notAspect() { }
2)選擇與customType參數
@Pointcut("execution(* com.example..*.*Clicked(com.example.CustomType)) && args(custom)";)
public void customClicked(CustomType custom) { }
3)我@Around
所有 「點擊」 方法: -
@Around("notAspect() && customClicked()")
public Object selectedClicked(final ProceedingJoinPoint joinPoint, CustomType custom) throws Throwable {
Log.d(TAG, "Found a clicked method " + custom);
Object result = joinPoint.proceed();
return result;
}
當我建立我的Android應用程序,我得到這些消息
no match for this type name: CustomType [Xlint:invalidAbsoluteTypeName]
bad parameter to pointcut reference
formal unbound in pointcut
no match for this type name: com.example.aspect [Xlint:invalidAbsoluteTypeName]
the parameter custom is not bound in [all branches of] pointcut
use of ProceedingJoinPoint is allowed only on around advice (arg 1 in (before(extraFlags: 2): (((!within(com.example.aspect+) && execution(* com.example..*.*Clicked(com.example.CustomType)) && args(custom)) && persingleton(com.example.aspect.TraceAspect))->void com.example.aspect.TraceAspect.selectedClicked(org.aspectj.lang.JoinPoint, com.example.CustomType)))
我做錯了什麼?
UPDATE
我有固定的錯誤之一/通過糾正!within()
如下警告信息: -
1)忽略我的看點類:
@Pointcut("!within(com.example.aspect.TraceAspect)")
public void notAspect() { }
不錯的工作!這固定我的問題,雖然我不得不刪除「pointcut =」fronte圍繞諮詢 – Hector
很高興知道幫助! :) –