Information Technology Reference
In-Depth Information
KieStoreServices - creating and loading KIE
sessions
Once all environment components are created, we will not directly create the persistent
KIE session implementation. Instead, we will use a special service to handle that creation
for us. As a matter of fact, we will not even load the special service class directly; we will
use the KieServices helper class to load it for us, as shown in the following line of
code:
KieStoreServices kstore = KieServices.Factory.get().
getStoreServices();
The KieStoreServices interface will define two methods—one to create a new per-
sistent KIE session and another to load an existing one, as shown in the following code:
KieSession ksession = kstore.newKieSession(kbase, null, env);
Integer sessionId = ksession.getId();
...
//on a different part of your code
KieSession reloadedKsession =
kstore.loadKieSession(sessionId, kbase, null, env);
The KIE session ID is the only data that the application will need to remember to retrieve
the same KIE session later on. Depending on how much we wish to reuse the KIE session,
we might consider temporarily storing the ID, or maybe even registering it in a database
reference or file to be reused all the time.
The actual implementation behind the KieStoreServices interface knows we have to
use JPA to persist our runtime and create all the necessary components to make a persistent
KIE session. In order to have the specific implementation of the service in the classpath,
we will need to add a dependency to our projects that holds that implementation:
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-persistence-jpa</artifactId>
<version>6.1.0.Beta3</version>
</dependency>
Search WWH ::




Custom Search