2 Replies Latest reply on Jun 13, 2007 5:59 PM by y_zl

    Questions about injection and outjection

    y_zl

      1)When a method in a session bean is invoked, will Seam inject all the variables annotated by @IN or just inject the variables used by the being invoked method?

      2)When a Session Bean is injected as a facade, is it possible for the mthod in the session facade bean inject or outject varibales?

      3)Could an injected variable such as EntitManager "em" be passed to a POJO method as a parameter?

        • 1. Re: Questions about injection and outjection

          1 - yes
          2 - don't understand the question
          3 - We've talked about that, but as I recall the problem is that java doesn't store the parameter names (it does, but only as debug information). That means we can't get to the names to do injection in a way that is both simple and consistent with the rest of Seam. Given that you can have an EL method-binding like #{bean.doSomething(em)} now, it's generally not a big issue.

          • 2. Re: Questions about injection and outjection
            y_zl

            1) If the answer to question one is Yes, does it mean that it will inject non-relevant variables as well? Does it affect performance ?
            2) For question 2, If I have two session beans A and B. B is used as a session facade.

             @Stateless
             @Name("a")
             public Class A ...{
             @In B b;
             public String test1()
             {
             return b.test2("cccc");
             }
             }
            
             @Stateless
             @Name("b")
             public Class B ...{
             @In String s1;
             @Out String s2;
             public String test2(String s)
             {
             s2=s+"aaaa";
             return s+s1;
             }
             }


            is the above codes legal ? Could I get the variable named s2 outjected?

            3) For question 3, Could you give a simple example to demo that?

            For example
             @Stateless
             @Name("actionA")
             public class ActionA implents ActionAInf {
             @PersistenceContext
             private EntityManager em;
            
             public String methodA()
             {
             new Bean(em);
             }
             }

            How do I use the EL binding in this case?