newInstance

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.

Return

a new instance of type T with dependencies injected

Throws

if any required service is not found in the provider

Example usage:

val constructor = MyClass::class.java.getConstructor(Dependency::class.java)
val factory = InjectableObjectFactory(constructor, serviceProvider)
val instance = factory.newInstance() // automatically injects Dependency