|
From: <kab...@jb...> - 2006-06-30 11:58:40
|
I think the simplest approach is to have an interceptor at the start of the chain, which manages this.
| public class ReentrancyStopperInterceptor implements Interceptor
| {
| ThreadLocal done = new ThreadLocal();
|
| private Object invoke(Invocation invocation) throws Throwable
| {
| boolean wasDone = ((Boolean)done.get()).booleanValue();
|
| try
| {
| if (!wasDone)
| {
| done.set(Boolean.TRUE);
| return invocation.invokeNext();
| }
| else
| {
| //Needs adding, and will invoke target joinpoint skipping the rest of the chain
| return invocation.dispatch();
| }
| }
| finally
| {
| if (!wasDone)
| {
| done.set(Boolean.FALSE);
| }
| }
|
| return ret;
| }
| }
|
I could implement the new dispatch() method pretty quickly, and I think this interceptor should belong in the aop module.
Similar functionality _could_ be added to the woven bytecode, but I don't think it is a good idea to code use-case stuff in there.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954648#3954648
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954648
|
|
From: <ben...@jb...> - 2006-06-30 12:35:16
|
Sounds good. But we need to consider the following calling stack: | pojo.methodA(); | pojo.methodB(); | ... | pojo.methodB(); // so we can skip this field interception | pojo.methodA(); // oops, it will fail. | So in essence, we need to have a local thread array done[] such that this will work properly. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954657#3954657 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954657 |
|
From: <kab...@jb...> - 2006-06-30 12:51:44
|
Hmmm, I'm not getting you, please elaborate. BTW the interceptor I outlined was for field interception, and would be used only for a field for a particular instance. I see now that it was a bit too simple. It should really be scoped PER_JOINPOINT, so that the "done" book-keeping is only done for a particular field. Now, this is not possible with the existing InstanceAdvisor API, since per instance aspect added there apply to ALL joinpoints. However, with the new AOP 2 weaving this is possible. Take a look at org.jboss.test.aop.dynamicgenadvisor.DynamicTester to see how this works. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954663#3954663 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954663 |
|
From: <ben...@jb...> - 2006-07-05 06:54:05
|
Ok, what I meant more properly is the PER_JOINTPOINT scope that you proposed where we track the recursion call at the joint point scope. Now which test specifically you were referring to? I don't see any PER_JOINTPOINT scope test. :-) View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3955380#3955380 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3955380 |
|
From: <kab...@jb...> - 2006-07-05 08:37:01
|
I meant the DynamicTester. It shows how the new per instance API works :-) View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3955407#3955407 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3955407 |
|
From: <kab...@jb...> - 2006-07-05 12:18:17
|
Hi Ben, I have added this method to the invocation object in head. I have called it invokeTarget() instead of dispatch(). http://jira.jboss.com/jira/browse/JBAOP-270 View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3955465#3955465 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3955465 |