シナリオ
2 つのメソッドの同じ EJB 内の 2 つの同じインターセプター:
...
@Interceptors(PerformanceAuditor.class)
public Date refreshIfNecessary() {
// there is also the PerformanceAuditor-Interceptor on this method
Pair<Date,String> lastImportDate = importDbDAO.findLatestImportLog();
someContainer.reloadIfNecessary(lastImportDate);
return lastImportDate.getLeft();
}
@Interceptors(PerformanceAuditor.class)
public boolean checkAndRefreshIfNecessary(final Date importDate) {
Date lastImportDate = refreshIfNecessary();
return lastImportDate.after(importDate);
}
...
次に、この EJB のメソッドを外部から呼び出して、次の結果を得ます。
- refreshIfNecessary() の呼び出し-> PerformanceAuditor が2 回呼び出されます
- checkAndRefreshIfNecessary() の呼び出し-> PerformanceAuditor も2 回呼び出されます。(ただし、ネスト レベルが 1 つ増えるため、3 回と予想されます!)
ここで何が起こっているのでしょうか?