/** {@inheritDoc} */ public ApplicationResource getResource(String localePath) { return context.getResource(localePath); }
/** {@inheritDoc} */ @Override protected List<ApplicationResource> getSources(ApplicationContext applicationContext) { List<ApplicationResource> urls = new ArrayList<ApplicationResource>(); urls.addAll(applicationContext .getResources("/WEB-INF/**/tiles-defs*.xml")); urls.add(applicationContext.getResource( "classpath:/org/apache/tiles/classpath-defs.xml")); urls.add(applicationContext.getResource( "classpath:/org/apache/tiles/freemarker-classpath-defs.xml")); urls.add(applicationContext.getResource( "classpath:/org/apache/tiles/velocity-classpath-defs.xml")); return urls; } }
Collection<ApplicationResource> resources = applicationContext .getResources("classpath*:META-INF/MANIFEST.MF"); ApplicationResource mainResource = applicationContext.getResource("/META-INF/MANIFEST.MF"); if (mainResource != null) { resources.add(mainResource);
/** {@inheritDoc} */ public ApplicationResource getResource(ApplicationResource base, Locale locale) { return context.getResource(base, locale); }
/** {@inheritDoc} */ @Override protected List<ApplicationResource> getSources(ApplicationContext applicationContext) { List<ApplicationResource> urls = new ArrayList<ApplicationResource>(URL_COUNT); urls.add(applicationContext.getResource("classpath:/org/apache/tiles/test/alt/defs/tiles-alt-defs.xml")); urls.add(applicationContext.getResource("classpath:/org/apache/tiles/test/alt/defs/tiles-alt-freemarker-defs.xml")); urls.add(applicationContext.getResource("classpath:/org/apache/tiles/test/alt/defs/tiles-alt-velocity-defs.xml")); return urls; }
/** * Returns a list containing the resources to be parsed. By default, it returns a * list containing the resource at "/WEB-INF/tiles.xml". * @param applicationContext The Tiles application context. * @return The resources. * @since 2.1.1 */ protected List<ApplicationResource> getSources(ApplicationContext applicationContext) { List<ApplicationResource> retValue = new ArrayList<ApplicationResource>(1); retValue.add(applicationContext.getResource("/WEB-INF/tiles.xml")); return retValue; }
/** {@inheritDoc} */ public boolean refreshRequired() { boolean status = false; Set<String> paths = lastModifiedDates.keySet(); try { for (String path : paths) { Long lastModifiedDate = lastModifiedDates.get(path); ApplicationResource resource = applicationContext.getResource(path); long newModDate = resource.getLastModified(); if (newModDate != lastModifiedDate) { status = true; break; } } } catch (IOException e) { log.warn("Exception while monitoring update times.", e); return true; } return status; }
/** {@inheritDoc} */ public Map<String, Definition> getDefinitions(Locale customizationKey) { ArrayList<Locale> postfixes = computeLocales(customizationKey); Map<String, Definition> localeDefsMap = new HashMap<String, Definition>(); // process the postfixes from the root to the most specific for (Locale postfix : postfixes) { // For each postfix, all the sources must be loaded. for (ApplicationResource resource : sources) { ApplicationResource newResource = applicationContext.getResource(resource, postfix); if (newResource != null) { Map<String, Definition> defsMap = loadDefinitionsFromResource(newResource); if (defsMap != null) { localeDefsMap.putAll(defsMap); } } } } return localeDefsMap; }
private boolean renderAttempt(final String template, final Request request) throws IOException { boolean result = false; if (Cache.attemptTemplate(template)) { try { if (null != applicationContext.getResource(template)) { renderer.render(template, request); result = true; } } catch (IOException ex) { if (ex.getMessage().contains(template)) { // expected outcome. continue loop. LOG.trace(ex.getMessage()); } else { // comes from an inner templateAttribute.render(..) so throw on throw ex; } } catch (RuntimeException ex) { if (ex.getMessage().contains(template)) { // expected outcome. continue loop. LOG.trace(ex.getMessage()); } else { // comes from an inner templateAttribute.render(..) so throw on throw ex; } } Cache.update(template, result); } return result; }
/** * Loads the raw definitions from the sources associated with a locale. * * @param customizationKey The locale to use when loading Resources. * @return The loaded definitions. * @since 2.1.3 */ protected Map<String, Definition> loadRawDefinitionsFromResources( Locale customizationKey) { Map<String, Definition> localeDefsMap; Locale parentLocale = LocaleUtil.getParentLocale(customizationKey); localeDefsMap = new LinkedHashMap<String, Definition>(); if (parentLocale != null) { Map<String, Definition> parentDefs = loadRawDefinitionsFromResources(parentLocale); if (parentDefs != null) { localeDefsMap.putAll(parentDefs); } } // For each source, the resource must be loaded. for (ApplicationResource resource : sources) { ApplicationResource newResource = applicationContext.getResource(resource, customizationKey); if (newResource != null) { Map<String, Definition> defsMap = loadDefinitionsFromResource(newResource); if (defsMap != null) { localeDefsMap.putAll(defsMap); } } } return localeDefsMap; }