Exemplo n.º 1
0
    public WorkingMemoryReteAssertAction(MarshallerReaderContext context) throws IOException {
      this.factHandle = context.handles.get(context.readInt());
      this.removeLogical = context.readBoolean();
      this.updateEqualsMap = context.readBoolean();

      if (context.readBoolean()) {
        String pkgName = context.readUTF();
        String ruleName = context.readUTF();
        Package pkg = context.ruleBase.getPackage(pkgName);
        this.ruleOrigin = pkg.getRule(ruleName);
      }
      if (context.readBoolean()) {
        this.leftTuple = context.terminalTupleMap.get(context.readInt());
      }
    }
  @Test
  public void backwardsCompatibleEventFactHandleTest() throws IOException, ClassNotFoundException {
    InternalKnowledgeBase kBase = createKnowledgeBase();
    StatefulKnowledgeSessionImpl wm = createWorkingMemory(kBase);
    InternalFactHandle factHandle = createEventFactHandle(wm, kBase);

    // marshall/serialize workItem
    byte[] byteArray;
    {
      ObjectMarshallingStrategy[] strats =
          new ObjectMarshallingStrategy[] {
            MarshallerFactory.newSerializeMarshallingStrategy(),
            new MarshallerProviderImpl().newIdentityMarshallingStrategy()
          };

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      MarshallerWriteContext outContext =
          new MarshallerWriteContext(
              baos,
              null,
              null,
              null,
              new ObjectMarshallingStrategyStoreImpl(strats),
              true,
              true,
              null);
      OldOutputMarshallerMethods.writeFactHandle_v1(
          outContext,
          (ObjectOutputStream) outContext,
          outContext.objectMarshallingStrategyStore,
          2,
          factHandle);
      outContext.close();
      byteArray = baos.toByteArray();
    }

    // unmarshall/deserialize workItem
    InternalFactHandle newFactHandle;
    {
      // Only put serialization strategy in
      ObjectMarshallingStrategy[] newStrats =
          new ObjectMarshallingStrategy[] {MarshallerFactory.newSerializeMarshallingStrategy()};

      ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
      MarshallerReaderContext inContext =
          new MarshallerReaderContext(
              bais,
              null,
              null,
              new ObjectMarshallingStrategyStoreImpl(newStrats),
              Collections.EMPTY_MAP,
              true,
              true,
              null);
      inContext.wm = wm;
      newFactHandle = InputMarshaller.readFactHandle(inContext);
      inContext.close();
    }

    assertTrue(
        "Serialized FactHandle not the same as the original.",
        compareInstances(factHandle, newFactHandle));
  }
Exemplo n.º 3
0
 public DeactivateCallback(MarshallerReaderContext context) throws IOException {
   this.ruleFlowGroup =
       (InternalRuleFlowGroup) context.wm.getAgenda().getRuleFlowGroup(context.readUTF());
 }
Exemplo n.º 4
0
 public WorkingMemoryReteExpireAction(MarshallerReaderContext context) throws IOException {
   this.factHandle = context.handles.get(context.readInt());
   final int nodeId = context.readInt();
   this.node = (ObjectTypeNode) context.sinks.get(Integer.valueOf(nodeId));
 }