Thank you both for the very helpful suggestions.
It appears that the following simple pattern works, and there is no need to
use ProceedingJoinPoint:
Object around(final Object obj) : somePointCut(obj) {
// Prepare for execution
final Callable<Object> action = new Callable<Object>() {
@Override
public Object call() throws Exception {
return proceed(obj);
}
};
// Do whatever...
}
Does this look OK? I didn't realize that the AJC compiler would properly
handle proceed() inside a nested class, but it appears that it does.
I'm using AspectJ 1.7.2.
Thanks,
-Archie
On Wed, Jul 17, 2013 at 1:21 AM, Alexander Kriegisch <
[email protected]> wrote:
> In
> http://stackoverflow.com/questions/17114843/aop-using-around-to-avoid-executing-a-method/17616813#17616813I
> am describing a simpler example also using the worker object pattern. It
> even uses Callable. Maybe it is a better example for you than my more
> complex one Ramnivas has pointed you to.
>
> Alexander Kriegisch
> http://scrum-master.de
>
>
> Am 17.07.2013 um 01:44 schrieb Ramnivas Laddad <[email protected]>:
>
> See worker object pattern described in
> http://stackoverflow.com/questions/12018585/how-to-intercept-proceed-in-another-aspectj-aspect
>
>
> On Tue, Jul 16, 2013 at 3:59 PM, Archie Cobbs <[email protected]> wrote:
>
>> Is it possible to invoke proceed() in an aspect from an inner class?
>>
>> I have a need to pass off the execution of an advised method to another
>> method that is going to invoke it as a Callable. This will all be done
>> synchronously.
>>
>> A simplified version of what I'm trying to do would be:
>>
>> public aspect MyAspect {
>>
>> Object around(final Object obj) : somePointcut(obj) {
>> Callable<Object> c = new Callable<Object>() {
>> @Override
>> public void call() throws Exception {
>> return MyAspect.this.proceed(obj);
>> }
>> });
>> ...
>> return c.call();
>> }
>>
>> In the real version, c gets passed off to another method that invokes
>> and returns c.call().
>>
>> If that's not possible, is there some other way to "wrap" the advised
>> method invocation in a Callable?
>>
>> Thanks,
>> -Archie
>>
>> --
>> Archie L. Cobbs
>>
>> _______________________________________________
>> aspectj-users mailing list
>> [email protected]
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
--
Archie L. Cobbs
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users