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

Good pointer, but I think you are misreading it.
The 3rd case means that the producer method parameter (that is a dependent bean) is a dependent of the product of the producer method - of the bean it creates. In other words, that dependent bean will exist so long as does the bean created by given producer method.
Here is a TCK test that asserts this - https://github.com/eclipse-ee4j/cdi-tck/blob/master/impl/src/main/java/org/jboss/cdi/tck/tests/context/dependent/DependentContextTest.java#L391-L392

On Wed, Jun 30, 2021 at 11:49 AM Ladislav Thon <lthon@xxxxxxxxxx> wrote:
On Wed, Jun 30, 2021 at 11:39 AM Matej Novotny <manovotn@xxxxxxxxxx> wrote:
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.

I think CDI already defines this behavior for several other cases: https://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#dependent_objects What seems particularly similar is the 3rd case, where an instance of a `@Dependent` bean, which is injected into a producer method, is a dependent object of the bean instance that declares the producer method (if I understand correctly -- that sentence is a little hard to read :-) ).

LT
 

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