1 Reply Latest reply on Jun 23, 2008 3:15 PM by Tom Goring

    Injection creates two object instances

    Joerg Schneider Newbie

      Hi,


      may be a bit of a dumb question, but I found out that while injecting one seam component, actually two object instances are created. I played around with the helloworld seam remoting example and created a new component HelloModel that gets injected into HelloAction like this :


        @In(create = true, value = helloModel)
        private HelloModel model = null;


      Inside the HelloModel components constructor, I've placed a log statement like this :


        public HelloModel() {
           log.info(HelloModel() instantiated + this.hashCode());
        }


      If I now access the helloworld example, I can see the following output in the logs :


      2008-06-22 10:05:44,339 INFO  [org.jboss.seam.example.remoting.HelloAction] HelloAction() instantiated[10455745]


      2008-06-22 10:07:25,361 INFO  [org.jboss.seam.example.remoting.HelloModel] HelloModel() instantiated[8619693]


      2008-06-22 10:07:25,391 INFO  [org.jboss.seam.example.remoting.HelloModel] HelloModel() instantiated[10967064]




      Anyone any idea why injection creates two instances of the HelloModel component ? I'm not saying that this necessarily is a bug, it's certainly that I don't understand the injection mechanism here - anyway, I'd love to understand what's happening here and why this is needed.


      Any help appreciated :-)


      Cheers, Joerg.