|
Re: stop the execution of a method [message #667513 is a reply to message #665325] |
Fri, 29 April 2011 09:41 |
Alexander Winter Messages: 1 Registered: July 2009 |
Junior Member |
|
|
Am 14.04.2011 12:45, schrieb moha:
> Hi,
>
> I want to deny the execution of a method using Aspectj, wath i should
> put in my advice and my Pointcut.
>
> thanks in advance.
Hi Moha,
I started looking into AspectJ myself and can not call myself and
expert, but how about an around advice, something like:
pointcut methodExecution() : execution(....);
Object around() : methodExecution()
{
// check if some condition is fulfilled for executing the method
if (...)
{
return proceed();
}
return ... ;
}
With this solution, you can skip the execution (denying would be rather
to throw a runtime exception within the advice). Of course, you need to
decide what give back if the caller expects some result, so that is not
easy for a general method call.
Best regards,
Alexander
|
|
|
Powered by
FUDForum. Page generated in 0.03128 seconds