Examples of AbstractWorkingMemory


Examples of org.drools.core.common.AbstractWorkingMemory

        objectTypeNode.attach(context);

        final MockObjectSink sink = new MockObjectSink();
        objectTypeNode.addObjectSink( sink );
      
        final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) ruleBase.newStatefulSession();

        // objectTypeNode.
    }
View Full Code Here

Examples of org.drools.core.common.AbstractWorkingMemory

        InternalRuleBase rbase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();

        this.rule = new Rule("test-rule");
        pctxFactory = rbase.getConfiguration().getComponentFactory().getPropagationContextFactory();
        this.context = pctxFactory.createPropagationContext(0, PropagationContext.INSERTION, null, null, null);
        this.workingMemory = new AbstractWorkingMemory(1, rbase);

        final RuleBaseConfiguration configuration = new RuleBaseConfiguration();

        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        BuildContext buildContext = new BuildContext(ruleBase,
View Full Code Here

Examples of org.drools.core.common.AbstractWorkingMemory

        conf.setPhreakEnabled(false);
        conf.setSequential( true );

        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase( conf );

        this.workingMemory = new AbstractWorkingMemory( 1,
                                                      ruleBase );

        BuildContext buildContext = new BuildContext( ruleBase,
                                                      ruleBase.getReteooBuilder().getIdGenerator() );
View Full Code Here

Examples of org.drools.core.common.AbstractWorkingMemory

        final LeftInputAdapterNode liaNode = new LeftInputAdapterNode( 23,
                                                                       objectTypeNode,
                                                                       buildContext );
        liaNode.attach(context);

        final AbstractWorkingMemory workingMemory = new AbstractWorkingMemory( 1,
                                                                           (ReteooRuleBase) RuleBaseFactory.newRuleBase() );

        final MockLeftTupleSink sink = new MockLeftTupleSink();
        liaNode.addTupleSink( sink );

        final Object string1 = "cheese";

        // assert object
        final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.insert( string1 );
        liaNode.assertObject( f0,
                              pcontext,
                              workingMemory );

        final List asserted = sink.getAsserted();
        assertLength( 1,
                      asserted );
        final Tuple tuple0 = (Tuple) ((Object[]) asserted.get( 0 ))[0];
        assertSame( string1,
                    workingMemory.getObject( tuple0.get( 0 ) ) );

    }
View Full Code Here

Examples of org.drools.core.common.AbstractWorkingMemory

     *
     * @throws org.drools.core.FactException
     */
    @Test
    public void testCache() throws FactException {
        final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) this.ruleBase.newStatefulSession();

        // Create a Rete network with ObjectTypeNodes for List, Collection and ArrayList
        final Rete rete = ruleBase.getRete();
        ObjectTypeNode objectTypeNode = new ObjectTypeNode(1,
                                                           this.entryPoint,
                                                           new ClassObjectType(List.class),
                                                           buildContext);
        objectTypeNode.attach(buildContext);
        MockObjectSink sink = new MockObjectSink();
        objectTypeNode.addObjectSink(sink);

        objectTypeNode = new ObjectTypeNode(1,
                                            this.entryPoint,
                                            new ClassObjectType(Collection.class),
                                            buildContext);
        objectTypeNode.attach(buildContext);
        sink = new MockObjectSink();
        objectTypeNode.addObjectSink(sink);

        objectTypeNode = new ObjectTypeNode(1,
                                            this.entryPoint,
                                            new ClassObjectType(ArrayList.class),
                                            buildContext);
        objectTypeNode.attach(buildContext);
        sink = new MockObjectSink();
        objectTypeNode.addObjectSink(sink);

        // ArrayList matches all three ObjectTypeNodes
        final DefaultFactHandle h1 = new DefaultFactHandle(1,
                                                           new ArrayList());
        rete.assertObject(h1,
                          pctxFactory.createPropagationContext(0,
                                                               PropagationContext.INSERTION,
                                                               null,
                                                               null,
                                                               null),
                          workingMemory);

        // LinkedList matches two ObjectTypeNodes       
        h1.setObject(new LinkedList());
        rete.assertObject(h1,
                          pctxFactory.createPropagationContext(0,
                                                               PropagationContext.INSERTION,
                                                               null,
                                                               null,
                                                               null),
                          workingMemory);

        ClassObjectTypeConf conf = (ClassObjectTypeConf) workingMemory.getObjectTypeConfigurationRegistry().getObjectTypeConf(this.entryPoint.getEntryPoint(), new ArrayList());
        assertLength(3,
                     conf.getObjectTypeNodes());

        conf = (ClassObjectTypeConf) workingMemory.getObjectTypeConfigurationRegistry().getObjectTypeConf(this.entryPoint.getEntryPoint(), new ArrayList());
        assertLength(3,
                     conf.getObjectTypeNodes());

    }
View Full Code Here

Examples of org.drools.core.common.AbstractWorkingMemory

     *
     * @throws Exception
     */
    @Test
    public void testAssertObject() throws Exception {
        final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) this.ruleBase.newStatefulSession();

        // Create a Rete network with ObjectTypeNodes for List, Collection and ArrayList
        final Rete rete = ruleBase.getRete();
        final ObjectTypeNode objectTypeNode = new ObjectTypeNode(1,
                                                                 this.entryPoint,
View Full Code Here

Examples of org.drools.core.common.AbstractWorkingMemory

                // first unwrap the byte[]
                ObjectInputStream ois = new ObjectInputStream( stream );

                // standard serialisation would have written the statateful session instance info to the stream first
                // so we read it, but we don't need it, so just ignore.
                AbstractWorkingMemory rsession = (AbstractWorkingMemory) ois.readObject();

                // now unmarshall that byte[]
                ByteArrayInputStream bais = new ByteArrayInputStream( rsession.bytes );
                Marshaller marshaller = MarshallerFactory.newMarshaller(new KnowledgeBaseImpl(this), new ObjectMarshallingStrategy[]{MarshallerFactory.newSerializeMarshallingStrategy()});
View Full Code Here

Examples of org.drools.core.common.AbstractWorkingMemory

        }

        readLock();
        try {
            WorkingMemoryFactory wmFactory = kieComponentFactory.getWorkingMemoryFactory();
            AbstractWorkingMemory session = ( AbstractWorkingMemory ) wmFactory.createWorkingMemory( id, this,
                                                                                                     sessionConfig, environment );
            new StatefulKnowledgeSessionImpl(session);

            if ( sessionConfig.isKeepReference() ) {
                addStatefulSession(session);
                for (Object listener : session.getRuleBaseUpdateListeners()) {
                    addEventListener((RuleBaseEventListener) listener);
                }
            }

            return session;
View Full Code Here

Examples of org.drools.core.common.AbstractWorkingMemory

                                        false,
                                        buildContext );

        this.node.addTupleSink( this.sink );

        this.workingMemory = new AbstractWorkingMemory( 1,
                                                      (ReteooRuleBase) RuleBaseFactory.newRuleBase( conf ) );

        this.memory = ((AccumulateMemory) this.workingMemory.getNodeMemory( this.node )).betaMemory;

        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
View Full Code Here

Examples of org.drools.core.common.AbstractWorkingMemory

    /*
     * @see JBRULES-356
     */
    @Test
    public void testBasicWorkingMemoryActions() {
        final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) RuleBaseFactory.newRuleBase().newStatefulSession();
        final TruthMaintenanceSystem tms = ((NamedEntryPoint)workingMemory.getWorkingMemoryEntryPoint( EntryPointId.DEFAULT.getEntryPointId() ) ).getTruthMaintenanceSystem();
        final String string = "test";

        workingMemory.insert( string );

        FactHandle fd = workingMemory.insertLogical( string );

        assertEquals( 1,
                      tms.getEqualityKeyMap().size() );

        EqualityKey key = tms.get( string );
        assertSame( fd,
                    key.getFactHandle() );
        assertEquals( 1, key.size() );

        workingMemory.update( fd,
                                    string );

        assertEquals( 1,
                      tms.getEqualityKeyMap().size() );
        key = tms.get( string );
        assertSame( fd,
                    key.getFactHandle() );
        assertEquals( 1, key.size() );

        workingMemory.retract( fd );

        assertEquals( 0,
                      tms.getEqualityKeyMap().size() );
        key = tms.get( string );
        assertNull( key );

        fd = workingMemory.insert( string );

        assertEquals( 1,
                      tms.getEqualityKeyMap().size() );

        assertEquals( 1,
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.