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

    Type-safe DI in 299

    asookazian

      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.

        • 1. Re: Type-safe DI in 299
          gavin.king

          So I still don't understand what type-safe DI means exactly

          It means not referring to beans by string-based names that can't be validated by the compiler.

          • 2. Re: Type-safe DI in 299
            nickarls

            I think the nice thing about 299/Weld is that you don't need to use that many annotations when you get started. I'm sure in the beginning you will get by nicely by sticking @*Scoped, @Named and @Inject on/in classes. After a while you will get a I'm sure there is a (better) way of..., then you go read the RefDoc and most probably will find it...

            • 3. Re: Type-safe DI in 299
              asookazian

              Gavin King wrote on Nov 10, 2009 19:59:


              So I still don't understand what type-safe DI means exactly

              It means not referring to beans by string-based names that can't be validated by the compiler.


              Ok, thx.  Good idea.  Is anybody compiling a FAQ on Weld/299?

              • 4. Re: Type-safe DI in 299
                nickarls

                The reference docs (last updated by Dan Allen) is a good place to start, it will be in the distro or you could take it down and build it yourself from http://anonsvn.jboss.org/repos/weld/doc/trunk/reference/