コード例 #1
0
  public static void readFactHandles(MarshallerReaderContext context, ObjectStore objectStore)
      throws IOException, ClassNotFoundException {
    ObjectInputStream stream = context.stream;
    InternalWorkingMemory wm = context.wm;

    int size = stream.readInt();

    // load the handles
    InternalFactHandle[] handles = new InternalFactHandle[size];
    for (int i = 0; i < size; i++) {
      InternalFactHandle handle = readFactHandle(context);

      context.handles.put(handle.getId(), handle);
      handles[i] = handle;

      if (handle.getObject() != null) {
        objectStore.addHandle(handle, handle.getObject());
      }

      readRightTuples(handle, context);
    }

    readLeftTuples(context); // object store

    if (stream.readBoolean()) {
      readLeftTuples(context); // activation fact handles
    }

    // add handles to object type nodes
    for (InternalFactHandle factHandle : handles) {
      Object object = factHandle.getObject();

      EntryPoint ep =
          ((InternalWorkingMemoryEntryPoint) factHandle.getEntryPoint()).getEntryPoint();

      ObjectTypeConf typeConf =
          ((InternalWorkingMemoryEntryPoint) factHandle.getEntryPoint())
              .getObjectTypeConfigurationRegistry()
              .getObjectTypeConf(ep, object);
      ObjectTypeNode[] cachedNodes = typeConf.getObjectTypeNodes();
      for (int i = 0, length = cachedNodes.length; i < length; i++) {
        ObjectHashSet set = (ObjectHashSet) wm.getNodeMemory(cachedNodes[i]);
        set.add(factHandle, false);
      }
    }
  }