This content has been marked as final. 
    
Show                 2 replies
    
- 
        1. Re: Exception handling with interceptorsjteb Feb 8, 2008 9:44 AM (in response to nickarls)I've been using Interceptors for this kind of work. However one can only define EJB3 interceptors at the class level. 
 What I do is a workaround, which I find rather nasty, but since I haven't thought of another way yet and this works, I'll point it out.
 I define an annotation which has Interceptors defined on it, with targets TYPE and METHOD. I put it on the class where I want a method to be intercepted and put it on the method(s) to be intercepted inside that class as well.
 In the aroundInvoke, I do a check on that same annotation being present on the calling method. Something like the following:@AroundInvoke public Object aroundInvoke(InvocationContext ctx) { Object result = null; if(ctx.getMethod().getAnnotation(SomeAnnotation.class) != null) { try { result = .... // The rest of your code } catch( ... ) { } } return result; }
 Might not be the most elegant method, but it works for me.
 I hope that helps you!
 Regards,
 Jan
- 
        2. Re: Exception handling with interceptorspmuir Feb 17, 2008 2:21 PM (in response to nickarls)When do you mean the transaction has gone sour? after the exception? This is expected - you need a new transaction at this point. 
 
     
    