Around

annotation class Around(val target: KClass<out Annotation>, val inherits: Boolean = false)(source)

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.

Example

@Around(target = [Timed::class])
fun measureTime(joinPoint: ProceedingJoinPoint) {
val start = System.currentTimeMillis()
joinPoint.proceed()
println("Elapsed: ${System.currentTimeMillis() - start} ms")
}

See also

Properties

Link copied to clipboard
val inherits: Boolean = false

When true, the advice is also applied to functions that override a function annotated with one of the target annotations, even if the overriding function itself is not directly annotated. Defaults to false.

Link copied to clipboard
val target: Array<out KClass<out Annotation>>

One or more annotation classes that identify the functions to intercept.