Search in sources :

Example 1 with StatelessKnowledgeSessionImpl

use of org.drools.kiesession.session.StatelessKnowledgeSessionImpl in project drools by kiegroup.

the class KieContainerImpl method newStatelessKieSession.

public StatelessKieSession newStatelessKieSession(String kSessionName, KieSessionConfiguration conf) {
    KieSessionModelImpl kSessionModel = kSessionName != null ? (KieSessionModelImpl) getKieSessionModel(kSessionName) : (KieSessionModelImpl) findKieSessionModel(true);
    if (kSessionModel == null) {
        log.error("Unknown KieSession name: " + kSessionName);
        return null;
    }
    if (kSessionModel.getType() == KieSessionModel.KieSessionType.STATEFUL) {
        throw new RuntimeException("Trying to create a stateless KieSession from a stateful KieSessionModel: " + kSessionModel.getName());
    }
    KieBase kBase = getKieBase(kSessionModel.getKieBaseModel().getName());
    if (kBase == null) {
        log.error("Unknown KieBase name: " + kSessionModel.getKieBaseModel().getName());
        return null;
    }
    StatelessKieSession statelessKieSession = kBase.newStatelessKieSession(conf != null ? conf : getKieSessionConfiguration(kSessionModel));
    if (isJndiAvailable()) {
        wireSessionComponents(kSessionModel, statelessKieSession);
    }
    registerLoggers(kSessionModel, statelessKieSession);
    ((StatelessKnowledgeSessionImpl) statelessKieSession).initMBeans(containerId, ((InternalKnowledgeBase) kBase).getId(), kSessionModel.getName());
    statelessKSessions.put(kSessionModel.getName(), statelessKieSession);
    return statelessKieSession;
}
Also used : KieSessionModelImpl(org.drools.compiler.kproject.models.KieSessionModelImpl) StatelessKnowledgeSessionImpl(org.drools.kiesession.session.StatelessKnowledgeSessionImpl) KieBase(org.kie.api.KieBase) StatelessKieSession(org.kie.api.runtime.StatelessKieSession)

Aggregations

KieSessionModelImpl (org.drools.compiler.kproject.models.KieSessionModelImpl)1 StatelessKnowledgeSessionImpl (org.drools.kiesession.session.StatelessKnowledgeSessionImpl)1 KieBase (org.kie.api.KieBase)1 StatelessKieSession (org.kie.api.runtime.StatelessKieSession)1