<div dir="ltr"><div dir="ltr">Em qui., 1 de jun. de 2023 às 18:27, Attila Kelemen <<a href="mailto:attila.kelemen85@gmail.com">attila.kelemen85@gmail.com</a>> escreveu:<br></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>I don't understand this problem. What is this code that incorrectly rebound the factory to some inappropriate value? Why does this code have this power? There is an intuition here about DI frameworks that I also don't understand: that factory clients don't want the new-like operation to react to the actually current context, but must react to some previously-current-at-that-time context. Is this really how standard DI works? I would expect that, if my application updates the current context somehow, and then calls into a new-like operation, this call must be affect by the changes I just applied.</div></div></blockquote><div><br></div><div>Standard DI frameworks do not need to concern themselves with this since they do not even know about SV. However, in some abstract sense they do work this way (at least some do). For example, you can organize Spring's `ApplicationContext` instances into a tree. In which case a bean in the parent `ApplicationContext` will not see the beans in a child `ApplicationContext`. However, note that an SV based DI framework would use the SV bindings as its "ApplicationContext" (`ScopedValue.Snapshot` essentially). So, for such a framework it is an essential feature (if you want parent child relationships, which you often need).</div></div></div></blockquote><div><br></div><div>But this is a cross thread relationship, right? The scoping in this case is transversal to lexical scoping or thread scoping. A bean that is bound to some sub-context of the application context, is bound during a time that is defined by the application life cycle, not by some call chain active in some thread. Why would one implement all this inside ScopedValue?</div></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Pedro Lamarão</div></div></div></div>