title: CDI with unmanaged objects
body: <p>Suppose that I have two classes, first a class without any properties, fields or annotations:</p>
  
  <pre><code>public class B {}
  </code></pre>
  
  <p>And a class which gets B injected, like this:</p>
  
  <pre><code>public class A {
      @Inject
      private B b;
  
      public B getB() {
          return b;
      }
  }
  </code></pre>
  
  <p>Now class A is pretty useless until we use it, so there are two options:</p>
  
  <ul>
  <li>@Inject it</li>
  <li>Construct it manually, using the trusty "new A()"</li>
  </ul>
  
  <p>If A gets injected, CDI manages it and is kind enough to inject B which has the implicit scope of @Dependent. Cool, just what I want.</p>
  
  <p>However, if I manually construct A (let's say in a factory or a builder), CDI completely ignores my object and won't inject an object of type B. </p>
  
  <p>Example I'm talking about when it doesn't work, here object a will always remain null:</p>
  
  <pre><code>public class Builder {
      @Inject
      private A a;
  
      public static Builder ofTypeSomething() {
          // do some magic here
          return new Builder();
      }
  
      private Builder() {
          // and some more here
      }
  }
  </code></pre>
  
  <p>Why doesn't this work? </p>
  
  <p>Class A is a valid managed bean and has a valid scope, just like class B. Even if I add @Producer to the static method, it won't change anything (which is fine, cause the idea of the static method is to call it, not to inject Builder anywhere).</p>