clearCache ( )源码实例Demo

java.util.ResourceBundle#clearCache ( )源码实例Demo

下面列出了java.util.ResourceBundle#clearCache ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: arcusplatform   文件: ResourceBundleDAOImpl.java
@Override
public void saveBundle(final String bundleName, final Locale locale, Map<String, String> localizedValues) {
   Preconditions.checkArgument(!StringUtils.isBlank(bundleName), "bundleName must not be blank");
   Preconditions.checkNotNull(locale, "locale must not be null");

   if(localizedValues.isEmpty()) {
      return;
   }

   localizedValues = new HashMap<String,String>(localizedValues);
   final BatchStatement batch = new BatchStatement();

   localizedValues.forEach((k,v) -> {
      batch.add(new BoundStatement(saveBundleStmt).bind(bundleName, sanitizeLocale(locale), k, v));
   });

   try(Timer.Context ctxt = saveBundleTimer.time()) {
      session.execute(batch);
   }

   // make sure the cache is flushed for the bundle
   // TODO:  this works for this node, but we have no way of notifying the cluster to flush the cache
   ResourceBundle.clearCache();
}
 
源代码2 项目: ripme   文件: LabelsBundlesTest.java
@Test
void testKeyCount() {
    ResourceBundle defaultBundle = Utils.getResourceBundle(null);
    HashMap<String, ArrayList<String>> dictionary = new HashMap<>();
    for (String lang : Utils.getSupportedLanguages()) {
        ResourceBundle.clearCache();
        if (lang.equals(DEFAULT_LANG))
            continue;
        ResourceBundle selectedLang = Utils.getResourceBundle(lang);
        for (final Enumeration<String> keys = defaultBundle.getKeys(); keys.hasMoreElements();) {
            String element = keys.nextElement();
            if (selectedLang.containsKey(element)
                    && !selectedLang.getString(element).equals(defaultBundle.getString(element))) {
                if (dictionary.get(lang) == null)
                    dictionary.put(lang, new ArrayList<>());
                dictionary.get(lang).add(element);
            }
        }
    }

    dictionary.keySet().forEach(d -> {
        logger.warn(String.format("Keys missing in %s", d));
        dictionary.get(d).forEach(v -> logger.warn(v));
        logger.warn("\n");
    });
}
 
源代码3 项目: drftpd   文件: SiteManagementHandler.java
public CommandResponse doSITE_RELOAD(CommandRequest request) {
    try {
        GlobalContext.getGlobalContext().getSectionManager().reload();
        GlobalContext.getGlobalContext().reloadFtpConfig();
        GlobalContext.getGlobalContext().getSlaveSelectionManager().reload();
        // Send event to every plugins
        GlobalContext.getEventService().publish(new ReloadEvent());
    } catch (IOException e) {
        logger.log(Level.FATAL, "Error reloading config", e);
        return new CommandResponse(200, e.getMessage());
    }

    // Clear base system classloader also
    ResourceBundle.clearCache(ClassLoader.getSystemClassLoader());
    return StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK");
}
 
源代码4 项目: bladecoder-adventure-engine   文件: I18N.java
public ResourceBundle getBundle(String filename, boolean clearCache) {
	ResourceBundle rb = null;

	try {
		if (clearCache)
			ResourceBundle.clearCache();

		rb = ResourceBundle.getBundle(filename, locale, new I18NControl(ENCODING));
	} catch (Exception e) {
		EngineLogger.error("ERROR LOADING BUNDLE: " + filename);
	}

	return rb;
}
 
源代码5 项目: ctsms   文件: WebUtil.java
public static void clearResourceBundleCache() throws Exception {
	WebUtil.getServiceLocator().getToolsService().clearResourceBundleCache();
	//https://stackoverflow.com/questions/4325164/how-to-reload-resource-bundle-in-web-application
	ResourceBundle.clearCache(Thread.currentThread().getContextClassLoader());
	Iterator<ApplicationResourceBundle> it = ApplicationAssociate.getCurrentInstance().getResourceBundles().values().iterator();
	while (it.hasNext()) {
		ApplicationResourceBundle appBundle = it.next();
		Map<Locale, ResourceBundle> resources = CommonUtil.getDeclaredFieldValue(appBundle, "resources");
		resources.clear();
	}
}
 
源代码6 项目: smarthome   文件: MetadataUtils.java
private static void loadBundle(String filename) {
    descriptionsBundle = ResourceBundle.getBundle(filename, Locale.getDefault());
    for (String key : descriptionsBundle.keySet()) {
        descriptions.put(key, descriptionsBundle.getString(key));
    }
    ResourceBundle.clearCache();
    descriptionsBundle = null;
}
 
源代码7 项目: MLib   文件: Functions.java
public static Version getProgVersion() {
    String TOKEN_VERSION = "VERSION";
    try {
        ResourceBundle.clearCache();
        ResourceBundle rb = ResourceBundle.getBundle(RBVERSION);
        if (rb.containsKey(TOKEN_VERSION)) {
            return new Version(rb.getString(TOKEN_VERSION));
        }
    } catch (Exception e) {
        Log.errorLog(134679898, e);
    }
    return new Version("");
}
 
源代码8 项目: lutece-core   文件: I18nService.java
/**
 * Reset the caches
 * 
 * @since 5.1
 */
public static void resetCache( )
{
    ResourceBundle.clearCache( );

    if ( _overrideLoader != null )
    {
        ResourceBundle.clearCache( _overrideLoader );
    }

    _resourceBundleCache.clear( );
}
 
源代码9 项目: tech-gallery   文件: I18n.java
/**
 * Get the message in the file for the respective language.
 * @param string message.
 * @return translated message.
 */
public String t(String string) {
  Locale locale = new Locale(language, country);
  ResourceBundle.clearCache();
  ResourceBundle translation = ResourceBundle.getBundle("i18n/Tech_Gallery", locale);
  return translation.getString(string);
}
 
源代码10 项目: MLib   文件: Functions.java
@Deprecated
public static String getBuildNr() {
    String TOKEN_VERSION = "VERSION";
    try {
        ResourceBundle.clearCache();
        ResourceBundle rb = ResourceBundle.getBundle(RBVERSION);
        if (rb.containsKey(TOKEN_VERSION)) {
            return new Version(rb.getString(TOKEN_VERSION)).toString();
        }
    } catch (Exception e) {
        Log.errorLog(134679898, e);
    }
    return new Version("").toString();
}
 
源代码11 项目: ph-commons   文件: ResourceBundleHelper.java
/**
 * Clear the complete resource bundle cache using the specified class loader!
 *
 * @param aClassLoader
 *        The class loader to be used. May not be <code>null</code>.
 */
public static void clearCache (@Nonnull final ClassLoader aClassLoader)
{
  ResourceBundle.clearCache (aClassLoader);
  if (LOGGER.isDebugEnabled ())
    LOGGER.debug ("Cache was cleared: " + ResourceBundle.class.getName () + "; classloader=" + aClassLoader);
}
 
@After
public void tearDown() {
	ResourceBundle.clearCache();
}
 
源代码13 项目: MetarParser   文件: Messages.java
/**
 * Sets the locale of the bundle.
 *
 * @param locale the locale to set.
 */
public void setLocale(final Locale locale) {
    Locale.setDefault(locale);
    ResourceBundle.clearCache();
    fResourceBundle = ResourceBundle.getBundle(BUNDLE_NAME, locale);
}
 
源代码14 项目: ctsms   文件: Compile.java
public static void clearResourceBundleCache() {
	if (classLoader != null) {
		ResourceBundle.clearCache(classLoader);
	}
}
 
/**
 * Return content of testWatch.properties. It should be resolved to target/classes until
 * resources-watch/testWatch.properties is modified, then it should return the new value.
 */
protected String getHelloResourceWatch() {
    ResourceBundle.clearCache();
    return ResourceBundle.getBundle("testWatch").getString("hello");
}
 
/**
 * Releases any cached resources which were managed by this class from the {@link ResourceBundle}.
 */
public void clearCache() {
    ResourceBundle.clearCache(this.resourceClassLoader);
}
 
源代码17 项目: Shuffle-Move   文件: I18nFactory.java
public static void clearCache() {
   ResourceBundle.clearCache();
}
 
/**
 * Return basic resource, it should be handled from target/extra directory.
 */
protected String getHelloResource() {
    ResourceBundle.clearCache();
    return ResourceBundle.getBundle("test").getString("hello");
}
 
/**
 * Return content of testWatch.properties. It should be resolved to target/classes until
 * resources-watch/testWatch.properties is modified, then it should return the new value.
 */
protected String getHelloResourceWatch() {
    ResourceBundle.clearCache();
    return ResourceBundle.getBundle("testWatch").getString("hello");
}
 
/**
 * Return basic resource, it should be handled from target/extra directory.
 */
protected String getHelloResource() {
    ResourceBundle.clearCache();
    return ResourceBundle.getBundle("test").getString("hello");
}