Package org.kie.internal.runtime

Examples of org.kie.internal.runtime.StatefulKnowledgeSession.addEventListener()


        final List created = new ArrayList();
        final List cancelled = new ArrayList();
        final List fired = new ArrayList();

        ks.addEventListener( new DefaultAgendaEventListener() {

            public void matchCreated( MatchCreatedEvent event ) {
                created.add( event.getMatch().getRule().getName() );
            }
View Full Code Here


        final List created = new ArrayList();
        final List cancelled = new ArrayList();
        final List fired = new ArrayList();

        ks.addEventListener( new DefaultAgendaEventListener() {

            public void matchCreated( MatchCreatedEvent event ) {
                created.add( event.getMatch().getRule().getName() );}

            public void matchCancelled( MatchCancelledEvent event ) {
View Full Code Here

                     "  System.out.println( \"Rule2\" + $p ); " +
                     "  modify ( $p ) { setName( \"john\" ); } \n" +
                     "end";
        KnowledgeBase kb = loadKnowledgeBaseFromString( drl );
        StatefulKnowledgeSession ks = kb.newStatefulKnowledgeSession();
        ks.addEventListener( new DebugAgendaEventListener(  ) );

        ks.fireAllRules();

        Person p = new Person( "mark", 76 );
        ks.insert( p );
View Full Code Here

                     "  System.out.println( \"Rule2\" + $p ); " +
                     "  modify ( $p ) { setName( \"john\" ); } \n" +
                     "end";
        KnowledgeBase kb = loadKnowledgeBaseFromString( drl );
        StatefulKnowledgeSession ks = kb.newStatefulKnowledgeSession();
        ks.addEventListener( new DebugAgendaEventListener(  ) );

        ks.fireAllRules();

        Person p = new Person( "mark", 76 );
        ks.insert( p );
View Full Code Here

        KnowledgeBase kbase = loadKnowledgeBaseFromString( kconf, drl );
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        final AtomicInteger i = new AtomicInteger(0);

        ksession.addEventListener( new DefaultAgendaEventListener() {
            public void matchCreated( MatchCreatedEvent event ) {
                i.incrementAndGet();
            }

            public void matchCancelled( MatchCancelledEvent event ) {
View Full Code Here

            public void afterRuleFlowGroupDeactivated(org.kie.api.event.rule.RuleFlowGroupDeactivatedEvent event) {
            }
        };

        ksession.addEventListener(agendaEventListener);

        FactHandle fact1 = ksession.insert(new Person("Mario", 38));
        ((InternalAgenda)ksession.getAgenda()).activateRuleFlowGroup("test");
        ksession.fireAllRules();
        assertEquals(1, res.size());
View Full Code Here

    public void testFactBindings() throws Exception {
        KnowledgeBase kbase = SerializationHelper.serializeObject( loadKnowledgeBase( "test_FactBindings.drl" ) );
        StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );

        RuleRuntimeEventListener wmel = mock( RuleRuntimeEventListener.class );
        ksession.addEventListener( wmel );

        final Person bigCheese = new Person( "big cheese" );
        final Cheese cheddar = new Cheese( "cheddar",
                                           15 );
        bigCheese.setCheese( cheddar );
View Full Code Here

    public void testEventModel() throws Exception {
        KnowledgeBase kbase = SerializationHelper.serializeObject( loadKnowledgeBase( "test_EventModel.drl" ) );
        StatefulKnowledgeSession wm = createKnowledgeSession( kbase );

        RuleRuntimeEventListener wmel = mock( RuleRuntimeEventListener.class );
        wm.addEventListener( wmel );

        final Cheese stilton = new Cheese( "stilton",
                                           15 );

        final org.kie.api.runtime.rule.FactHandle stiltonHandle = wm.insert( stilton );
View Full Code Here

    public void testMapNullConstraint() throws Exception {
        KnowledgeBase kbase = loadKnowledgeBase( "test_mapNullConstraints.drl" );
        StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );

        org.kie.api.event.rule.AgendaEventListener ael = mock( org.kie.api.event.rule.AgendaEventListener.class );
        ksession.addEventListener( ael );
        new WorkingMemoryConsoleLogger( ksession );

        Map addresses = new HashMap();
        addresses.put( "home",
                       new Address( "home street" ) );
View Full Code Here

        StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );

        // creating listener as a jmock proxy
        final RuleRuntimeEventListener wmeListener = mock( RuleRuntimeEventListener.class );

        ksession.addEventListener( wmeListener );

        // listener will be notified of both facts insertion
        ksession.insert( new Cheese( "stilton" ) );
        ksession.insert( wmeListener );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.