Search in sources :

Example 1 with ConstructorSignature

use of org.aspectj.lang.reflect.ConstructorSignature in project AndroidDevMetrics by frogermcs.

the class Dagger2GraphAnalyzer method logAndExecute.

@Around("providesMethod() || injectConstructor()")
public Object logAndExecute(ProceedingJoinPoint joinPoint) throws Throwable {
    long start = System.nanoTime();
    Object result = joinPoint.proceed();
    long stop = System.nanoTime();
    long took = TimeUnit.NANOSECONDS.toMillis(stop - start);
    if (!enabled) {
        return result;
    }
    CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
    Class<?> cls = codeSignature.getDeclaringType();
    if (codeSignature instanceof ConstructorSignature) {
        InitManager.getInstance().addInitMetric(cls, joinPoint.getArgs(), took);
    }
    if (isMethodWithReturnType(codeSignature)) {
        if (result != null) {
            InitManager.getInstance().addInitMetric(result.getClass(), joinPoint.getArgs(), took);
        }
    }
    return result;
}
Also used : ConstructorSignature(org.aspectj.lang.reflect.ConstructorSignature) CodeSignature(org.aspectj.lang.reflect.CodeSignature) Around(org.aspectj.lang.annotation.Around)

Aggregations

Around (org.aspectj.lang.annotation.Around)1 CodeSignature (org.aspectj.lang.reflect.CodeSignature)1 ConstructorSignature (org.aspectj.lang.reflect.ConstructorSignature)1