panda.ioc.aop.config.impl.AnnotationAopConfigration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of panda-glue Show documentation
Show all versions of panda-glue Show documentation
Panda Glue is a ASM/AOP module of the Panda Framework.
The newest version!
package panda.ioc.aop.config.impl;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import panda.aop.MethodInterceptor;
import panda.aop.MethodMatcher;
import panda.aop.matcher.SimpleMethodMatcher;
import panda.ioc.Ioc;
import panda.ioc.aop.Aop;
import panda.ioc.aop.config.AopConfigration;
import panda.ioc.aop.config.InterceptorPair;
import panda.lang.reflect.Methods;
/**
* 通过扫描@Aop标注过的Method判断需要拦截哪些方法
*/
public class AnnotationAopConfigration implements AopConfigration {
public List getInterceptorPairList(Ioc ioc, Class> clazz) {
List aops = this.getAopMethod(clazz);
List ipList = new ArrayList();
if (aops.size() < 1) {
return ipList;
}
for (Method m : aops) {
MethodMatcher mm = new SimpleMethodMatcher(m);
for (String nm : m.getAnnotation(Aop.class).value())
ipList.add(new InterceptorPair(ioc.get(MethodInterceptor.class, nm), mm));
}
return ipList;
}
private List getAopMethod(Class> cls) {
List aops = new LinkedList();
for (Method m : Methods.getDeclaredMethods(cls)) {
if (null != m.getAnnotation(Aop.class)) {
int modify = m.getModifiers();
if (Modifier.isAbstract(modify)
|| Modifier.isFinal(modify)
|| Modifier.isPrivate(modify)
|| Modifier.isStatic(modify)) {
continue;
}
aops.add(m);
}
}
return aops;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy