Package org.drools.spi

Examples of org.drools.spi.Activation


        }
    }

    public void testSetResolverStraties() throws Exception {
        MockControl leftActivationControl = mocks.createControl(Activation.class);
        Activation leftActivationMock = (Activation) leftActivationControl.getMock();
        MockControl rightActivationControl = mocks.createControl(Activation.class);
        Activation rightActivationMock = (Activation) rightActivationControl.getMock();

        MockControl resolverControl_1 = mocks.createControl(ConflictResolver.class);
        final ConflictResolver resolverMock_1 = (ConflictResolver) resolverControl_1.getMock();
        MockControl resolverControl_2 = mocks.createControl(ConflictResolver.class);
        final ConflictResolver resolverMock_2 = (ConflictResolver) resolverControl_2.getMock();
View Full Code Here


            
        agenda.fireNextItem( null );

        List rules = new ArrayList();
        Iterator it = activations.iterator();
        Activation activation;
        while ( it.hasNext() )
        {
            activation = ( Activation ) it.next();
            rules.add( activation.getRule() );
        }
       
        assertContains( rule4,
                        rules );
       
View Full Code Here

                 * For each Activation remove the handle. If the Set is empty then remove the activation
                 * from justiers.
                 */
                Set activationList = (Set) this.justified.remove( ( (FactHandleImpl) handle ).getId() );
                Iterator it = activationList.iterator();
                Activation eachActivation;
                while ( it.hasNext() )
                {
                    eachActivation = (Activation) it.next();
                    Set handles = (Set) this.justifiers.get( eachActivation );
                    handles.remove( handle );
View Full Code Here

        /* Test single activation for a single logical assertions */
        agenda.addToAgenda( tuple1,
                            context1,
                            rule1 );
        ModuleImpl main = (ModuleImpl) agenda.getFocus();
        Activation activation1 = (Activation) main.getActivationQueue().get();

        String logicalString = new String ( "logical" );
        FactHandle logicalHandle = workingMemory.assertObject( logicalString,
                                                               false,
                                                               true,
View Full Code Here

        /* Test single activation for a single logical assertions */
        agenda.addToAgenda( tuple1,
                            context1,
                            rule1 );
        ModuleImpl main = (ModuleImpl) agenda.getFocus();
        Activation activation1 = (Activation) main.getActivationQueue().get();

        String logicalString1 = new String( "logical" );
        FactHandle logicalHandle1 = workingMemory.assertObject( logicalString1,
                                                                false,
                                                                true,
View Full Code Here

        /* Test that a STATED assertion overrides a logical assertion */
        agenda.addToAgenda( tuple1,
                            context1,
                            rule1 );
        ModuleImpl main = (ModuleImpl) agenda.getFocus();
        Activation activation1 = (Activation) main.getActivationQueue().get();

        String logicalString1 = new String( "logical" );
        FactHandle logicalHandle1 = workingMemory.assertObject( logicalString1,
                                                               false,
                                                               true,
View Full Code Here

        PropagationContext context =  new PropagationContextImpl( PropagationContext.ASSERTION,
                                                              null,
                                                              null );
       
        Activation activation1 = new AgendaItem( tuple1,
                                                 context,
                                                 rule1 );
           
        /* Assert the logical "logical" fact */
        String logicalString1 = new String ( "logical" );
        FactHandle logicalHandle1 = workingMemory.assertObject( logicalString1,
                                                                false,
                                                                true,
                                                                rule1,
                                                                activation1 );
       
        /* create the second activation to justify the "logical" fact */
        final Rule rule2 = new Rule( "test-rule2" );
        rule2.setConsequence( consequence );         
       
        FactHandleImpl handle2 = new FactHandleImpl( 2 );
        ReteTuple tuple2 = new ReteTuple( 0,
                                          handle2,
                                          workingMemory );

        Activation activation2 = new AgendaItem( tuple2,
                                                 context,
                                                 rule2 );

       
        /* Assert the logical "logical" fact */
 
View Full Code Here

        ModuleImpl main = (ModuleImpl) agenda.getFocus();
        Activation[] activations = ( Activation[] ) main.getActivationQueue().toArray( new Activation[] {} );              
       
        /* Create the first justifieable relationship */
        String logicalString1 = new String ( "logical" );
        Activation activation1 = activations[0];
        FactHandle logicalHandle1 = workingMemory.assertObject( logicalString1,
                                                               false,
                                                               true,
                                                               activation1.getRule(),
                                                               activation1 );
       
        /* Create the second justifieable relationship */
        String logicalString2 = new String ( "logical" );
        Activation activation2 = activations[1];       
        FactHandle logicalHandle2 = workingMemory.assertObject( logicalString2,
                                                               false,
                                                               true,
                                                               activation2.getRule(),
                                                               activation2 );
       
        /* "logical" should only appear once */
        assertLength( 1,
                      workingMemory.getJustified().values() );
        /* but has two justifications */
        assertLength( 2,
                      workingMemory.getJustifiers().values() )
       
        /* Now lets cancel the first activation */
        agenda.removeFromAgenda( ( (ReteTuple) activation2.getTuple() ).getKey(),
                                 context2,
                                 activation2.getRule() );
       
        /* because this logical fact has two relationships it shouldn't retract yet */
        assertLength( 0,
                      sink.getRetracted() );       
       
View Full Code Here

        // or could be true due to lock-on-active blocking activation creation
        if ( obj == null || obj == Boolean.TRUE) {
            return;
        }

        final Activation activation = (Activation) leftTuple.getObject();

        activation.setMatched( false );
       
        final InternalAgenda agenda = (InternalAgenda) workingMemory.getAgenda();

        agenda.cancelActivation( leftTuple,
                                 context,
View Full Code Here

                            final InternalWorkingMemory workingMemory) {
            if ( leftTuple.getLeftTupleSink() != node ) {
                return;
            }

            final Activation activation = (Activation) leftTuple.getObject();

            // this is to catch a race condition as activations are activated and unactivated on timers
            if ( activation instanceof ScheduledAgendaItem ) {
                ScheduledAgendaItem scheduled = (ScheduledAgendaItem) activation;
                workingMemory.getTimerService().removeJob( scheduled.getJobHandle() );
                scheduled.getJobHandle().setCancel( true );
            }

            if ( activation.isActivated() ) {
                activation.remove();
                ((EventSupport) workingMemory).getAgendaEventSupport().fireActivationCancelled( activation,
                                                                                                workingMemory,
                                                                                                ActivationCancelledCause.CLEAR );
            }
View Full Code Here

TOP

Related Classes of org.drools.spi.Activation

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.