Aspectj 注解
2021-06-16 23:06
标签:encoding case instance throw ace cas iso www. oid 1.aspectj 注解 配置文件 单测 Aspectj 注解 标签:encoding case instance throw ace cas iso www. oid 原文地址:http://www.cnblogs.com/shiwz/p/7267945.htmlpublic interface ISomeService {
public void doSome();
public String doSecont();
}
public class SomeService implements ISomeService {
//核心业务
public void doSome() {
System.out.println("拜托别让他一番努力换来是奢求!");
}
public String doSecont() {
System.out.println("++===================Secont 天天新网友====================++");
return "doSecont";
}
}
public class MySecont {
//前置增强
@Before(value = "execution(* *..spring12aop_note.*.*(..))")
public void myBefore(){
System.out.println("===我是前置增强内容======");
}
//后置增强
//@AfterReturning(value = "execution(* *..spring12aop_note.*.*(..))")
public void myAferReturing(){
System.out.println("===我是after后置增强内容======");
}
//环绕增强
//@Around(value = "execution(* *..spring12aop_note.*.*(..))")
public Object myAround(ProceedingJoinPoint proceed) throws Throwable {
System.out.println("===我是环绕前内容======");
Object result = proceed.proceed();
System.out.println("===我是环绕后内容======");
if (result!=null){
String str=(String)result;
return str.toUpperCase();
}else{
return null;
}
}
}
"1.0" encoding="UTF-8"?>
//1.aspectj 注解
@Test
public void test05(){
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext09_aop09_note.xml");
ISomeService service = (ISomeService) ctx.getBean("someService");
service.doSome();
service.doSecont();
}