import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.Interceptor;
import jakarta.interceptor.InvocationContext;
@Interceptor
@Priority(Interceptor.Priority.APPLICATION - 1)
public class CustomInterceptor extends ParentInterceptor {
@Override
@AroundInvoke
public Object checkSecurity(InvocationContext ctx) throws Exception {
// Custom logic to determine whether to skip the parent interceptor
if (shouldSkip()) {
return ctx.proceed(); // This still calls the parent intercptor
}
// Call the parent interceptor's logic if not skipping
return super.checkSecurity(ctx);
}
private boolean shouldSkip() {
return true; // Example condition
}
}
@Interceptor
@Priority(Interceptor.Priority.APPLICATION) // Default priority
public class ParentInterceptor {
@AroundInvoke
public Object checkSecurity(InvocationContext ctx) throws Exception {
// Logic for the parent interceptor
return ctx.proceed();
}
}
< /code>
Вопросы: < /p>
- Можно ли пропустить вызов метода родительского перехватчика (Super.CheckSecurity (CTX)) в этом сценарии? Такие сценарии в цепях перехватчиков Java EE?
Подробнее здесь: https://stackoverflow.com/questions/797 ... in-java-ee