7 Replies Latest reply on Jun 2, 2006 12:08 PM by Emmanuel Bernard


    Peter Voringer Newbie


      is there alternative dynamic way to inject an EJB into another EJB?

      In my SFSB X i have an injected SFSB Y, so lifecycle and ExendedPersistenceContext are bound together like

      Y y;

      Problem is i have about 30 injected EJBs. It is very inefficient when X is created and all other EJBs are created and injected.

      Any hints?



        • 1. Re: @EJB
          Peter Voringer Newbie

          not possible? The solution not have to be pretty, because it's only one SFSB
          which is buried under other abstract layers. So it only has to work.



          • 2. Re: @EJB
            Emmanuel Bernard Master

            Why is it so slow?

            • 3. Re: @EJB
              Peter Voringer Newbie

              i think it is in my case.

              SFSB X is something like a Context (Application, Session, Request, Event) in Seam, so there will be a lot of them.

              Y is a single DAO (per Entity one DAO) and i would have to include all of them.

              Why i need this:

              I cannot work with my DAOs, because each DAO has it's own ExtendedPersistenceContext. So if i have a unit-of-work i have
              to use more than one of them and so the changes are not atomar
              anymore. So i have to bind the lifecycle and PersistenceContext
              of my DAOs with something like a Context SFSB (in the example X)
              but this only works, if the DAOs are injected via Container and not
              fetched via JNDI.
              Unfortunatelly i can not use Seam for my application,
              because Seam uses a SFSB per Use-Case and in my modular-application
              the use-cases can not be foreknown.
              So i need a very dynamic and abstract facade which give out persistent and not detached object.

              Very simple Problem, but no simple solution (not any yet).



              • 4. Re: @EJB
                Peter Voringer Newbie

                any hints or solutions?

                • 5. Re: @EJB
                  Carlo de Wolf Master

                  Lazy initialization?
                  It would require some JNDI calls though.

                  • 6. Re: @EJB
                    Peter Voringer Newbie

                    all relations are Lazy. For fetching via joines i have additional finder-methods in my DAOs.

                    All i want is a facade where i can get persistent (undetached) entities which are associated with one persistence-context.

                    If someone knows Liferay-Portal similar to their facade, but not with
                    the restriction of detached objects. I do not need a remote calls to the SFSBs, it is one JVM and one JBoss where Isolation is disabled.



                    • 7. Re: @EJB
                      Emmanuel Bernard Master

                      Yes JBoss probably should lazy initialize the session beans. Open a JIRA request