• 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

EJB 3.0 Interceptors question

 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From EJB IN Action 3.0
"In the pure AOP world, interception takes place at various points (called point
cuts) including at the beginning of a method, at the end of a method, and when an
exception is triggered."

With @Interceptors annotation applied to a bean method, the registered class's AroundInvoke method will be invoked when the bean method is invoked by
the client which will log the entry point of the method and finally invoke proceed() on InvocationContext.
How can one log @ the end of the bean method and when an exception is thrown? as stated in the EJB 3 in action
How can one access the return values
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

How can one log @ the end of the bean method and when an exception is thrown?


That's an AOP concept, so maybe you should read something about AOP if you're interested in it. Your object is proxied, so when you think you're calling a method of your bean, you're actually calling the method of a proxy of your bean. In the proxy, anything can be controlled. Before/After calling the actual method of your bean, the proxy can do things, like calling interceptor methods. Same for exceptions, where the proxy can catch some exceptions and do something special when it happens.
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So is it supported by EJB 3 like AroundInvoke tags ?
Are they any tags to do so.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, anything other than @AroundInvoke is not supported.
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Limited supported in EJB 3.0.
I hope they come up with annotations to handle exit and exceptions in a method.
Only then one can think of implementing Logging [Cross Cutting concern] in a separate module. With current support its pretty much like a servlet filter.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it's possible to use a try catch around the proceed method invocation, then log exception.
The return value is taken from the return value of proceed method.

Cheers

Germano
 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The book already mentions that for elaborate AOP support one must think of
dedicated frameworks like AspectJ.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic