use of org.kie.api.marshalling.KieMarshallers in project drools by kiegroup.
the class MarshallingTest method marshallAndUnmarshall.
public static KieSession marshallAndUnmarshall(KieBase kbase1, KieBase kbase2, KieSession ksession, KieSessionConfiguration sessionConfig) {
// Serialize and Deserialize
try {
KieMarshallers kieMarshallers = KieServices.Factory.get().getMarshallers();
Marshaller marshaller = kieMarshallers.newMarshaller(kbase1);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
marshaller.marshall(baos, ksession);
marshaller = kieMarshallers.newMarshaller(kbase2);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
baos.close();
ksession = marshaller.unmarshall(bais, sessionConfig, null);
bais.close();
} catch (Exception e) {
e.printStackTrace();
fail("unexpected exception :" + e.getMessage());
}
return ksession;
}
Aggregations