-
1. Re: Interceptors not fired on methods called from within bea
abl Jul 10, 2006 2:30 AM (in response to jnorris10)this is correct behavior. it IS in the spec - don't ask me exactly where. there have been posts here already related to that.
-
2. Re: Interceptors not fired on methods called from within bea
jnorris10 Jul 10, 2006 3:06 PM (in response to jnorris10)Ok, I looked at the spec again, and it says it intercepts *business* methods (which are public, among other things I think). However, if I make the internal methods public, it still does not intercept them when they are called internally.
-
3. Re: Interceptors not fired on methods called from within bea
peterj Jul 10, 2006 3:19 PM (in response to jnorris10)Interceptors only work if you call the method via a bean reference (i.e., one you got from JNDI). By calling the method via a bean reference, the server has a chance to determine that an interceptor exists and can deflect the method call to the interceptor. But, within the bean, if you call another method dicrectly, that all gets compiled into the class file and the server does not have any chance to intercept the method call. To get the behavior you want, you need to investigate AOP, most likely AspectJ. (The comments above are based on my suppositions on how this feature works, not on knowledge of the actual implementation, so I could be wrong.)
-
4. Re: Interceptors not fired on methods called from within bea
jnorris10 Jul 10, 2006 4:47 PM (in response to jnorris10)"PeterJ" wrote:
Interceptors only work if you call the method via a bean reference (i.e., one you got from JNDI). By calling the method via a bean reference, the server has a chance to determine that an interceptor exists and can deflect the method call to the interceptor. But, within the bean, if you call another method dicrectly, that all gets compiled into the class file and the server does not have any chance to intercept the method call.
Interesting. I was under the impression that is was implemented via byte code instrumentation by the underlying provider in the classloader, in the case of JBossAS, jboss-aop. Thus, there should be no real technical restrictions on when the method can be intercepted. The spec may have additional restrictions though.
Is this bean reference restriction stuff mentioned in the spec? I didn't see anything like this under the Interceptors section."PeterJ" wrote:
To get the behavior you want, you need to investigate AOP, most likely AspectJ. (The comments above are based on my suppositions on how this feature works, not on knowledge of the actual implementation, so I could be wrong.)
Thanks for the reply. -
5. Re: Interceptors not fired on methods called from within bea
jnorris10 Jul 12, 2006 6:54 PM (in response to jnorris10)"jnorris10" wrote:
Is this bean reference restriction stuff mentioned in the spec? I didn't see anything like this under the Interceptors section.
This stuff is definitely in the spec. PeterJ is right, Interceptors only work if you call the method via a bean reference. It's true that in theory you may not have this restriction with AOP weaving, but I don't think the spec wants to mandate AOP for EJB3 implementers. -
6. Re: Interceptors not fired on methods called from within bea
wolfc Jul 13, 2006 9:22 AM (in response to jnorris10)Please try:
getBusinessObject(MyInterface.class).sayHelloTo("me");
-
7. Re: Interceptors not fired on methods called from within bea
jnorris10 Jul 13, 2006 10:44 AM (in response to jnorris10)"wolfc" wrote:
Please try:getBusinessObject(MyInterface.class).sayHelloTo("me");
Yeah, I've found that, thanks. That call currently is "Not Implemented" (in EJB3 RC7) although it seems to be implemented in source control now.
For now I simply inject "myself" which works fine:
ie:@EJB MyInterface myself
Although this seems dirty and I'm not sure if this is really supposed to be supported in the spec.