Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
512 views
in Technique[技术] by (71.8m points)

aop - Can I do Aspect Oriented Programming in Scala?

I'm not talking about mimicking AOP features in Scala (i.e. using Traits instead of Aspects), I'm wondering if it is possible to do true AOP in Scala (i.e. advices, aspects, joint points, weaving etc ...)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...