public class ScriptCompilerImpl extends Object implements ScriptCompiler
| Modifier and Type | Field and Description |
|---|---|
protected JavaCompiler |
javaCompiler
Instance of JavaCompiler that will be used to compile classes
|
protected Iterable<File> |
libraries
List of jar files
|
protected ScriptClassLoader |
parentClassLoader
Parent classloader that has to be used for this compiler
|
| Constructor and Description |
|---|
ScriptCompilerImpl()
Creates new instance of JavaCompilerImpl.
|
| Modifier and Type | Method and Description |
|---|---|
protected Class<?>[] |
classNamesToClasses(Collection<String> classNames,
ScriptClassLoader cl)
Reolves list of classes by their names
|
CompilationResult |
compile(Iterable<File> compilationUnits)
Compiles given files.
|
CompilationResult |
compile(String[] classNames,
String[] sourceCode)
Compiles list of classes.
|
CompilationResult |
compile(String className,
String sourceCode)
Compiles given class.
|
protected CompilationResult |
doCompilation(Iterable<JavaFileObject> compilationUnits)
Actually performs compilation.
|
String[] |
getSupportedFileTypes()
Only java files are supported by java compiler
|
void |
setLibraires(Iterable<File> files)
Sets jar files that should be used for this compiler as libraries
|
void |
setParentClassLoader(ScriptClassLoader classLoader)
Sets parent classLoader for this JavaCompilerImpl
|
protected final JavaCompiler javaCompiler
protected ScriptClassLoader parentClassLoader
public ScriptCompilerImpl()
RuntimeException - if compiler is not availablepublic void setParentClassLoader(ScriptClassLoader classLoader)
setParentClassLoader in interface ScriptCompilerclassLoader - parent classloaderpublic void setLibraires(Iterable<File> files)
setLibraires in interface ScriptCompilerfiles - list of jar filespublic CompilationResult compile(String className, String sourceCode)
compile in interface ScriptCompilerclassName - Name of the classsourceCode - source codeRuntimeException - if compilation failed with errrospublic CompilationResult compile(String[] classNames, String[] sourceCode) throws IllegalArgumentException
compile in interface ScriptCompilerclassNames - classNamessourceCode - list of source codesIllegalArgumentException - if size of classNames not equals to size of sourceCodesRuntimeException - if compilation failed with errrospublic CompilationResult compile(Iterable<File> compilationUnits)
compile in interface ScriptCompilercompilationUnits - files to compileRuntimeException - if compilation failed with errrosprotected CompilationResult doCompilation(Iterable<JavaFileObject> compilationUnits)
compilationUnits - Units that will be compiledRuntimeException - if compilation failed with errrosprotected Class<?>[] classNamesToClasses(Collection<String> classNames, ScriptClassLoader cl)
classNames - names of the classescl - classLoader to use to resove classesRuntimeException - if can't find classpublic String[] getSupportedFileTypes()
getSupportedFileTypes in interface ScriptCompilerCopyright © 2014–2015. All rights reserved.