Around
Marks a function inside an Aspect-annotated class as around advice.
The annotated function replaces the target function's execution. The advice receives a ProceedingJoinPoint and can call ProceedingJoinPoint.proceed to invoke the original function body, optionally supplying different arguments. If ProceedingJoinPoint.proceed is never called, the original body is skipped entirely.
The advice function must declare exactly one parameter of type ProceedingJoinPoint. When the intercepted function is suspend, the advice must instead take a SuspendProceedingJoinPoint and be declared suspend itself.
Example
@Around(target = [Timed::class])
fun measureTime(joinPoint: ProceedingJoinPoint) {
val start = System.currentTimeMillis()
joinPoint.proceed()
println("Elapsed: ${System.currentTimeMillis() - start} ms")
}Content copied to clipboard