• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

interceptor method overriden is not invoked

 
Ranch Hand
Posts: 1749
12
  • 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

 
Creator of Enthuware JWS+ V6
Posts: 3292
296
Android Eclipse IDE Chrome
  • 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
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!