• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

interceptor method overriden is not invoked

 
Bartender
Posts: 2419
13
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
What's brown and sticky? ... a stick. Or a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic