1 Reply Latest reply on Jan 20, 2009 2:51 PM by cpopetz

    Bijection question: @IN(create=true)

    mpssantos.mpssantos.gmail.com

      Hello there!!


      I have a question about bijection. I'm getting in a seam project and a found the follow variable definition:


      '
      @IN(create=true)
      protected PontonTrasmission pontonTransmission
      '


      But PontonTrasmission is an Interface!! How does Seam knows what class to instanciate?


      Thanks a lot!


      Melhores cumprimentos / Best regards


      Marco Santos


        • 1. Re: Bijection question: @IN(create=true)
          cpopetz

          The binding is by name only, not by class.  Seam looks for an object in the relevant context named 'pontonTransmission.'  If it doesn't find one, it looks for a component registered (either through the @Name annotation or through components.xml) with the name 'pontonTransmission' and instantiates that class.  Since only non-abstract classes can be registered, it knows exactly which class to instantiate.  It then puts that result in the relevant context (unless it's stateless), and sets the injected field with the result as well.  If the registered class for the name 'pontonTransmission' doesn't implement PontonTransmission, you'll get a ClassCastException at runtime when the injection occurs.


          (There are possible complications to that scenario, e.g. you might have a @Factory for the name 'pontenTransmission' instead.  But in the general case, the above description applies.)