Examples of JavaProgram


Examples of org.apache.cocoon.components.language.programming.java.JavaProgram

        // Used for preload/precompile option.
        // Don't need to test for existence of the object code as it might be bundled into the WAR.
        try {
            Class program = this.loadProgram(filename, baseDirectory);
            Object testInstance = program.newInstance();
            return new JavaProgram(program);
        } catch (Throwable t) {
            // Ignore errors if any, try to compile.
        }

        // Does source file exist?
        File sourceFile = new File(baseDirectory, filename + "." + this.getSourceExtension());
        if (!sourceFile.exists()) {
            throw new LanguageException("Can't load program - File doesn't exist: " + IOUtils.getFullFilename(sourceFile));
        }
        if (!sourceFile.isFile()) {
            throw new LanguageException("Can't load program - File is not a normal file: " + IOUtils.getFullFilename(sourceFile));
        }
        if (!sourceFile.canRead()) {
            throw new LanguageException("Can't load program - File cannot be read: " + IOUtils.getFullFilename(sourceFile));
        }
        this.compile(filename, baseDirectory, encoding);
        if (this.deleteSources) {
            sourceFile.delete();
        }
        Class program = this.loadProgram(filename, baseDirectory);

        // Try to instantiate once to ensure there are no exceptions thrown in the constructor
        try {
            Object testInstance = program.newInstance();
        } catch(IllegalAccessException iae) {
            getLogger().debug("No public constructor for class " + program.getName());
        } catch(Exception e) {
            // Unload class and delete the object file, or it won't be recompiled
            // (leave the source file to allow examination).
            this.doUnload(program);
            new File(baseDirectory, filename + "." + this.getObjectExtension()).delete();

            String message = "Error while instantiating " + filename;
            getLogger().debug(message, e);
            throw new LanguageException(message, e);
        }

        if (program == null) {
            throw new LanguageException("Can't load program : " + baseDirectory.toString() + File.separator + filename);
        }

        return new JavaProgram(program);
    }
View Full Code Here

Examples of org.apache.cocoon.components.language.programming.java.JavaProgram

        // Don't need to test for existence of the object code as it might be bundled into the WAR.
        try {
            Class program = this.loadProgram(filename, baseDirectory);
            // Create and discard test instance.
            program.newInstance();
            return new JavaProgram(program);
        } catch (Throwable t) {
            throw new LanguageException("Unable to preload program " + filename, t);
        }
    }
View Full Code Here

Examples of org.apache.cocoon.components.language.programming.java.JavaProgram

        if (program == null) {
            throw new LanguageException("Can't load program : " + baseDirectory.toString() + File.separator + filename);
        }

        return new JavaProgram(program);
    }
View Full Code Here

Examples of org.apache.cocoon.components.language.programming.java.JavaProgram

        // Don't need to test for existence of the object code as it might be bundled into the WAR.
        try {
            Class program = this.loadProgram(filename, baseDirectory);
            // Create and discard test instance.
            program.newInstance();
            return new JavaProgram(program);
        } catch (Throwable t) {
            throw new LanguageException("Unable to preload program " + filename, t);
        }
    }
View Full Code Here

Examples of org.apache.cocoon.components.language.programming.java.JavaProgram

        if (program == null) {
            throw new LanguageException("Can't load program : " + baseDirectory.toString() + File.separator + filename);
        }

        return new JavaProgram(program);
    }
View Full Code Here

Examples of org.apache.cocoon.components.language.programming.java.JavaProgram

    public Program preload(String filename, File baseDirectory, String encoding) throws LanguageException {
        // Don't need to test for existence of the object code as it might be bundled into the WAR.
        try {
            Class program = this.loadProgram(filename, baseDirectory);
            Object testInstance = program.newInstance();
            return new JavaProgram(program);
        } catch (Throwable t) {
            throw new LanguageException("Unable to preload program " + filename, t);
        }
    }
View Full Code Here

Examples of org.apache.cocoon.components.language.programming.java.JavaProgram

        if (program == null) {
            throw new LanguageException("Can't load program : " + baseDirectory.toString() + File.separator + filename);
        }

        return new JavaProgram(program);
    }
View Full Code Here

Examples of org.apache.cocoon.components.language.programming.java.JavaProgram

        // Don't need to test for existence of the object code as it might be bundled into the WAR.
        try {
            Class program = this.loadProgram(filename, baseDirectory);
            // Create and discard test instance.
            program.newInstance();
            return new JavaProgram(program);
        } catch (Throwable t) {
            throw new LanguageException("Unable to preload program " + filename, t);
        }
    }
View Full Code Here

Examples of org.apache.cocoon.components.language.programming.java.JavaProgram

        if (program == null) {
            throw new LanguageException("Can't load program : " + baseDirectory.toString() + File.separator + filename);
        }

        return new JavaProgram(program);
    }
View Full Code Here

Examples of org.apache.cocoon.components.language.programming.java.JavaProgram

        // Don't need to test for existence of the object code as it might be bundled into the WAR.
        try {
            Class program = this.loadProgram(filename, baseDirectory);
            // Create and discard test instance.
            program.newInstance();
            return new JavaProgram(program);
        } catch (Throwable t) {
            throw new LanguageException("Unable to preload program " + filename, t);
        }
    }
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.