Inner-component AOP

9 views
Skip to first unread message

shieldsjared

unread,
Sep 16, 2011, 12:09:48 PM9/16/11
to ColdSpring-Users
Not sure if this is possible or not, but wanted to ask anyhow....

Pretend i've got a component with two methods:

component {
// AOP method interceptor applied to method1
method1()
// calls method 1
method2()
}

I recognize that when using AOP - it creates a proxy that sits in the
middle - so from outside of the component - everything is fine - but
what about from within?

I got it to work by injecting the component into itself, and doing it
that way (getComponent().method1())....

But I'm not sure how smart that is....

Thoughts anyone?

Barney Boisvert

unread,
Sep 16, 2011, 12:23:07 PM9/16/11
to coldspri...@googlegroups.com
Using proxy-based AOP (as ColdSpring does), this is impossible. You
need weaving to apply AOP to this type of internal call.

Doing this is of great utility in certain situations, but the majority
of cases it's unneeded. Further, it's ENORMOUSLY more difficult to
implement, because the AOP engine needs to weave it's stuff into the
application code, which means it's actually changing the code you
write, rather than just adding some new code (the proxy).

AspectJ is an example of an AOP framework that does weaving, though
it's for Java. Java's static typing and explicit compile cycle with
native AST transform support (via annotations) make compile-time
weaving fairly straightforward. AspectJ also supports runtime weaving
where it manipulates the bytecode of the application as classes are
loaded into the JVM. Again, Java provides great support with runtime
annotations and a couple different bytecode stream editing packages (I
believe AspectJ uses ASM). This runtime bytecode manipulation is also
the way Hibernate achieves a lot of it's magic.

cheers,
barneyb

> --
> You received this message because you are subscribed to the Google Groups "ColdSpring-Users" group.
> To post to this group, send email to coldspri...@googlegroups.com.
> To unsubscribe from this group, send email to coldspring-use...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/coldspring-users?hl=en.
>
>

--
Barney Boisvert
bboi...@gmail.com
http://www.barneyb.com/

shieldsjared

unread,
Sep 16, 2011, 1:21:49 PM9/16/11
to ColdSpring-Users
Excellent....answer!

Im used working entirely in a Java environment - so its hard getting
used to only have a runtime environment (and facilities that lend
itself to it) vice the luxury of compile-time facilities....

Thanks for the feedback!
> bboisv...@gmail.comhttp://www.barneyb.com/
Reply all
Reply to author
Forward
0 new messages