title: How google guice works internally
body: <p>I was going through the google <code>guice</code> and then i thought about how it might be working.</p>
  
  <p>So This is my theory on how <code>property injector</code> might be working.    </p>
  
  <p><code>Guice</code> first wants us to create a <code>injector</code> and pass all the <code>binding</code> information to it.</p>
  
  <pre><code>Injector injector = Guice.createInjector(new BillingModule());
  </code></pre>
  
  <p>*code snippets from <a href="https://code.google.com/p/google-guice/wiki/GettingStarted" rel="nofollow noreferrer">google guice page</a></p>
  
  <p>OK at this point i can think that there is a class with all the information of <code>binding</code>.</p>
  
  <p>and when we do </p>
  
  <pre><code>injector.getInstance(RealBillingService.class);
  </code></pre>
  
  <p>Here we do the trick. </p>
  
  <p><code>injector</code> will return a <code>proxy instance</code> for the real <code>RealBillingService</code> object and when we call a   </p>
  
  <p>method of <code>RealBillingService</code> object, <code>proxy instance</code> invocation handler uses <code>reflection</code> to </p>
  
  <p>figure out the properties to inject and fullfill it based on the information passed during the creation of injector.</p>
  
  <p><strong>QUESTION</strong></p>
  
  <p>This is the way i suppose, the <code>guice</code> works. If i am wrong, what would be the actual way by which <code>'Guice'</code> achieve it ?</p>
  
  <p>If this is the way <code>guice</code> work then <code>Guice</code> always returns the <code>proxy object</code> and the user code always makes call on the <code>proxy objects</code>. is this true ?</p>
  
  <hr>
  
  <p>Pictorial representation on my explaination</p>
  
  <p><img src="https://i.stack.imgur.com/Z2bn1.png" alt="enter image description here"></p>