String filename = filenames.get(j); PropertiesHolder propHolder = getProperties(filename); if (propHolder.getProperties() != null) { mergedProps.putAll(propHolder.getProperties()); if (propHolder.getFileTimestamp() > latestTimestamp) { latestTimestamp = propHolder.getFileTimestamp();
String filename = filenames.get(j); PropertiesHolder propHolder = getProperties(filename); if (propHolder.getProperties() != null) { mergedProps.putAll(propHolder.getProperties()); if (propHolder.getFileTimestamp() > latestTimestamp) { latestTimestamp = propHolder.getFileTimestamp();
public List<String> getPropertyKeys(Locale locale) { ArrayList<String> keys = new ArrayList<String>(); PropertiesHolder ph = this.getMergedProperties(locale); for (Object o : ph.getProperties().keySet()) { keys.add(o.toString()); } return keys; } }
String filename = filenames.get(j); PropertiesHolder propHolder = getProperties(filename); if (propHolder.getProperties() != null) { mergedProps.putAll(propHolder.getProperties()); if (propHolder.getFileTimestamp() > latestTimestamp) { latestTimestamp = propHolder.getFileTimestamp();
@Override protected PropertiesHolder refreshProperties(final String filename, final PropertiesHolder propHolder) { final Properties properties = new Properties(); long lastModified = -1; if (!(resourceLoader instanceof ResourcePatternResolver)) { LOGGER.warn( "Resource Loader {} doensn't support getting multiple resources. Default properties mechanism will used", resourceLoader.getClass().getName()); return super.refreshProperties(filename, propHolder); } try { final Resource[] resources = ((ResourcePatternResolver) resourceLoader) .getResources(filename + PROPERTIES_SUFFIX); for (final Resource resource : resources) { final String sourcePath = resource.getURI().toString().replace(PROPERTIES_SUFFIX, ""); final PropertiesHolder holder = super.refreshProperties(sourcePath, propHolder); properties.putAll(holder.getProperties()); if (lastModified < resource.lastModified()) { lastModified = resource.lastModified(); } } } catch (final IOException ignored) { LOGGER.warn("Resource with filname " + filename + " couldn't load", ignored); } return new PropertiesHolder(properties, lastModified); }
private PropertiesHolder refreshClassPathProperties(String filename, PropertiesHolder propHolder) { Properties properties = new Properties(); long lastModified = -1; try { Resource[] resources = resolver.getResources(filename + PROPERTIES_SUFFIX); for (Resource resource : resources) { String sourcePath = resource.getURI().toString().replace(PROPERTIES_SUFFIX, ""); PropertiesHolder holder = super.refreshProperties(sourcePath, propHolder); properties.putAll(holder.getProperties()); if (lastModified < resource.lastModified()) { lastModified = resource.lastModified(); } } } catch (IOException ignored) { } PropertiesHolder holder = new PropertiesHolder(properties, lastModified); holder.setRefreshTimestamp(getCacheMillis() < 0 ? -1 : System.currentTimeMillis()); cachedClasspathProperties.put(filename, holder); return holder; } }
/** * Handle classpath syntax. * * @param filename "classpath*:"-prefixed filename. * @param propHolder The properties holder. * @return The new properties holder. */ private PropertiesHolder refreshClassPathProperties(String filename, PropertiesHolder propHolder) { Properties properties = new Properties(); long lastModified = -1; try { Resource[] resources = resolver.getResources(filename + PROPERTIES_SUFFIX); for (Resource resource : resources) { String sourcePath = resource.getURI().toString().replace(PROPERTIES_SUFFIX, ""); PropertiesHolder holder = super.refreshProperties(sourcePath, propHolder); properties.putAll(holder.getProperties()); lastModified = Math.min(lastModified, resource.lastModified()); } } catch (Exception e) { log.warn("Error reading message source: " + filename); } return new PropertiesHolder(properties, lastModified); }
/** * Handle classpath syntax. * * @param filename "classpath*:"-prefixed filename. * @param propHolder The properties holder. * @return The new properties holder. */ private PropertiesHolder refreshClassPathProperties(String filename, PropertiesHolder propHolder) { Properties properties = new Properties(); long lastModified = -1; try { Resource[] resources = resolver.getResources(filename + PROPERTIES_SUFFIX); for (Resource resource : resources) { String sourcePath = resource.getURI().toString().replace(PROPERTIES_SUFFIX, ""); PropertiesHolder holder = super.refreshProperties(sourcePath, propHolder); properties.putAll(holder.getProperties()); lastModified = Math.min(lastModified, resource.lastModified()); } } catch (Exception e) { log.warn(() -> "Error reading message source: " + filename); } return new PropertiesHolder(properties, lastModified); }
@Override protected PropertiesHolder refreshProperties(final String filename, final PropertiesHolder propHolder) { final Properties properties = new Properties(); long lastModified = -1; if (!(resourceLoader instanceof ResourcePatternResolver)) { LOGGER.warn( "Resource Loader {} doensn't support getting multiple resources. Default properties mechanism will used", resourceLoader.getClass().getName()); return super.refreshProperties(filename, propHolder); } try { final Resource[] resources = ((ResourcePatternResolver) resourceLoader) .getResources(filename + PROPERTIES_SUFFIX); for (final Resource resource : resources) { final String sourcePath = resource.getURI().toString().replace(PROPERTIES_SUFFIX, ""); final PropertiesHolder holder = super.refreshProperties(sourcePath, propHolder); properties.putAll(holder.getProperties()); if (lastModified < resource.lastModified()) { lastModified = resource.lastModified(); } } } catch (final IOException ignored) { LOGGER.warn("Resource with filname " + filename + " couldn't load", ignored); } return new PropertiesHolder(properties, lastModified); }
@Override protected PropertiesHolder refreshProperties(String filename, PropertiesHolder propHolder) { Properties properties = new Properties(); long lastModified = -1; try { Resource[] resources = resolver.getResources(filename + "*" + PROPERTIES_SUFFIX); for (Resource resource : resources) { String sourcePath = resource.getURI().toString().replace(PROPERTIES_SUFFIX, ""); PropertiesHolder holder = super.refreshProperties(sourcePath, propHolder); properties.putAll(holder.getProperties()); if (lastModified < resource.lastModified()) { lastModified = resource.lastModified(); } } } catch (IOException e) { logger.error(e.getMessage(), e); } return new PropertiesHolder(properties, lastModified); } }
@Override protected String getMessageInternal(final String code, final Object[] args, final Locale locale) { boolean foundCode = false; if (!locale.equals(Locale.ENGLISH)) { for (int i = 0; !foundCode && i < this.basenames.length; i++) { final String filename = this.basenames[i] + '_' + locale; logger.debug("Examining language bundle [{}] for the code [{}]", filename, code); final PropertiesHolder holder = this.getProperties(filename); foundCode = holder != null && holder.getProperties() != null && holder.getProperty(code) != null; } if (!foundCode) { logger.debug("The code [{}] cannot be found in the language bundle for the locale [{}]", code, locale); } } return super.getMessageInternal(code, args, locale); }
@Override protected String getMessageInternal(final String code, final Object[] args, final Locale locale) { if (!locale.equals(Locale.ENGLISH)) { val foundCode = IntStream.range(0, this.basenames.length) .filter(i -> { val filename = this.basenames[i] + '_' + locale; LOGGER.trace("Examining language bundle [{}] for the code [{}]", filename, code); val holder = this.getProperties(filename); return holder != null && holder.getProperties() != null && holder.getProperty(code) != null; }) .findFirst() .isPresent(); if (!foundCode) { LOGGER.trace("The code [{}] cannot be found in the language bundle for the locale [{}]", code, locale); } } return super.getMessageInternal(code, args, locale); }
private PropertiesHolder refreshClassPathProperties(String filename, PropertiesHolder propHolder) { Properties properties = new Properties(); long lastModified = -1; try { Resource[] resources = resolver.getResources(filename + PROPERTIES_SUFFIX); for (Resource resource : resources) { String sourcePath = resource.getURI().toString().replace(PROPERTIES_SUFFIX, ""); PropertiesHolder holder = super.refreshProperties(sourcePath, propHolder); properties.putAll(holder.getProperties()); if (lastModified < resource.lastModified()) lastModified = resource.lastModified(); } } catch (IOException ignored) { } return new PropertiesHolder(properties, lastModified); } }
@Override protected PropertiesHolder refreshProperties(String filename, PropertiesHolder propHolder) { Properties properties = new Properties(); long lastModified = -1; try { Resource[] resources = resolver.getResources(filename + "*" + PROPERTIES_SUFFIX); for (Resource resource : resources) { String sourcePath = resource.getURI().toString().replace(PROPERTIES_SUFFIX, ""); PropertiesHolder holder = super.refreshProperties(sourcePath, propHolder); properties.putAll(holder.getProperties()); if (lastModified < resource.lastModified()) { lastModified = resource.lastModified(); } } } catch (IOException e) { logger.error(e.getMessage(), e); } return new PropertiesHolder(properties, lastModified); } }
public Properties getAllProperties(Locale locale) { return super.getMergedProperties(locale).getProperties(); }
public Properties getAllProperties(String filename) { return super.getProperties(filename).getProperties(); }
public Properties getAllProperties(Locale locale) { clearCacheIncludingAncestors(); PropertiesHolder propertiesHolder = getMergedProperties(locale); Properties properties = propertiesHolder.getProperties(); return properties; } }