import org.drools.spi.PropagationContext;
import org.drools.spi.RuleFlowGroup;
public class OutputMarshaller {
public static void writeSession(MarshallerWriteContext context) throws IOException {
ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
final boolean multithread = wm.isPartitionManagersActive();
// is multi-thread active?
if( multithread ) {
context.writeBoolean( true );
wm.stopPartitionManagers();
} else {
context.writeBoolean( false );
}
context.writeInt( wm.getFactHandleFactory().getId() );
context.writeLong( wm.getFactHandleFactory().getRecency() );
////context.out.println( "FactHandleFactory int:" + wm.getFactHandleFactory().getId() + " long:" + wm.getFactHandleFactory().getRecency() );
InternalFactHandle handle = context.wm.getInitialFactHandle();
context.writeInt( handle.getId() );
context.writeLong( handle.getRecency() );
//context.out.println( "InitialFact int:" + handle.getId() + " long:" + handle.getRecency() );
context.writeLong( wm.getPropagationIdCounter() );
//context.out.println( "PropagationCounter long:" + wm.getPropagationIdCounter() );
writeAgenda( context );
writeFactHandles( context );
writeActionQueue( context );
if ( wm.getTruthMaintenanceSystem() != null ) {
context.writeBoolean( true );
writeTruthMaintenanceSystem( context );
} else {
context.writeBoolean( false );
}
if ( context.marshalProcessInstances ) {
writeProcessInstances( context );
}
if ( context.marshalWorkItems ) {
writeWorkItems( context );
}
writeTimers( context );
if( multithread ) {
wm.startPartitionManagers();
}
}