Serialization 全局变量的drools序列化

Serialization 全局变量的drools序列化,serialization,global-variables,drools,Serialization,Global Variables,Drools,我使用此代码完全序列化/反序列化drools(5.4.0.CR1)状态完整会话对象: private static void writeObject(ObjectOutputStream out, KnowledgeBase knowledgeBase, StatefulKnowledgeSession session) throws IOException { // out.defaultWriteObject(); DroolsObjectOutputStream drool

我使用此代码完全序列化/反序列化drools(5.4.0.CR1)状态完整会话对象:

private static void writeObject(ObjectOutputStream out, KnowledgeBase knowledgeBase, StatefulKnowledgeSession session) throws IOException
{
    // out.defaultWriteObject();
    DroolsObjectOutputStream droolsOut = new DroolsObjectOutputStream(out);
    droolsOut.writeObject(knowledgeBase);
    Marshaller marshaller = createSerializableMarshaller(knowledgeBase);
    marshaller.marshall(droolsOut, session);
}

private static Marshaller createSerializableMarshaller(KnowledgeBase knowledgeBase)
{
    ObjectMarshallingStrategyAcceptor acceptor = MarshallerFactory.newClassFilterAcceptor(new String[] { "*.*" });
    ObjectMarshallingStrategy strategy = MarshallerFactory.newSerializeMarshallingStrategy(acceptor);
    Marshaller marshaller = MarshallerFactory.newMarshaller(knowledgeBase, new ObjectMarshallingStrategy[] { strategy });
    return marshaller;
}

private static StatefulKnowledgeSession readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
    // in.defaultReadObject();
    DroolsObjectInputStream droolsIn = new DroolsObjectInputStream(in);
    KnowledgeBase knowledgeBase = (KnowledgeBase) droolsIn.readObject();
    Marshaller marshaller = createSerializableMarshaller(knowledgeBase);
    StatefulKnowledgeSession statefulSession = marshaller.unmarshall(droolsIn);

    return statefulSession;
}
它工作正常,唯一的问题是会话的全局变量丢失


我做错了什么?

我相信我在CR1发布后修复了这个问题。释放当前快照或CR2时,请尝试使用它