public createComponent(typeInfo as Type, name as String = "") as Object throws Exception:
Creates and manages a component from reflected type metadata.
The context invokes the zero-argument constructor, registers the resulting instance, injects properties annotated with @Autowired, then invokes zero-argument methods annotated with @InitMethod.
| Parameter | Description |
|---|---|
typeInfo | Concrete component type. |
name | Optional registration name. The short type name is used when omitted. |
The created and initialized component.
import klyn.di
context = DIContext()
service = context.createComponent(MyService.type, "service") as MyService
assert context.getComponent("service") is service