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


> 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?

Thought about it as well. Definitely has to be after CDI container bootstrap. You cannot even look up beans up until very late in portable extension lifecycle.

> 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.

Yea, was thinking the same, there is no other way around it.


One more notable thing - the method execution might spawn a new @Dependent bean (as a parameter of the method) - what do we do with that?
Technically this dependent bean should be scoped to the bean that it is dependent on (the bean to which the executable method belongs), but is that expected? It would mean the same instance would then be reused for several invocations up until the calling bean instance is destroyed.

On Wed, Jun 30, 2021 at 10:20 AM Ladislav Thon <lthon@xxxxxxxxxx> wrote:
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
_______________________________________________
cdi-dev mailing list
cdi-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdi-dev

Back to the top