InjectableObjectFactory

class InjectableObjectFactory<T : Any>(constructorAccessor: ConstructorAccessor<T>, serviceProvider: ServiceProvider) : ObjectFactory<T>

ObjectFactory implementation that creates objects using dependency injection. This factory automatically resolves constructor parameters from a ServiceProvider, enabling automatic dependency injection during object instantiation.

Parameters

T

the type of object that will be created

Constructors

Link copied to clipboard
constructor(constructorAccessor: ConstructorAccessor<T>, serviceProvider: ServiceProvider)
constructor(constructor: Constructor<T>, serviceProvider: ServiceProvider)

Secondary constructor that creates an InjectableObjectFactory with a Constructor and ServiceProvider. Automatically wraps the constructor in a DefaultConstructorAccessor.

Functions

Link copied to clipboard
open override fun newInstance(): T

Creates a new instance by resolving all constructor parameters from the service provider. Each constructor parameter type is looked up in the service provider, and the resolved services are passed as arguments to the constructor.