Package com.envoisolutions.sxc.builder

Examples of com.envoisolutions.sxc.builder.BuildException


                writer = (Writer) writerCls.getConstructor(Context.class).newInstance(this);
            } else {
                writer = null;
            }
        } catch (Exception e) {
            throw new BuildException(e);
        }
    }
View Full Code Here


        model = buildContext.getCodeModel();
        try {
            readerClass = model._class(className);
            baseClass = model.ref(Reader.class);
        } catch (JClassAlreadyExistsException e) {
            throw new BuildException(e);
        }

        constructor = readerClass.constructor(JMod.PUBLIC);
        constructor.body().invoke("super").arg(constructor.param(Context.class,"context"));
View Full Code Here

            boolean accessibility = field.isAccessible();
            field.setAccessible(true);
            field.set(method, type);
            field.setAccessible(accessibility);
        } catch (Exception e) {
            throw new BuildException(e);
        }
    }
View Full Code Here

       
        try {
            writerClass = model._class(className);
            writerClass._extends(Writer.class);
        } catch (JClassAlreadyExistsException e) {
            throw new BuildException(e);
        }

        JMethod ctr = writerClass.constructor(JMod.PUBLIC);
        ctr.body().invoke("super").arg(ctr.param(Context.class,"context"));
       
View Full Code Here

                cc.method(JMod.PUBLIC, Writer.class,"createWriter")
                    .body()._return( writerBuilder!=null
                        ? JExpr._new(writerBuilder.getWriterClass())
                        : JExpr._null());
            } catch (JClassAlreadyExistsException e) {
                throw new BuildException(e);
            }
        }
        this.contextClassName = contextClassName;
    }
View Full Code Here

                dir.mkdirs();
                write(dir);
               
               
            } catch (IOException e) {
                throw new BuildException(e);
            }
        }
       
        ClassLoader cl = compiler.compile(file);
View Full Code Here

        model = buildContext.getCodeModel();
        try {
            readerClass = model._class(className);
            baseClass = model.ref(Reader.class);
        } catch (JClassAlreadyExistsException e) {
            throw new BuildException(e);
        }

        constructor = readerClass.constructor(JMod.PUBLIC);
        constructor.body().invoke("super").arg(constructor.param(Context.class,"context"));
View Full Code Here

            boolean accessibility = field.isAccessible();
            field.setAccessible(true);
            field.set(method, type);
            field.setAccessible(accessibility);
        } catch (Exception e) {
            throw new BuildException(e);
        }
    }
View Full Code Here

            }
        }

        // throw an exception if we had some errors
        if (errorCount > 0) {
            throw new BuildException("Compile completed with " + errorCount + " errors and " + (compilerRequestor.getProblems().size() - errorCount) + " warnings");
        }

        // wrap generted byte code with a classloader
        return new MemoryClassLoader(Thread.currentThread().getContextClassLoader(), byteCode);
    }
View Full Code Here

        // create temp directory for classes
        String tmpdir = System.getProperty("java.io.tmpdir");
        File classDir = new File(new File(tmpdir), "classes" + hashCode() + System.currentTimeMillis());
        if (!classDir.mkdir()) {
            throw new BuildException("Could not create output directory.");
        }

        try {
            // class loader used to compile classes
            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            if (classLoader == null) classLoader = getClass().getClassLoader();

            // compile classes
            compile(sources, classDir, classLoader);

            // load classes
            Thread.currentThread().setContextClassLoader(classLoader);
            URLClassLoader cl = new URLClassLoader(new URL[]{classDir.toURL()}, classLoader);
            List<String> failedToLoad = new ArrayList<String>();
            for (String className : sources.keySet()) {
                try {
                    cl.loadClass(className);
                } catch (ClassNotFoundException e) {
                    failedToLoad.add(className);
                }
            }
            if (!failedToLoad.isEmpty()) {
                throw new BuildException("Could not load generated classes " + failedToLoad);
            }

            return cl;
        } catch (IOException e) {
            throw new BuildException(e);
        } finally {
            // clean up the temp directory
            Util.delete(classDir);
        }
    }
View Full Code Here

TOP

Related Classes of com.envoisolutions.sxc.builder.BuildException

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.