/* * Scans the directory identified by startPath, along with its * sub-directories, for TLDs. * * Keep in sync with o.a.c.startup.TldConfig */ private void tldScanDir(File start) throws IOException { File[] fileList = start.listFiles(); if (fileList != null) { for (int i = 0; i < fileList.length; i++) { // Scan recursively if (fileList[i].isDirectory()) { tldScanDir(fileList[i]); } else if (fileList[i].getAbsolutePath().endsWith(TLD_EXT)) { InputStream stream = null; try { stream = new FileInputStream(fileList[i]); tldScanStream(fileList[i].toURI().toString(), null, stream); } finally { if (stream != null) { try { stream.close(); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); } } } } } } }
/* * Scans the web application's sub-directory identified by startPath, * along with its sub-directories, for TLDs and adds an implicit map entry * to the taglib map for any TLD that has a <uri> element. * * Initially, rootPath equals /WEB-INF/. The /WEB-INF/classes and * /WEB-INF/lib sub-directories are excluded from the search, as per the * JSP 2.0 spec. * * Keep code in sync with o.a.c.startup.TldConfig */ private void tldScanResourcePaths(String startPath) throws Exception { Set<String> dirList = ctxt.getResourcePaths(startPath); if (dirList != null) { Iterator<String> it = dirList.iterator(); while (it.hasNext()) { String path = it.next(); if (!path.endsWith(TLD_EXT) && (path.startsWith(WEB_INF_LIB) || path.startsWith("/WEB-INF/classes/"))) { continue; } if (path.endsWith(TLD_EXT)) { if (path.startsWith("/WEB-INF/tags/") && !path.endsWith("implicit.tld")) { continue; } InputStream stream = ctxt.getResourceAsStream(path); try { tldScanStream(path, null, stream); } finally { if (stream != null) { try { stream.close(); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); } } } } else { tldScanResourcePaths(path); } } } }
public void destroy() { if (theServlet != null) { theServlet.destroy(); InstanceManager instanceManager = InstanceManagerFactory.getInstanceManager(config); try { instanceManager.destroyInstance(theServlet); } catch (Exception e) { Throwable t = ExceptionUtils.unwrapInvocationTargetException(e); ExceptionUtils.handleThrowable(t); // Log any exception, since it can't be passed along log.error(Localizer.getMessage("jsp.error.file.not.found", e.getMessage()), t); } } }
public Servlet getServlet() throws ServletException { // DCL on 'reload' requires that 'reload' be volatile // (this also forces a read memory barrier, ensuring the // new servlet object is read consistently) if (reload) { synchronized (this) { // Synchronizing on jsw enables simultaneous loading // of different pages, but not the same page. if (reload) { // This is to maintain the original protocol. destroy(); final Servlet servlet; try { InstanceManager instanceManager = InstanceManagerFactory.getInstanceManager(config); servlet = (Servlet) instanceManager.newInstance(ctxt.getFQCN(), ctxt.getJspLoader()); } catch (Exception e) { Throwable t = ExceptionUtils.unwrapInvocationTargetException(e); ExceptionUtils.handleThrowable(t); throw new JasperException(t); } servlet.init(config); if (!firstTime) { ctxt.getRuntimeContext().incrementJspReloadCount(); } theServlet = servlet; reload = false; // Volatile 'reload' forces in order write of 'theServlet' and new // servlet object } } } return theServlet; }
/** Get a list of files that the current page has source dependency on. */ public java.util.Map<String, Long> getDependants() { try { Object target; if (isTagFile) { if (reload) { tagHandlerClass = ctxt.load(); reload = false; } target = tagHandlerClass.newInstance(); } else { target = getServlet(); } if (target != null && target instanceof JspSourceDependent) { return ((JspSourceDependent) target).getDependants(); } } catch (AbstractMethodError ame) { // Almost certainly a pre Tomcat 7.0.17 compiled JSP using the old // version of the interface. Force a re-compile. return ALWAYS_OUTDATED_DEPENDENCIES; } catch (Throwable ex) { ExceptionUtils.handleThrowable(ex); } return null; }