JBoss.orgCommunity Documentation

Chapter 10. CDI

10.1. Introduction
10.2. Annotations
10.2.1. @KRealaseId
10.2.2. @KContainer
10.2.3. @KBase
10.2.4. @KSession for KieSession
10.2.5. @KSession for StatelessKieSession
10.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, @KBaser 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 intsance 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.