3 Replies Latest reply on May 30, 2008 1:28 PM by pmuir

    Lazy injection

    adamw

      Hello,


      correct me if I'm wrong, but as I understand from what I've read in the manual and on the forum, bijection happens every time I invoke a method on a seam bean, that is, all fields with @In/@Out are written/read by reflection, yes?


      I don't know what are the experiences of other users, but in my applications I often use a pattern, where the majority of my beans are stateless beans, which have some other stateless beans injected, and occasionally a conversationally scoped bean.


      However, most methods of my stateless beans use only a subset of the injected beans - depending both on the method and on user data. That's why I started to wonder, if it wouldn't be reasonable to provide a lazy option for @In - that is, a bean would be searched in the contexts when a method on it would be invoked for the first time.


      There's also another problem, when invoking methods on seam beans when rendering a page, for example in a loop:



      <ui:repeat var="x" value="#{list}">
         #{myBean.myMethod(x)}
      </ui:repeat>




      Again, if I didn't miss something, bijection will happen every time myMethod is called, which in fact isn't really necessary, and in larger applications can make performance to decrease. So maybe it would be possible to inject proxies to the bean once, which would then, when invoked, search for the required bean in the contexts? That would save some writes of the fields. Of course, the search would happen only once on a method call, and after the method completes the state of the search should be reset. This still isn't the optimal performance, but I think it could do better then the current way. Or not? :)


      --
      Adam

        • 1. Re: Lazy injection
          pmuir

          There won't be any more major changes to the legacy seam core as the future core development will be web beans based.

          • 2. Re: Lazy injection
            adamw

            Hello,


            so any of this will be available in WebBeans? As far as I remember Guice, they inject only once - proxies - a bit of what I was writing here. But did this idea make it to WebBeans as well?


            Also, is there any future in Seam, or will I just have to migrate my app to WebBeans style (annotations etc) to keep up-2-date with the newest libs? :)


            --
            Adam

            • 3. Re: Lazy injection
              pmuir

              Read the spec, send feedback :-)