4 Replies Latest reply on Feb 12, 2007 10:14 PM by gmanwani

    Injection when using abstract parent class

    gmanwani

      I currently have an abstract base class

      public abstract AbstractFoo {
      init() {
      }
      }

      public Foo extends AbstractFoo {
      @In
      private SomeObj seamcomp1;

      public Foo() {
      init();
      }

      }

      When I create an object of Foo will seamcomp1 be initialized i.e would it have had it value injected?

        • 1. Re: Injection when using abstract parent class
          pmuir

          Please post using [ code ] tags. Assuming Foo is a seam component, bijection will take place on it and it's superclasses.

          • 2. Re: Injection when using abstract parent class
            gmanwani

            Sorry about the missing the code tags! My bad, here is my setup

            Foo is not really a Seam component but I make it available through the Seam manager pattern. SeamComp1 is a typical JavaBean seam component with Name and Scope(EVENT) annotations.

            
            public abstract AbstractFoo {
             @In
             private SeamComp1 seamcomp1;
            
             init() {
             seamcomp1.getSomething();
             }
            }
            
            public Foo extends AbstractFoo {
             public Foo() {
             init();
             }
            }
            
            @Name("foo")
            @Scope(EVENT)
            public class FooMgr {
             @Unwrap
             public Foo getFoo() {
             return new Foo();
             }
            }
            


            Hope my setup is clear.

            Thanks in advance for all the help!







            • 3. Re: Injection when using abstract parent class
              pmuir

              In this case seamcomp1 will never be bijected (you cannot use Seam to inject into something that isn't a Seam component).

              • 4. Re: Injection when using abstract parent class
                gmanwani

                I have made Foo a Seam component but I do not see the injection happening. On the contrary if I have an init() method in the derived class and apply the @Create annotation to it then the injection does take place.

                This looks like a bug to me.