Search in sources :

Example 1 with MarshallingConfigurationImpl

use of org.drools.core.marshalling.impl.MarshallingConfigurationImpl in project drools by kiegroup.

the class PersistableRunner method initExistingKnowledgeSession.

protected void initExistingKnowledgeSession(Long sessionId, KieBase kbase, KieSessionConfiguration conf, PersistenceContext persistenceContext) {
    if (!doRollback && this.ksession != null) {
        return;
    // nothing to initialise
    }
    this.doRollback = false;
    try {
        // if locking is active, this will also lock the (found) SessionInfo instance
        this.sessionInfo = (SessionInfo) persistenceContext.findSession(sessionId);
    } catch (Exception e) {
        throw new SessionNotFoundException("Could not find session data for id " + sessionId, e);
    }
    if (sessionInfo == null) {
        throw new SessionNotFoundException("Could not find session data for id " + sessionId);
    }
    if (this.marshallingHelper == null) {
        // this should only happen when this class is first constructed
        this.marshallingHelper = new SessionMarshallingHelper(kbase, conf, env);
        MarshallingConfigurationImpl config = (MarshallingConfigurationImpl) this.marshallingHelper.getMarshaller().getMarshallingConfiguration();
        config.setMarshallProcessInstances(false);
        config.setMarshallWorkItems(false);
    }
    this.sessionInfo.setJPASessionMashallingHelper(this.marshallingHelper);
    // if this.ksession is null, it'll create a new one, else it'll use the existing one
    this.ksession = this.marshallingHelper.loadSnapshot(this.sessionInfo.getData(), this.ksession, new JpaSessionInitializer(this));
    // update the session id to be the same as the session info id
    InternalKnowledgeRuntime kruntime = ((InternalKnowledgeRuntime) ksession);
    kruntime.setIdentifier(this.sessionInfo.getId());
    kruntime.setEndOperationListener(new EndOperationListenerImpl(this.txm, this.sessionInfo));
    this.runner = new TransactionInterceptor();
    // apply interceptors
    Iterator<ChainableRunner> iterator = this.interceptors.descendingIterator();
    while (iterator.hasNext()) {
        addInterceptor(iterator.next(), false);
    }
    initKieSessionMBeans(this.ksession);
}
Also used : InternalKnowledgeRuntime(org.drools.core.common.InternalKnowledgeRuntime) MarshallingConfigurationImpl(org.drools.core.marshalling.impl.MarshallingConfigurationImpl) ChainableRunner(org.drools.core.runtime.ChainableRunner) SessionMarshallingHelper(org.drools.persistence.api.SessionMarshallingHelper) SessionNotFoundException(org.drools.persistence.api.SessionNotFoundException) SessionNotFoundException(org.drools.persistence.api.SessionNotFoundException)

Example 2 with MarshallingConfigurationImpl

use of org.drools.core.marshalling.impl.MarshallingConfigurationImpl in project drools by kiegroup.

the class PersistableRunner method initNewKnowledgeSession.

protected void initNewKnowledgeSession(KieBase kbase, KieSessionConfiguration conf) {
    this.sessionInfo = new SessionInfo();
    // create session but bypass command service
    this.ksession = kbase.newKieSession(conf, this.env);
    initKieSessionMBeans(this.ksession);
    this.marshallingHelper = new SessionMarshallingHelper(this.ksession, conf);
    MarshallingConfigurationImpl config = (MarshallingConfigurationImpl) this.marshallingHelper.getMarshaller().getMarshallingConfiguration();
    config.setMarshallProcessInstances(false);
    config.setMarshallWorkItems(false);
    this.sessionInfo.setJPASessionMashallingHelper(this.marshallingHelper);
    ((InternalKnowledgeRuntime) this.ksession).setEndOperationListener(new EndOperationListenerImpl(this.txm, this.sessionInfo));
    this.runner = new TransactionInterceptor();
    TimerJobFactoryManager timerJobFactoryManager = ((InternalKnowledgeRuntime) ksession).getTimerService().getTimerJobFactoryManager();
    if (timerJobFactoryManager instanceof CommandServiceTimerJobFactoryManager) {
        ((CommandServiceTimerJobFactoryManager) timerJobFactoryManager).setRunner(this);
    }
}
Also used : InternalKnowledgeRuntime(org.drools.core.common.InternalKnowledgeRuntime) MarshallingConfigurationImpl(org.drools.core.marshalling.impl.MarshallingConfigurationImpl) CommandServiceTimerJobFactoryManager(org.drools.core.time.impl.CommandServiceTimerJobFactoryManager) TimerJobFactoryManager(org.drools.core.time.impl.TimerJobFactoryManager) CommandServiceTimerJobFactoryManager(org.drools.core.time.impl.CommandServiceTimerJobFactoryManager) SessionInfo(org.drools.persistence.info.SessionInfo) SessionMarshallingHelper(org.drools.persistence.api.SessionMarshallingHelper)

Aggregations

InternalKnowledgeRuntime (org.drools.core.common.InternalKnowledgeRuntime)2 MarshallingConfigurationImpl (org.drools.core.marshalling.impl.MarshallingConfigurationImpl)2 SessionMarshallingHelper (org.drools.persistence.api.SessionMarshallingHelper)2 ChainableRunner (org.drools.core.runtime.ChainableRunner)1 CommandServiceTimerJobFactoryManager (org.drools.core.time.impl.CommandServiceTimerJobFactoryManager)1 TimerJobFactoryManager (org.drools.core.time.impl.TimerJobFactoryManager)1 SessionNotFoundException (org.drools.persistence.api.SessionNotFoundException)1 SessionInfo (org.drools.persistence.info.SessionInfo)1