PDA

View Full Version : Spring AOP and method access restriction



tom_bangalore
Mar 14th, 2005, 12:17 AM
Hi ,

I am using tracingbeforeadvice and tracingafteradvice for intercepting before and after a method .

Is there any way that i can intercept my code at the starting of the method .

Say my method is

void foo()
{
//I want to intercept my code here......(here my security code
//comes which restricts access to this method

}


Thanks in Advance ,

Tom

Costin Leau
Mar 14th, 2005, 03:22 AM
I don't know if it's possible but you can intercept the method before it is executing:

-->pointcut
foo()

It's the same as if the code is executed right away in your method (i.e.:
foo()
{
-->pointcut
}

tom_bangalore
Mar 14th, 2005, 03:48 AM
Thanks Costin,


If my TracingBeforeMethod is the same as the code included in method ,i have a code which will secure the method.I need to test it.

Can I change the arguments passed to the method and the return value ?

As the invocation in Advice provides me with (Object args) as an argument,Can I change it.?

Thanks again.

TOM

Costin Leau
Mar 14th, 2005, 03:55 AM
Read the docs and you'll see the restrictions.
AFAIK, depending on what type of interceptor you are using, you can change the objects (parameters passed to the method), the return type or skip the method invocation even.