Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>NO YOU DONT</p> <p>GUICE does not ask you to inject every single object. GUICE will try and create only injected objects. So you can @Inject objects that you want to be injected. </p> <p>On the scope bit - Scope essentially controls how your objects gets created by GUICE. When you write your own custom scope you can have a datastructure that controls the way objects are created. When you scope a class with your custom annotation, GUICE will call your scope method before creation with a Provider for that class. You can then decide if you want to create a new object or use an existing object from a datastructure (such as hashmap or something). If you want to use an existing one you get that and return the object, else you do a provider.get() and return. </p> <p>Notice this </p> <pre><code>public &lt;T&gt; Provider&lt;T&gt; scope(final Key&lt;T&gt; key, final Provider&lt;T&gt; unscoped) { return new Provider&lt;T&gt;() { public T get() { Map&lt;Key&lt;?&gt;, Object&gt; scopedObjects = getScopedObjectMap(key); @SuppressWarnings("unchecked") T current = (T) scopedObjects.get(key); if (current == null &amp;&amp; !scopedObjects.containsKey(key)) { current = unscoped.get(); scopedObjects.put(key, current); } // what you return here is going to be injected .... // in this scope object you can have a datastructure that holds all references // and choose to return that instead depending on your logic and external // dependencies such as session variable etc... return current; } }; } </code></pre> <p>Here's a tutorial ...</p> <p><a href="http://code.google.com/p/google-guice/wiki/CustomScopes" rel="nofollow">http://code.google.com/p/google-guice/wiki/CustomScopes</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload