Package org.drools.rule

Examples of org.drools.rule.JavaDialectRuntimeData$PackageClassLoader


    javaDialect.addClassCompileTask(context.getPkg().getName() + "."
        + processDescr.getClassName(), processDescr, processClass,
        null, new ProcessErrorHandler(processDescr, process,
            "Process Compilation error"));

    JavaDialectRuntimeData data = (JavaDialectRuntimeData) context.getPkg()
      .getDialectRuntimeRegistry().getDialectData(javaDialect.getId());

    for (final Iterator it = context.getInvokers().keySet().iterator(); it
        .hasNext();) {
      final String className = (String) it.next();

      // Check if an invoker - Action has been associated
      // If so we add it to the PackageCompilationData as it will get
      // wired up on compilation
      final Object invoker = context.getInvokerLookups().get(className);
      if (invoker != null) {
        data.putInvoker(className, invoker);
      }
      final String text = (String) context.getInvokers().get(className);

      final BaseDescr descr = (BaseDescr) context.getDescrLookups().get(
          className);
View Full Code Here


        if ( type.isNovel() ) {
            try {
                ClassBuilder cb = new ClassBuilder();
                byte[] d = cb.buildClass( def );

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

                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

        }

        if ( type.isNovel() ) {
            String fullName = typeDescr.getType().getFullName();
            JavaDialectRuntimeData dialect = (JavaDialectRuntimeData) pkgRegistry.getDialectRuntimeRegistry().getDialectData( "java" );
            switch ( type.getKind() ) {
                case TRAIT :
                    try {
                        ClassBuilder tb = this.configuration.getClassBuilderFactory().getTraitBuilder();
                        byte[] d = tb.buildClass( def );
                        String resourceName = JavaDialectRuntimeData.convertClassToResourcePath( fullName );
                        dialect.putClassDefinition( resourceName, d );
                        if ( ruleBase != null ) {
                            ruleBase.registerAndLoadTypeDefinition( fullName, d );
                        } else {
                            dialect.write( resourceName, d );
                        }
                    } catch ( Exception e ) {
                        this.results.add( new TypeDeclarationError( typeDescr,
                                                                    "Unable to compile declared trait " + fullName +
                                                                    ": " + e.getMessage() + ";" ) );
                    }
                    break;
                case ENUM :
                    try {
                        ClassBuilder eb = this.configuration.getClassBuilderFactory().getEnumClassBuilder();
                        byte[] d = eb.buildClass( def );
                        String resourceName = JavaDialectRuntimeData.convertClassToResourcePath( fullName );
                        dialect.putClassDefinition( resourceName, d );
                        if ( ruleBase != null ) {
                            ruleBase.registerAndLoadTypeDefinition( fullName, d );
                        } else {
                            dialect.write( resourceName, d );
                        }
                    } catch ( Exception e ) {
                        e.printStackTrace();
                        this.results.add( new TypeDeclarationError( typeDescr,
                                                                    "Unable to compile declared enum " + fullName +
                                                                    ": " + e.getMessage() + ";" ) );
                    }
                    break;
                case CLASS :
                default :
                    try {
                        ClassBuilder cb = this.configuration.getClassBuilderFactory().getBeanClassBuilder();
                        byte[] d = cb.buildClass( def );
                        String resourceName = JavaDialectRuntimeData.convertClassToResourcePath( fullName );
                        dialect.putClassDefinition( resourceName, d );
                        if ( ruleBase != null ) {
                            ruleBase.registerAndLoadTypeDefinition( fullName, d );
                        }
                        else {
                            dialect.write( resourceName, d );
                        }
                    } catch ( Exception e ) {
                        this.results.add( new TypeDeclarationError( typeDescr,
                                                                    "Unable to create a class for declared type " + fullName +
                                                                    ": " + e.getMessage() + ";" ) );
View Full Code Here

    }

    public void dispose() {
        for ( PackageRegistry pkgRegistry : this.getPackageRegistry().values() ) {
            DialectRuntimeRegistry dialects = pkgRegistry.getPackage().getDialectRuntimeRegistry();
            JavaDialectRuntimeData java = (JavaDialectRuntimeData) dialects.getDialectData( JavaDialect.ID );
            java.dispose();
        }
        this.rootClassLoader.dispose();
        this.getPackageRegistry().clear();
    }
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.src = new MemoryResourceReader();

        this.generatedClassList = new ArrayList<String>();

        JavaDialectRuntimeData data = (JavaDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData( ID );

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

                             this.src,
                             new RuleErrorHandler( ruleDescr,
                                                   rule,
                                                   "Rule Compilation error" ) );

        JavaDialectRuntimeData data = (JavaDialectRuntimeData) this.pkg.getDialectRuntimeRegistry().getDialectData( ID );

        for ( Map.Entry<String, String> invokers : context.getInvokers().entrySet() ) {
            final String className = invokers.getKey();

            // Check if an invoker - returnvalue, predicate, eval or consequence has been associated
            // If so we add it to the PackageCompilationData as it will get wired up on compilation
            final Object invoker = context.getInvokerLookups().get( className );
            if ( invoker != null ) {
                data.putInvoker( className,
                                 invoker );
            }
            final String text = invokers.getValue();

            final BaseDescr descr = (BaseDescr) context.getDescrLookups().get( className );
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

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.