Better internal logic for DefaultComponentTemplateCompilerConfiguration.
This commit is contained in:
parent
9c21fb9a83
commit
8b7ffd64f8
@ -4,41 +4,45 @@ import groovy.lang.GroovyClassLoader;
|
|||||||
import org.codehaus.groovy.control.CompilePhase;
|
import org.codehaus.groovy.control.CompilePhase;
|
||||||
import org.codehaus.groovy.control.CompilerConfiguration;
|
import org.codehaus.groovy.control.CompilerConfiguration;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
public class DefaultComponentTemplateCompilerConfiguration implements ComponentTemplateCompilerConfiguration {
|
public class DefaultComponentTemplateCompilerConfiguration implements ComponentTemplateCompilerConfiguration {
|
||||||
|
|
||||||
private GroovyClassLoader groovyClassLoader;
|
private GroovyClassLoader groovyClassLoader;
|
||||||
private CompilerConfiguration groovyCompilerConfiguration;
|
private CompilerConfiguration groovyCompilerConfiguration;
|
||||||
private CompilePhase toCompilePhase;
|
private CompilePhase toCompilePhase;
|
||||||
|
|
||||||
|
public DefaultComponentTemplateCompilerConfiguration() {
|
||||||
|
this.groovyClassLoader = new GroovyClassLoader(Thread.currentThread().getContextClassLoader());
|
||||||
|
this.groovyCompilerConfiguration = new CompilerConfiguration();
|
||||||
|
this.toCompilePhase = CompilePhase.CLASS_GENERATION;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GroovyClassLoader getGroovyClassLoader() {
|
public GroovyClassLoader getGroovyClassLoader() {
|
||||||
return this.groovyClassLoader != null
|
return this.groovyClassLoader;
|
||||||
? this.groovyClassLoader
|
|
||||||
: new GroovyClassLoader(this.getClass().getClassLoader());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroovyClassLoader(GroovyClassLoader groovyClassLoader) {
|
public void setGroovyClassLoader(GroovyClassLoader groovyClassLoader) {
|
||||||
this.groovyClassLoader = groovyClassLoader;
|
this.groovyClassLoader = requireNonNull(groovyClassLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompilerConfiguration getGroovyCompilerConfiguration() {
|
public CompilerConfiguration getGroovyCompilerConfiguration() {
|
||||||
return this.groovyCompilerConfiguration != null
|
return this.groovyCompilerConfiguration;
|
||||||
? this.groovyCompilerConfiguration
|
|
||||||
: CompilerConfiguration.DEFAULT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroovyCompilerConfiguration(CompilerConfiguration groovyCompilerConfiguration) {
|
public void setGroovyCompilerConfiguration(CompilerConfiguration groovyCompilerConfiguration) {
|
||||||
this.groovyCompilerConfiguration = groovyCompilerConfiguration;
|
this.groovyCompilerConfiguration = requireNonNull(groovyCompilerConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompilePhase getToCompilePhase() {
|
public CompilePhase getToCompilePhase() {
|
||||||
return this.toCompilePhase != null ? this.toCompilePhase : CompilePhase.CLASS_GENERATION;
|
return this.toCompilePhase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToCompilePhase(CompilePhase toCompilePhase) {
|
public void setToCompilePhase(CompilePhase toCompilePhase) {
|
||||||
this.toCompilePhase = toCompilePhase;
|
this.toCompilePhase = requireNonNull(toCompilePhase);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user