Package org.drools.compiler.builder.impl

Examples of org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addPackageFromDrl()


    private void initPackage() {
        final InputStream resourceAsStream = null;
        try {
            final KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl();
            builder.addPackageFromDrl( new InputStreamReader( RuleEngineTestBase.class.getResourceAsStream( this.bindUri ) ) );
            InternalKnowledgePackage pkg = builder.getPackage();

            this.pkg = pkg;
        } catch ( final IOException e ) {
            throw new ExceptionInInitializerError( "setUp() could not init the " + "RuleSet due to an IOException in the InputStream: " + e );
View Full Code Here


    @Test
    public void testCreateFromObject() throws Exception {
        final InputStream inputStream = null;
        try {
            final KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl();
            builder.addPackageFromDrl( new InputStreamReader( RuleEngineTestBase.class.getResourceAsStream( this.bindUri ) ) );
            InternalKnowledgePackage pkg = builder.getPackage();
            final RuleExecutionSet ruleExecutionSet = this.ruleSetProvider.createRuleExecutionSet( pkg,
                                                                                                   null );
            assertEquals( "rule set name",
                          "SistersRules",
View Full Code Here

           
            if ( dsrl == null ) {
                if ( source.equals( Constants.RES_SOURCE_TYPE_XML ) || source.equals( "xml" ) ) {
                    builder.addPackageFromXml( ruleExecutionSetReader );
                } else {
                    builder.addPackageFromDrl( ruleExecutionSetReader );
                }
            } else {
                if ( source.equals( Constants.RES_SOURCE_TYPE_XML ) || source.equals( "xml" ) ) {
                    // xml cannot specify a dsl
                    builder.addPackageFromXml( ruleExecutionSetReader );
View Full Code Here

                if ( source.equals( Constants.RES_SOURCE_TYPE_XML ) || source.equals( "xml" ) ) {
                    // xml cannot specify a dsl
                    builder.addPackageFromXml( ruleExecutionSetReader );
                } else {
                    if  ( dsrl instanceof Reader ) {
                        builder.addPackageFromDrl( ruleExecutionSetReader,
                                                   (Reader) dsrl );
                    } else {
                        builder.addPackageFromDrl( ruleExecutionSetReader,
                                                   new StringReader( (String) dsrl ) );
                    }
View Full Code Here

                } else {
                    if  ( dsrl instanceof Reader ) {
                        builder.addPackageFromDrl( ruleExecutionSetReader,
                                                   (Reader) dsrl );
                    } else {
                        builder.addPackageFromDrl( ruleExecutionSetReader,
                                                   new StringReader( (String) dsrl ) );
                    }
                }
            }
View Full Code Here

        try {
            //            logger.info(drl);
            // read in the source
            Reader source = new StringReader(drl);
            KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl();
            builder.addPackageFromDrl(source);
            InternalKnowledgePackage pkg = builder.getPackage();

            // add the package to a rulebase (deploy the rule package).
            InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
            kBase.addPackage(pkg);
View Full Code Here

        JavaDialectConfiguration javaConf = ( JavaDialectConfiguration ) conf.getDialectConfiguration( "java" );
        javaConf.setCompiler( JavaDialectConfiguration.ECLIPSE );
        javaConf.setJavaLanguageLevel( "1.5" );
       
        final KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl( conf );
        builder.addPackageFromDrl( new InputStreamReader( this.getClass().getResourceAsStream( "java5_rule.drl" ) ) );
        if ( builder.hasErrors() ) {
            fail( builder.getErrors().toString() );
        }
    }
View Full Code Here

    public void testJava14Defaults() throws Exception {
        final KnowledgeBuilderConfigurationImpl conf = new KnowledgeBuilderConfigurationImpl();
        JavaDialectConfiguration javaConf = ( JavaDialectConfiguration ) conf.getDialectConfiguration( "java" );
        javaConf.setCompiler( JavaDialectConfiguration.JANINO );
        final KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl( conf );
        builder.addPackageFromDrl( new InputStreamReader( this.getClass().getResourceAsStream( "java5_rule.drl" ) ) );
        assertTrue( builder.hasErrors() );
    }

}
View Full Code Here

    private void build(String msg, String resource, boolean showResults) throws DroolsParserException,
                        IOException {
        final KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl();
        long start = System.currentTimeMillis();
        builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( resource ) ) );
        InternalKnowledgePackage pkg = builder.getPackage();
        assertFalse(builder.hasErrors());
        assertNotNull(pkg);
        if (showResults) {
            System.out.print( "Time taken for " + msg + " : " + (System.currentTimeMillis() - start) );
View Full Code Here

                       out );
    }

    private void checkRuleBase(final String name) throws Exception {
        final KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl();
        builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_" + name + ".drl" ) ) );
        InternalKnowledgePackage pkg = builder.getPackage();

        final InternalKnowledgeBase kBase = (InternalKnowledgeBase) getKnowledgeBase();
        kBase.addPackage( pkg );
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.