Lifestyle Policy
A lifestyle policy has a direct impact on the number of instances of a component that are created by the runtime. The following table list the semantics of the respective lifestyle policies.
Policy | Description |
---|---|
SINGLETON | The SINGLETON lifestyle policy dictates that only a single runtime instance will be created for the given component. Components requesting the SINGLETON must declare themselves as thread-safe capable. In effect the SINGLETON instance will be shared across multiple potentially concurrent threads. |
THREAD | The THREAD lifestyle policy dictates that a new runtime instance of a component will be created per-identified thread. As such, requests for service access by objects within the same thread will share the same instance reference. If a request is received from a new thread then a new instance of the component will be established and served to the requesting client. |
TRANSIENT | The TRANSIENT lifestyle policy dictates that a new component instance will be created for every request. |
Default Policy
If the component type declares itself as thread-safe capable the default policy will be SINGLETON otherwise the THREAD policy will be assigned.