if (summary != null) {
synchronized (servletConfig) {
ServletContext sctx = context.getServletContext();
Options opt = new EmbeddedServletOptions(servletConfig, sctx);
JspRuntimeContext jrctx = new JspRuntimeContext(sctx, opt);
try {
//
// we need to pass context classloader here, so the jsps can reference /WEB-INF/classes and
// /WEB-INF/lib. JspCompilationContext would only take URLClassLoader, so we fake it
//
URLClassLoader classLoader = new URLClassLoader(new URL[]{}, context.getLoader().getClassLoader());
for (Iterator it = names.iterator(); it.hasNext();) {
String name = (String) it.next();
long time = System.currentTimeMillis();
JspCompilationContext jcctx = createJspCompilationContext(name, false, opt, sctx, jrctx, classLoader);
ClassLoader prevCl = ClassUtils.overrideThreadContextClassLoader(classLoader);
try {
Item item = (Item) summary.getItems().get(name);
if (item != null) {
try {
org.apache.jasper.compiler.Compiler c = jcctx.createCompiler();
c.compile();
item.setState(Item.STATE_READY);
item.setException(null);
logger.info("Compiled " + name + ": OK");
} catch (Exception e) {
item.setState(Item.STATE_FAILED);
item.setException(e);
logger.info("Compiled " + name + ": FAILED", e);
}
item.setCompileTime(System.currentTimeMillis() - time);
} else {
logger.error(name + " is not on the summary list, ignored");
}
} finally {
ClassUtils.overrideThreadContextClassLoader(prevCl);
}
}
} finally {
jrctx.destroy();
}
}
} else {
logger.error("summary is null for " + context.getName() + ", request ignored");
}