package ssh.lxl.aop;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import ssh.lxl.util.MyUtil;
public class LogBean
{
Logger log=LogManager.getLogger(LogBean.class);
/**
* 环绕通知
* @param pjp
* @return
* @throws Throwable
*/
public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable
{
String className=pjp.getTarget().getClass().getName();
String methodName=pjp.getSignature().getName();
log.warn(MyUtil.getCurrentDate()+"类"+className+",开始执行,方法:"+methodName);
long startTime=System.currentTimeMillis();
Object retVal=null;
try {
retVal=pjp.proceed();
log.warn(MyUtil.getCurrentDate()+"类"+className+",执行结束,方法:"+methodName);
} catch (RuntimeException e) {
e.printStackTrace();
log.warn(MyUtil.getCurrentDate()+"类"+className+",执行出错,方法:"+methodName);
}
return retVal;
}
}