Skip to content

Commit a48fdfd

Browse files
author
Kin Man Chung
committed
svn path=/trunk/; revision=1465
1 parent 4478e34 commit a48fdfd

File tree

4 files changed

+59
-19
lines changed

4 files changed

+59
-19
lines changed

impl/src/main/java/org/apache/jasper/EmbeddedServletOptions.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -201,6 +201,11 @@ public final class EmbeddedServletOptions implements Options {
201201
*/
202202
private String compilerSourceVM = "1.5";
203203

204+
/**
205+
* The compiler class name.
206+
*/
207+
private String compilerClassName = null;
208+
204209
/**
205210
* Cache for the TLD locations
206211
*/
@@ -412,6 +417,14 @@ public String getCompilerSourceVM() {
412417
return compilerSourceVM;
413418
}
414419

420+
/**
421+
* @see Options#getCompilerName
422+
*/
423+
public String getCompilerClassName() {
424+
return compilerClassName;
425+
}
426+
427+
415428
public boolean getErrorOnUseBeanInvalidClassAttribute() {
416429
return errorOnUseBeanInvalidClassAttribute;
417430
}
@@ -596,6 +609,11 @@ public EmbeddedServletOptions(ServletConfig config,
596609
this.javaEncoding = javaEncoding;
597610
}
598611

612+
String compilerClassName = config.getInitParameter("compilerClassName");
613+
if (compilerClassName != null) {
614+
this.compilerClassName = compilerClassName;
615+
}
616+
599617
String reloadIntervalString =
600618
config.getInitParameter("reload-interval");
601619
if (reloadIntervalString != null) {

impl/src/main/java/org/apache/jasper/JspC.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,13 @@ public void setCompilerSourceVM(String vm) {
728728
compilerSourceVM = vm;
729729
}
730730

731+
/**
732+
* @see Options#getCompilerClassName.
733+
*/
734+
public String getCompilerClassName() {
735+
return null;
736+
}
737+
731738
public TldScanner getTldScanner() {
732739
return tldScanner;
733740
}

impl/src/main/java/org/apache/jasper/Options.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -172,6 +172,11 @@ public interface Options {
172172
*/
173173
public String getCompilerSourceVM();
174174

175+
/**
176+
* The name of class that implements JavaCompiler, used for Java compilations.
177+
*/
178+
public String getCompilerClassName();
179+
175180
/**
176181
* The cache for the location of the TLD's
177182
* for the various tag libraries 'exposed'

impl/src/main/java/org/apache/jasper/compiler/Compiler.java

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -732,27 +732,37 @@ public void removeGeneratedClassFiles() {
732732

733733
/**
734734
* Get an instance of JavaCompiler.
735-
* If Running with JDK 6, use a Jsr199JavaCompiler that supports JSR199,
735+
* If a compiler is specified in Options, use that,
736+
* else if Running with JDK 6, use a Jsr199JavaCompiler that supports JSR199,
736737
* else if eclipse's JDT compiler is available, use that.
737738
* The default is to use javac from ant.
738739
*/
739740
private void initJavaCompiler() throws JasperException {
740-
boolean disablejsr199 = Boolean.TRUE.toString().equals(
741-
System.getProperty("org.apache.jasper.compiler.disablejsr199"));
742-
Double version =
743-
Double.valueOf(System.getProperty("java.specification.version"));
744-
if (!disablejsr199 &&
745-
(version >= 1.6 || getClassFor("javax.tools.Tool") != null)) {
746-
// JDK 6 or bundled with jsr199 compiler
747-
javaCompiler = new Jsr199JavaCompiler();
748-
} else {
749-
Class c = getClassFor("org.eclipse.jdt.internal.compiler.Compiler");
750-
if (c != null) {
751-
c = getClassFor("org.apache.jasper.compiler.JDTJavaCompiler");
741+
if (options.getCompilerClassName() != null) {
742+
Class c = getClassFor(options.getCompilerClassName());
743+
try {
744+
javaCompiler = (JavaCompiler) c.newInstance();
745+
} catch (Exception ex) {
746+
}
747+
}
748+
if (javaCompiler == null) {
749+
boolean disablejsr199 = Boolean.TRUE.toString().equals(
750+
System.getProperty("org.apache.jasper.compiler.disablejsr199"));
751+
Double version =
752+
Double.valueOf(System.getProperty("java.specification.version"));
753+
if (!disablejsr199 &&
754+
(version >= 1.6 || getClassFor("javax.tools.Tool") != null)) {
755+
// JDK 6 or bundled with jsr199 compiler
756+
javaCompiler = new Jsr199JavaCompiler();
757+
} else {
758+
Class c = getClassFor("org.eclipse.jdt.internal.compiler.Compiler");
752759
if (c != null) {
753-
try {
754-
javaCompiler = (JavaCompiler) c.newInstance();
755-
} catch (Exception ex) {
760+
c = getClassFor("org.apache.jasper.compiler.JDTJavaCompiler");
761+
if (c != null) {
762+
try {
763+
javaCompiler = (JavaCompiler) c.newInstance();
764+
} catch (Exception ex) {
765+
}
756766
}
757767
}
758768
}

0 commit comments

Comments
 (0)