首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

spring札记

2012-08-26 
spring笔记常见Pointcout1.NameMatchMethodPointcutNameMatchMethodPointcut pointcut new NameMatchMeth

spring笔记
常见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
@ClassLevelAnnotationpublic 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




热点排行