TagFileProcessorpublic class TagFileProcessor extends Object 1. Processes and extracts the directive info in a tag file.
2. Compiles and loads tag files used in a JSP file. |
Fields Summary |
---|
private Vector | tempVector |
Methods Summary |
---|
private java.lang.Class | loadTagFile(Compiler compiler, java.lang.String tagFilePath, javax.servlet.jsp.tagext.TagInfo tagInfo, PageInfo parentPageInfo)Compiles and loads a tagfile.
JspCompilationContext ctxt = compiler.getCompilationContext();
JspRuntimeContext rctxt = ctxt.getRuntimeContext();
JspServletWrapper wrapper =
(JspServletWrapper) rctxt.getWrapper(tagFilePath);
synchronized(rctxt) {
if (wrapper == null) {
wrapper = new JspServletWrapper(ctxt.getServletContext(),
ctxt.getOptions(),
tagFilePath,
tagInfo,
ctxt.getRuntimeContext(),
(URL) ctxt.getTagFileJarUrls().get(tagFilePath));
rctxt.addWrapper(tagFilePath,wrapper);
// Use same classloader and classpath for compiling tag files
wrapper.getJspEngineContext().setClassLoader(
(URLClassLoader) ctxt.getClassLoader());
wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
}
else {
// Make sure that JspCompilationContext gets the latest TagInfo
// for the tag file. TagInfo instance was created the last
// time the tag file was scanned for directives, and the tag
// file may have been modified since then.
wrapper.getJspEngineContext().setTagInfo(tagInfo);
}
Class tagClazz;
int tripCount = wrapper.incTripCount();
try {
if (tripCount > 0) {
// When tripCount is greater than zero, a circular
// dependency exists. The circularily dependant tag
// file is compiled in prototype mode, to avoid infinite
// recursion.
JspServletWrapper tempWrapper
= new JspServletWrapper(ctxt.getServletContext(),
ctxt.getOptions(),
tagFilePath,
tagInfo,
ctxt.getRuntimeContext(),
(URL) ctxt.getTagFileJarUrls().get(tagFilePath));
tagClazz = tempWrapper.loadTagFilePrototype();
tempVector.add(
tempWrapper.getJspEngineContext().getCompiler());
} else {
tagClazz = wrapper.loadTagFile();
}
} finally {
wrapper.decTripCount();
}
// Add the dependants for this tag file to its parent's
// dependant list. The only reliable dependency information
// can only be obtained from the tag instance.
try {
Object tagIns = tagClazz.newInstance();
if (tagIns instanceof JspSourceDependent) {
Iterator iter =
/* GlassFish Issue 812
((JspSourceDependent)tagIns).getDependants().iterator();
*/
// START GlassFish Issue 812
((java.util.List) ((JspSourceDependent)tagIns).getDependants()).iterator();
// END GlassFish Issue 812
while (iter.hasNext()) {
parentPageInfo.addDependant((String)iter.next());
}
}
} catch (Exception e) {
// ignore errors
}
return tagClazz;
}
| public void | loadTagFiles(Compiler compiler, Node.Nodes page)Implements a phase of the translation that compiles (if necessary)
the tag files used in a JSP files. The directives in the tag files
are assumed to have been proccessed and encapsulated as TagFileInfo
in the CustomTag nodes.
tempVector = new Vector();
page.visit(new TagFileLoaderVisitor(compiler));
| public static javax.servlet.jsp.tagext.TagInfo | parseTagFileDirectives(ParserController pc, java.lang.String name, java.lang.String path, javax.servlet.jsp.tagext.TagLibraryInfo tagLibInfo)Parses the tag file, and collects information on the directives included
in it. The method is used to obtain the info on the tag file, when the
handler that it represents is referenced. The tag file is not compiled
here.
ErrorDispatcher err = pc.getCompiler().getErrorDispatcher();
Node.Nodes page = null;
try {
page = pc.parseTagFileDirectives(path);
} catch (FileNotFoundException e) {
err.jspError("jsp.error.file.not.found", path);
} catch (IOException e) {
err.jspError("jsp.error.file.not.found", path);
}
TagFileDirectiveVisitor tagFileVisitor
= new TagFileDirectiveVisitor(pc.getCompiler(), tagLibInfo, name,
path);
page.visit(tagFileVisitor);
tagFileVisitor.postCheck();
return tagFileVisitor.getTagInfo();
| public void | removeProtoTypeFiles(java.lang.String classFileName)Removed the java and class files for the tag prototype
generated from the current compilation.
Iterator iter = tempVector.iterator();
while (iter.hasNext()) {
Compiler c = (Compiler) iter.next();
if (classFileName == null) {
c.removeGeneratedClassFiles();
} else if (classFileName.equals(
c.getCompilationContext().getClassFileName())) {
c.removeGeneratedClassFiles();
tempVector.remove(c);
return;
}
}
|
|