spring札记
spring笔记
常见Pointcout
1.NameMatchMethodPointcut
2.JdkRegexpMethodPointcut、Perl5RegexpMethodPointcut
3.AnnotationMatchingPointcut
只匹配Class
或者用静态方法
只匹配Method
或者用静态方法
匹配Class及Method
4.ComposablePointcut
5.定制Pointcut
继承StaticMethodMatcherPointcut
继承DynamicMethodMatcherPointcut
常见Pointcout
1.NameMatchMethodPointcut
NameMatchMethodPointcut pointcut =new NameMatchMethodPointcut(); pointcut.setMappedName("matches"); //或多个方法 pointcut.setMappedNames(new String[]{"matches","isRuntime"});
2.JdkRegexpMethodPointcut、Perl5RegexpMethodPointcut
JdkRegexpMethodPointcut pointcut=new JdkRegexpMethodPointcut(); pointcut.setPattern(".*match.*"); //或者 pointcut.setPatterns(new String[](".*match.*",".*matches"});
3.AnnotationMatchingPointcut
@ClassLevelAnnotation public class GenericTargetObject{ @MethodLevelAnnotation public void method1(){....}; public void method2(){....}; }
只匹配Class
AnnotationMatchingPointcut pointcut=new AnnotationMatchingPointcut( ClassLevelAnnotation.class);
或者用静态方法
AnnotationMatchingPointcut pointcut=AnnotationMatchingPointcut.forClassAnnotation( ClassLevelAnnotation.class);
只匹配Method
AnnotationMatchingPointcut pointcut=new AnnotationMatchingPointcut( MethodLevelAnnotation.class);
或者用静态方法
AnnotationMatchingPointcut pointcut=AnnotationMatchingPointcut.forMethodAnnotation( MethodLevelAnnotation.class);
匹配Class及Method
AnnotationMatchingPointcut pointcut=new AnnotationMatchingPointcut( ClassLevelAnnotation.class,MethodLevelAnnotation.class);
4.ComposablePointcut
5.定制Pointcut
继承StaticMethodMatcherPointcut
继承DynamicMethodMatcherPointcut