The specification
says, in part:
Up to one interceptor method of each interceptor method type may be defined in the same class. More specifically, up to one around-invoke interceptor method, one around-timeout interceptor method, and one lifecycle callback interceptor method for each of the different lifecycle events may be defined in the same class.
I noticed in Weld (one of I'm sure many possible Jakarta Interceptors implementations) that if I have, in the same class:
@AroundInvoke // 1
private Object frobnicate(final InvocationContext ic) throws Exception {
System.out.println("*** frobnicate");
return ic.proceed();
}
@AroundInvoke // 2...er, isn't this a problem?
private Object caturgiate(final InvocationContext ic) throws Exception {
System.out.println("*** caturgiate");
…in the same class, i.e. two methods, not just one, annotated with @AroundInvoke, and if I have everything else set up properly for interception, that both interceptor methods are invoked and everything proceeds normally. This surprised me.
It seems to me the specification's intent is that this state of affairs should result in some kind of deployment or definition error instead.
Does the specification intend for this state of affairs to be expressly prohibited? Or am I misreading what seems like a pretty clear prohibition?
Best,
Laird