Class XJspCompiler
java.lang.Object
org.apache.jasper.compiler.Compiler
org.apache.jasper.compiler.JDTCompiler
net.sf.basedb.clients.web.extensions.XJspCompiler
public class XJspCompiler extends JDTCompiler
Class that enabled compilation of custom JSP pages that are
part of an extension that uses classes from the extension JAR
file (eg. a JAR file in the /WEB-INF/extensions directory).
To make this compiler work the following is required:
- The JSP file must have a '.xjsp' extension.
- This compiler class must be installed in Tomcat's /lib directory.
- The '.xjsp' extensions must be mapped to the regular JSP servlet with the 'compilerClass' parameter set to this class.
- Version:
- 2.7
- Author:
- nicklas
- Last modified
- $Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
-
Field Summary
Fields Modifier and Type Field Description private File
extensionsJar
private boolean
isXJsp
private long
lastModified
private Log
log
private static Pattern
PATH_MATCH
Path to JSP must match: /extensions/[jar-file-name]/[jsp-path].xjsp group(1) = JAR name, group(2) = JSP pathprivate File
pluginsDir
static String
RESOURCES_URL
The location where the extensions resources are extracted. -
Constructor Summary
Constructors Constructor Description XJspCompiler()
-
Method Summary
Modifier and Type Method Description void
compile(boolean compileClass, boolean jspcMode)
Called when a JSP page needs recompiling.protected URLClassLoader
getExtensionClassLoader()
Get a class loader that can load classes from the current web application as well as the extensions JAR file.protected File
getPluginsDir()
Get the path to the plug-in directory from BASE.protected ClassLoader
getWebAppClassLoader()
Get the class loader for the web application this JSP is located in.void
init(JspCompilationContext ctxt, JspServletWrapper jsw)
Initialises the compiler.boolean
isOutDated(boolean checkClass)
Checks if the extensions JAR file has been modified.protected void
setContextClassLoader()
Sets the context class loader if this JSP page is an extension JSP page and if the extensions JAR file has been modified since the last time the class loader was set.Methods inherited from class org.apache.jasper.compiler.JDTCompiler
generateClass
Methods inherited from class org.apache.jasper.compiler.Compiler
compile, compile, generateJava, getCompilationContext, getErrorDispatcher, getPageInfo, getSmap, isOutDated, removeGeneratedClassFiles, removeGeneratedFiles
-
Field Details
-
RESOURCES_URL
The location where the extensions resources are extracted.- See Also:
- Constant Field Values
-
PATH_MATCH
Path to JSP must match: /extensions/[jar-file-name]/[jsp-path].xjsp group(1) = JAR name, group(2) = JSP path -
log
-
pluginsDir
-
isXJsp
private boolean isXJsp -
extensionsJar
-
lastModified
private long lastModified
-
-
Constructor Details
-
XJspCompiler
public XJspCompiler()
-
-
Method Details
-
init
Initialises the compiler. The JSP name is matched against the required pattern and the name of the extensions JAR file is extracted from the request path. -
compile
public void compile(boolean compileClass, boolean jspcMode) throws FileNotFoundException, JasperException, ExceptionCalled when a JSP page needs recompiling. We check if the extension JAR file has been modified and update the class loader if it has.- Overrides:
compile
in classCompiler
- Throws:
FileNotFoundException
JasperException
Exception
-
isOutDated
public boolean isOutDated(boolean checkClass)Checks if the extensions JAR file has been modified. If not, calls super.isOutDated(checkClass)- Overrides:
isOutDated
in classCompiler
-
setContextClassLoader
Sets the context class loader if this JSP page is an extension JSP page and if the extensions JAR file has been modified since the last time the class loader was set. This method does nothing if the JSP file is not an extensions JSP file, or if the JAR file hasn't changed since the last use.- Throws:
Exception
-
getExtensionClassLoader
Get a class loader that can load classes from the current web application as well as the extensions JAR file. The class loader for the current web application can be found in JspRuntimeContext.getParentClassLoader(). The extensions class loader is loaded from JarClassLoader in BASE.- Throws:
Exception
-
getWebAppClassLoader
Get the class loader for the web application this JSP is located in. Default implementation returns JspRuntimeContext.getParentClassLoader() -
getPluginsDir
Get the path to the plug-in directory from BASE.- Since:
- 3.0
-