|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Pointcut scoped variablesIs there a way to have "point-cut joinpoint scoped" variables shared across @Before advices and @After advices (for the same joinpoint instance)?
Consider the following simple example, just to illustrate the case. Imagine it is running in a multi-threading application: public void doTask(TheTask task) { //these two lines should be in a separate aspect @Before the pointcut for this method String oldname = Thread.currentThread().getName(); Thread.currentThread().setName(task.getName()); try { //do the actual task task.execute(); } finally { //the following should be in a separate aspect @After the pointcut for this method Thread.currentThread().setName(oldname); } } How do I carry the oldname variable for the same joinpoint, from one advice to another (in the same pointcut scope), if at all possible? Thanks. |
|
|
Re: Pointcut scoped variablesHi. I think you may want to use an around advice.
Eric 2008/7/2 jbx <josef.bajada@...>: > > Is there a way to have "point-cut joinpoint scoped" variables shared across > @Before advices and @After advices (for the same joinpoint instance)? > > Consider the following simple example, just to illustrate the case. Imagine > it is running in a multi-threading application: > > public void doTask(TheTask task) > { > //these two lines should be in a separate aspect @Before the pointcut for > this method > String oldname = Thread.currentThread().getName(); > Thread.currentThread().setName(task.getName()); > > try > { > //do the actual task > task.execute(); > } > finally > { > //the following should be in a separate aspect @After the pointcut > for this method > Thread.currentThread().setName(oldname); > } > } > > > How do I carry the oldname variable for the same joinpoint, from one advice > to another (in the same pointcut scope), if at all possible? > > Thanks. > -- > View this message in context: http://www.nabble.com/Pointcut-scoped-variables-tp18240663p18240663.html > Sent from the AspectJ - users mailing list archive at Nabble.com. > > _______________________________________________ > aspectj-users mailing list > aspectj-users@... > https://dev.eclipse.org/mailman/listinfo/aspectj-users > -- Eric Bodden Sable Research Group McGill University, Montréal, Canada _______________________________________________ aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
| Free embeddable forum powered by Nabble | Forum Help |