Before

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

Marks a function inside an Aspect-annotated class as before advice.

The annotated function is invoked at every call site of any function carrying one of the target annotations, before the target function body executes. The injection is performed at compile time by the AspectK compiler plugin.

The advice function must declare exactly one parameter of type JoinPoint.

Multiple target annotations may be listed; the advice will be applied to all of them. Multiple @Before declarations may also share the same target, enabling many-to-many relationships between targets and advice.

Example

@Before(target = [Authenticated::class, Logged::class])
fun checkAndLog(joinPoint: JoinPoint) { ... }

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.