Package org.drools

Examples of org.drools.KnowledgeBaseConfiguration


        if (kbuilder.hasErrors())
        {
            throw new ConfigurationException(MessageFactory.createStaticMessage("Errors while parsing ruleset defined in file " + rulesFile + " : " + kbuilder.getErrors().toString()));
        }       

        KnowledgeBaseConfiguration conf =
            KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null, Thread.currentThread().getContextClassLoader());
        if (rules.getConfiguration() != null)
        {
            conf.setOption((KnowledgeBaseOption) rules.getConfiguration());
        }
        else if (rules.isCepMode())
        {
            conf.setOption(EventProcessingOption.STREAM);
        }
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(conf);
        kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());           
       
        if (rules.isStateless())
View Full Code Here


    @Ignore
    public void testCompareInstances() throws Exception {

        StatefulKnowledgeSession ksessionA = null;
        {
            KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
            config.setOption(EventProcessingOption.STREAM);
            KnowledgeBase knowledgeBaseA = KnowledgeBaseFactory.newKnowledgeBase(config);
            KnowledgeSessionConfiguration ksconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
            ksconf.setOption(ClockTypeOption.get("pseudo"));
            ((SessionConfiguration) ksconf).setTimerJobFactoryManager(new TrackableTimeJobFactoryManager());
            ksessionA = knowledgeBaseA.newStatefulKnowledgeSession(ksconf, null);
        }

        StatefulKnowledgeSession ksessionB = null;
        {
            KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
            config.setOption(EventProcessingOption.STREAM);
            KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(config);
            KnowledgeSessionConfiguration ksconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
            ksconf.setOption(ClockTypeOption.get("pseudo"));
            ((SessionConfiguration) ksconf).setTimerJobFactoryManager(new TrackableTimeJobFactoryManager());
            ksessionB = knowledgeBase.newStatefulKnowledgeSession(ksconf, null);
View Full Code Here

        if ( !errors.isEmpty() ) {
            throw new RuntimeException( errors.toString() );
        }

        //KnowledgeBase
        KnowledgeBaseConfiguration kbaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null, DroolsBlueprintBean.class.getClassLoader());
        KnowledgeBase kbase = node.get( KnowledgeBaseFactoryService.class ).newKnowledgeBase(kbaseConfig);
        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

        return kbase;
    }
View Full Code Here

                throw new InitialisationException(CoreMessages.cannotLoadFromClasspath(rulesFile), this);
            }

            KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
            builder.add(ResourceFactory.newInputStreamResource(is), ResourceType.DRL);
            KnowledgeBaseConfiguration conf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
            conf.setOption(EventProcessingOption.STREAM);
            KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(conf);
            kbase.addKnowledgePackages(builder.getKnowledgePackages());           
           
            session = kbase.newStatefulKnowledgeSession();
           
View Full Code Here

        KnowledgeBuilder kbuilder =  KnowledgeBuilderFactory.newKnowledgeBuilder();
        kbuilder.add( ResourceFactory.newByteArrayResource(str.getBytes()), ResourceType.DRL );
        if ( kbuilder.hasErrors() ) {
            fail( kbuilder.getErrors().toString() );
        }
        KnowledgeBaseConfiguration kbConf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
                kbConf.setOption(AssertBehaviorOption.EQUALITY);
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( kbConf );
        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        java.util.List list = new java.util.ArrayList();
View Full Code Here

        if ( kbuilder.hasErrors() ) {
            System.out.println( kbuilder.getErrors().toString() );
            System.exit( 1 );
        }

        KnowledgeBaseConfiguration kbaseConf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
        kbaseConf.setOption( AssertBehaviorOption.EQUALITY );

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( kbaseConf );
        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

        Counter c = new Counter();
View Full Code Here

        assertTrue(eps.contains(s3));
    }

    @Test
    public void testEventDoesNotExpireIfNotInPattern() throws Exception {
        KnowledgeBaseConfiguration kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
        kconf.setOption(EventProcessingOption.STREAM);
        KnowledgeBase kbase = loadKnowledgeBase("test_EventExpiration.drl",
                kconf);

        KnowledgeSessionConfiguration ksessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
        ksessionConfig.setOption(ClockTypeOption.get("pseudo"));
View Full Code Here

                equalTo(0));
    }

    @Test
    public void testEventExpirationSetToZero() throws Exception {
        KnowledgeBaseConfiguration kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
        kconf.setOption(EventProcessingOption.STREAM);
        KnowledgeBase kbase = loadKnowledgeBase("test_EventExpirationSetToZero.drl",
                kconf);

        KnowledgeSessionConfiguration ksessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
        ksessionConfig.setOption(ClockTypeOption.get("pseudo"));
View Full Code Here

                ResourceType.DRL);
        kbuilder.add(ResourceFactory.newByteArrayResource(drl2.getBytes()),
                ResourceType.DRL);
        assertFalse(kbuilder.getErrors().toString(),
                kbuilder.hasErrors());
        KnowledgeBaseConfiguration kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
        kconf.setOption( EventProcessingOption.STREAM );
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( kconf );
        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

        List<ObjectTypeNode> otns = ( (ReteooRuleBase) ( (KnowledgeBaseImpl) kbase ).getRuleBase() ).getRete().getObjectTypeNodes();
        ObjectType stot = new ClassObjectType( StockTick.class );
View Full Code Here

                "    accumulate( $s : StockTick( price > 20 ) from window RedHatTicks,\n" +
                "                $sum : sum( $s.getPrice() ),\n" +
                "                $cnt : count( $s ) )\n" +
                "then\n" +
                "end\n";
        KnowledgeBaseConfiguration kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
        kconf.setOption(EventProcessingOption.STREAM);
        KnowledgeBase kbase = loadKnowledgeBaseFromString(kconf,
                drl);

        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        AgendaEventListener ael = mock(AgendaEventListener.class);
View Full Code Here

TOP

Related Classes of org.drools.KnowledgeBaseConfiguration

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.