Reputation: 23
I am writing a common component for team members.So I write an aspect with Spring-aop.Ideally,what others only need to do is defining an point-cut expression in .properties or others.But I find it is a bit difficult。
I have searched some information in stackoverflow,but i'm confused。
1、the value of @Pointcut
:Attribute value must be constant
,does this mean the value must be compile-time constant and can't use ${}
? If it does,why? the Spring aop is based on LTW why the pointcut expression must be constant?
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface Pointcut {
String value() default "";
String argNames() default "";
}
2、Can I read an external constant as the compile-time constant may like follow?
private static final String a;
static{
String b = "xx";// read external file
a = b;
}
@Pointcut(a) //not work
public void pointcut(){}
3、We use entire Annotation way without xml,So I can't let others define an another aop.xml
,though I know it will work.
4、I have found a indirect way is
public abstract void pointcut();
and others to implement this abstract way,but not very elegant。
4、Should I implement it in a runtime-way? (But I have no idea)
5、Any suggestion will help me a lot!
Upvotes: 0
Views: 321