org.apache.struts2.jasper.compiler

## Class Compiler

- java.lang.Object
- - org.apache.struts2.jasper.compiler.Compiler

- Direct Known Subclasses:
    CustomCompiler

      public abstract class Compiler
      extends Object

  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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected JspCompilationContext` | `ctxt`
    `protected ErrorDispatcher` | `errDispatcher`
    `protected JspServletWrapper` | `jsw`
    `protected org.apache.juli.logging.Log` | `log`
    `protected Options` | `options`
    `protected org.apache.struts2.jasper.compiler.PageInfo` | `pageInfo`
    `protected Node.Nodes` | `pageNodes`
    `protected org.apache.struts2.jasper.compiler.TagFileProcessor` | `tfp`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Compiler()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `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)` Compile the servlet from .java file to .class file
    `protected String[]` | `generateJava()` Compile the jsp file into equivalent servlet in .java file
    `JspCompilationContext` | `getCompilationContext()`
    `ErrorDispatcher` | `getErrorDispatcher()`
    `org.apache.struts2.jasper.compiler.PageInfo` | `getPageInfo()`
    `Node.Nodes` | `getPageNodes()` Retrieves the parsed nodes of the JSP page, if they are available.
    `void` | `init(JspCompilationContext ctxt, JspServletWrapper jsw)`
    `boolean` | `isOutDated()` 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` | `removeGeneratedClassFiles()`
    `void` | `removeGeneratedFiles()` Remove generated files

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### log

          protected org.apache.juli.logging.Log log

    - #### ctxt

          protected JspCompilationContext ctxt

    - #### errDispatcher

          protected ErrorDispatcher errDispatcher

    - #### pageInfo

          protected org.apache.struts2.jasper.compiler.PageInfo pageInfo

    - #### jsw

          protected JspServletWrapper jsw

    - #### tfp

          protected org.apache.struts2.jasper.compiler.TagFileProcessor tfp

    - #### options

          protected Options options

    - #### pageNodes

          protected Node.Nodes pageNodes

  - ### Constructor Detail

    - #### Compiler

          public Compiler()

  - ### Method Detail

    - #### init

          public void init(JspCompilationContext ctxt,
                  JspServletWrapper jsw)

    - #### getPageNodes

          public 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://issues.apache.org/bugzilla/show_bug.cgi?id=37062.

      Returns:
        page nodes

    - #### generateJava

          protected String[] generateJava()
                                   throws Exception

      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` - in case of any errors

    - #### generateClass

          protected abstract void generateClass(String[] smap)
                                         throws FileNotFoundException,
                                                JasperException,
                                                Exception

      Compile the servlet from .java file to .class file
      Parameters:
        `smap` - string array
      Throws:
        `FileNotFoundException` - is file was not found
        `JasperException` - in case of jasper errors
        `Exception` - in case of other errors

    - #### compile

          public void compile()
                       throws FileNotFoundException,
                              JasperException,
                              Exception

      Compile the jsp file from the current engine context
      Throws:
        `FileNotFoundException` - is file was not found
        `JasperException` - in case of jasper errors
        `Exception` - in case of other errors

    - #### compile

          public void compile(boolean compileClass)
                       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 file
      Throws:
        `FileNotFoundException` - is file was not found
        `JasperException` - in case of jasper errors
        `Exception` - in case of other errors

    - #### 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 file
        `jspcMode` - true if invoked from JspC, false otherwise
      Throws:
        `FileNotFoundException` - is file was not found
        `JasperException` - in case of jasper errors
        `Exception` - in case of other errors

    - #### 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 out dated

    - #### 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 dependants, 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 out dated

    - #### getErrorDispatcher

          public ErrorDispatcher getErrorDispatcher()

      Returns:
        the error dispatcher.

    - #### getPageInfo

          public org.apache.struts2.jasper.compiler.PageInfo getPageInfo()

      Returns:
        the info about the page under compilation

    - #### getCompilationContext

          public JspCompilationContext getCompilationContext()

    - #### removeGeneratedFiles

          public void removeGeneratedFiles()

      Remove generated files

    - #### removeGeneratedClassFiles

          public void removeGeneratedClassFiles()

Copyright © 2000–2020 Apache Software Foundation. All rights reserved.