In meiner aktuellen Android-Anwendung arbeitet ich die Verwendung von @AspectJ
Android AspectJ @Around mit Methode args nicht
untersuche ich, „Capture“, um alle Hinrichtung zu Methoden, deren Unterschrift bin versucht, ähnelt: -
public void onMethodClicked(com.example.CustomType customType) {}
ich habe nach dem POINTCUTS
1) Ignorieren meine Aspect Klasse:
@Pointcut("!within(com.example.aspect)")
public void notAspect() { }
2) Wählen Sie alle "Clicked" Methoden mit customType Argument
@Pointcut("execution(* com.example..*.*Clicked(com.example.CustomType)) && args(custom)";)
public void customClicked(CustomType custom) { }
3) Mein @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;
}
Wenn ich meine Applikation für Android bauen erhalte ich diese Meldungen
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)))
Was habe ich falsch gemacht?
UPDATE
ich einer der Fehler behoben haben/Warnmeldungen durch die !within()
Korrektur wie folgt: -
1) meine Aspect Klasse ignorieren:
@Pointcut("!within(com.example.aspect.TraceAspect)")
public void notAspect() { }
nette arbeit! dies behob mein Problem, obwohl ich die "pointcut =" fronte um den Rat entfernen musste – Hector
Gut zu wissen das half! :) –