Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interceptor method overriden is not invoked

 
Himai Minh
Ranch Hand
Posts: 1359
7
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On p.118 of Ivan's notes,

Interceptor methods overridden in a subclass will not be invoked, regardless of whether the overriding method is an interceptor method or not.


I believe it is the other way round. The interceptor method being overridden is not invoked, but the overriding method is invoked.
I modified Ivan's example:

Output on the console with overriding @AroundInvoke method in the interceptor:

MyDefaultInterceptor intercepting : SingletonSessionBeanA. retrieveMessage
Info: LogInterceptor - entering method: retrieveMessage
Info: MyAroundInvoke - entering method: retrieveMessage
Info: *** retrieve message :Message from SingletonSessionBeanA-Ivan Thu Mar 12 16:34:19 EDT 2015
Info: MyAroundInvoke- exiting method: retrieveMessage
Info: MyAroundInvoke- exiting method: retrieveMessage


However, if the @AroundInvoke method in LogInterceptor is not overriding its superclass, like this:


The interceptor of LogInterceptorSuperclass is invoked when its @AroundInvoke method is not overridden:

When @AroundInvoke is not overriden in LogInterceptorSuperclass, it is invoked.
MyDefaultInterceptor intercepting : SingletonSessionBeanA. retrieveMessage
Info: LogInterceptorSuperclass intercepting SingletonSessionBeanA.retrieveMessage
Info: LogInterceptor - entering method: retrieveMessage
Info: MyAroundInvoke - entering method: retrieveMessage
Info: *** retrieve message :Message from SingletonSessionBeanA-[no message set] Thu Mar 12 16:44:00 EDT 2015
Info: MyAroundInvoke- exiting method: retrieveMessage
Info: LogInterceptor- exiting method: retrieveMessage
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2531
112
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct and that is exactly what Ivan meant. I guess you can interpret his sentence in two ways
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic