Package org.drools.reteoo

Examples of org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction


        }

    }

    public static void readActionQueue(MarshallerReaderContext context) throws IOException {
        ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
        Queue actionQueue = wm.getActionQueue();
        while ( context.readShort() == PersisterEnums.WORKING_MEMORY_ACTION ) {
            actionQueue.offer( PersisterHelper.readWorkingMemoryAction( context ) );
        }
    }
View Full Code Here


import org.drools.workflow.instance.node.TimerNodeInstance;
import org.drools.workflow.instance.node.WorkItemNodeInstance;

public class OutputMarshaller {
    public static void writeSession(MarshallerWriteContext context) throws IOException {
        ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
       
        final boolean multithread = wm.isPartitionManagersActive();
        // is multi-thread active?
        if( multithread ) {
            context.writeBoolean( true );
            wm.stopPartitionManagers();
        } else {
            context.writeBoolean( false );
        }

        context.writeInt( wm.getFactHandleFactory().getId() );
        context.writeLong( wm.getFactHandleFactory().getRecency() );
//        context.out.println( "FactHandleFactory int:" + wm.getFactHandleFactory().getId() + " long:" + wm.getFactHandleFactory().getRecency() );

        InternalFactHandle handle = context.wm.getInitialFactHandle();
        context.writeInt( handle.getId() );
        context.writeLong( handle.getRecency() );
//        context.out.println( "InitialFact int:" + handle.getId() + " long:" + handle.getRecency() );

        context.writeLong( wm.getPropagationIdCounter() );
//        context.out.println( "PropagationCounter long:" + wm.getPropagationIdCounter() );

        writeAgenda( context );

        writeFactHandles( context );

        writeActionQueue( context );

        if ( wm.getTruthMaintenanceSystem() != null ) {
            context.writeBoolean( true );
            writeTruthMaintenanceSystem( context );
        } else {
            context.writeBoolean( false );
        }

        writeProcessInstances( context );

        writeWorkItems( context );

        writeTimers( context );
       
        if( multithread ) {
            wm.startPartitionManagers();
        }
    }
View Full Code Here

            return group1.getName().compareTo( group2.getName() );
        }
    }

    public static void writeActionQueue(MarshallerWriteContext context) throws IOException {
        ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;

        WorkingMemoryAction[] queue = wm.getActionQueue().toArray( new WorkingMemoryAction[wm.getActionQueue().size()] );
        for ( int i = queue.length - 1; i >= 0; i-- ) {
            context.writeShort( PersisterEnums.WORKING_MEMORY_ACTION );
            queue[i].write( context );
        }
        context.writeShort( PersisterEnums.END );
View Full Code Here

    }

    public static void readActionQueue(MarshallerReaderContext context,
                                       RuleData _session) throws IOException,
                                                                 ClassNotFoundException {
        ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
        Queue<WorkingMemoryAction> actionQueue = wm.getActionQueue();
        for ( ProtobufMessages.ActionQueue.Action _action : _session.getActionQueue().getActionList() ) {
            actionQueue.offer( PersisterHelper.deserializeWorkingMemoryAction( context,
                                                                               _action ) );
        }
    }
View Full Code Here

    PersisterHelper.writeToStreamWithHeader(context, _session);
  }

  private static ProtobufMessages.KnowledgeSession serializeSession(
      MarshallerWriteContext context) throws IOException {
    ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
    wm.getAgenda().unstageActivations();

    ProtobufMessages.RuleData.Builder _ruleData = ProtobufMessages.RuleData
        .newBuilder();

    final boolean multithread = wm.isPartitionManagersActive();
    if (multithread) {
      wm.stopPartitionManagers();
    }

    long time = 0;
    if (context.wm.getTimerService() instanceof PseudoClockScheduler) {
      time = context.clockTime;
    }
    _ruleData.setLastId(wm.getFactHandleFactory().getId());
    _ruleData.setLastRecency(wm.getFactHandleFactory().getRecency());

    InternalFactHandle handle = context.wm.getInitialFactHandle();
    ProtobufMessages.FactHandle _ifh = ProtobufMessages.FactHandle
        .newBuilder()
        .setType(ProtobufMessages.FactHandle.HandleType.INITIAL_FACT)
        .setId(handle.getId()).setRecency(handle.getRecency()).build();
    _ruleData.setInitialFact(_ifh);

    writeAgenda(context, _ruleData);

    writeNodeMemories(context, _ruleData);

    for (WorkingMemoryEntryPoint wmep : wm.getEntryPoints().values()) {
      org.drools.marshalling.impl.ProtobufMessages.EntryPoint.Builder _epb = ProtobufMessages.EntryPoint
          .newBuilder();
      _epb.setEntryPointId(wmep.getEntryPointId());
     
          writeObjectTypeConfiguration( context,
                   ((InternalWorkingMemoryEntryPoint)wmep).getObjectTypeConfigurationRegistry(),
                   _epb );

      writeFactHandles(context, _epb,
          ((NamedEntryPoint) wmep).getObjectStore());
      _ruleData.addEntryPoint(_epb.build());
    }

    writeActionQueue(context, _ruleData);

    writeTruthMaintenanceSystem(context, _ruleData);

    ProtobufMessages.KnowledgeSession.Builder _session = ProtobufMessages.KnowledgeSession
        .newBuilder().setMultithread(multithread).setTime(time)
        .setRuleData(_ruleData.build());

    if (processMarshaller != null) {
      Builder _pdata = ProtobufMessages.ProcessData.newBuilder();
      if (context.marshalProcessInstances) {
        context.parameterObject = _pdata;
        processMarshaller.writeProcessInstances(context);
      }

      if (context.marshalWorkItems) {
        context.parameterObject = _pdata;
        processMarshaller.writeWorkItems(context);
      }

      // this now just assigns the writer, it will not write out any timer
      // information
      context.parameterObject = _pdata;
      processMarshaller.writeProcessTimers(context);

      _session.setProcessData(_pdata.build());
    }

    Timers _timers = writeTimers(context.wm.getTimerService()
        .getTimerJobInstances(), context);
    if (_timers != null) {
      _session.setTimers(_timers);
    }

    if (multithread) {
      wm.startPartitionManagers();
    }

    return _session.build();
  }
View Full Code Here

  }

  public static void writeActionQueue(MarshallerWriteContext context,
      ProtobufMessages.RuleData.Builder _session) throws IOException {

    ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
    if (!wm.getActionQueue().isEmpty()) {
      ProtobufMessages.ActionQueue.Builder _queue = ProtobufMessages.ActionQueue
          .newBuilder();

      WorkingMemoryAction[] queue = wm.getActionQueue().toArray(
          new WorkingMemoryAction[wm.getActionQueue().size()]);
      for (int i = queue.length - 1; i >= 0; i--) {
        _queue.addAction(queue[i].serialize(context));
      }
      _session.setActionQueue(_queue.build());
    }
View Full Code Here

        }

    }

    public static void readActionQueue( MarshallerReaderContext context ) throws IOException, ClassNotFoundException {
        ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
        Queue<WorkingMemoryAction> actionQueue = wm.getActionQueue();
        while (context.readShort() == PersisterEnums.WORKING_MEMORY_ACTION) {
            actionQueue.offer( PersisterHelper.readWorkingMemoryAction( context ) );
        }
    }
View Full Code Here

import org.drools.spi.PropagationContext;
import org.drools.spi.RuleFlowGroup;

public class OutputMarshaller {
    public static void writeSession(MarshallerWriteContext context) throws IOException {
        ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
       
        final boolean multithread = wm.isPartitionManagersActive();
        // is multi-thread active?
        if( multithread ) {
            context.writeBoolean( true );
            wm.stopPartitionManagers();
        } else {
            context.writeBoolean( false );
        }

        context.writeInt( wm.getFactHandleFactory().getId() );
        context.writeLong( wm.getFactHandleFactory().getRecency() );
//        context.out.println( "FactHandleFactory int:" + wm.getFactHandleFactory().getId() + " long:" + wm.getFactHandleFactory().getRecency() );

        InternalFactHandle handle = context.wm.getInitialFactHandle();
        context.writeInt( handle.getId() );
        context.writeLong( handle.getRecency() );
//        context.out.println( "InitialFact int:" + handle.getId() + " long:" + handle.getRecency() );

        context.writeLong( wm.getPropagationIdCounter() );
//        context.out.println( "PropagationCounter long:" + wm.getPropagationIdCounter() );

        writeAgenda( context );

        writeFactHandles( context );

        writeActionQueue( context );

        if ( wm.getTruthMaintenanceSystem() != null ) {
            context.writeBoolean( true );
            writeTruthMaintenanceSystem( context );
        } else {
            context.writeBoolean( false );
        }

        if ( context.marshalProcessInstances ) {
            writeProcessInstances( context );
        }

        if ( context.marshalWorkItems ) {
            writeWorkItems( context );
        }

        writeTimers( context );
       
        if( multithread ) {
            wm.startPartitionManagers();
        }
    }
View Full Code Here

            return group1.getName().compareTo( group2.getName() );
        }
    }

    public static void writeActionQueue(MarshallerWriteContext context) throws IOException {
        ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;

        WorkingMemoryAction[] queue = wm.getActionQueue().toArray( new WorkingMemoryAction[wm.getActionQueue().size()] );
        for ( int i = queue.length - 1; i >= 0; i-- ) {
            context.writeShort( PersisterEnums.WORKING_MEMORY_ACTION );
            queue[i].write( context );
        }
        context.writeShort( PersisterEnums.END );
View Full Code Here

  public FactHandle execute(Context context) {
        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
        FactHandle factHandle = ksession.insert( object );
       
        ReteooWorkingMemory session = ((StatefulKnowledgeSessionImpl)ksession).session;

        if ( outIdentifier != null ) {
            if ( this.returnObject ) {
                session.getExecutionResult().getResults().put( this.outIdentifier,
                                                               object );
            }
            session.getExecutionResult().getFactHandles().put( this.outIdentifier,
                                                         factHandle );
        }

        return factHandle;
    }
View Full Code Here

TOP

Related Classes of org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.