Hi, Ivan
I guess you must be very familiar with both aspectj and scala, could you
help me on below question?
I'm trying to do some experimental point cut on scala.concurrent.Future,
something like:
@Aspect
class FutureAspect {
@Around(value = "execution (* scala.concurrent.Future$.apply(..)) &&
args(body)", argNames = "jp,body")
def futureCP(jp: ProceedingJoinPoint, body: AnyRef) {
println("something")
val args = jp.getArgs
args(0) = wrap(body)
jp.proceed(args)
}
def wrap[T](f: =>T) : T ={
try{
println("start body")
f
}finally{
println("end body")
}
}
}
and my test-aop.xml:
<aspectj>
<aspects>
<aspect name="com.leon.mypackage.FutureAspect"/>
</aspects>
<weaver options="-XnoInline">
<include within="scala.concurrent.Future$"/>
</weaver>
</aspectj>
My test class:
class FutureAspectTest extends FlatSpecLike with Matchers {
"FutureAspect" should "work" in {
val f = {println("Hello world")}
Future(f)
}
}
My VM setting in IDEA:
-javaagent:C:\Users\lma\.ivy2\cache\org.aspectj\aspectjweaver\jars\aspectjweaver-1.7.4.jar
-Dorg.aspectj.weaver.loadtime.configuration=META-INF/test-aop.xml
However, It seems not work.
Could you give me some suggestions? Anything missed?
Btw, How to handle the generics in aspectj with scala ? like the input
parameter for Future(body: =>T), should I use AnyRef instead?
Thanks
Leon
在 2014年6月4日星期三UTC-7下午4时59分13秒,Ivan Topolnjak写道:
>
> Leon,
>
> Yes, we are using aspectj to instrument the Scala/Akka/Spray/Play! code
> and we choose to go with load-time weaving.. before elaborating a bit more
> on how to use the TraceLocal storage, from your code sample, I might be
> oversimplifying your requirements, but why don't you just pass your
> `MyObject` to `handleAppRequest`?, it seems like you are using a actor per
> request and I don't see any reason why a simpler approach couldn't work
> there.
>
> If you still want to use the TraceLocal storage I highly encourage you to
> raise this concern in the Kamon mailing list [1] and discuss it there, that
> way we also leave a record that might be useful to other Kamon users. Hope
> to hear back from you soon, best regards!
>
> [1] https://groups.google.com/forum/#!forum/kamon-user
>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.