protected void parseTld(String resourcePath) throws IOException, SAXException { TldResourcePath tldResourcePath = new TldResourcePath(context.getResource(resourcePath), resourcePath); parseTld(tldResourcePath); }
private long[] getLastModified(TldResourcePath tldResourcePath) { long[] result = new long[2]; result[0] = -1; result[1] = -1; try { URL url = servletContext.getResource(tldResourcePath.getWebappPath()); URLConnection conn = url.openConnection(); result[0] = conn.getLastModified(); if ("file".equals(url.getProtocol())) { // Reading the last modified time opens an input stream so we // need to make sure it is closed again otherwise the TLD file // will be locked until GC runs. conn.getInputStream().close(); } Jar jar = tldResourcePath.getJar(); if (jar != null) { result[1] = jar.getLastModified(tldResourcePath.getEntryName()); } } catch (IOException e) { // Ignore (shouldn't happen) } return result; }
@Override protected void scanPlatform() { super.scanPlatform(); if (URLClassLoaderFirst.shouldSkipJsf(Thread.currentThread().getContextClassLoader(), "javax.faces.FactoryFinder")) { uriTldResourcePathMapParent.putAll(URI_TLD_RESOURCE); tldResourcePathTaglibXmlMapParent.putAll(TLD_RESOURCE_TAG_LIB); } else { // exclude myfaces for (final Map.Entry<String, TldResourcePath> entry : URI_TLD_RESOURCE.entrySet()) { final TldResourcePath path = entry.getValue(); if (path.getUrl() != MYFACES_URL) { // ref works uriTldResourcePathMapParent.put(entry.getKey(), path); final TaglibXml tl = TLD_RESOURCE_TAG_LIB.get(path); if (tl != null) { tldResourcePathTaglibXmlMapParent.put(path, tl); } } } } }
private long[] getLastModified(TldResourcePath tldResourcePath) { long[] result = new long[2]; result[0] = -1; result[1] = -1; try { String webappPath = tldResourcePath.getWebappPath(); if (webappPath != null) { // webappPath will be null for JARs containing TLDs that are on // the class path but not part of the web application URL url = servletContext.getResource(tldResourcePath.getWebappPath()); URLConnection conn = url.openConnection(); result[0] = conn.getLastModified(); if ("file".equals(url.getProtocol())) { // Reading the last modified time opens an input stream so we // need to make sure it is closed again otherwise the TLD file // will be locked until GC runs. conn.getInputStream().close(); } } try (Jar jar = tldResourcePath.openJar()) { if (jar != null) { result[1] = jar.getLastModified(tldResourcePath.getEntryName()); } } } catch (IOException e) { // Ignore (shouldn't happen) } return result; }
public TaglibXml parse(TldResourcePath path) throws IOException, SAXException { try (InputStream is = path.openStream()) { XmlErrorHandler handler = new XmlErrorHandler(); digester.setErrorHandler(handler); TaglibXml taglibXml = new TaglibXml(); digester.push(taglibXml); InputSource source = new InputSource(path.toExternalForm()); source.setByteStream(is); digester.parse(source); if (!handler.getWarnings().isEmpty() || !handler.getErrors().isEmpty()) { handler.logFindings(log, source.getSystemId()); if (!handler.getErrors().isEmpty()) { // throw the first to indicate there was a error during processing throw handler.getErrors().iterator().next(); } } return taglibXml; } finally { digester.reset(); } }
try (Jar jar = tldResourcePath.openJar()) { String path = tldResourcePath.getWebappPath(); if (path != null) { String entryName = tldResourcePath.getEntryName(); try { pageInfo.addDependant(jar.getURL(entryName), if (tldResourcePath.getUrl() == null) { err.jspError("jsp.error.tld.missing", prefix, uri);
tagFileInfo.getTagInfo().getTagLibrary().getURI()); try (Jar jar = tldResourcePath.openJar()) { pageInfo.addDependant(jar.getURL(tldResourcePath.getEntryName()), Long.valueOf(jar.getLastModified(tldResourcePath.getEntryName())));
Jar jar; try { jar = tldResourcePath.getJar(); } catch (IOException ioe) { throw new JasperException(ioe); try { pageInfo.addDependant(jar.getURL(tldResourcePath.getEntryName()), Long.valueOf(jar.getLastModified(tldResourcePath.getEntryName())));
try { tagJar = compiler.getCompilationContext().getTldResourcePath( tagInfo.getTagLibrary().getURI()).getJar(); } catch (IOException ioe) { throw new JasperException(ioe);
original = Thread.currentThread().getContextClassLoader(); try (InputStream is = path.openStream()) { if (Constants.IS_SECURITY_ENABLED) { PrivilegedSetTccl pa = new PrivilegedSetTccl(TldParser.class.getClassLoader()); digester.push(taglibXml); InputSource source = new InputSource(path.toExternalForm()); source.setByteStream(is); digester.parse(source);
private void parseTld(String resourcePath) throws IOException, SAXException { TldResourcePath tldResourcePath = new TldResourcePath(context.getResource(resourcePath), resourcePath); parseTld(tldResourcePath); }
original = Thread.currentThread().getContextClassLoader(); try (InputStream is = path.openStream()) { if (Constants.IS_SECURITY_ENABLED) { PrivilegedSetTccl pa = new PrivilegedSetTccl(TldParser.class.getClassLoader()); digester.push(taglibXml); InputSource source = new InputSource(path.toExternalForm()); source.setByteStream(is); digester.parse(source);
jar = tldResourcePath.getJar(); } catch (IOException ioe) { throw new JasperException(ioe); String path = tldResourcePath.getWebappPath(); String entryName = tldResourcePath.getEntryName(); try { pageInfo.addDependant(jar.getURL(entryName),
@Override public void scanJars() { for (URL url : preScannedURLs){ String str = url.toExternalForm(); int a = str.indexOf("jar:"); int b = str.indexOf("!/"); if (a >= 0 && b> 0) { String fileUrl = str.substring(a + 4, b); String path = str.substring(b + 2); try { parseTld(new TldResourcePath(new URL(fileUrl), null, path)); } catch (Exception e) { throw new IllegalStateException(e); } } else { throw new IllegalStateException("Bad tld url: "+str); } } } }
TldResourcePath path = new TldResourcePath(url, resourcePath); parseTld(path); tldFound = true;
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (!file.getFileName().toString() .toLowerCase(Locale.ENGLISH).endsWith(TLD_EXT)) { return FileVisitResult.CONTINUE; } String subPath = file.subpath( filePath.getNameCount(), file.getNameCount()).toString(); if ('/' != File.separatorChar) { subPath = subPath.replace(File.separatorChar, '/'); } String resourcePath = webappPath + "/" + subPath; try { URL url = file.toUri().toURL(); TldResourcePath path = new TldResourcePath(url, resourcePath); parseTld(path); tldFound = true; } catch (SAXException e) { throw new IOException(e); } return FileVisitResult.CONTINUE; } });
TldResourcePath path = new TldResourcePath(url, resourcePath); parseTld(path); } catch (SAXException e) {
try parseTld(new TldResourcePath(new URL(fileUrl), null, path)); parseTld(new TldResourcePath(url, null, null));
err.jspError("jsp.error.tld.missing_jar", uri); return new TldResourcePath(url, uri, "META-INF/taglib.tld"); } else if (uri.startsWith("/WEB-INF/lib/") || uri.startsWith("/WEB-INF/classes/") || (uri.startsWith("/WEB-INF/tags/") && uri.endsWith(".tld")&& !uri.endsWith("implicit.tld"))) { err.jspError("jsp.error.tld.invalid_tld_file", uri); return new TldResourcePath(url, uri);
err.jspError("jsp.error.tld.missing_jar", uri); return new TldResourcePath(url, uri, "META-INF/taglib.tld"); } else { return new TldResourcePath(url, uri);