# domainObjectContainer

abstract fun <T> domainObjectContainer(elementType: Class<T>): NamedDomainObjectContainer<T>

Creates a new NamedDomainObjectContainer for managing named objects of the specified type.

The specified element type must have a public constructor which takes the name as a String parameter. The type must be non-final and a class or abstract class.

Interfaces are supported if they declare a read-only `name` property of type String, and are otherwise empty or consist entirely of managed properties.

All objects MUST expose their name as a bean property called "name". The name must be constant for the life of the object.

The objects created by the container are decorated and extensible, and have services available for injection. See newInstance for more details.

#### Return

The container. Never returns null.

#### Since

5.5

#### Parameters

elementType

The type of objects for the container to contain.

<T>

The type of objects for the container to contain.

abstract fun <T> domainObjectContainer(elementType: Class<T>, factory: NamedDomainObjectFactory<T>): NamedDomainObjectContainer<T>

Creates a new NamedDomainObjectContainer for managing named objects of the specified type. The given factory is used to create object instances.

All objects MUST expose their name as a bean property named "name". The name must be constant for the life of the object.

#### Return

The container. Never returns null.

#### Since

5.5

#### Parameters

elementType

The type of objects for the container to contain.

factory

The factory to use to create object instances.

<T>

The type of objects for the container to contain.