AOP切入點表達我有一種情況是這樣..特定批註的變量
自定義註釋定義...
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface CacheMe{
String node();
}
用戶詳細信息類...
class User {
String name;
String ssn;
}
而且以「User」對象作爲變量並使用@CacheMe註釋的類
Class Test{
@CacheMe(node="user")
User user;
public User getUser(Long id){
if(user != null){
user = someImplementingClass.getUserDetails(id);
}
....
.....
}
}
當「用戶」對象驗證爲空或訪問用戶對象時,我需要切入點表達式。 我正在使用基於Spring架構的AOP。
謝謝你的時間。
Spring的AOP僅限於方法。它不能攔截字段訪問。 –
Sotirios感謝您的快速回復。如果不是春季AOP,還有其他建議嗎? – joe4java
AspectJ應該支持這一點。 –