Package org.apache.jasper.compiler
Class Compiler
java.lang.Object
org.apache.jasper.compiler.Compiler
- Direct Known Subclasses:
AntCompiler
,JDTCompiler
Main JSP compiler class. This class uses Ant for compiling.
- Author:
- Anil K. Vijendran, Mandar Raje, Pierre Delisle, Kin-man Chung, Remy Maucherat, Mark Roth
-
Field Summary
Modifier and TypeFieldDescriptionprotected JspCompilationContext
protected ErrorDispatcher
protected JspServletWrapper
protected Options
protected org.apache.jasper.compiler.PageInfo
protected org.apache.jasper.compiler.Node.Nodes
protected org.apache.jasper.compiler.TagFileProcessor
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
compile()
Compile the jsp file from the current engine context.void
compile
(boolean compileClass) Compile the jsp file from the current engine context.void
compile
(boolean compileClass, boolean jspcMode) Compile the jsp file from the current engine context.protected abstract void
generateClass
(String[] smap) Servlet compilation.protected String[]
Compile the jsp file into equivalent servlet in .java fileorg.apache.jasper.compiler.PageInfo
org.apache.jasper.compiler.Node.Nodes
Retrieves the parsed nodes of the JSP page, if they are available.void
init
(JspCompilationContext ctxt, JspServletWrapper jsw) boolean
This is a protected method intended to be overridden by subclasses of Compiler.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.void
void
Remove generated files
-
Field Details
-
ctxt
-
errDispatcher
-
pageInfo
protected org.apache.jasper.compiler.PageInfo pageInfo -
jsw
-
tfp
protected org.apache.jasper.compiler.TagFileProcessor tfp -
options
-
pageNodes
protected org.apache.jasper.compiler.Node.Nodes pageNodes
-
-
Constructor Details
-
Compiler
public Compiler()
-
-
Method Details
-
init
-
getPageNodes
public org.apache.jasper.compiler.Node.Nodes getPageNodes()Retrieves the parsed nodes of the JSP page, if they are available. May return null. Used in development mode for generating detailed error messages. http://bz.apache.org/bugzilla/show_bug.cgi?id=37062.
- Returns:
- the page nodes
-
generateJava
Compile the jsp file into equivalent servlet in .java file- Returns:
- a smap for the current JSP page, if one is generated, null otherwise
- Throws:
Exception
- Error generating Java source
-
generateClass
protected abstract void generateClass(String[] smap) throws FileNotFoundException, JasperException, Exception Servlet compilation. This compiles the generated sources into Servlets.- Parameters:
smap
- The SMAP files for source debugging- Throws:
FileNotFoundException
- Source files not foundJasperException
- Compilation errorException
- Some other error
-
compile
Compile the jsp file from the current engine context.- Throws:
FileNotFoundException
- Source files not foundJasperException
- Compilation errorException
- Some other error
-
compile
Compile 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:
FileNotFoundException
- Source files not foundJasperException
- Compilation errorException
- Some other error
-
compile
public void compile(boolean compileClass, boolean jspcMode) throws FileNotFoundException, JasperException, Exception Compile 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 filejspcMode
- true if invoked from JspC, false otherwise- Throws:
FileNotFoundException
- Source files not foundJasperException
- Compilation errorException
- Some other error
-
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.- Returns:
true
if the source generation and compilation should occur
-
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 dependents, and so on. This method can by overridden by a subclasses of Compiler.- Parameters:
checkClass
- If true, check against .class file, if false, check against .java file.- Returns:
true
if the source generation and compilation should occur
-
getErrorDispatcher
- Returns:
- the error dispatcher.
-
getPageInfo
public org.apache.jasper.compiler.PageInfo getPageInfo()- Returns:
- the info about the page under compilation
-
getCompilationContext
-
removeGeneratedFiles
public void removeGeneratedFiles()Remove generated files -
removeGeneratedClassFiles
public void removeGeneratedClassFiles()
-