Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdi-dev] [External] : CDI Meeting 29/06/2021

On Tue, Jun 29, 2021 at 8:48 PM Tomas Langer <tomas.langer@xxxxxxxxxx> wrote:
- Executable methods in CDI: I have created the example showing how it could be used: https://github.com/tomas-langer/cdi-exec-methods

Thanks!

From what you said on the call yesterday, I thought that invoke() takes no parameters, but here, it takes the instance on which the method should be invoked. I thought that the instance, similarly to the parameters, would be looked up from the CDI container. Would that make [more] sense?

Also, I'm not quite sure what the `Executable.process` attribute means, could you please elaborate on that?

All in all it seems like a great idea.

I know Matěj mentioned a couple of things that probably deserve explicit treatment. Here's my take on it -- in general, we should do what CDI already does in similar cases.

- What contexts are active during the method invocation? I'd expect the usual CDI rules for context propagation to apply, and nothing more (or less). This may lead to `ContextNotActiveException` when e.g. one parameter of the bound method is `@RequestScoped` and the request context is not active when `boundMethod.invoke()` is called -- but that's nothing unusual.
- Assuming that `boundMethod.invoke()` takes no parameter and looks up the instance from the CDI container, what happens when the bean is `@Dependent`? I'd expect the usual CDI rules for calling producer or observer methods on dependent beans: the bean instance is created for that single invocation and is destroyed immediately after the invocation finishes.
- When can the bound method be invoked? I'd probably expect something like "after the application is deployed", so perhaps forbid that during Portable Extension execution -- but maybe the `process` attribute has a meaning here?

(Yea sorry, I started calling it "bound methods", as that seems a bit more appropriate than "executable methods". All methods are executable :-) )

LT

Back to the top