/** * Initialize with the application's ServletContext. * * @param context the application's servletContext */ public TldScanner(ServletContext context, boolean namespaceAware, boolean validation, boolean blockExternal) { this.context = context; this.tldParser = new TldParser(namespaceAware, validation, blockExternal); }
/** * Set the class loader used by the digester to create objects as a result * of this scan. Normally this only needs tobe set when using JspC. */ public void setClassLoader(ClassLoader classLoader) { tldParser.setClassLoader(classLoader); }
protected void parseTld(TldResourcePath path) throws IOException, SAXException { if (tldResourcePathTaglibXmlMap.containsKey(path)) { // TLD has already been parsed as a result of processing web.xml return; } TaglibXml tld = tldParser.parse(path); String uri = tld.getUri(); if (uri != null) { if (!uriTldResourcePathMap.containsKey(uri)) { uriTldResourcePathMap.put(uri, path); } } tldResourcePathTaglibXmlMap.put(path, tld); if (tld.getListeners() != null) { listeners.addAll(tld.getListeners()); } }
private void parseTld(TldResourcePath path) throws IOException, SAXException { if (tldResourcePathTaglibXmlMap.containsKey(path)) { // TLD has already been parsed as a result of processing web.xml return; } TaglibXml tld = tldParser.parse(path); String uri = tld.getUri(); if (uri != null) { if (!uriTldResourcePathMap.containsKey(uri)) { uriTldResourcePathMap.put(uri, path); } } tldResourcePathTaglibXmlMap.put(path, tld); if (tld.getListeners() != null) { listeners.addAll(tld.getListeners()); } }
TaglibXml tld = tldParser.parse(tldResourcePath); uriTldResourcePathMap.put(taglibURI, tldResourcePath); tldResourcePathTaglibXmlMap.put(tldResourcePath, tld);
/** * Initialise with the application's ServletContext. * * @param context the application's servletContext * @param namespaceAware should the XML parser used to parse TLD files be * configured to be name space aware * @param validation should the XML parser used to parse TLD files be * configured to use validation * @param blockExternal should the XML parser used to parse TLD files be * configured to be block references to external * entities */ public TldScanner(ServletContext context, boolean namespaceAware, boolean validation, boolean blockExternal) { this.context = context; this.tldParser = new TldParser(namespaceAware, validation, blockExternal); }
/** * Set the class loader used by the digester to create objects as a result * of this scan. Normally this only needs to be set when using JspC. * * @param classLoader Class loader to use when creating new objects while * parsing TLDs */ public void setClassLoader(ClassLoader classLoader) { tldParser.setClassLoader(classLoader); }
TaglibXml tld = tldParser.parse(tldResourcePath); uriTldResourcePathMap.put(taglibURI, tldResourcePath); tldResourcePathTaglibXmlMap.put(tldResourcePath, tld);
public TldCache(ServletContext servletContext, Map<String, TldResourcePath> uriTldResourcePathMap, Map<TldResourcePath, TaglibXml> tldResourcePathTaglibXmlMap) { this.servletContext = servletContext; this.uriTldResourcePathMap.putAll(uriTldResourcePathMap); for (Entry<TldResourcePath, TaglibXml> entry : tldResourcePathTaglibXmlMap.entrySet()) { TldResourcePath tldResourcePath = entry.getKey(); long lastModified[] = getLastModified(tldResourcePath); TaglibXmlCacheEntry cacheEntry = new TaglibXmlCacheEntry( entry.getValue(), lastModified[0], lastModified[1]); this.tldResourcePathTaglibXmlMap.put(tldResourcePath, cacheEntry); } boolean validate = Boolean.parseBoolean( servletContext.getInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM)); String blockExternalString = servletContext.getInitParameter( Constants.XML_BLOCK_EXTERNAL_INIT_PARAM); boolean blockExternal; if (blockExternalString == null) { blockExternal = true; } else { blockExternal = Boolean.parseBoolean(blockExternalString); } tldParser = new TldParser(true, validate, blockExternal); }
public TaglibXml getTaglibXml(TldResourcePath tldResourcePath) throws JasperException { TaglibXmlCacheEntry cacheEntry = tldResourcePathTaglibXmlMap.get(tldResourcePath); long lastModified[] = getLastModified(tldResourcePath); if (lastModified[0] != cacheEntry.getWebAppPathLastModified() || lastModified[1] != cacheEntry.getEntryLastModified()) { synchronized (cacheEntry) { if (lastModified[0] != cacheEntry.getWebAppPathLastModified() || lastModified[1] != cacheEntry.getEntryLastModified()) { // Re-parse TLD TaglibXml updatedTaglibXml; try { updatedTaglibXml = tldParser.parse(tldResourcePath); } catch (IOException | SAXException e) { throw new JasperException(e); } cacheEntry.setTaglibXml(updatedTaglibXml); cacheEntry.setWebAppPathLastModified(lastModified[0]); cacheEntry.setEntryLastModified(lastModified[1]); } } } return cacheEntry.getTaglibXml(); }
public TldCache(ServletContext servletContext, Map<String, TldResourcePath> uriTldResourcePathMap, Map<TldResourcePath, TaglibXml> tldResourcePathTaglibXmlMap) { this.servletContext = servletContext; this.uriTldResourcePathMap.putAll(uriTldResourcePathMap); for (Entry<TldResourcePath, TaglibXml> entry : tldResourcePathTaglibXmlMap.entrySet()) { TldResourcePath tldResourcePath = entry.getKey(); long lastModified[] = getLastModified(tldResourcePath); TaglibXmlCacheEntry cacheEntry = new TaglibXmlCacheEntry( entry.getValue(), lastModified[0], lastModified[1]); this.tldResourcePathTaglibXmlMap.put(tldResourcePath, cacheEntry); } boolean validate = Boolean.parseBoolean( servletContext.getInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM)); String blockExternalString = servletContext.getInitParameter( Constants.XML_BLOCK_EXTERNAL_INIT_PARAM); boolean blockExternal; if (blockExternalString == null) { blockExternal = Constants.IS_SECURITY_ENABLED; } else { blockExternal = Boolean.parseBoolean(blockExternalString); } tldParser = new TldParser(true, validate, blockExternal); }
public TaglibXml getTaglibXml(TldResourcePath tldResourcePath) throws JasperException { TaglibXmlCacheEntry cacheEntry = tldResourcePathTaglibXmlMap.get(tldResourcePath); if (cacheEntry == null) { return null; } long lastModified[] = getLastModified(tldResourcePath); if (lastModified[0] != cacheEntry.getWebAppPathLastModified() || lastModified[1] != cacheEntry.getEntryLastModified()) { synchronized (cacheEntry) { if (lastModified[0] != cacheEntry.getWebAppPathLastModified() || lastModified[1] != cacheEntry.getEntryLastModified()) { // Re-parse TLD TaglibXml updatedTaglibXml; try { updatedTaglibXml = tldParser.parse(tldResourcePath); } catch (IOException | SAXException e) { throw new JasperException(e); } cacheEntry.setTaglibXml(updatedTaglibXml); cacheEntry.setWebAppPathLastModified(lastModified[0]); cacheEntry.setEntryLastModified(lastModified[1]); } } } return cacheEntry.getTaglibXml(); }