5 Replies Latest reply on Apr 17, 2009 4:41 AM by joblini

    global injection config possible?

    gonorrhea

      is it possible to configure your Seam app (e.g. in the components.xml) to inject specified objects/instances into, say all SFSB's?


      e.g. why do we have to manually hand-code the following into every SFSB or JavaBean that is conversation-scoped?


      @In
           private EntityManager entityManager;
           
           @Logger
           private Log log;



      We should be able to config once globally (like we can do now with a4j:queue global default queue in web.xml) and override as required in the components.


      Any votes??

        • 1. Re: global injection config possible?
          gonorrhea

          well then the compiler would complain I guess, but you Seam core dev geniuses should be able to figure this one out, no???

          • 2. Re: global injection config possible?
            swd847

            Create a utility class with those injections and inherit from it.

            • 3. Re: global injection config possible?
              gonorrhea

              which means every class must inherit from the utility class.


              fully automatic after config'd once is better (like the RF a4j:queue global default queue).  but thanks, that would work (I take it you mean to have the SFSB component extend the utility class?)...


              there are certain dependencies that should always be available by default for just about any Seam component...

              • 4. Re: global injection config possible?
                swd847

                To do this you would need to add a code generation step before the code is compiled. This would also mean that you loose all auto complete and IDE error checking functionality, and you would probably also need to add an annotation to the class to tell the code generator which classes to enhance. For the sake of a few lines I don't think its worth the hassle.

                • 5. Re: global injection config possible?
                  joblini

                  We extend EntityController for components that require entityManager, logger, etc.


                  BTW, thanks for the hint regarding the global queue for A4J in web.xml.  I didn't realize that was possible.