1 16 17 package org.springframework.dao.annotation; 18 19 import java.lang.annotation.Annotation ; 20 21 import org.aopalliance.aop.Advice; 22 23 import org.springframework.aop.Pointcut; 24 import org.springframework.aop.support.AbstractPointcutAdvisor; 25 import org.springframework.aop.support.annotation.AnnotationMatchingPointcut; 26 import org.springframework.beans.factory.ListableBeanFactory; 27 import org.springframework.dao.support.PersistenceExceptionTranslationInterceptor; 28 import org.springframework.dao.support.PersistenceExceptionTranslator; 29 30 41 public class PersistenceExceptionTranslationAdvisor extends AbstractPointcutAdvisor { 42 43 private final PersistenceExceptionTranslationInterceptor advice; 44 45 private final AnnotationMatchingPointcut pointcut; 46 47 48 53 public PersistenceExceptionTranslationAdvisor( 54 PersistenceExceptionTranslator persistenceExceptionTranslator, 55 Class <? extends Annotation > repositoryAnnotationType) { 56 57 this.advice = new PersistenceExceptionTranslationInterceptor(persistenceExceptionTranslator); 58 this.pointcut = new AnnotationMatchingPointcut(repositoryAnnotationType); 59 } 60 61 67 PersistenceExceptionTranslationAdvisor( 68 ListableBeanFactory beanFactory, Class <? extends Annotation > repositoryAnnotationType) { 69 70 this.advice = new PersistenceExceptionTranslationInterceptor(beanFactory); 71 this.pointcut = new AnnotationMatchingPointcut(repositoryAnnotationType); 72 } 73 74 75 public Advice getAdvice() { 76 return this.advice; 77 } 78 79 public Pointcut getPointcut() { 80 return this.pointcut; 81 } 82 83 } 84 | Popular Tags |