java.util.ResourceBundle.clearCache()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(270)

本文整理了Java中java.util.ResourceBundle.clearCache方法的一些代码示例,展示了ResourceBundle.clearCache的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceBundle.clearCache方法的具体详情如下:
包路径:java.util.ResourceBundle
类名称:ResourceBundle
方法名:clearCache

ResourceBundle.clearCache介绍

[英]Removes all resource bundles from the cache that have been loaded using the caller's class loader.
[中]从缓存中删除使用调用方的类加载器加载的所有资源束。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@After
public void tearDown() {
  ResourceBundle.clearCache();
}

代码示例来源:origin: eclipse/smarthome

/**
 * Releases any cached resources which were managed by this class from the {@link ResourceBundle}.
 */
public void clearCache() {
  ResourceBundle.clearCache(this.resourceClassLoader);
}

代码示例来源:origin: i2p/i2p.i2p

/**
   *  Clear the cache.
   *  Call this after adding new bundles to the classpath.
   *  @since 0.7.12
   */
  public static void clearCache() {
    _missing.clear();
    _bundles.clear();
    ResourceBundle.clearCache();
  }
}

代码示例来源:origin: mulesoft/mule

private void cleanUpResourceBundle() {
 try {
  ResourceBundle.clearCache(this.getClass().getClassLoader());
 } catch (Exception e) {
  logger.warn("Couldn't clean up ResourceBundle. This can cause a memory leak.", e);
 }
}

代码示例来源:origin: mulesoft/mule

/**
 * Attempts to initialize resources that should not be initialized from an application class loader. system or parent class
 * loader is the {@link Thread#contextClassLoader} of the current thread when method is invoked.
 */
public void initialize() {
 // When plugins have com.sun.xml.bind:jaxb-impl:jar a reference to the MuleArtifactClassLoader (plugin) will be
 // referenced by com.sun.xml.bind.DatatypeConverterImpl. Loading this class with the system or container class loader
 // will prevent this class loader leak.
 try {
  Class.forName("javax.xml.bind.DatatypeConverterImpl");
 } catch (ClassNotFoundException e) {
  // Nothing to do...
 } catch (Throwable t) {
  logger.warn("Couldn't initialize DataTypeConverterImpl in order to prevent a class loader leak", t);
 }
 // This is done so the ResourceBundle.NONEXISTENT_BUNDLE gets loaded with the container classloader thus preventing a memory
 // leak.
 clearCache();
 initializeDriverManager();
}

代码示例来源:origin: org.seasar.util/s2util

@Override
  public void dispose() {
    ResourceBundle.clearCache();
    initialized = false;
  }
});

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Removes all resource bundles from the cache that have been loaded
 * using the caller's class loader.
 *
 * @since 1.6
 * @see ResourceBundle.Control#getTimeToLive(String,Locale)
 */
public static final void clearCache() {
  clearCache(null);
}

代码示例来源:origin: jtulach/bck2brwsr

/**
 * Removes all resource bundles from the cache that have been loaded
 * using the caller's class loader.
 *
 * @since 1.6
 * @see ResourceBundle.Control#getTimeToLive(String,Locale)
 */
public static final void clearCache() {
  clearCache(null);
}

代码示例来源:origin: openhab/openhab-core

/**
 * Releases any cached resources which were managed by this class from the {@link ResourceBundle}.
 */
public void clearCache() {
  ResourceBundle.clearCache(this.resourceClassLoader);
}

代码示例来源:origin: com.remondis.limbus/limbus-engine-impl

static void clearResourceBundleCache(PluginClassLoader classloader) {
 try {
  ResourceBundle.clearCache(classloader);
 } catch (SecurityException e) {
  throw e;
 } catch (Throwable t) {
  // keep this silent.
 }
}

代码示例来源:origin: Silverpeas/Silverpeas-Core

/**
 * Resets any caches used directly or indirectly by the ResourceLocator. As consequence, the
 * bundles will be reloaded when accessing.
 * <p>
 * The cache containing the content of the bundles are usually expired at regularly time if a
 * such time was defined in the system properties of Silverpeas. Otherwise, this method should be
 * explicitly used to reset this cache and then to force the reload of the bundles' content.
 */
public static void resetCache() {
 bundles.clear();
 ResourceBundle.clearCache();
}

代码示例来源:origin: org.nuxeo.lib.runtime/nuxeo-runtime-tomcat-adapter

public synchronized void flushWebResources() {
  resourceEntries.clear();
  ResourceBundle.clearCache(this);
}

代码示例来源:origin: vivo-project/Vitro

/** Only clear the cache one time per request. */
private void clearCacheOnRequest(HttpServletRequest req) {
  if (req.getAttribute(ATTRIBUTE_CACHE_CLEARED) != null) {
    log.debug("Cache was already cleared on this request.");
  } else {
    ResourceBundle.clearCache();
    log.debug("Cache cleared.");
    req.setAttribute(ATTRIBUTE_CACHE_CLEARED, Boolean.TRUE);
  }
}

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

public static 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;
}

代码示例来源:origin: org.molgenis/molgenis-settings

private void updateEntity(Entity entity) {
 RunAsSystemAspect.runAsSystem(
   () -> {
    dataService.update(entityTypeId, entity);
    ResourceBundle.clearCache();
    // cache refresh is handled via entity listener
    return null;
   });
}

代码示例来源:origin: com.github.livesense/org.liveSense.misc.i18n

@Override
public void registerResourceBundle(Bundle bundle, String className) {
  synchronized (classNames) {
    ResourceBundle.clearCache(getClassLoader(className, null));
    classNames.add(className);
    bundleResourceCaches.put(className, new BundleProxyClassLoader(bundle));
    // Iterate over existing locales in cache and add new entry
    for (Locale locale : resourceBundles.keySet()) {
      addToCache(className, locale, getCompositeProxyResourceBundleFromCache(locale));
    }            
  }
}

代码示例来源:origin: org.zaproxy/zap

private void removeAddOnClassLoader(AddOn addOn) {
  if (this.addOnLoaders.containsKey(addOn.getId())) {
    try (AddOnClassLoader addOnClassLoader = this.addOnLoaders.remove(addOn.getId())) {
      if (!addOn.getIdsAddOnDependencies().isEmpty()) {
        addOnClassLoader.clearDependencies();
      }
      ResourceBundle.clearCache(addOnClassLoader);
    } catch (Exception e) {
      logger.error("Failure while closing class loader of " + addOn.getId() + " add-on:", e);
    }
  }
}

代码示例来源:origin: Geomatys/geotoolkit

/**
 * Restores the locale to its default value after the test.
 */
@AfterClass
public static void restoreLocale() {
  Locale.setDefault(defaultLocale);
  TimeZone.setDefault(defaultTimezone);
  ResourceBundle.clearCache();
}

代码示例来源:origin: astamuse/asta4d

protected ResourceBundle getResourceBundle(String resourceName, Locale locale) {
  Configuration config = Configuration.getConfiguration();
  if (!config.isCacheEnable()) {
    ResourceBundle.clearCache();
  }
  return resourceBundleFactory.retrieveResourceBundle(resourceName, LocalizeUtil.defaultWhenNull(locale));
}

代码示例来源:origin: com.ovea.tajin/tajin-framework

private ResourceBundle getBundle() {
    if (isDebug()) {
      ResourceBundle.clearCache(loader());
      return ResourceBundle.getBundle(bundleName(), locale(), loader());
    }
    if (this.bundle == null) {
      this.bundle = ResourceBundle.getBundle(bundleName(), locale(), loader());
    }
    return this.bundle;
  }
};

相关文章