/** * Initialize the {@link TaglibFactory} for the given ServletContext. */ @Override public void setServletContext(ServletContext servletContext) { this.taglibFactory = new TaglibFactory(servletContext); }
TldLocation explicitlyMappedTldLocation = getExplicitlyMappedTldLocation(taglibUri); if (explicitlyMappedTldLocation != null) { tldLocation = explicitlyMappedTldLocation; urlType = getUriType(taglibUri); } catch (MalformedURLException e) { throw new TaglibGettingException("Malformed taglib URI: " + StringUtil.jQuote(taglibUri), e); normalizedTaglibUri = resolveRelativeUri(taglibUri); } else if (urlType == URL_TYPE_ABSOLUTE) { normalizedTaglibUri = taglibUri; } else if (urlType == URL_TYPE_FULL) { String failedTLDsList = getFailedTLDsList(); failedTldListAlreadyIncluded = true; throw new TaglibGettingException("No TLD was found for the " tldLocation = isJarPath(normalizedTaglibUri) ? (TldLocation) new ServletContextJarEntryTldLocation( normalizedTaglibUri, DEFAULT_TLD_RESOURCE_PATH) String failedTLDsList = failedTldListAlreadyIncluded ? null : getFailedTLDsList(); throw new TemplateModelException( "Error while looking for TLD file for " + StringUtil.jQuoteNoXSS(taglibUri) return loadTaglib(tldLocation, normalizedTaglibUri); } catch (Exception e) { throw new TemplateModelException("Error while loading tag library for URI "
private void addTldLocationsFromWebXml() throws SAXException, IOException { LOG.debug("Looking for TLD locations in servletContext:/WEB-INF/web.xml"); WebXmlParser webXmlParser = new WebXmlParser(); InputStream in = servletContext.getResourceAsStream("/WEB-INF/web.xml"); if (in == null) { LOG.debug("No web.xml was found in servlet context"); return; } try { parseXml(in, servletContext.getResource("/WEB-INF/web.xml").toExternalForm(), webXmlParser); } finally { in.close(); } }
/** * Use this overload only if you already have the {@link InputStream} for some reason, otherwise use * {@link #addTldLocationFromTld(TldLocation)}. * * @param reusedIn * The stream that we already had (so we don't have to open a new one from the {@code tldLocation}). */ private void addTldLocationFromTld(InputStream reusedIn, TldLocation tldLocation) throws SAXException, IOException { String taglibUri; try { taglibUri = getTaglibUriFromTld(reusedIn, tldLocation.getXmlSystemId()); } catch (SAXException e) { LOG.error("Error while parsing TLD; skipping: " + tldLocation, e); synchronized (failedTldLocations) { failedTldLocations.add(tldLocation.toString()); } taglibUri = null; } if (taglibUri != null) { addTldLocation(tldLocation, taglibUri); } }
TaglibFactory taglibFactory = new TaglibFactory(servletContext); taglibFactory.setObjectWrapper(objectWrapper); taglibFactory.setMetaInfTldSources(mergedMetaInfTldSources); taglibFactory.setClasspathTlds(mergedClassPathTlds);
addLocationsFromWebXml(); lookupPhase = LOOKUP_WEB_XML; return loadTaglib(path, uri); addLocationsFromWebApp(); lookupPhase = LOOKUP_WEB_APP; return loadTaglib(path, uri); switch(getUriType(uri)) { case ABS_URI: { uri = resolveRelativeUri(uri); return loadTaglib(new TldPath(uri, DEFAULT_JAR_TLD), uri); return loadTaglib(new TldPath(uri), uri);
TaglibFactory taglibFactory = new TaglibFactory(servletContext); taglibFactory.setObjectWrapper(objectWrapper); taglibFactory.setMetaInfTldSources(mergedMetaInfTldSources); taglibFactory.setClasspathTlds(mergedClassPathTlds);
/** * Use this overload only if you already have the {@link InputStream} for some reason, otherwise use * {@link #addTldLocationFromTld(TldLocation)}. * * @param reusedIn * The stream that we already had (so we don't have to open a new one from the {@code tldLocation}). */ private void addTldLocationFromTld(InputStream reusedIn, TldLocation tldLocation) throws SAXException, IOException { String taglibUri; try { taglibUri = getTaglibUriFromTld(reusedIn, tldLocation.getXmlSystemId()); } catch (SAXException e) { LOG.error("Error while parsing TLD; skipping: " + tldLocation, e); synchronized (failedTldLocations) { failedTldLocations.add(tldLocation.toString()); } taglibUri = null; } if (taglibUri != null) { addTldLocation(tldLocation, taglibUri); } }
/** * Initialize the {@link TaglibFactory} for the given ServletContext. */ @Override public void setServletContext(ServletContext servletContext) { this.taglibFactory = new TaglibFactory(servletContext); }
TaglibFactory taglibFactory = new TaglibFactory(servletContext); taglibFactory.setObjectWrapper(objectWrapper); taglibFactory.setMetaInfTldSources(mergedMetaInfTldSources); taglibFactory.setClasspathTlds(mergedClassPathTlds);
TldLocation explicitlyMappedTldLocation = getExplicitlyMappedTldLocation(taglibUri); if (explicitlyMappedTldLocation != null) { tldLocation = explicitlyMappedTldLocation; urlType = getUriType(taglibUri); } catch (MalformedURLException e) { throw new TaglibGettingException("Malformed taglib URI: " + StringUtil.jQuote(taglibUri), e); normalizedTaglibUri = resolveRelativeUri(taglibUri); } else if (urlType == URL_TYPE_ABSOLUTE) { normalizedTaglibUri = taglibUri; } else if (urlType == URL_TYPE_FULL) { String failedTLDsList = getFailedTLDsList(); failedTldListAlreadyIncluded = true; throw new TaglibGettingException("No TLD was found for the " tldLocation = isJarPath(normalizedTaglibUri) ? (TldLocation) new ServletContextJarEntryTldLocation( normalizedTaglibUri, DEFAULT_TLD_RESOURCE_PATH) String failedTLDsList = failedTldListAlreadyIncluded ? null : getFailedTLDsList(); throw new TemplateModelException( "Error while looking for TLD file for " + StringUtil.jQuoteNoXSS(taglibUri) return loadTaglib(tldLocation, normalizedTaglibUri); } catch (Exception e) { throw new TemplateModelException("Error while loading tag library for URI "
private String getTaglibUriFromTld(InputStream tldFileIn, String tldFileXmlSystemId) throws SAXException, IOException { TldParserForTaglibUriExtraction tldParser = new TldParserForTaglibUriExtraction(); parseXml(tldFileIn, tldFileXmlSystemId, tldParser); return tldParser.getTaglibUri(); }
/** * Use this overload only if you already have the {@link InputStream} for some reason, otherwise use * {@link #addTldLocationFromTld(TldLocation)}. * * @param reusedIn * The stream that we already had (so we don't have to open a new one from the {@code tldLocation}). */ private void addTldLocationFromTld(InputStream reusedIn, TldLocation tldLocation) throws SAXException, IOException { String taglibUri; try { taglibUri = getTaglibUriFromTld(reusedIn, tldLocation.getXmlSystemId()); } catch (SAXException e) { LOG.error("Error while parsing TLD; skipping: " + tldLocation, e); synchronized (failedTldLocations) { failedTldLocations.add(tldLocation.toString()); } taglibUri = null; } if (taglibUri != null) { addTldLocation(tldLocation, taglibUri); } }
/** * Invoked on startup. Looks for a single FreeMarkerConfig bean to * find the relevant Configuration for this factory. * <p>Checks that the template for the default Locale can be found: * FreeMarker will check non-Locale-specific templates if a * locale-specific one is not found. * @see freemarker.cache.TemplateCache#getTemplate */ @Override protected void initServletContext(ServletContext servletContext) throws BeansException { if (getConfiguration() != null) { this.taglibFactory = new TaglibFactory(servletContext); } else { FreeMarkerConfig config = autodetectConfiguration(); setConfiguration(config.getConfiguration()); this.taglibFactory = config.getTaglibFactory(); } GenericServlet servlet = new GenericServletAdapter(); try { servlet.init(new DelegatingServletConfig()); } catch (ServletException ex) { throw new BeanInitializationException("Initialization of GenericServlet adapter failed", ex); } this.servletContextHashModel = new ServletContextHashModel(servlet, getObjectWrapper()); }
TldLocation explicitlyMappedTldLocation = getExplicitlyMappedTldLocation(taglibUri); if (explicitlyMappedTldLocation != null) { tldLocation = explicitlyMappedTldLocation; urlType = getUriType(taglibUri); } catch (MalformedURLException e) { throw new TaglibGettingException("Malformed taglib URI: " + StringUtil.jQuote(taglibUri), e); normalizedTaglibUri = resolveRelativeUri(taglibUri); } else if (urlType == URL_TYPE_ABSOLUTE) { normalizedTaglibUri = taglibUri; } else if (urlType == URL_TYPE_FULL) { String failedTLDsList = getFailedTLDsList(); failedTldListAlreadyIncluded = true; throw new TaglibGettingException("No TLD was found for the " tldLocation = isJarPath(normalizedTaglibUri) ? (TldLocation) new ServletContextJarEntryTldLocation( normalizedTaglibUri, DEFAULT_TLD_RESOURCE_PATH) String failedTLDsList = failedTldListAlreadyIncluded ? null : getFailedTLDsList(); throw new TemplateModelException( "Error while looking for TLD file for " + StringUtil.jQuoteNoXSS(taglibUri) return loadTaglib(tldLocation, normalizedTaglibUri); } catch (Exception e) { throw new TemplateModelException("Error while loading tag library for URI "
private void addLocationsFromWebXml() throws Exception { WebXmlParser webXmlParser = new WebXmlParser(); InputStream in = ctx.getResourceAsStream("/WEB-INF/web.xml"); if (in == null) { // No /WEB-INF/web.xml - do nothing return; } try { parseXml(in, ctx.getResource("/WEB-INF/web.xml").toExternalForm(), webXmlParser); } finally { in.close(); } }
/** * Invoked on startup. Looks for a single FreeMarkerConfig bean to * find the relevant Configuration for this factory. * <p>Checks that the template for the default Locale can be found: * FreeMarker will check non-Locale-specific templates if a * locale-specific one is not found. * @see freemarker.cache.TemplateCache#getTemplate */ @Override protected void initServletContext(ServletContext servletContext) throws BeansException { if (getConfiguration() != null) { this.taglibFactory = new TaglibFactory(servletContext); } else { FreeMarkerConfig config = autodetectConfiguration(); setConfiguration(config.getConfiguration()); this.taglibFactory = config.getTaglibFactory(); } GenericServlet servlet = new GenericServletAdapter(); try { servlet.init(new DelegatingServletConfig()); } catch (ServletException ex) { throw new BeanInitializationException("Initialization of GenericServlet adapter failed", ex); } this.servletContextHashModel = new ServletContextHashModel(servlet, getObjectWrapper()); }
private void addTldLocationsFromWebXml() throws SAXException, IOException { LOG.debug("Looking for TLD locations in servletContext:/WEB-INF/web.xml"); WebXmlParser webXmlParser = new WebXmlParser(); InputStream in = servletContext.getResourceAsStream("/WEB-INF/web.xml"); if (in == null) { LOG.debug("No web.xml was found in servlet context"); return; } try { parseXml(in, servletContext.getResource("/WEB-INF/web.xml").toExternalForm(), webXmlParser); } finally { in.close(); } }
/** * Initialize the {@link TaglibFactory} for the given ServletContext. */ public void setServletContext(ServletContext servletContext) { this.taglibFactory = new TaglibFactory(servletContext); }
private void addTldLocationsFromWebXml() throws SAXException, IOException { LOG.debug("Looking for TLD locations in servletContext:/WEB-INF/web.xml"); WebXmlParser webXmlParser = new WebXmlParser(); InputStream in = servletContext.getResourceAsStream("/WEB-INF/web.xml"); if (in == null) { LOG.debug("No web.xml was found in servlet context"); return; } try { parseXml(in, servletContext.getResource("/WEB-INF/web.xml").toExternalForm(), webXmlParser); } finally { in.close(); } }