Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdi-dev] Open question regarding @AroundInvoke on target classes in CDI Lite

Hello,

there have been some discussions around what interception is supported in Lite and a sort of agreement was reached over the course of time with a notable exception of `@AroundInvoke` declared on a bean class.

Here is a link to a table summarizing what was generally agreed upon[1].
In short, all kinds of lifecycle callbacks are supported, but we want to only support interceptors declared with bindings plus priority as means on enablement.

The open question is @AroundInvoke declared on target class which looks something like this:

@ApplicationScoped
public class Foo { // a standard bean class declaration

  @AroundInvoke
  public Object intercept2(InvocationContext ctx) throws Exception {
    return ctx.proceed(); // interceptor declaration inside bean
  }

  public void ping(){
    doSomething(); // some bean method that would be intercepted
  }
}

The above is a very rarely used case of interception which the interceptors specification only briefly mentions in this section[2].
It brings no new functionality as such behavior can be easily achieved via standard java means. Alternatively, you can just declare a standard interceptor with binding and around invoke method on it. See this comment[3] by Martin for details.

Therefore, my suggestion is to drop this feature from the initial version of CDI Lite. We can always revisit if we see this feature is requested or even required by some use case which we haven't thought of so far. Thoughts, agreements/disagreements, ideas are welcome :-)

Regards
Matej

___________________________________________
[1] https://github.com/eclipse-ee4j/cdi-tck/issues/262#issuecomment-906496780
[2] https://jakarta.ee/specifications/interceptors/2.0/interceptors-spec-2.0.html#business_method_interceptor_methods
[3] https://github.com/eclipse-ee4j/cdi-tck/issues/262#issuecomment-907039527

Back to the top