org.kuali.student.common.util
Class ExceptionMappingAdvice
java.lang.Object
org.kuali.student.common.util.ExceptionMappingAdvice
- All Implemented Interfaces:
- org.aopalliance.aop.Advice, AfterAdvice, ThrowsAdvice, Ordered
public class ExceptionMappingAdvice
- extends Object
- implements ThrowsAdvice, Ordered
- Author:
- Daniel Epstein
Use this Advice to map one exception to another for use when other
advice eats your runtime exceptions outside of your code. This happens in
Transactions when commit is not called until outside of your DAO
layer.
Set the property "exceptionMapping" as a map that maps an exception class to
your own exception class
Remember that aspect order is important and that this bean will always be
order "500"
Example:
<tx:annotation-driven transaction-manager="JtaTxManager" order="1000"/>
lt;bean id="mapExceptionAdvisor"
class="org.myfoo.ExceptionMappingAdvice">
<property name="exceptionMapping">
<map>
<entry key="javax.persistence.EntityExistsException"
value="org.myfoo.exceptions.AlreadyExistsException" />
</map>
</property>
lt;/bean>
lt;aop:config>
<aop:aspect id="dataAccessToBusinessException"
ref="mapExceptionAdvisor">
<aop:after-throwing
pointcut="execution(* org.myfoo.service.*.*(..))"
method="afterThrowing" throwing="ex" />
</aop:aspect>
lt;/aop:config>
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
order
private int order
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
exceptionMapping
private Map<Class<? extends Exception>,Class<? extends Exception>> exceptionMapping
defaultException
private Class<? extends Exception> defaultException
logger
final Logger logger
ExceptionMappingAdvice
public ExceptionMappingAdvice()
afterThrowing
public void afterThrowing(Exception ex)
throws Exception
- This method will use the real exception thrown and look up the exception
that should be thrown
- Parameters:
ex
-
- Throws:
Exception
getOrder
public int getOrder()
- Specified by:
getOrder
in interface Ordered
setOrder
public void setOrder(int order)
- Parameters:
order
- the order to set
getExceptionMapping
public Map<Class<? extends Exception>,Class<? extends Exception>> getExceptionMapping()
- Returns:
- the exceptionMapping
setExceptionMapping
public void setExceptionMapping(Map<Class<? extends Exception>,Class<? extends Exception>> exceptionMapping)
- Parameters:
exceptionMapping
- the exceptionMapping to set
getDefaultException
public Class<? extends Exception> getDefaultException()
- Returns:
- the defaultException
setDefaultException
public void setDefaultException(Class<? extends Exception> defaultException)
- Parameters:
defaultException
- the defaultException to set
Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.