org.springframework.dao.annotation
Class PersistenceExceptionTranslationAdvisor

java.lang.Object
  extended by org.springframework.aop.support.AbstractPointcutAdvisor
      extended by org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor
All Implemented Interfaces:
java.io.Serializable, Advisor, PointcutAdvisor, Ordered

public class PersistenceExceptionTranslationAdvisor
extends AbstractPointcutAdvisor

Spring AOP exception translation aspect for use at Repository or DAO layer level. Translates native persistence exceptions into Spring's DataAccessException hierarchy, based on a given PersistenceExceptionTranslator.

Since:
2.0
Author:
Rod Johnson, Juergen Hoeller
See Also:
DataAccessException, PersistenceExceptionTranslator, Serialized Form

Field Summary
private  PersistenceExceptionTranslationInterceptor advice
           
private  AnnotationMatchingPointcut pointcut
           
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
PersistenceExceptionTranslationAdvisor(ListableBeanFactory beanFactory, java.lang.Class<? extends java.lang.annotation.Annotation> repositoryAnnotationType)
          Create a new PersistenceExceptionTranslationAdvisor.
PersistenceExceptionTranslationAdvisor(PersistenceExceptionTranslator persistenceExceptionTranslator, java.lang.Class<? extends java.lang.annotation.Annotation> repositoryAnnotationType)
          Create a new PersistenceExceptionTranslationAdvisor.
 
Method Summary
 Advice getAdvice()
          Return the advice part of this aspect.
 Pointcut getPointcut()
          Get the Pointcut that drives this advisor.
 
Methods inherited from class org.springframework.aop.support.AbstractPointcutAdvisor
equals, getOrder, hashCode, isPerInstance, setOrder
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

advice

private final PersistenceExceptionTranslationInterceptor advice

pointcut

private final AnnotationMatchingPointcut pointcut
Constructor Detail

PersistenceExceptionTranslationAdvisor

public PersistenceExceptionTranslationAdvisor(PersistenceExceptionTranslator persistenceExceptionTranslator,
                                              java.lang.Class<? extends java.lang.annotation.Annotation> repositoryAnnotationType)
Create a new PersistenceExceptionTranslationAdvisor.

Parameters:
persistenceExceptionTranslator - the PersistenceExceptionTranslator to use
repositoryAnnotationType - the annotation type to check for

PersistenceExceptionTranslationAdvisor

PersistenceExceptionTranslationAdvisor(ListableBeanFactory beanFactory,
                                       java.lang.Class<? extends java.lang.annotation.Annotation> repositoryAnnotationType)
Create a new PersistenceExceptionTranslationAdvisor.

Parameters:
beanFactory - the ListableBeanFactory to obtaining all PersistenceExceptionTranslators from
repositoryAnnotationType - the annotation type to check for
Method Detail

getAdvice

public Advice getAdvice()
Description copied from interface: Advisor
Return the advice part of this aspect. An advice may be an interceptor, a before advice, a throws advice, etc.

Returns:
the advice that should apply if the pointcut matches
See Also:
org.aopalliance.intercept.MethodInterceptor, BeforeAdvice, ThrowsAdvice, AfterReturningAdvice

getPointcut

public Pointcut getPointcut()
Description copied from interface: PointcutAdvisor
Get the Pointcut that drives this advisor.