Groovy Documentation

org.gradle.api
[Java] Interface ExtensiblePolymorphicDomainObjectContainer

org.gradle.util.Configurable
  org.gradle.api.ExtensiblePolymorphicDomainObjectContainer
      org.gradle.api.NamedDomainObjectCollection
          java.lang.Iterable
              org.gradle.api.NamedDomainObjectContainer
                  org.gradle.api.PolymorphicDomainObjectContainer
                      org.gradle.api.DomainObjectCollection
                          org.gradle.api.NamedDomainObjectSet
                              java.util.Collection
All Superinterfaces:
Configurable, NamedDomainObjectCollection, Iterable, NamedDomainObjectContainer, PolymorphicDomainObjectContainer, DomainObjectCollection, NamedDomainObjectSet, Collection

@Incubating
public interface ExtensiblePolymorphicDomainObjectContainer
extends PolymorphicDomainObjectContainer

A PolymorphicDomainObjectContainer that can be extended at runtime to create elements of new types.

Parameters:
- the (base) container element type


Method Summary
void registerBinding(Class type, Class implementationType)

Registers a binding from the specified "public" domain object type to the specified implementation type.

void registerFactory(Class type, NamedDomainObjectFactory factory)

Registers a factory for creating elements of the specified type.

void registerFactory(Class type, Closure factory)

Registers a factory for creating elements of the specified type.

 
Methods inherited from interface PolymorphicDomainObjectContainer
create, create
 
Methods inherited from interface NamedDomainObjectContainer
configure, create, create, create, maybeCreate
 
Methods inherited from interface NamedDomainObjectSet
findAll, matching, matching, withType
 
Methods inherited from interface NamedDomainObjectCollection
add, addAll, addRule, addRule, findByName, getAsMap, getAt, getByName, getByName, getNamer, getRules, matching, matching, withType
 
Methods inherited from interface Set
add, equals, hashCode, clear, contains, isEmpty, size, toArray, toArray, addAll, iterator, remove, containsAll, removeAll, retainAll
 

Method Detail

registerBinding

public void registerBinding(Class type, Class implementationType)
Registers a binding from the specified "public" domain object type to the specified implementation type. Whenever the container is asked to create an element with the binding's public type, it will instantiate the binding's implementation type. If the implementation type has a constructor annotated with javax.inject.Inject, its arguments will be injected.

In general, registering a binding is preferable over implementing and registering a factory.

Parameters:
type - a public domain object type
implementationType - the corresponding implementation type
- a public domain object type


registerFactory

public void registerFactory(Class type, NamedDomainObjectFactory factory)
Registers a factory for creating elements of the specified type. Typically, the specified type is an interface type.
throws:
IllegalArgumentException if the specified type is not a subtype of the container element type
Parameters:
type - the type of objects created by the factory
factory - the factory to register
- the type of objects created by the factory


registerFactory

public void registerFactory(Class type, Closure factory)
Registers a factory for creating elements of the specified type. Typically, the specified type is an interface type.
throws:
IllegalArgumentException if the specified type is not a subtype of the container element type
Parameters:
type - the type of objects created by the factory
factory - the factory to register
- the type of objects created by the factory


 

Gradle API 1.7-rc-2