public static void readAgenda(MarshallerReaderContext context, DefaultAgenda agenda)
      throws IOException {
    ObjectInputStream stream = context.stream;

    agenda.setDormantActivations(stream.readInt());
    agenda.setActiveActivations(stream.readInt());

    while (stream.readShort() == PersisterEnums.AGENDA_GROUP) {
      BinaryHeapQueueAgendaGroup group =
          new BinaryHeapQueueAgendaGroup(stream.readUTF(), context.ruleBase);
      group.setActive(stream.readBoolean());
      agenda.getAgendaGroupsMap().put(group.getName(), group);
    }

    while (stream.readShort() == PersisterEnums.AGENDA_GROUP) {
      String agendaGroupName = stream.readUTF();
      agenda.getStackList().add(agenda.getAgendaGroup(agendaGroupName));
    }

    while (stream.readShort() == PersisterEnums.RULE_FLOW_GROUP) {
      String rfgName = stream.readUTF();
      boolean active = stream.readBoolean();
      boolean autoDeactivate = stream.readBoolean();
      RuleFlowGroupImpl rfg = new RuleFlowGroupImpl(rfgName, active, autoDeactivate);
      agenda.getRuleFlowGroupsMap().put(rfgName, rfg);
      int nbNodeInstances = stream.readInt();
      for (int i = 0; i < nbNodeInstances; i++) {
        Long processInstanceId = stream.readLong();
        String nodeInstanceId = stream.readUTF();
        rfg.addNodeInstance(processInstanceId, nodeInstanceId);
      }
    }
  }