Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [interceptors-dev] Multiple @AroundInvoke methods in the same interceptor class?

I think this is outside the spec, but I actually don't think it's a bad feature.

The real trick is sensible rules around ordering so it could actually be tested in a JVM-independent way.


-- 
David Blevins
http://twitter.com/dblevins
http://www.tomitribe.com

On Apr 26, 2021, at 9:59 PM, Laird Nelson <ljnelson@xxxxxxxxx> wrote:

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");
  return ic.proceed();
}

…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
_______________________________________________
interceptors-dev mailing list
interceptors-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/interceptors-dev


Back to the top