Results 1 to 2 of 2

Thread: updating injections without proxying/aop

  1. #1

    Default updating injections without proxying/aop

    I have a scope defined to hold beans that change, sometimes quickly. Imagine a UI that has the concept of a current window. When the current window changes, the window object in the scope/parent context changes because the current window is set through another process and obviously, changes the scope.

    I want to inject the current window into a bean. Then when the current window changes, have that window injection updated inside my bean automatically. I know this is doable using a value holder concept or just have my bean access the context each time (which I want to avoid because it makes my bean aware of the spring framework), but is there a mechanism in spring that allows me to do this without AOP and proxying?

    The mechanism should work regardless of whether the changing object (the window) is in a scope or a parent context. Is there a "list of injections that were used for this bean" list that is accessible and usable to swap out a bean? Or a @Dynamic or @Autowired(dynamic=true) type capability?

  2. #2

    Default

    After looking at this, it seems that obtaining a list of non-construction injections (to replay them back when a value changes) is not easy. So the standard way of either using a hot swappable target source (or something equivalent), using a value model concept, or using a custom scope that looks for the proxied objects when aop:scope-proxy is used seems to be the answer.

    For me, the custom scope works best since it can provide an easy swap api (using a standard put method and the original object name) and as long as the items are in that scope and the scope-proxy was used, its easy to swap any object out dynamically and have the change show up in the originally injected object.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •