@Test public void testGetAopProxy3() throws Exception { AopProxyUtil aopProxyUtil = new AopProxyUtil(); AroundAdvice aroundAdvice = new AroundAdviceImpl01(); Pointcut pointcut = new Pointcut(); pointcut.setName("xx"); pointcut.setExpression("execution(* *.add*(..))"); PointcutAndAdvice paa = new PointcutAndAdvice(pointcut, aroundAdvice); AroundAdvice aroundAdvice2 = new AroundAdviceImpl02(); Pointcut pointcut2 = new Pointcut(); pointcut2.setName("yy"); pointcut2.setExpression("execution(* *.add*(..))"); PointcutAndAdvice paa2 = new PointcutAndAdvice(pointcut2, aroundAdvice2); aopProxyUtil.addPointcutAndAdvice(paa); aopProxyUtil.addPointcutAndAdvice(paa2); UserService student = new UserServiceImpl(); UserService proxy = aopProxyUtil.getAopProxy(student); proxy.add(); proxy.find(); }
@Test public void testGetAopProxy4() throws Exception { AopProxyUtil aopProxyUtil = new AopProxyUtil(); BeforeAdvice beforeAdvice = new BeforeAdviceImpl01(); Pointcut pointcut = new Pointcut(); pointcut.setName("xx"); pointcut.setExpression("execution(* *.*(..))"); PointcutAndAdvice paa = new PointcutAndAdvice(pointcut, beforeAdvice); AroundAdvice aroundAdvice2 = new AroundAdviceImpl02(); Pointcut pointcut2 = new Pointcut(); pointcut2.setName("yy"); pointcut2.setExpression("execution(* *.*(..))"); PointcutAndAdvice paa2 = new PointcutAndAdvice(pointcut2, aroundAdvice2); ExceptionAdvice exceptionAdvice = new ExceptionAdviceImpl01(); Pointcut pointcut3 = new Pointcut(); pointcut3.setName("2yy"); pointcut3.setExpression("execution(* *.*(..))"); PointcutAndAdvice paa3 = new PointcutAndAdvice(pointcut3, exceptionAdvice); ExceptionAdvice exceptionAdvice2 = new ExceptionAdviceImpl02(); Pointcut pointcut4 = new Pointcut(); pointcut4.setName("4yy"); pointcut4.setExpression("execution(* *.*(..))"); PointcutAndAdvice paa4 = new PointcutAndAdvice(pointcut4, exceptionAdvice2); aopProxyUtil.addPointcutAndAdvice(paa); aopProxyUtil.addPointcutAndAdvice(paa2); aopProxyUtil.addPointcutAndAdvice(paa3); aopProxyUtil.addPointcutAndAdvice(paa4); UserService student = new UserServiceImpl(); UserService proxy = aopProxyUtil.getAopProxy(student); // proxy.add(); // proxy.find(); proxy.delete(); }