public static void writeAgenda(MarshallerWriteContext context) throws IOException { InternalWorkingMemory wm = context.wm; DefaultAgenda agenda = (DefaultAgenda) wm.getAgenda(); context.writeInt(agenda.getDormantActivations()); context.writeInt(agenda.getActiveActivations()); Map<String, ActivationGroup> activationGroups = agenda.getActivationGroupsMap(); AgendaGroup[] agendaGroups = (AgendaGroup[]) agenda .getAgendaGroupsMap() .values() .toArray(new AgendaGroup[agenda.getAgendaGroupsMap().size()]); Arrays.sort(agendaGroups, AgendaGroupSorter.instance); for (AgendaGroup group : agendaGroups) { context.writeShort(PersisterEnums.AGENDA_GROUP); context.writeUTF(group.getName()); context.writeBoolean(group.isActive()); } context.writeShort(PersisterEnums.END); LinkedList<AgendaGroup> focusStack = agenda.getStackList(); for (Iterator<AgendaGroup> it = focusStack.iterator(); it.hasNext(); ) { AgendaGroup group = it.next(); context.writeShort(PersisterEnums.AGENDA_GROUP); context.writeUTF(group.getName()); } context.writeShort(PersisterEnums.END); RuleFlowGroupImpl[] ruleFlowGroups = (RuleFlowGroupImpl[]) agenda .getRuleFlowGroupsMap() .values() .toArray(new RuleFlowGroupImpl[agenda.getRuleFlowGroupsMap().size()]); Arrays.sort(ruleFlowGroups, RuleFlowGroupSorter.instance); for (RuleFlowGroupImpl group : ruleFlowGroups) { context.writeShort(PersisterEnums.RULE_FLOW_GROUP); // group.write( context ); context.writeUTF(group.getName()); context.writeBoolean(group.isActive()); context.writeBoolean(group.isAutoDeactivate()); Map<Long, String> nodeInstances = group.getNodeInstances(); context.writeInt(nodeInstances.size()); for (Map.Entry<Long, String> entry : nodeInstances.entrySet()) { context.writeLong(entry.getKey()); context.writeUTF(entry.getValue()); } } context.writeShort(PersisterEnums.END); }
public static void writeTrigger(Trigger trigger, MarshallerWriteContext outCtx) throws IOException { if (trigger instanceof CronTrigger) { outCtx.writeShort(PersisterEnums.CRON_TRIGGER); CronTrigger cronTrigger = (CronTrigger) trigger; outCtx.writeLong(cronTrigger.getStartTime().getTime()); if (cronTrigger.getEndTime() != null) { outCtx.writeBoolean(true); outCtx.writeLong(cronTrigger.getEndTime().getTime()); } else { outCtx.writeBoolean(false); } outCtx.writeInt(cronTrigger.getRepeatLimit()); outCtx.writeInt(cronTrigger.getRepeatCount()); outCtx.writeUTF(cronTrigger.getCronEx().getCronExpression()); if (cronTrigger.getNextFireTime() != null) { outCtx.writeBoolean(true); outCtx.writeLong(cronTrigger.getNextFireTime().getTime()); } else { outCtx.writeBoolean(false); } outCtx.writeObject(cronTrigger.getCalendarNames()); } else if (trigger instanceof IntervalTrigger) { outCtx.writeShort(PersisterEnums.INT_TRIGGER); IntervalTrigger intTrigger = (IntervalTrigger) trigger; outCtx.writeLong(intTrigger.getStartTime().getTime()); if (intTrigger.getEndTime() != null) { outCtx.writeBoolean(true); outCtx.writeLong(intTrigger.getEndTime().getTime()); } else { outCtx.writeBoolean(false); } outCtx.writeInt(intTrigger.getRepeatLimit()); outCtx.writeInt(intTrigger.getRepeatCount()); if (intTrigger.getNextFireTime() != null) { outCtx.writeBoolean(true); outCtx.writeLong(intTrigger.getNextFireTime().getTime()); } else { outCtx.writeBoolean(false); } outCtx.writeLong(intTrigger.getPeriod()); outCtx.writeObject(intTrigger.getCalendarNames()); } else if (trigger instanceof PointInTimeTrigger) { outCtx.writeShort(PersisterEnums.POINT_IN_TIME_TRIGGER); PointInTimeTrigger pinTrigger = (PointInTimeTrigger) trigger; outCtx.writeLong(pinTrigger.hasNextFireTime().getTime()); } // else if ( trigger instanceof DelayedTrigger ) { // // } else if ( trigger instanceof PointInTimeTrigger ) { // // } else if ( trigger instanceof CompositeMaxDurationTimer ) { // // } }