JBoss.orgCommunity Documentation

Chapter 11. CDI

11.1. Introduction
11.2. Annotations
11.2.1. @KReleaseId
11.2.2. @KContainer
11.2.3. @KBase
11.2.4. @KSession for KieSession
11.2.5. @KSession for StatelessKieSession
11.3. API Example Comparison

CDI, Contexts and Dependency Injection, is Java specification that provides declarative controls and strucutres to an application. KIE can use it to automatically instantiate and bind things, without the need to use the programmatic API.

@KContainer, @KBase and @KSession all support an optional 'name' attribute. CDI typically does "getOrCreate" when it injects, all injections receive the same instance for the same set of annotations. the 'name' annotation forces a unique instance for each name, although all instance for that name will be identity equals.

CDI can inject instances into fields, or even pass them as arguments. In this example field injection is used.


This is less code and more declarative than the API approach.