use of org.kie.api.runtime.Environment in project drools by kiegroup.
the class MarshallingTest method marsallStatefulKnowledgeSession.
private KieSession marsallStatefulKnowledgeSession(KieSession ksession) throws IOException, ClassNotFoundException {
Globals globals = ksession.getGlobals();
KieBase kbase = ksession.getKieBase();
ByteArrayOutputStream out = new ByteArrayOutputStream();
MarshallerFactory.newMarshaller(kbase).marshall(out, ksession);
KieSessionConfiguration ksconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
ksconf.setOption(TimerJobFactoryOption.get("trackable"));
ksconf.setOption(ClockTypeOption.get("pseudo"));
Environment env = EnvironmentFactory.newEnvironment();
env.set(EnvironmentName.GLOBALS, globals);
ksession = MarshallerFactory.newMarshaller(kbase).unmarshall(new ByteArrayInputStream(out.toByteArray()), ksconf, env);
return ksession;
}
Aggregations