com.google.inject
Interface Scope


public interface Scope

A scope which bound objects can reside in. Add a new scope using ContainerBuilder.put(String, Scope) and reference it from bindings using its name.

Scope implementations should override toString() and include the creator's toString() output. Doing so aids debugging.

Author:
crazybob@google.com (Bob Lee)

Method Summary
<T> Factory<T>
scope(Key<T> key, Factory<T> creator)
          Scopes a factory.
 

Method Detail

scope

<T> Factory<T> scope(Key<T> key,
                     Factory<T> creator)
Scopes a factory. The returned factory returns objects from this scope. If an object does not exist in this scope, the factory can use the given creator to create one.

Parameters:
key - binding key
creator - creates new instances as needed
Returns:
a new factory which only delegates to the given factory when an instance of the requested object doesn't already exist in the scope