Examples of ReteooRuleBase


Examples of org.drools.core.reteoo.ReteooRuleBase

    }

    @Test
    public void testRuleEnabled() {
        WorkingMemory wm = new ReteooRuleBase("x", null).newStatefulSession();
       
        final Rule rule = new Rule( "myrule" );
        rule.setEnabled( EnabledBoolean.ENABLED_FALSE );
        assertFalse( rule.isEffective( null, new RuleTerminalNode(), wm ) );
View Full Code Here

Examples of org.drools.core.reteoo.ReteooRuleBase

    @Test
    public void testTimeMachine() {
        SessionConfiguration conf = new SessionConfiguration();
        conf.setClockType( ClockType.PSEUDO_CLOCK );
        WorkingMemory wm = new ReteooRuleBase("x", null).newStatefulSession(conf, null);
       
        final Calendar future = Calendar.getInstance();
        ((PseudoClockScheduler)wm.getSessionClock()).setStartupTime( future.getTimeInMillis() );
       
        final Rule rule = new Rule( "myrule" );
View Full Code Here

Examples of org.drools.core.reteoo.ReteooRuleBase

    @Test
    public void testCodeSourceUrl() throws Exception {
        final String className = TestEvalExpression.class.getName();
       
        ReteooRuleBase rb = new ReteooRuleBase( "xxx", null );
       
        Package pkg = new Package( "org.drools" );
        pkg.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) );
        JavaDialectRuntimeData data = new JavaDialectRuntimeData();
        data.onAdd( pkg.getDialectRuntimeRegistry(), rb.getRootClassLoader()  );
        pkg.getDialectRuntimeRegistry().setDialectData( "java", data );
       
        rb.addPackage( pkg );
       
        final JavaDialectRuntimeData pcData = ( JavaDialectRuntimeData ) pkg.getDialectRuntimeRegistry().getDialectData( "java" );
       
       
        final EvalCondition invoker = new EvalCondition(null);
        pcData.putInvoker(className, invoker);
        final InputStream is = getClass().getClassLoader().getResourceAsStream(className.replace('.', '/') + ".class");
        try {
            pcData.write(className.replace('.', '/') + ".class", read(is));
        } finally {
            is.close();
        }
       
        pcData.onAdd( pkg.getDialectRuntimeRegistry(), rb.getRootClassLoader() );
        pcData.onBeforeExecute();
       
        Class cls = ((InternalRuleBase)rb).getRootClassLoader().loadClass( "org.drools.core.rule.PackageCompilationDataTest$TestEvalExpression" );
       
        final CodeSource codeSource = invoker.getEvalExpression().getClass().getProtectionDomain().getCodeSource();
View Full Code Here

Examples of org.drools.core.reteoo.ReteooRuleBase

     *
     * @throws IntrospectionException
     */
    @Test
    public void testLiteralConstraint() throws IntrospectionException {
        final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        final InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newStatefulSession();

        final ClassFieldReader extractor = store.getReader(Cheese.class,
                "type",
                getClass().getClassLoader());

View Full Code Here

Examples of org.drools.core.reteoo.ReteooRuleBase

     *
     * @throws IntrospectionException
     */
    @Test
    public void testPrimitiveLiteralConstraint() throws IntrospectionException {
        final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        final InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newStatefulSession();

        final ClassFieldReader extractor = store.getReader(Cheese.class,
                "price",
                getClass().getClassLoader());

View Full Code Here

Examples of org.drools.core.reteoo.ReteooRuleBase

     *
     * @throws IntrospectionException
     */
    @Test
    public void testPredicateConstraint() throws IntrospectionException {
        final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        final InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newStatefulSession();

        final InternalReadAccessor priceExtractor = store.getReader( Cheese.class,
                                                                     "price",
                                                                     getClass().getClassLoader() );

View Full Code Here

Examples of org.drools.core.reteoo.ReteooRuleBase

     * @see junit.framework.TestCase#setUp()
     */
    @Before
    public void setUp() throws Exception {
        this.builder = new ReteooRuleBuilder();
        this.rulebase = new ReteooRuleBase( "default", null );
    }
View Full Code Here

Examples of org.drools.core.reteoo.ReteooRuleBase

        this.session = (ReteooWorkingMemory) session;
    }

    public StatefulKnowledgeSessionInfo getSessionInfo() {
        StatefulKnowledgeSessionInfo info = new StatefulKnowledgeSessionInfo();
        ReteooRuleBase rulebase = (ReteooRuleBase) session.getRuleBase();

        info.setSession( session );

        Stack<NetworkNode> nodeStack = new Stack<NetworkNode>();
        gatherNodeInfo( rulebase.getRete(),
                        nodeStack,
                        info );

        return info;
    }
View Full Code Here

Examples of org.drools.core.reteoo.ReteooRuleBase

        DrlParser parser = new DrlParser();
        PackageDescr packageDescr = parser.parse(null, drl);
        PackageBuilder builder = new PackageBuilder();
        builder.addPackage(packageDescr);
        Package pkg = builder.getPackage();
        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase(RuleBase.RETEOO);
        ruleBase.addPackage(pkg);

        final ReteooVisitor visitor = new ReteooVisitor( graph );
        visitor.visit( ruleBase );

        BaseVertex root = visitor.getRootVertex();
View Full Code Here

Examples of org.drools.reteoo.ReteooRuleBase

        this.ruleBase.writeExternal( out );
    }

    public void readExternal(ObjectInput in) throws IOException,
                                            ClassNotFoundException {
        ruleBase = new ReteooRuleBase();
        ruleBase.readExternal( in );
    }
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.