com.google.gwt.inject.rebind.binding
Class FactoryBinding

java.lang.Object
  extended by com.google.gwt.inject.rebind.binding.FactoryBinding
All Implemented Interfaces:
Binding

public class FactoryBinding
extends java.lang.Object
implements Binding

Binder producing assisted inject factories.

For each method in the factory interface, the binder will determine the implementation type from the return type and the provided bindings. It will then check all constructors in the implementation type against the method parameters (taking named @Assisted annotations into account) and pick a matching one (if available). To inject the selected constructor the binder will write a common method injection, replacing the parameters commonly retrieved through key-specific getter methods with values obtained from the matching method arguments. Finally, after an instance has been constructed, it will be member-injected before it is returned to the caller of the method.


Constructor Summary
FactoryBinding(SourceWriteUtil sourceWriteUtil, KeyUtil keyUtil, NameGenerator nameGenerator)
           
 
Method Summary
 java.util.Set<Key<?>> getImplementations()
           
 RequiredKeys getRequiredKeys()
           
 void setKeyAndCollector(Key<?> factoryKey, java.util.Map<Key<?>,TypeLiteral<?>> bindings)
           
 void writeCreatorMethods(com.google.gwt.user.rebind.SourceWriter writer, java.lang.String creatorMethodSignature)
          Writes the method necessary to create the binding's type to the writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FactoryBinding

@Inject
public FactoryBinding(SourceWriteUtil sourceWriteUtil,
                             KeyUtil keyUtil,
                             NameGenerator nameGenerator)
Method Detail

setKeyAndCollector

public void setKeyAndCollector(Key<?> factoryKey,
                               java.util.Map<Key<?>,TypeLiteral<?>> bindings)
                        throws com.google.gwt.core.ext.typeinfo.NotFoundException
Throws:
com.google.gwt.core.ext.typeinfo.NotFoundException

writeCreatorMethods

public void writeCreatorMethods(com.google.gwt.user.rebind.SourceWriter writer,
                                java.lang.String creatorMethodSignature)
                         throws NoSourceNameException
Description copied from interface: Binding
Writes the method necessary to create the binding's type to the writer. A method with the creatorMethodSignature must be written, other methods are optional.

Specified by:
writeCreatorMethods in interface Binding
Parameters:
writer - writer that methods are written to
creatorMethodSignature - signature of method that needs to be created
Throws:
NoSourceNameException - if source name is not available for type

getRequiredKeys

public RequiredKeys getRequiredKeys()
Specified by:
getRequiredKeys in interface Binding
Returns:
A tuple of two sets: One set of keys that this binding requires. This set is used to find more classes that need to be bound. The second set contains all keys that have been optionally requested.

getImplementations

public java.util.Set<Key<?>> getImplementations()