Package org.drools.compiler.builder.impl

Examples of org.drools.compiler.builder.impl.KnowledgeBuilderImpl


           "    @role(event)\n" +             
           "end\n" +
           "declare " + DImpl.class.getCanonicalName() + "\n" +
           "end\n";

        KnowledgeBuilderImpl builder = getPackageBuilder( str );
        TypeDeclaration tdecl = builder.getTypeDeclaration( DImpl.class );
        assertEquals( true, tdecl.isTypesafe() );
        assertEquals( Role.Type.EVENT, tdecl.getRole() );
    }   
View Full Code Here


           "    @role(event)\n" +             
           "end\n" +          
           "declare " + DImpl.class.getCanonicalName() + "\n" +
           "    @typesafe(false)\n" +
           "end\n";
        KnowledgeBuilderImpl builder = getPackageBuilder( str );
        TypeDeclaration tdecl = builder.getTypeDeclaration( DImpl.class );
        assertEquals( false, tdecl.isTypesafe() );
        assertEquals( Role.Type.EVENT, tdecl.getRole() );
    }
View Full Code Here

           "    @role(event)\n" +             
           "end\n" +          
           "declare " + DImpl.class.getCanonicalName() + "\n" +
           "    @typesafe(false)\n" +
           "end\n";
        KnowledgeBuilderImpl builder = getPackageBuilder( str );
        TypeDeclaration tdecl = builder.getTypeDeclaration( DImpl.class );
        assertEquals( false, tdecl.isTypesafe() );
        assertEquals( Role.Type.EVENT, tdecl.getRole() );
    }   
View Full Code Here

           "declare " + IB.class.getCanonicalName() + "\n" +
           "    @role(fact)\n" +             
           "end\n" +            
           "declare " + DImpl.class.getCanonicalName() + "\n" +
           "end\n";
        KnowledgeBuilderImpl builder = getPackageBuilder( str );
        TypeDeclaration tdecl = builder.getTypeDeclaration( DImpl.class );
        assertEquals( true, tdecl.isTypesafe() );
        assertEquals( Role.Type.FACT, tdecl.getRole() );
    }       
View Full Code Here

           "declare " + IB.class.getCanonicalName() + "\n" +
           "    @typesafe(true)\n" +
           "    @role(event)\n" +             
           "end\n";

        KnowledgeBuilderImpl builder = getPackageBuilder( str );
        TypeDeclaration tdecl = builder.getTypeDeclaration( DImpl.class );
        assertEquals( true, tdecl.isTypesafe() );
        assertEquals( Role.Type.EVENT, tdecl.getRole() );
    }   
View Full Code Here

           "    @role(event)\n" +          
           "end\n" +
           "declare " + DImpl.class.getCanonicalName() + "\n" +
           "end\n";

        KnowledgeBuilderImpl builder = getPackageBuilder( str );
        TypeDeclaration tdecl = builder.getTypeDeclaration( DImpl.class );
        assertEquals( true, tdecl.isTypesafe() );
        assertEquals( Role.Type.EVENT, tdecl.getRole() );
    }    
View Full Code Here

           "declare " + CImpl.class.getCanonicalName() + "\n" +
           "    @role(fact)\n" +             
           "end\n" +            
           "declare " + DImpl.class.getCanonicalName() + "\n" +
           "end\n";
        KnowledgeBuilderImpl builder = getPackageBuilder( str );
        TypeDeclaration tdecl = builder.getTypeDeclaration( DImpl.class );
        assertEquals( true, tdecl.isTypesafe() );
        assertEquals( Role.Type.FACT, tdecl.getRole() );
    }     
View Full Code Here

                // have to save for later removal to avoid iteration errors
                kbasesToRemove.add( kbaseName );
            } else {
                // attaching the builder to the kbase
                KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder((KnowledgeBase) kBaseEntry.getValue());
                KnowledgeBuilderImpl pkgbuilder = (KnowledgeBuilderImpl)kbuilder;
                CompositeKnowledgeBuilder ckbuilder = kbuilder.batch();

                boolean modifyingUsedClass = false;
                for (String modifiedClass : modifiedClasses) {
                    if ( pkgbuilder.isClassInUse( convertResourceToClassName(modifiedClass) ) ) {
                        modifyingUsedClass = true;
                        break;
                    }
                }

                boolean shouldRebuild = modifyingUsedClass;
                if (modifyingUsedClass) {
                    // there are modified classes used by this kbase, so it has to be completely updated
                    updateAllResources(currentKM, newKM, kieBaseModel, pkgbuilder, ckbuilder);
                } else {
                    // there are no modified classes used by this kbase, so update it incrementally
                    shouldRebuild = updateResourcesIncrementally(currentKM, newKM, cs, modifiedClasses, kBaseEntry,
                                                                 kieBaseModel, pkgbuilder, ckbuilder) > 0;
                }

                pkgbuilder.startPackageUpdate();
                try {
                    // remove resources first
                    for ( ResourceChangeSet rcs : cs.getChanges().values() ) {
                        if ( rcs.getChangeType() == ChangeType.REMOVED ) {
                            String resourceName = rcs.getResourceName();
                            if ( !resourceName.endsWith( ".properties" ) && isFileInKBase(newKM, kieBaseModel, resourceName) ) {
                                pkgbuilder.removeObjectsGeneratedFromResource( currentKM.getResource( resourceName ) );
                            }
                        }
                    }

                    if ( shouldRebuild ) {
                        rebuildAll(newReleaseId, results, newKM, modifiedClasses, kieBaseModel, pkgbuilder, ckbuilder);
                    }
                } finally {
                    pkgbuilder.completePackageUpdate();
                }
            }
        }

        for (String kbaseToRemove : kbasesToRemove) {
View Full Code Here

        if (className == null) {
            return null;
        }

        String namespace = context.getRuleDescr().getNamespace();
        KnowledgeBuilderImpl packageBuilder = context.getKnowledgeBuilder();

        Class<?> clazz = null;
        try {
            clazz = Class.forName(className.indexOf('.') < 0 ? namespace + "." + className : className, false, packageBuilder.getRootClassLoader());
        } catch (ClassNotFoundException e) { }

        if (clazz != null) {
            return clazz;
        }

        Set<String> imports = new HashSet<String>();
        List<PackageDescr> pkgDescrs = packageBuilder.getPackageDescrs(namespace);
        if (pkgDescrs == null) {
            return null;
        }
        for (PackageDescr pkgDescr : pkgDescrs) {
            for (ImportDescr importDescr : pkgDescr.getImports()) {
                imports.add(importDescr.getTarget());
            }
        }
        return findClass(className, imports, packageBuilder.getRootClassLoader());
    }
View Full Code Here

        catch ( Exception e ) {
            kbuilder.getErrors().add(new BayesNetworkAssemblerError(resource, "Unable to build Junction Tree:\n" + e.toString()));
            return;
        }

        KnowledgeBuilderImpl kbuilderImpl = (KnowledgeBuilderImpl) kbuilder;
        PackageRegistry pkgReg = kbuilderImpl.getPackageRegistry( network.getPackageName() );
        if ( pkgReg == null ) {
            pkgReg = kbuilderImpl.newPackage( new PackageDescr( network.getPackageName() ) );
        }

        InternalKnowledgePackage kpkgs = pkgReg.getPackage();

View Full Code Here

TOP

Related Classes of org.drools.compiler.builder.impl.KnowledgeBuilderImpl

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.