org.apache.jasper

Class JspC

public class JspC extends Object implements Options

Shell for the jspc compiler. Handles all options associated with the command line and creates compilation contexts which it then compiles according to the specified options. This version can process files from a _single_ webapp at once, i.e. a single docbase can be specified. It can be used as an Ant task using:
   <taskdef classname="org.apache.jasper.JspC" name="jasper2" >
      <classpath>
          <pathelement location="${java.home}/../lib/tools.jar"/>
          <fileset dir="${ENV.CATALINA_HOME}/server/lib">
              <include name="*.jar"/>
          </fileset>
          <fileset dir="${ENV.CATALINA_HOME}/common/lib">
              <include name="*.jar"/>
          </fileset>
          <path refid="myjars"/>
       </classpath>
  </taskdef>

  <jasper2 verbose="0"
           package="my.package"
           uriroot="${webapps.dir}/${webapp.name}"
           webXmlFragment="${build.dir}/generated_web.xml"
           outputDir="${webapp.dir}/${webapp.name}/WEB-INF/src/my/package" />
 

Author: Danno Ferrin Pierre Delisle Costin Manolache Yoav Shapira

Field Summary
static StringDEFAULT_IE_CLASS_ID
The default Microsoft Internet Explorer class ID.
Constructor Summary
JspC()
Constructor.
Method Summary
protected voidaddExtension(String extension)
Adds the given file extension to the list of extensions handled as JSP files.
voidexecute()
Executes the compilation.
voidgenerateWebMapping(String file, JspCompilationContext clctxt)
booleangenStringAsCharArray()
Indicates whether text strings are to be generated as char arrays.
MapgetCache()
intgetCheckInterval()
Background compilation check intervals in seconds
booleangetClassDebugInfo()
StringgetClassPath()
StringgetCompiler()
Compiler to use.
StringgetCompilerSourceVM()
StringgetCompilerTargetVM()
booleangetDevelopment()
Is Jasper being used in development mode?
booleangetErrorOnUseBeanInvalidClassAttribute()
ListgetExtensions()
Returns the list of file extensions that are treated as JSP files.
booleangetFailOnError()
booleangetFork()
StringgetIeClassId()
Gets the class-id value that is sent to Internet Explorer when using tags.
StringgetJavaEncoding()
Returns the encoding to use for java files.
StringgetJspCompilerPath()
ClassgetJspCompilerPlugin()
JspConfiggetJspConfig()
Obtain JSP configuration informantion specified in web.xml.
booleangetKeepGenerated()
booleangetMappedFile()
Are we supporting HTML mapped servlets?
intgetModificationTestInterval()
Modification test interval.
ProjectgetProject()
Returns the project: may be null if not running inside an Ant project.
ObjectgetProtectionDomain()
FilegetScratchDir()
booleangetSendErrorToClient()
TagPluginManagergetTagPluginManager()
intgetTagPoolSize()
TldLocationsCachegetTldLocationsCache()
booleangetTrimSpaces()
booleanisCaching()
booleanisPoolingEnabled()
booleanisSmapDumped()
Should SMAP info for JSR45 debugging be dumped to a file?
booleanisSmapSuppressed()
Is the generation of SMAP info for JSR45 debuggin suppressed?
booleanisXpoweredBy()
static voidmain(String[] arg)
protected voidmergeIntoWebXml()
Include the generated web.xml inside the webapp's web.xml.
protected FileresolveFile(String s)
Resolves the relative or absolute pathname correctly in both Ant and command-line situations.
voidscanFiles(File base)
Locate all jsp files in the webapp.
voidsetAddWebXmlMappings(boolean b)
voidsetArgs(String[] arg)
voidsetCaching(boolean caching)
voidsetClassDebugInfo(boolean b)
voidsetClassName(String p)
Class name of the generated file ( without package ).
voidsetClassPath(String s)
voidsetCompile(boolean b)
Sets the compile flag.
voidsetCompiler(String c)
voidsetCompilerSourceVM(String vm)
voidsetCompilerTargetVM(String vm)
voidsetErrorOnUseBeanInvalidClassAttribute(boolean b)
voidsetFailOnError(boolean b)
Set the option that throws an exception in case of a compilation error.
voidsetGenStringAsCharArray(boolean genStringAsCharArray)
Determines whether text strings are to be generated as char arrays, which improves performance in some cases.
voidsetIeClassId(String ieClassId)
Sets the class-id value to be sent to Internet Explorer when using tags.
voidsetJavaEncoding(String encodingName)
Sets the encoding to use for java files.
voidsetJspFiles(String jspFiles)
Parses comma-separated list of JSP files to be processed.
voidsetListErrors(boolean b)
voidsetOutputDir(String s)
voidsetPackage(String p)
voidsetPoolingEnabled(boolean poolingEnabled)
voidsetProject(Project theProject)
Sets the project.
voidsetSmapDumped(boolean smapDumped)
Set smapSuppressed flag.
voidsetSmapSuppressed(boolean smapSuppressed)
Set smapSuppressed flag.
voidsetTrimSpaces(boolean ts)
voidsetUriroot(String s)
Base dir for the webapp.
voidsetValidateXml(boolean b)
voidsetVerbose(int level)
Sets the verbosity level.
voidsetWebXml(String s)
File where we generate a complete web.xml with the class definitions.
voidsetWebXmlFragment(String s)
File where we generate a web.xml fragment with the class definitions.
voidsetXpoweredBy(boolean xpoweredBy)

Field Detail

DEFAULT_IE_CLASS_ID

public static final String DEFAULT_IE_CLASS_ID
The default Microsoft Internet Explorer class ID.

Constructor Detail

JspC

public JspC()
Constructor.

Method Detail

addExtension

protected void addExtension(String extension)
Adds the given file extension to the list of extensions handled as JSP files.

Parameters: extension The extension to add, e.g. "myjsp"

execute

public void execute()
Executes the compilation.

Throws: JasperException If an error occurs

generateWebMapping

public void generateWebMapping(String file, JspCompilationContext clctxt)

genStringAsCharArray

public boolean genStringAsCharArray()
Indicates whether text strings are to be generated as char arrays.

Returns: true if text strings are to be generated as char arrays, false otherwise

getCache

public Map getCache()

See Also: getCache

getCheckInterval

public int getCheckInterval()
Background compilation check intervals in seconds

getClassDebugInfo

public boolean getClassDebugInfo()

getClassPath

public String getClassPath()

getCompiler

public String getCompiler()
Compiler to use.

getCompilerSourceVM

public String getCompilerSourceVM()

See Also: getCompilerSourceVM

getCompilerTargetVM

public String getCompilerTargetVM()

See Also: Options

getDevelopment

public boolean getDevelopment()
Is Jasper being used in development mode?

getErrorOnUseBeanInvalidClassAttribute

public boolean getErrorOnUseBeanInvalidClassAttribute()

getExtensions

public List getExtensions()
Returns the list of file extensions that are treated as JSP files.

Returns: The list of extensions

getFailOnError

public boolean getFailOnError()

getFork

public boolean getFork()

getIeClassId

public String getIeClassId()
Gets the class-id value that is sent to Internet Explorer when using tags.

Returns: Class-id value

getJavaEncoding

public String getJavaEncoding()
Returns the encoding to use for java files. The default is UTF-8.

Returns: String The encoding

getJspCompilerPath

public String getJspCompilerPath()

getJspCompilerPlugin

public Class getJspCompilerPlugin()

getJspConfig

public JspConfig getJspConfig()
Obtain JSP configuration informantion specified in web.xml.

getKeepGenerated

public boolean getKeepGenerated()

getMappedFile

public boolean getMappedFile()
Are we supporting HTML mapped servlets?

getModificationTestInterval

public int getModificationTestInterval()
Modification test interval.

getProject

public Project getProject()
Returns the project: may be null if not running inside an Ant project.

Returns: The project

getProtectionDomain

public Object getProtectionDomain()

getScratchDir

public File getScratchDir()

getSendErrorToClient

public boolean getSendErrorToClient()

getTagPluginManager

public TagPluginManager getTagPluginManager()

getTagPoolSize

public int getTagPoolSize()

getTldLocationsCache

public TldLocationsCache getTldLocationsCache()

getTrimSpaces

public boolean getTrimSpaces()

isCaching

public boolean isCaching()

See Also: isCaching

isPoolingEnabled

public boolean isPoolingEnabled()

isSmapDumped

public boolean isSmapDumped()
Should SMAP info for JSR45 debugging be dumped to a file?

isSmapSuppressed

public boolean isSmapSuppressed()
Is the generation of SMAP info for JSR45 debuggin suppressed?

isXpoweredBy

public boolean isXpoweredBy()

main

public static void main(String[] arg)

mergeIntoWebXml

protected void mergeIntoWebXml()
Include the generated web.xml inside the webapp's web.xml.

resolveFile

protected File resolveFile(String s)
Resolves the relative or absolute pathname correctly in both Ant and command-line situations. If Ant launched us, we should use the basedir of the current project to resolve relative paths. See Bugzilla 35571.

Parameters: s The file

Returns: The file resolved

scanFiles

public void scanFiles(File base)
Locate all jsp files in the webapp. Used if no explicit jsps are specified.

setAddWebXmlMappings

public void setAddWebXmlMappings(boolean b)

setArgs

public void setArgs(String[] arg)

setCaching

public void setCaching(boolean caching)

See Also: isCaching

setClassDebugInfo

public void setClassDebugInfo(boolean b)

setClassName

public void setClassName(String p)
Class name of the generated file ( without package ). Can only be used if a single file is converted. XXX Do we need this feature ?

setClassPath

public void setClassPath(String s)

setCompile

public void setCompile(boolean b)
Sets the compile flag.

Parameters: b Flag value

setCompiler

public void setCompiler(String c)

setCompilerSourceVM

public void setCompilerSourceVM(String vm)

See Also: getCompilerSourceVM

setCompilerTargetVM

public void setCompilerTargetVM(String vm)

setErrorOnUseBeanInvalidClassAttribute

public void setErrorOnUseBeanInvalidClassAttribute(boolean b)

setFailOnError

public void setFailOnError(boolean b)
Set the option that throws an exception in case of a compilation error.

setGenStringAsCharArray

public void setGenStringAsCharArray(boolean genStringAsCharArray)
Determines whether text strings are to be generated as char arrays, which improves performance in some cases.

Parameters: genStringAsCharArray true if text strings are to be generated as char arrays, false otherwise

setIeClassId

public void setIeClassId(String ieClassId)
Sets the class-id value to be sent to Internet Explorer when using tags.

Parameters: ieClassId Class-id value

setJavaEncoding

public void setJavaEncoding(String encodingName)
Sets the encoding to use for java files.

Parameters: encodingName The name, e.g. "UTF-8"

setJspFiles

public void setJspFiles(String jspFiles)
Parses comma-separated list of JSP files to be processed. If the argument is null, nothing is done.

Each file is interpreted relative to uriroot, unless it is absolute, in which case it must start with uriroot.

Parameters: jspFiles Comma-separated list of JSP files to be processed

setListErrors

public void setListErrors(boolean b)

setOutputDir

public void setOutputDir(String s)

setPackage

public void setPackage(String p)

setPoolingEnabled

public void setPoolingEnabled(boolean poolingEnabled)

setProject

public void setProject(Project theProject)
Sets the project.

Parameters: theProject The project

setSmapDumped

public void setSmapDumped(boolean smapDumped)
Set smapSuppressed flag.

setSmapSuppressed

public void setSmapSuppressed(boolean smapSuppressed)
Set smapSuppressed flag.

setTrimSpaces

public void setTrimSpaces(boolean ts)

setUriroot

public void setUriroot(String s)
Base dir for the webapp. Used to generate class names and resolve includes

setValidateXml

public void setValidateXml(boolean b)

setVerbose

public void setVerbose(int level)
Sets the verbosity level. The actual number doesn't matter: if it's greater than zero, the verbose flag will be true.

Parameters: level Positive means verbose

setWebXml

public void setWebXml(String s)
File where we generate a complete web.xml with the class definitions.

setWebXmlFragment

public void setWebXmlFragment(String s)
File where we generate a web.xml fragment with the class definitions.

setXpoweredBy

public void setXpoweredBy(boolean xpoweredBy)
Copyright © 2000-2004 Apache Software Foundation. All Rights Reserved.