Package org.drools.runtime.rule

Examples of org.drools.runtime.rule.WorkingMemoryEntryPoint


                                       org.drools.marshalling.impl.ProtobufMessages.EntryPoint _ep,
                                       ObjectStore objectStore) throws IOException,
                                                               ClassNotFoundException {
        InternalWorkingMemory wm = context.wm;

        WorkingMemoryEntryPoint entryPoint = context.wm.getEntryPoints().get( _ep.getEntryPointId() );
        // load the handles
        for ( ProtobufMessages.FactHandle _handle : _ep.getHandleList() ) {
            InternalFactHandle handle = readFactHandle( context,
                                                        entryPoint,
                                                        _handle );
View Full Code Here


            readRightTuples( initialFactHandle,
                             context );
        }
        while ( context.readShort() == PersisterEnums.ENTRY_POINT) {
            String entryPointId = context.stream.readUTF();
            WorkingMemoryEntryPoint wmep = context.wm.getEntryPoints().get( entryPointId );
            readFactHandles( context,
                             ( (NamedEntryPoint) wmep ).getObjectStore() );
        }
        InternalFactHandle handle = context.wm.getInitialFactHandle();
        while (context.stream.readShort() == PersisterEnums.LEFT_TUPLE) {
View Full Code Here

        // If either way retrieves a strategy, use it
        if (strategy != null) {
            object = strategy.read( context.stream );
        }

        WorkingMemoryEntryPoint entryPoint = null;
        if (context.readBoolean()) {
            String entryPointId = context.readUTF();
            if (entryPointId != null && !entryPointId.equals( "" )) {
                entryPoint = context.wm.getEntryPoints().get( entryPointId );
            }
View Full Code Here

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

        final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        final WorkingMemoryEntryPoint ep = ksession.getWorkingMemoryEntryPoint( "testep" );

        List list = new ArrayList();
        ksession.setGlobal( "list",
                            list );

        ksession.insert( new Cheese( "cheddar" ) );
        ksession.fireAllRules();

        Runnable fireUntilHalt = new Runnable() {
            public void run() {
                ksession.fireUntilHalt();
            }
        };

        Thread t1 = new Thread( fireUntilHalt );
        t1.start();

        Thread.currentThread().sleep( 500 );
        ep.insert( new Person( "darth" ) );
        Thread.currentThread().sleep( 500 );
        ksession.halt();
        t1.join( 5000 );
        boolean alive = t1.isAlive();
        if ( alive ) {
View Full Code Here

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

        final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        final WorkingMemoryEntryPoint ep = ksession.getWorkingMemoryEntryPoint( "testep" );

        List list = new ArrayList();
        ksession.setGlobal( "list",
                            list );

        list.add( new Person( "darth" ) );
        ep.insert( new Cheese( "cheddar" ) );

        ksession.fireAllRules();
        assertEquals( 3,
                      list.size() );
    }
View Full Code Here

        ((SessionConfiguration) ksconf).setTimerJobFactoryManager( new TrackableTimeJobFactoryManager( ) );
        StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession(ksconf, null);
       
        List list = new ArrayList();
        ksession.setGlobal( "list", list );
        WorkingMemoryEntryPoint aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
       
        ksession = marsallStatefulKnowledgeSession(ksession);       
       
        WorkingMemoryEntryPoint bep = ksession.getWorkingMemoryEntryPoint( "b-ep" );
        bep.insert( new B() );
       
        ksession = marsallStatefulKnowledgeSession(ksession);      
       
        WorkingMemoryEntryPoint cep = ksession.getWorkingMemoryEntryPoint( "c-ep" );
        cep.insert( new C() );

        ksession = marsallStatefulKnowledgeSession(ksession);    
       
        ksession.fireAllRules();
       
        ksession = marsallStatefulKnowledgeSession(ksession);         
       
        assertEquals( 3,
                      list.size() );
       
        aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        assertEquals( 1, aep.getFactHandles().size() );
       
        bep = ksession.getWorkingMemoryEntryPoint( "b-ep" );
        assertEquals( 1, bep.getFactHandles().size() );
       
        cep = ksession.getWorkingMemoryEntryPoint( "c-ep" );
        assertEquals( 1, cep.getFactHandles().size() );
       
        PseudoClockScheduler timeService = ( PseudoClockScheduler ) ksession.getSessionClock();       
        timeService.advanceTime( 11, TimeUnit.SECONDS );      
       
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        ksession.fireAllRules();
       
        ksession = marsallStatefulKnowledgeSession(ksession);       
       
        aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        assertEquals( 0, aep.getFactHandles().size() );
       
        bep = ksession.getWorkingMemoryEntryPoint( "b-ep" );
        assertEquals( 0, bep.getFactHandles().size() );
       
        cep = ksession.getWorkingMemoryEntryPoint( "c-ep" );
        assertEquals( 1, cep.getFactHandles().size() );
    }   
View Full Code Here

        ((SessionConfiguration) ksconf).setTimerJobFactoryManager( new TrackableTimeJobFactoryManager( ) );
        StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession(ksconf, null);
       
        List list = new ArrayList();
        ksession.setGlobal( "list", list );
        WorkingMemoryEntryPoint aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
       
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        PseudoClockScheduler timeService = ( PseudoClockScheduler ) ksession.getSessionClock();       
        timeService.advanceTime( 3, TimeUnit.SECONDS )
View Full Code Here

        StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession(ksconf, null);
       
        List list = new ArrayList();
        ksession.setGlobal( "list", list );
       
        WorkingMemoryEntryPoint aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        list.clear();
        ksession.fireAllRules();
        ksession = marsallStatefulKnowledgeSession(ksession);
        assertEquals( 2, ((List)list.get( 0 )).size() );
       
        PseudoClockScheduler timeService = ( PseudoClockScheduler ) ksession.getSessionClock();       
        timeService.advanceTime( 15, TimeUnit.SECONDS );         
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        list.clear();
        ksession.fireAllRules();
        ksession = marsallStatefulKnowledgeSession(ksession);
View Full Code Here

        StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession(ksconf, null);
       
        List list = new ArrayList();
        ksession.setGlobal( "list", list );
       
        WorkingMemoryEntryPoint aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        list.clear();
        ksession.fireAllRules();
        ksession = marsallStatefulKnowledgeSession(ksession);
        assertEquals( 2, ((List)list.get( 0 )).size() );
       
        aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        list.clear();
        ksession.fireAllRules();
        ksession = marsallStatefulKnowledgeSession(ksession);
View Full Code Here

        sconf.setOption( ClockTypeOption.get( "pseudo" ) );

        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession( sconf,
                                                                               null );

        WorkingMemoryEntryPoint eventStream = ksession.getWorkingMemoryEntryPoint( "Event Stream" );

        SessionPseudoClock clock = ksession.getSessionClock();

        final List results = new ArrayList();
        ksession.setGlobal( "results",
                            results );

        EventFactHandle handle1 = (EventFactHandle) eventStream.insert( new StockTick( 1,
                                                                                       "ACME",
                                                                                       50,
                                                                                       System.currentTimeMillis(),
                                                                                       3 ) );
View Full Code Here

TOP

Related Classes of org.drools.runtime.rule.WorkingMemoryEntryPoint

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.