Package org.drools.reteoo

Examples of org.drools.reteoo.ObjectTypeNode


       
        final Rete source = this.ruleBase.getRete();
        final ClassObjectType cot = new ClassObjectType( object.getClass() );
        final Map<ObjectType, ObjectTypeNode> map = source.getObjectTypeNodes( EntryPoint.DEFAULT );
        final ObjectTypeNode node = map.get( cot );
        final ObjectHashSet memory = (ObjectHashSet) this.wm.getNodeMemory( node );
     
        // All objects of this type that are already there were certainly stated,
        // since this method call happens at the first logical insert, for any given type.
        org.drools.core.util.Iterator it = memory.iterator();
View Full Code Here


            // @propertyChangeSupport annotation, and clean them up
            if( conf.isDynamic() && conf.isSupportsPropertyChangeListeners() ) {
                // it is enough to iterate the facts on the concrete object type nodes
                // only, as the facts will always be in their concrete object type nodes
                // even if they were also asserted into higher level OTNs as well
                ObjectTypeNode otn = conf.getConcreteObjectTypeNode();
                final ObjectHashSet memory = (ObjectHashSet) this.getInternalWorkingMemory().getNodeMemory( otn );
                Iterator it = memory.iterator();
                for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
                    InternalFactHandle handle = (InternalFactHandle) entry.getValue();
                    removePropertyChangeListener( handle, false );
View Full Code Here

                             context.wm.getInitialFactHandle() );

        if (context.stream.readBoolean()) {
            InternalFactHandle initialFactHandle = context.wm.getInitialFactHandle();
            int sinkId = context.stream.readInt();
            ObjectTypeNode initialFactNode = (ObjectTypeNode) context.sinks.get( sinkId );
            if (initialFactNode == null) {
                // ------ START RANT ------
                // The following code is as bad as it looks, but since I was so far
                // unable to convince Mark that creating OTNs on demand is really bad,
                // I have to continue doing it :)
                EntryPointNode defaultEPNode = context.ruleBase.getRete().getEntryPointNode( EntryPoint.DEFAULT );
                BuildContext buildContext = new BuildContext( context.ruleBase,
                                                              context.ruleBase.getReteooBuilder().getIdGenerator() );
                buildContext.setPartitionId(RuleBasePartitionId.MAIN_PARTITION);
                buildContext.setObjectTypeNodeMemoryEnabled( true );
                initialFactNode = new ObjectTypeNode( sinkId,
                                                      defaultEPNode,
                                                      ClassObjectType.InitialFact_ObjectType,
                                                      buildContext );
                // isn't contention something everybody loves?
                context.ruleBase.lock();
                try {
                    // Yeah, I know, because one session is being deserialized, we go and lock all of them...
                    InternalWorkingMemory[] wms = buildContext.getWorkingMemories();
                    if ( wms.length > 0 ) {
                        initialFactNode.attach( wms );
                    } else {
                        initialFactNode.attach();
                    }
                } finally {
                    context.ruleBase.unlock();
                }
                // ------- END RANT -----
View Full Code Here

    public static void writeInitialFactHandleRightTuples(MarshallerWriteContext context) throws IOException {
        ObjectOutputStream stream = context.stream;
        InternalRuleBase ruleBase = context.ruleBase;

        ObjectTypeNode initialFactNode = ruleBase.getRete().getEntryPointNode( EntryPoint.DEFAULT ).getObjectTypeNodes().get( ClassObjectType.InitialFact_ObjectType );

        // do we write the fact to the objecttypenode memory
        if ( initialFactNode != null ) {
            ObjectHashSet initialFactMemory = (ObjectHashSet) context.wm.getNodeMemory( initialFactNode );
            if ( initialFactMemory != null && !initialFactMemory.isEmpty() ) {
                //context.out.println( "InitialFactMemory true int:" + initialFactNode.getId() );
                stream.writeBoolean( true );
                stream.writeInt( initialFactNode.getId() );

                //context.out.println( "InitialFact RightTuples" );
                writeRightTuples( context.wm.getInitialFactHandle(),
                                  context );
            } else {
View Full Code Here

       
        final Rete source = this.ruleBase.getRete();
        final ClassObjectType cot = new ClassObjectType( object.getClass() );
        final Map<ObjectType, ObjectTypeNode> map = source.getObjectTypeNodes( EntryPoint.DEFAULT );
        final ObjectTypeNode node = map.get( cot );
        final ObjectHashSet memory = (ObjectHashSet) this.wm.getNodeMemory( node );
     
        // All objects of this type that are already there were certainly stated,
        // since this method call happens at the first logical insert, for any given type.
        org.drools.core.util.Iterator it = memory.iterator();
View Full Code Here

    @Override
    protected void doVisit(NetworkNode node,
                           Stack<NetworkNode> nodeStack,
                           StatefulKnowledgeSessionInfo info) {
        ObjectTypeNode otn = (ObjectTypeNode) node;
        DefaultNodeInfo ni = (DefaultNodeInfo) info.getNodeInfo( node );
        ni.setMemoryEnabled( otn.isObjectMemoryEnabled() );
       
        if( otn.isObjectMemoryEnabled() ) {
            final ObjectHashSet memory = (ObjectHashSet) info.getSession().getNodeMemory( otn );
            ni.setFactMemorySize( memory.size() );
        }

    }
View Full Code Here

        InternalWorkingMemory wm = context.wm;

        if ( stream.readBoolean() ) {
            InternalFactHandle initialFactHandle = wm.getInitialFactHandle();
            int sinkId = stream.readInt();
            ObjectTypeNode initialFactNode = (ObjectTypeNode) context.sinks.get( sinkId );
            ObjectHashSet initialFactMemory = (ObjectHashSet) context.wm.getNodeMemory( initialFactNode );

            initialFactMemory.add( initialFactHandle );
            readRightTuples( initialFactHandle,
                             context );
        }

        int size = stream.readInt();

        // load the handles
        InternalFactHandle[] handles = new InternalFactHandle[size];
        for ( int i = 0; i < size; i++ ) {
            InternalFactHandle handle = readFactHandle( context );

            context.handles.put( handle.getId(),
                                 handle );
            handles[i] = handle;

            context.wm.getObjectStore().addHandle( handle,
                                                   handle.getObject() );

            readRightTuples( handle,
                             context );
        }

        EntryPointNode node = ruleBase.getRete().getEntryPointNode( EntryPoint.DEFAULT );
        Map<ObjectType, ObjectTypeNode> objectTypeNodes = node.getObjectTypeNodes();

        // add handles to object type nodes
        for ( InternalFactHandle handle : handles ) {
            Object object = handle.getObject();
            ClassObjectType objectType = new ClassObjectType( object.getClass() );
            ObjectTypeNode objectTypeNode = objectTypeNodes.get( objectType );
            if (objectTypeNode != null) {
              ObjectHashSet set = (ObjectHashSet) context.wm.getNodeMemory( objectTypeNode );
              set.add( handle,
                       false );
            }
View Full Code Here

        str += "ObjectTypeNode :\n";
        str += "otn1, java.lang.Integer;\n";

        NodeTestResult result = executeTest( str );

        ObjectTypeNode otn1 = (ObjectTypeNode) result.context.get( "otn1" );
        assertNotNull( otn1 );

        assertEquals( new ClassObjectType( Integer.class ),
                      otn1.getObjectType() );
    }
View Full Code Here

        str += "LeftInputAdapterNode:\n";
        str += "    lian0, otn1;";

        NodeTestResult result = executeTest( str );

        ObjectTypeNode otn1 = (ObjectTypeNode) result.context.get( "otn1" );
        LeftInputAdapterNode lian0 = (LeftInputAdapterNode) result.context.get( "lian0" );
        assertNotNull( lian0 );

        assertSame( lian0,
                    otn1.getSinkPropagator().getSinks()[0] );
    }
View Full Code Here

        final InternalRuleBase internal = (InternalRuleBase) ruleBase;
        final TimeIntervalParser parser = new TimeIntervalParser();

        Map<ObjectType, ObjectTypeNode> objectTypeNodes = internal.getRete().getObjectTypeNodes( EntryPoint.DEFAULT );
        ObjectTypeNode node = objectTypeNodes.get( new ClassObjectType( StockTick.class ) );

        assertNotNull( node );

        // the expiration policy @expires(10m) should override the temporal operator usage
        assertEquals( parser.parse( "10m" )[0].longValue() + 1,
                      node.getExpirationOffset() );
    }
View Full Code Here

TOP

Related Classes of org.drools.reteoo.ObjectTypeNode

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.