blob: be0f66b69f07cacaf7c0ea2ac07aff270ba09414 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
public class Code4 {
public Object createBean(String name) {
return 37;
}
public static void main(String[] args) {
Code4 factory = new Code4();
System.out.println("Code4.main returned from call to createBean "+factory.createBean("s"));
}
}
@Aspect
class AfterReturningTestAspect {
@AfterReturning(pointcut = "call(Object createBean(String)) && args(beanName)", returning = "bean")
public void afterReturningCreateBean(Object bean, String beanName) throws Throwable {
System.out.println("afterReturningCreateBean advice input='" + beanName + "' ret=" + bean);
}
/*
@AfterReturning(pointcut = "call(Object aspects.SimpleAfterReturningTest.createBean(String)) " +
"&& args(beanName)", returning = "bean")
public void afterReturningCreateBean(JoinPoint joinPoint, Object bean,
String beanName) throws Throwable {
System.out.println("afterReturningCreateBean(JoinPoint joinPoint,
Object bean, String beanName) for '" + beanName + "'=" + bean);
}
*/
}
|