1 /*
2 * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3 * the spring framework, http://el4j.sf.net
4 * Copyright (C) 2005 by ELCA Informatique SA, Av. de la Harpe 22-24,
5 * 1000 Lausanne, Switzerland, http://www.elca.ch
6 *
7 * EL4J is published under the GNU Lesser General Public License (LGPL)
8 * Version 2.1. See http://www.gnu.org/licenses/
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * For alternative licensing, please contact info@elca.ch
16 */
17
18 package ch.elca.el4j.services.exceptionhandler;
19
20 import org.aopalliance.intercept.MethodInvocation;
21
22 /**
23 * This interceptor implements a safety facade. It allows to catch any
24 * exceptions thrown by the proxied bean and to handle them by exception
25 * handlers.
26 *
27 * <p/>Don't setup this interceptor directly as long as you don't need access to
28 * it. Instead use the {@link
29 * ch.elca.el4j.services.exceptionhandler.SafetyFacadeFactoryBean}.
30 *
31 * @svnLink $Revision: 3883 $;$Date: 2009-08-04 15:35:01 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/exception_handling/src/main/java/ch/elca/el4j/services/exceptionhandler/SafetyFacadeInterceptor.java $
32 *
33 * @author Andreas Bur (ABU)
34 * @see ch.elca.el4j.services.exceptionhandler.SafetyFacadeFactoryBean
35 */
36 public class SafetyFacadeInterceptor
37 extends AbstractExceptionHandlerInterceptor {
38
39 /** The exception configurations. */
40 ExceptionConfiguration[] m_exceptionConfigurations;
41
42 /**
43 * Default constructor. Configures the interceptor to handle only those
44 * exceptions that are <b>not</b> defined in the signature (excluding
45 * unchecked exceptions, which are handled always).
46 */
47 public SafetyFacadeInterceptor() {
48 super();
49 // change this behaviour in the SafetyFacadeFactoryBean too
50 // (to be done manually since Java doesn't support multi inheritance).
51 setForwardSignatureExceptions(true);
52 setHandleRTSignatureExceptions(true);
53 }
54
55 /**
56 * Sets the exception configurations.
57 *
58 * @param exceptionConfigurations
59 * The exception configurations to set.
60 */
61 public void setExceptionConfigurations(
62 ExceptionConfiguration[] exceptionConfigurations) {
63 m_exceptionConfigurations = exceptionConfigurations;
64 }
65
66 /**
67 * {@inheritDoc}
68 */
69 protected Object handleException(Throwable t, MethodInvocation invocation)
70 throws Throwable {
71
72 return doHandleException(t, invocation, m_exceptionConfigurations);
73 }
74 }