Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Calling proceed in a method

A possible solution is to use the worker object pattern. It will get you closer to the desired behavior.

Object around() : somePC() {
    Runnable work = new Runnable() {
         public void run() { proceed(); }
    }
    refactoredMethod(work);
}

void refactoredMethod(Runnable work) {
   ...
   work.run(); // which will end up calling proceed() on the original join point
   ...
}

-Ramnivas

On Sat, Jul 12, 2008 at 8:16 PM, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
Hi Ashley,

ProceedingJoinPoint was only designed for use with annotation style
advice, to allow the calling of proceed() in a legal java program.  I
have no test programs that do what you are attempting, so I don't know
if it'll work or not, but my feeling is that it will not.  Probably if
it is going to work at all you will need to use annotation style
around advice as that triggers different weaver paths that may set of
the ProceedingJoinPoint correctly before you pass it around.

Unfortunately the signature for proceed() on a ProceedingJoinPoint is
effectively Object... - so if you have problems setting up the
parameters for the proceed it will likely manifest as a runtime error
rather than compile time error.

If you think you have a suitable use case and it isn't working, please
raise a bug for us to discuss/consider what we can do.

Andy.

2008/7/11 Ashley Williams <ashley.williams@xxxxxx>:
> Hi,
>
> I have two pieces of around advice in my code-style aspect that I would like
> to refactor into an ordinary method in the same aspect. However I'm unsure
> how to make the call to proceed() in this method.
>
> Am I supposed to cast thisJointPoint to the annotation-style
> ProceedingJoinPoint and pass it as a paramter to the refactored method? If
> so, is there a way of invoking its proceed method that would work
> generically for the different sorts of args and return values in the two
> pieces of advice that are delegating to it?
>
> Many thanks
> - Ashley
>
> ---
>
> This e-mail may contain confidential and/or privileged information. If you
> are not the intended recipient (or have received this e-mail in error)
> please notify the sender immediately and delete this e-mail. Any
> unauthorized copying, disclosure or distribution of the material in this
> e-mail is strictly forbidden.
>
> Please refer to http://www.db.com/en/content/eu_disclosures.htm for
> additional EU corporate and regulatory disclosures.
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top