JBoss.orgCommunity Documentation

Chapter 12. CDI

12.1. Introduction
12.2. Annotations
12.2.1. @KReleaseId
12.2.2. @KContainer
12.2.3. @KBase
12.2.4. @KSession for KieSession
12.2.5. @KSession for StatelessKieSession
12.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.