我可以在Scala中进行面向方面的编程吗? [英] Can I do Aspect Oriented Programming in Scala?

查看:87
本文介绍了我可以在Scala中进行面向方面的编程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是在谈论在Scala中模仿AOP功能(即使用Traits而不是Aspects),我想知道是否有可能在Scala中进行真正的AOP(即建议,方面,联合点,编织等). )

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

推荐答案

Mixin是在Scala中引入AOP的经典方法(如" Scala中的AOP风格混合结构组合".

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

但是我只知道" Scala中基于方法代理的AOP "(Daniel Spiewak-也在此处SO -和Tian Zhao)作为Scala中的高级AOP实现(此处的源代码).

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).

我们的技术使用Scala的高阶函数来拦截方法调用,而对基础程序所施加的语法开销却最小.
该框架允许开发人员通过指定类类型和方法签名来定义切入点.该框架还允许访问上下文变量,而各方面可以在建议主体之前或之后插入建议代码.

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.

这篇关于我可以在Scala中进行面向方面的编程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆