Processes a single JSP file, compiling it and generating the web.xml mapping. @param file Context-relative path to the JSP file @throws JasperException If a compilation error occurs
(String file)
| 1384 | * @throws JasperException If a compilation error occurs |
| 1385 | */ |
| 1386 | protected void processFile(String file) throws JasperException { |
| 1387 | |
| 1388 | if (log.isDebugEnabled()) { |
| 1389 | log.debug(Localizer.getMessage("jspc.processing", file)); |
| 1390 | } |
| 1391 | |
| 1392 | ClassLoader originalClassLoader = null; |
| 1393 | Thread currentThread = Thread.currentThread(); |
| 1394 | |
| 1395 | try { |
| 1396 | // set up a scratch/output dir if none is provided |
| 1397 | if (scratchDir == null) { |
| 1398 | String temp = System.getProperty("java.io.tmpdir"); |
| 1399 | if (temp == null) { |
| 1400 | temp = ""; |
| 1401 | } |
| 1402 | scratchDir = new File(temp).getAbsoluteFile(); |
| 1403 | } |
| 1404 | |
| 1405 | String jspUri = file.replace('\\', '/'); |
| 1406 | JspCompilationContext clctxt = new JspCompilationContext(jspUri, this, context, null, rctxt); |
| 1407 | |
| 1408 | /* Override the defaults */ |
| 1409 | if ((targetClassName != null) && (!targetClassName.isEmpty())) { |
| 1410 | clctxt.setServletClassName(targetClassName); |
| 1411 | targetClassName = null; |
| 1412 | } |
| 1413 | if (targetPackage != null) { |
| 1414 | clctxt.setBasePackageName(targetPackage); |
| 1415 | } |
| 1416 | |
| 1417 | originalClassLoader = currentThread.getContextClassLoader(); |
| 1418 | currentThread.setContextClassLoader(loader); |
| 1419 | |
| 1420 | clctxt.setClassLoader(loader); |
| 1421 | clctxt.setClassPath(classPath); |
| 1422 | |
| 1423 | Compiler clc = clctxt.createCompiler(); |
| 1424 | |
| 1425 | // If compile is set, generate both .java and .class, if |
| 1426 | // .jsp file is newer than .class file; |
| 1427 | // Otherwise only generate .java, if .jsp file is newer than |
| 1428 | // the .java file |
| 1429 | if (clc.isOutDated(compile)) { |
| 1430 | if (log.isDebugEnabled()) { |
| 1431 | log.debug(Localizer.getMessage("jspc.outdated", jspUri)); |
| 1432 | } |
| 1433 | |
| 1434 | clc.compile(compile, true); |
| 1435 | } |
| 1436 | |
| 1437 | // Generate mapping |
| 1438 | generateWebMapping(file, clctxt); |
| 1439 | if (showSuccess) { |
| 1440 | log.info(Localizer.getMessage("jspc.built", file)); |
| 1441 | } |
| 1442 | |
| 1443 | } catch (JasperException je) { |
no test coverage detected