Question

I am migrating my Seam 2 powered application to CDI and one of the things that is critical for me to retain is the error handling. In Seam 2, I simply replaced the default exception handler with my own, but in CDI, I am guessing I'll have to use an Interceptor.

How would I set this up as using an Interceptor requires me to specify where it will intercept calls? I mostly want to accomplish auditing, so when an exception occurs, it is logged, then a notification (email, xmpp, sms, phone call) is sent out to administrators.

When an exception occurs, is there simply an event that I can listen for and act on?

Walter

Was it helpful?

Solution

Are you using JSF2? If yes, instead of writing an Interceptor, you could register an ExceptionHandlerFactory in your web.xml as described here. In a CustomExceptionHandler, you can catch all Exceptions and handle them programmatically. I'm using this approach in my JEE6-CDI-app, find it quite okay.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top