Can I do Aspect Oriented Programming in Scala?

Mixin has been the classic way to introduce AOP in Scala (as in “AOP-style Mixin Composition Stacks in Scala” from Jonas Bonér).

But I know only of “Method Proxy-Based AOP in Scala” (Daniel Spiewak — also here on SO — and Tian Zhao) as an advanced AOP implementation in Scala (source code here).

Our technique uses Scala’s higher-order functions to intercept method calls with minimal syntactic overhead imposed on the base program.
This framework allows developers to define pointcuts by specifying class types and method signatures. The framework also allows access to context variables, while aspects can insert advice code before or after the advised body.

Leave a Comment

tech