return null instead of DalNotFoundException

This commit is contained in:
Mengyi Zhou 2015-04-03 17:59:54 +08:00
parent e931cacafd
commit 293e62c524
2 changed files with 30 additions and 1 deletions

View file

@ -0,0 +1,28 @@
package com.ctrip.zeus.service.aop;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.unidal.dal.jdbc.DalNotFoundException;
/**
* Created by zhoumy on 2015/4/3.
*/
@Aspect
@Component
public class DalNotFoundAspect {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Around("execution(* com.ctrip.zeus..*Dao.*(..))")
public Object allowNullValue(ProceedingJoinPoint joinPoint) throws Throwable {
try {
return joinPoint.proceed();
} catch (DalNotFoundException ex) {
logger.info("Caught DalNotFoundException, return null instead.");
return null;
}
}
}

View file

@ -14,7 +14,8 @@
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">
<context:component-scan base-package="com.ctrip.zeus"/>
<aop:aspectj-autoproxy/>
<!-- use cglib -->
<aop:aspectj-autoproxy proxy-target-class="true"/>
<import resource="dao-beans.xml"/>
</beans>