4 Replies Latest reply on Nov 10, 2009 8:33 PM by Nicklas Karlsson

    Type-safe DI in 299

    Arbi Sookazian Master

      The dependency injection framework is type-safe, meaning the registry is organized around Java types, not a flat namespace, which gives more power and flexibility for component assembly.

      http://www.caucho.com/resin/doc/resin-ioc.xtp


      So I still don't understand what type-safe DI means exactly (referring to the italicized part above).  What is the difference between 299 DI and Seam @In, for example, in terms of type-safety? 


      I just read 5.3. Typesafe resolution of 299 spec.


      How about explaining the differences between these two examples:


      //Weld example
      @SessionScoped 
      public class Login {
           @Inject Credentials credentials;
           @Inject @Users EntityManager userDatabase;
           ...
      }
      
      //Seam example
      @Scope(ScopeType.SESSION)
      @Name("login")
      public class Login {
           @In(required=false, create=true) Credentials credentials;
           @In EntityManager entityManager;
           ...
      }




      The @Inject annotation defined by the Dependency Injection for Java specification identifies an injected field which is
      initialized by the container when the bean is instantiated, or an initializer method which is called by the container after the
      bean is instantiated, with injected parameters.

      source: 1.3.1. JSF example


      does not state anything about dynamic or static injection.


      299 is definitely very interesting but I will say that even for a seasoned Seam developer the concepts (e.g. stereotypes) may be difficult to understand and thus learning curve involved.