- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
AOP with scala
Tue, 2009-09-22, 20:07
I'm writing a framwork that needs to intercept getter and setter calls
on external scala classes (classes that will be written by users of the
framework). It seems that there is no feature to do this in the language,
is this correct ?
I know some form of interception can be done using implicit conversions,
but it seems that for a generic interception mechanism, one still needs an
AOP framework like AspectWerks ...
Has anyone used an AOP framework with scala ? Any recommendations
on which one ?
Thanks
Tue, 2009-09-22, 21:17
#2
Re: AOP with scala
Hi.
I wrote a blog post about an AOP framework that I wrote on top of
AspectJ together with mixin composition.
http://jonasboner.com/2008/02/06/aop-style-mixin-composition-stacks-in-s...
The code is OSS and available here:
http://github.com/jboner/skalman
Also, I'm using AspectWerkz in the Akka Transactors project now with
great success.
/Jonas
2009/9/22 Maxime Lévesque :
>
> I'm writing a framwork that needs to intercept getter and setter calls
> on external scala classes (classes that will be written by users of the
> framework). It seems that there is no feature to do this in the language,
> is this correct ?
> I know some form of interception can be done using implicit conversions,
> but it seems that for a generic interception mechanism, one still needs an
> AOP framework like AspectWerks ...
>
> Has anyone used an AOP framework with scala ? Any recommendations
> on which one ?
>
> Thanks
>
Tue, 2009-09-22, 22:27
#3
Re: AOP with scala
We discuss AspectJ-Scala interop a bit in "Programming Scala".
http://programming-scala.labs.oreilly.com/ch14.html#AspectJInterop
dean
2009/9/22 Jonas Bonér <lists@jonasboner.com>
--
Dean Wampler
coauthor of "Programming Scala" (O'Reilly)
- http://programmingscala.com
twitter: @deanwampler, @chicagoscala
Chicago-Area Scala Enthusiasts (CASE):
- http://groups.google.com/group/chicagoscala
- http://www.meetup.com/chicagoscala/ (Meetings)
http://www.objectmentor.com
http://www.polyglotprogramming.com
http://www.aspectprogramming.com
http://aquarium.rubyforge.org
http://www.contract4j.org
http://programming-scala.labs.oreilly.com/ch14.html#AspectJInterop
dean
2009/9/22 Jonas Bonér <lists@jonasboner.com>
Hi.
I wrote a blog post about an AOP framework that I wrote on top of
AspectJ together with mixin composition.
http://jonasboner.com/2008/02/06/aop-style-mixin-composition-stacks-in-scala.html
The code is OSS and available here:
http://github.com/jboner/skalman
Also, I'm using AspectWerkz in the Akka Transactors project now with
great success.
/Jonas
2009/9/22 Maxime Lévesque <maxime.levesque@gmail.com>:
>
> I'm writing a framwork that needs to intercept getter and setter calls
> on external scala classes (classes that will be written by users of the
> framework). It seems that there is no feature to do this in the language,
> is this correct ?
> I know some form of interception can be done using implicit conversions,
> but it seems that for a generic interception mechanism, one still needs an
> AOP framework like AspectWerks ...
>
> Has anyone used an AOP framework with scala ? Any recommendations
> on which one ?
>
> Thanks
>
--
Jonas Bonér
twitter: @jboner
blog: http://jonasboner.com
work: http://crisp.se
work: http://scalablesolutions.se
code: http://github.com/jboner
code: http://akkasource.org
--
Dean Wampler
coauthor of "Programming Scala" (O'Reilly)
- http://programmingscala.com
twitter: @deanwampler, @chicagoscala
Chicago-Area Scala Enthusiasts (CASE):
- http://groups.google.com/group/chicagoscala
- http://www.meetup.com/chicagoscala/ (Meetings)
http://www.objectmentor.com
http://www.polyglotprogramming.com
http://www.aspectprogramming.com
http://aquarium.rubyforge.org
http://www.contract4j.org
Tue, 2009-09-22, 22:37
#4
Re: AOP with scala
2009/9/22 Maxime Lévesque :
> Has anyone used an AOP framework with scala ? Any recommendations
> on which one ?
The Scala IDE for Eclipse uses AspectJ extensively.
Cheers,
Miles
Tue, 2009-09-22, 23:57
#5
Re: AOP with scala
Miles,
You use it to advise the Java code in the JDT, right? Do you also use it to advise Scala code? If so, any particular gotchas? In the book section, I discuss the issue of "name mangling", e.g., a "+" method has to be referred to as "$plus" in an AspectJ pointcut.
dean
2009/9/22 Miles Sabin <miles@milessabin.com>
--
Dean Wampler
coauthor of "Programming Scala" (O'Reilly)
- http://programmingscala.com
twitter: @deanwampler, @chicagoscala
Chicago-Area Scala Enthusiasts (CASE):
- http://groups.google.com/group/chicagoscala
- http://www.meetup.com/chicagoscala/ (Meetings)
http://www.objectmentor.com
http://www.polyglotprogramming.com
http://www.aspectprogramming.com
http://aquarium.rubyforge.org
http://www.contract4j.org
You use it to advise the Java code in the JDT, right? Do you also use it to advise Scala code? If so, any particular gotchas? In the book section, I discuss the issue of "name mangling", e.g., a "+" method has to be referred to as "$plus" in an AspectJ pointcut.
dean
2009/9/22 Miles Sabin <miles@milessabin.com>
2009/9/22 Maxime Lévesque <maxime.levesque@gmail.com>:
> Has anyone used an AOP framework with scala ? Any recommendations
> on which one ?
The Scala IDE for Eclipse uses AspectJ extensively.
Cheers,
Miles
--
Miles Sabin
tel: +44 (0)7813 944 528
skype: milessabin
http://www.chuusai.com/
http://twitter.com/milessabin
--
Dean Wampler
coauthor of "Programming Scala" (O'Reilly)
- http://programmingscala.com
twitter: @deanwampler, @chicagoscala
Chicago-Area Scala Enthusiasts (CASE):
- http://groups.google.com/group/chicagoscala
- http://www.meetup.com/chicagoscala/ (Meetings)
http://www.objectmentor.com
http://www.polyglotprogramming.com
http://www.aspectprogramming.com
http://aquarium.rubyforge.org
http://www.contract4j.org
Wed, 2009-09-23, 00:07
#6
Re: AOP with scala
2009/9/22 Dean Wampler :
> You use it to advise the Java code in the JDT, right?
Right. The advice typically calls out to Scala code via Java interfaces.
> Do you also use it to advise Scala code?
I don't currently because when I initially tried to mix Scala and
AspectJ in a single project ajc (the AspectJ compiler) choked on the
bytecode generated by Scala constructs which were then heavily used in
the IDE (specifically, early initializers). But I think things might
have changed since then and I know of several people who are mixing
Scala and AspectJ directly.
> If so, any particular gotchas? In the book section, I discuss the issue
> of "name mangling", e.g., a "+" method has to be referred to as "$plus"
> in an AspectJ pointcut.
This is the exact same encoding you would need to use to interact with
Scala from vanilla Java.
Cheers,
Miles
i.e. val x = new Foo with Bar
so you can't use them as decorators over existing object instances.
A few ppeople (myself included) are working on ways to address this shortfall and allow for dynamic mixins, but you're unlikely to see anything before the 2.8 release.
2009/9/22 Maxime Lévesque <maxime.levesque@gmail.com>