[cdi-dev] inheritance of cdi scopes

Romain Manni-Bucau rmannibucau at gmail.com
Sun Mar 6 09:31:35 EST 2016


Hi guys,

spoke on concurrency utilities about the ability to inherit a cdi scope.
Idea is to follow request scope more than cdi spec allows. First thought it
was a concurrency utilities thing but Reza mentionned can be a CDI one so
here it is.

Sample:
In a servlet i get MyBean which is @RequestScoped, I do some set on it. The
i go async (AsyncContext) and trigger a task in another thread. It would be
neat - and mandatory in some case by the loose coupling nature of CDI - to
get the *same* MyBean *instance* in this thread. With a direct dependency
you can easily use message passing pattern - but you loose the loose
coupling cause you need to know until which level you unwrap, think t
principal case which has 2-3 proxies!. However in practice you have a lot
of undirect dependencies, in particular with enterprise concerns (auditing,
security...) so you can't really do it easily/naturally.

Bonus:
One very verbose way is to be able to kind of push/pop an existing context
in a thread - wrappers doing it on a Runnable/Consumer/Function/... would
be neat.

Question:
Would CDI handle it in 2.0?

Side note: this is really about the fact to reuse a "context context" (its
current instances map) in another thread the more transparently possible
and match the user vision more than a technical question for now.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20160306/9d7810f1/attachment-0001.html 


More information about the cdi-dev mailing list