コード例 #1
0
ファイル: EntryPointNode.java プロジェクト: Brianxia/drools
  public void updateSink(
      final ObjectSink sink,
      final PropagationContext context,
      final InternalWorkingMemory workingMemory) {
    // @todo
    // JBRULES-612: the cache MUST be invalidated when a new node type is added to the network, so
    // iterate and reset all caches.
    final ObjectTypeNode node = (ObjectTypeNode) sink;

    final ObjectType newObjectType = node.getObjectType();

    InternalWorkingMemoryEntryPoint wmEntryPoint =
        (InternalWorkingMemoryEntryPoint)
            workingMemory.getWorkingMemoryEntryPoint(this.entryPoint.getEntryPointId());

    for (ObjectTypeConf objectTypeConf :
        wmEntryPoint.getObjectTypeConfigurationRegistry().values()) {
      if (newObjectType.isAssignableFrom(
          objectTypeConf.getConcreteObjectTypeNode().getObjectType())) {
        objectTypeConf.resetCache();
        ObjectTypeNode sourceNode = objectTypeConf.getConcreteObjectTypeNode();
        Iterator it =
            ((ObjectTypeNodeMemory) workingMemory.getNodeMemory(sourceNode)).memory.iterator();
        for (ObjectEntry entry = (ObjectEntry) it.next();
            entry != null;
            entry = (ObjectEntry) it.next()) {
          sink.assertObject((InternalFactHandle) entry.getValue(), context, workingMemory);
        }
      }
    }
  }
コード例 #2
0
  private static void assertHandleIntoOTN(
      MarshallerReaderContext context,
      InternalWorkingMemory wm,
      InternalFactHandle handle,
      List<PropagationContextImpl> pctxs) {
    Object object = handle.getObject();
    InternalWorkingMemoryEntryPoint ep = (InternalWorkingMemoryEntryPoint) handle.getEntryPoint();
    ObjectTypeConf typeConf =
        ((InternalWorkingMemoryEntryPoint) handle.getEntryPoint())
            .getObjectTypeConfigurationRegistry()
            .getObjectTypeConf(ep.getEntryPoint(), object);
    PropagationContextImpl propagationContext =
        new PropagationContextImpl(
            wm.getNextPropagationIdCounter(),
            PropagationContext.INSERTION,
            null,
            null,
            handle,
            ep.getEntryPoint(),
            context);
    // keeping this list for a later cleanup is necessary because of the lazy propagations that
    // might occur
    pctxs.add(propagationContext);

    ep.getEntryPointNode().assertObject(handle, propagationContext, typeConf, wm);

    propagationContext.evaluateActionQueue(wm);
    wm.executeQueuedActions();
  }