Package org.apache.jasper.compiler
Class Compiler
- java.lang.Object
-
- org.apache.jasper.compiler.Compiler
-
public class Compiler extends java.lang.ObjectMain JSP compiler class.
-
-
Field Summary
Fields Modifier and Type Field Description protected JspCompilationContextctxtprivate ErrorDispatchererrDispatcherprivate JavaCompilerjavaCompilerprivate booleanjavaCompilerOptionsSetprivate booleanjspcModeprivate longjspModTimeprivate JspServletWrapperjswprivate java.util.logging.Loggerlogprivate Optionsoptionsprivate PageInfopageInfoprivate Node.NodespageNodesprivate SmapUtilsmapUtilprivate static java.lang.String[]systemJarsprivate static java.lang.String[]systemJsfJarsprivate TagFileProcessortfp
-
Constructor Summary
Constructors Constructor Description Compiler(JspCompilationContext ctxt, JspServletWrapper jsw)Compiler(JspCompilationContext ctxt, JspServletWrapper jsw, boolean jspcMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcompile(boolean compileClass)Compile the jsp file from the current engine context.private voidgenerateClass()Compile the servlet from .java file to .class fileprivate voidgenerateJava()Compile the jsp file into equivalent servlet in java sourceprivate java.lang.ClassgetClassFor(java.lang.String className)JspCompilationContextgetCompilationContext()ErrorDispatchergetErrorDispatcher()Gets the error dispatcher.PageInfogetPageInfo()Gets the info about the page under compilationprivate voidinitJavaCompiler()Get an instance of JavaCompiler.booleanisOutDated()This is a protected method intended to be overridden by subclasses of Compiler.booleanisOutDated(boolean checkClass)Determine if a compilation is necessary by checking the time stamp of the JSP page with that of the corresponding .class or .java file.voidremoveGeneratedClassFiles()voidremoveGeneratedFiles()Remove generated filesprivate voidsetJavaCompilerOptions()voidsetPageInfo(PageInfo pageInfo)Sets the info about the page under compilationprivate booleansystemJarInWebinf(java.lang.String path)Return true if the path refers to a jar file in WEB-INF and is a system jar.
-
-
-
Field Detail
-
ctxt
protected JspCompilationContext ctxt
-
errDispatcher
private ErrorDispatcher errDispatcher
-
pageInfo
private PageInfo pageInfo
-
jsw
private JspServletWrapper jsw
-
tfp
private TagFileProcessor tfp
-
javaCompiler
private JavaCompiler javaCompiler
-
log
private java.util.logging.Logger log
-
jspcMode
private boolean jspcMode
-
smapUtil
private SmapUtil smapUtil
-
options
private Options options
-
pageNodes
private Node.Nodes pageNodes
-
jspModTime
private long jspModTime
-
javaCompilerOptionsSet
private boolean javaCompilerOptionsSet
-
systemJars
private static java.lang.String[] systemJars
-
systemJsfJars
private static java.lang.String[] systemJsfJars
-
-
Constructor Detail
-
Compiler
public Compiler(JspCompilationContext ctxt, JspServletWrapper jsw)
-
Compiler
public Compiler(JspCompilationContext ctxt, JspServletWrapper jsw, boolean jspcMode) throws JasperException
- Throws:
JasperException
-
-
Method Detail
-
generateJava
private void generateJava() throws java.lang.ExceptionCompile the jsp file into equivalent servlet in java source- Throws:
java.lang.Exception
-
setJavaCompilerOptions
private void setJavaCompilerOptions()
-
generateClass
private void generateClass() throws java.io.FileNotFoundException, JasperException, java.lang.ExceptionCompile the servlet from .java file to .class file- Throws:
java.io.FileNotFoundExceptionJasperExceptionjava.lang.Exception
-
compile
public void compile(boolean compileClass) throws java.io.FileNotFoundException, JasperException, java.lang.ExceptionCompile the jsp file from the current engine context. As an side- effect, tag files that are referenced by this page are also compiled.- Parameters:
compileClass- If true, generate both .java and .class file If false, generate only .java file- Throws:
java.io.FileNotFoundExceptionJasperExceptionjava.lang.Exception
-
isOutDated
public boolean isOutDated()
This is a protected method intended to be overridden by subclasses of Compiler. This is used by the compile method to do all the compilation.
-
isOutDated
public boolean isOutDated(boolean checkClass)
Determine if a compilation is necessary by checking the time stamp of the JSP page with that of the corresponding .class or .java file. If the page has dependencies, the check is also extended to its dependeants, and so on. This method can by overidden by a subclasses of Compiler.- Parameters:
checkClass- If true, check against .class file, if false, check against .java file.
-
getErrorDispatcher
public ErrorDispatcher getErrorDispatcher()
Gets the error dispatcher.
-
getPageInfo
public PageInfo getPageInfo()
Gets the info about the page under compilation
-
setPageInfo
public void setPageInfo(PageInfo pageInfo)
Sets the info about the page under compilation
-
getCompilationContext
public JspCompilationContext getCompilationContext()
-
removeGeneratedFiles
public void removeGeneratedFiles()
Remove generated files
-
removeGeneratedClassFiles
public void removeGeneratedClassFiles()
-
initJavaCompiler
private void initJavaCompiler() throws JasperExceptionGet an instance of JavaCompiler. If a compiler is specified in Options, use that, else if Running with JDK 6, use a Jsr199JavaCompiler that supports JSR199, else if eclipse's JDT compiler is available, use that. The default is to use javac from ant.- Throws:
JasperException
-
getClassFor
private java.lang.Class getClassFor(java.lang.String className)
-
systemJarInWebinf
private boolean systemJarInWebinf(java.lang.String path)
Return true if the path refers to a jar file in WEB-INF and is a system jar.
-
-