5 Replies Latest reply on Feb 13, 2007 1:55 AM by Gavin King

    Constructor versus @Create annotation

    Girish M Newbie

      Following is my current setup

      
      public abstract Foo {
      
      @In
      protected FooComp1 fooComp1;
      protected Foo foo;
      
      protected void init() {
       if (fooComp1 != null) {
       foo = "injection works";
       }
      }
      
      public class FooImpl1 {
      
       public Foo() {
       init();
       }
      
      }
      
      public class FooImpl2 {
      
       public Foo() {
       }
      
       @Create
       public void initchild() {
       init();
       }
      
      }
      
      


      FooImpl1 and FooImpl2 are components which I define in the className.component.xml files with auto-create=true.

      The interesting part is that when I create an instance of FooImpl2 injection works fine but in FooImpl1 (where my constructor calls init()) injection does not take place.

      Can anyone explain why this is the case?