Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Accessing the target from within @Around

Yes, there is.  See here for the details:
http://www.eclipse.org/aspectj/doc/released/adk15notebook/ataspectj-pcadvice.html

You can do something like

@Around("execution(void com.example.jobs.FooJob.run()) && this(job)")
 public void retryJob(ProceedingJoinPoint join_point, FooJob job)
throws Throwable {

On Wed, Aug 19, 2009 at 3:09 PM, Norman Elton<normelton@xxxxxxxxx> wrote:
> Suppose I've got the following simple wrapper around a Job's run() method:
>
> @Aspect
> public class JobWrapperAspect {
>        @Around("execution(void com.example.jobs.FooJob.run())")
>        public void retryJob(ProceedingJoinPoint join_point) throws Throwable {
>                System.out.println("About to run a FooJob");
>                join_point.proceed();
>                System.out.println("Done running a FooJob");
>        }
> }
>
> That's pretty straightforward, and works well.
>
> But is there any way to access the job object from within my advice?
> Something like...
>
> System.out.println("About to run a " + job.toString());
> join_point.proceed();
> System.out.println("Done running a " + job.toString());
>
> Any ideas? How do I access the "job" object?
>
> Thanks!
>
> Norman
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top