Package org.drools.rule

Examples of org.drools.rule.JavaDialectRuntimeData$PackageClassLoader


        }

        if ( type.isNovel() ) {
            String fullName = typeDescr.getType().getFullName();
            JavaDialectRuntimeData dialect = (JavaDialectRuntimeData) pkgRegistry.getDialectRuntimeRegistry().getDialectData( "java" );
            switch ( type.getFormat() ) {
                case TRAIT :
                    try {
                        byte[] d;

                        ClassBuilder tb = ClassBuilderFactory.getTraitBuilderService();
                        d = tb.buildClass( def );
                        dialect.write( JavaDialectRuntimeData.convertClassToResourcePath( fullName ),
                                       d );

                    } catch ( Exception e ) {
                        this.results.add( new TypeDeclarationError( "Unable to compile declared trait " + fullName + ": " + e.getMessage() + ";",
                                                                    typeDescr.getLine() ) );
                    }
                    break;
                case POJO :
                default :
                    try {
                        ClassBuilder cb = ClassBuilderFactory.getBeanClassBuilderService();
                        byte[] d = cb.buildClass( def );
                        dialect.write( JavaDialectRuntimeData.convertClassToResourcePath( fullName ),
                                       d );

                    } catch ( Exception e ) {
                        this.results.add( new TypeDeclarationError( "Unable to create a class for declared type " + fullName + ": " + e.getMessage() + ";",
                                                                    typeDescr.getLine() ) );
View Full Code Here


                def.addField( fieldDef );
            }

            byte[] d = cb.buildClass( def );

            JavaDialectRuntimeData dialect = (JavaDialectRuntimeData) pkgRegistry.getDialectRuntimeRegistry().getDialectData( "java" );

            dialect.write( JavaDialectRuntimeData.convertClassToResourcePath( fullName ),
                           d );

            type.setTypeClassDef( def );
        } catch ( Exception e ) {
            e.printStackTrace();
View Full Code Here

    private Package getPackage(String pack) {
        Package pkg = ruleBase.getPackage( pack );
        if ( pkg == null ) {
            pkg = new Package( pack );
            JavaDialectRuntimeData data = new JavaDialectRuntimeData();
            pkg.getDialectRuntimeRegistry().setDialectData( "java", data );
            data.onAdd(pkg.getDialectRuntimeRegistry(),
                    ruleBase.getRootClassLoader());
            ruleBase.addPackages( Arrays.asList(pkg) );
        }
        return pkg;
View Full Code Here

    private Package getPackage(String pack) {
        Package pkg = ruleBase.getPackage( pack );
        if ( pkg == null ) {
            pkg = new Package( pack );
            JavaDialectRuntimeData data = new JavaDialectRuntimeData();
            pkg.getDialectRuntimeRegistry().setDialectData( "java", data );
            data.onAdd(pkg.getDialectRuntimeRegistry(),
                    ruleBase.getRootClassLoader());
            ruleBase.addPackages( Arrays.asList(pkg) );
        }
        return pkg;
View Full Code Here

        this.rootClassLoader = this.config.getClassLoader();
        this.rootClassLoader.addClassLoader( getClass().getClassLoader() );

        this.declarationClassLoader = new JavaDialectRuntimeData.TypeDeclarationClassLoader(
                new JavaDialectRuntimeData(),
                this.rootClassLoader
        );
        this.rootClassLoader.addClassLoader( this.declarationClassLoader );

View Full Code Here

                                                               classLoaderCacheEnabled );

        droolsStream.setClassLoader( this.rootClassLoader );
        droolsStream.setRuleBase(this);

        JavaDialectRuntimeData typeStore = (JavaDialectRuntimeData) droolsStream.readObject();
        this.declarationClassLoader = new JavaDialectRuntimeData.TypeDeclarationClassLoader(
                        typeStore,
                        this.rootClassLoader
        );
        this.rootClassLoader.addClassLoader( this.declarationClassLoader );
View Full Code Here

        }


        if ( type.isNovel() ) {
            String fullName = typeDescr.getType().getFullName();
            JavaDialectRuntimeData dialect = (JavaDialectRuntimeData) pkgRegistry.getDialectRuntimeRegistry().getDialectData( "java" );
            switch (type.getFormat()) {
                case TRAIT:
                    try {
                        byte[] d;

                        ClassBuilder tb = ClassBuilderFactory.getTraitBuilderService();
                        d = tb.buildClass( def );
                        dialect.write( JavaDialectRuntimeData.convertClassToResourcePath( fullName ),
                                d );

                    } catch ( Exception e ) {
                        this.results.add( new TypeDeclarationError( "Unable to compile declared trait " + fullName + ": " + e.getMessage() + ";",
                                typeDescr.getLine() ) );
                    }
                    break;
                case POJO:
                default:
                    try {
                        ClassBuilder cb = ClassBuilderFactory.getBeanClassBuilderService( );
                        byte[] d = cb.buildClass( def );
                        dialect.write( JavaDialectRuntimeData.convertClassToResourcePath( fullName ),
                                d );

                    } catch ( Exception e ) {
                        this.results.add( new TypeDeclarationError( "Unable to create a class for declared type " + fullName + ": " + e.getMessage() + ";",
                                typeDescr.getLine() ) );
View Full Code Here

        this.rootClassLoader = this.config.getClassLoader();
        this.rootClassLoader.addClassLoader( getClass().getClassLoader() );

        this.declarationClassLoader = new JavaDialectRuntimeData.TypeDeclarationClassLoader(
                new JavaDialectRuntimeData(),
                this.rootClassLoader
        );
        this.rootClassLoader.addClassLoader( this.declarationClassLoader );

View Full Code Here

                                                               classLoaderCacheEnabled );

        droolsStream.setClassLoader(this.rootClassLoader);
        droolsStream.setRuleBase(this);

        JavaDialectRuntimeData typeStore = (JavaDialectRuntimeData) droolsStream.readObject();
        this.declarationClassLoader = new JavaDialectRuntimeData.TypeDeclarationClassLoader(
                        typeStore,
                        this.rootClassLoader
        );
        this.rootClassLoader.addClassLoader( this.declarationClassLoader );
View Full Code Here

        this.src = new MemoryResourceReader();

        this.generatedClassList = new ArrayList();

        JavaDialectRuntimeData data = null;

        // initialie the dialect runtime data if it doesn't already exist
        if ( pkg.getDialectRuntimeRegistry().getDialectData( ID ) == null ) {
            data = new JavaDialectRuntimeData();
            this.pkg.getDialectRuntimeRegistry().setDialectData( ID,
                                                                 data );
            data.onAdd( this.pkg.getDialectRuntimeRegistry(),
                        this.packageBuilder.getRootClassLoader() );
        }

        this.packageStoreWrapper = new PackageStore( data,
                                                     this.results );
View Full Code Here

TOP

Related Classes of org.drools.rule.JavaDialectRuntimeData$PackageClassLoader

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.