ResourceCache(long period) { checkPeriod = ((period != -1) ? period * 1000L * 60L : -1); resourceCache = new MultiKeyConcurrentHashMap<>(30); }
/** * <p>Empty the cache.</p> */ public void clear() { resourceCache.clear(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Cache Cleared"); } }
/** * Legacy method testing if some key maps into the specified value in this * table. This method is identical in functionality to {@link * #containsValue}, and exists solely to ensure full compatibility with * class {@link java.util.Hashtable}, which supported this method prior to * introduction of the Java Collections framework. * * @param value a value to search for. * * @return <tt>true</tt> if and only if some key maps to the <tt>value</tt> * argument in this table as determined by the <tt>equals</tt> * method; <tt>false</tt> otherwise. * * @throws NullPointerException if the value is <tt>null</tt>. */ public boolean contains(Object value) { return containsValue(value); }
/** * @see #containsKey(Object) */ public boolean containsKey(Object key1, Object key2, Object key3) { int hash = hash(key1, key2, key3, null); return segmentFor(hash).containsKey(key1, key2, key3, null, hash); }
/** * @param name the resource name * @param libraryName the library name * @param localePrefix the locale prefix * @param contracts the contracts * @return the {@link ResourceInfo} associated with <code>key<code> * if any. */ public ResourceInfo get(String name, String libraryName, String localePrefix, List<String> contracts) { Util.notNull("name", name); ResourceInfoCheckPeriodProxy proxy = resourceCache.get(name, libraryName, localePrefix, contracts); if (proxy != null && proxy.needsRefreshed()) { resourceCache.remove(name, libraryName, localePrefix, contracts); return null; } else { return ((proxy != null) ? proxy.getResourceInfo() : null); } }
/** * Add the {@link ResourceInfo} to the internal cache. * * @param info resource metadata * * @param contracts the contracts * @return previous value associated with specified key, or null * if there was no mapping for key */ public ResourceInfo add(ResourceInfo info, List<String> contracts) { Util.notNull("info", info); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Caching ResourceInfo: {0}", info.toString()); } ResourceInfoCheckPeriodProxy proxy = resourceCache.putIfAbsent(info.name, info.libraryName, info.localePrefix, new ArrayList(contracts), new ResourceInfoCheckPeriodProxy(info, checkPeriod)); return ((proxy != null) ? proxy.getResourceInfo() : null); }
/** * @see #containsKey(Object) */ public boolean containsKey(Object key1, Object key2, Object key3, Object key4) { int hash = hash(key1, key2, key3, key4); return segmentFor(hash).containsKey(key1, key2, key3, key4, hash); }
/** * @param name the resource name * @param libraryName the library name * @param localePrefix the locale prefix * @param contracts the contracts * @return the {@link ResourceInfo} associated with <code>key<code> * if any. */ public ResourceInfo get(String name, String libraryName, String localePrefix, List<String> contracts) { Util.notNull("name", name); ResourceInfoCheckPeriodProxy proxy = resourceCache.get(name, libraryName, localePrefix, contracts); if (proxy != null && proxy.needsRefreshed()) { resourceCache.remove(name, libraryName, localePrefix, contracts); return null; } else { return ((proxy != null) ? proxy.getResourceInfo() : null); } }
/** * Add the {@link ResourceInfo} to the internal cache. * * @param info resource metadata * * @param contracts the contracts * @return previous value associated with specified key, or null * if there was no mapping for key */ public ResourceInfo add(ResourceInfo info, List<String> contracts) { Util.notNull("info", info); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Caching ResourceInfo: {0}", info.toString()); } ResourceInfoCheckPeriodProxy proxy = resourceCache.putIfAbsent(info.name, info.libraryName, info.localePrefix, new ArrayList(contracts), new ResourceInfoCheckPeriodProxy(info, checkPeriod)); return ((proxy != null) ? proxy.getResourceInfo() : null); }
/** * @see Map#remove(Object) */ public V remove(K key1, K key2) { int hash = hash(key1, key2, null, null); return segmentFor(hash).remove(key1, key2, null, null, hash, null); }
/** * @param name the resource name * @param libraryName the library name * @param localePrefix the locale prefix * @param contracts the contracts * @return the {@link ResourceInfo} associated with <code>key<code> * if any. */ public ResourceInfo get(String name, String libraryName, String localePrefix, List<String> contracts) { Util.notNull("name", name); ResourceInfoCheckPeriodProxy proxy = resourceCache.get(name, libraryName, localePrefix, contracts); if (proxy != null && proxy.needsRefreshed()) { resourceCache.remove(name, libraryName, localePrefix, contracts); return null; } else { return ((proxy != null) ? proxy.getResourceInfo() : null); } }
/** * <p>Empty the cache.</p> */ public void clear() { resourceCache.clear(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Cache Cleared"); } }
ResourceCache(long period) { checkPeriod = ((period != -1) ? period * 1000L * 60L : -1); resourceCache = new MultiKeyConcurrentHashMap<Object, ResourceInfoCheckPeriodProxy>(30); }
/** * Legacy method testing if some key maps into the specified value in this * table. This method is identical in functionality to {@link * #containsValue}, and exists solely to ensure full compatibility with * class {@link java.util.Hashtable}, which supported this method prior to * introduction of the Java Collections framework. * * @param value a value to search for. * * @return <tt>true</tt> if and only if some key maps to the <tt>value</tt> * argument in this table as determined by the <tt>equals</tt> * method; <tt>false</tt> otherwise. * * @throws NullPointerException if the value is <tt>null</tt>. */ public boolean contains(Object value) { return containsValue(value); }
/** * Add the {@link ResourceInfo} to the internal cache. * * @param info resource metadata * * @param contracts the contracts * @return previous value associated with specified key, or null * if there was no mapping for key */ public ResourceInfo add(ResourceInfo info, List<String> contracts) { Util.notNull("info", info); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Caching ResourceInfo: {0}", info.toString()); } ResourceInfoCheckPeriodProxy proxy = resourceCache.putIfAbsent(info.name, info.libraryName, info.localePrefix, new ArrayList(contracts), new ResourceInfoCheckPeriodProxy(info, checkPeriod)); return ((proxy != null) ? proxy.getResourceInfo() : null); }
/** * @see Map#remove(Object) */ public V remove(K key1, K key2, K key3) { int hash = hash(key1, key2, key3, null); return segmentFor(hash).remove(key1, key2, null, null, hash, null); }
/** * @param name the resource name * @param libraryName the library name * @param localePrefix the locale prefix * @param contracts the contracts * @return the {@link ResourceInfo} associated with <code>key<code> * if any. */ public ResourceInfo get(String name, String libraryName, String localePrefix, List<String> contracts) { Util.notNull("name", name); ResourceInfoCheckPeriodProxy proxy = resourceCache.get(name, libraryName, localePrefix, contracts); if (proxy != null && proxy.needsRefreshed()) { resourceCache.remove(name, libraryName, localePrefix, contracts); return null; } else { return ((proxy != null) ? proxy.getResourceInfo() : null); } }
/** * <p>Empty the cache.</p> */ public void clear() { resourceCache.clear(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Cache Cleared"); } }
ResourceCache(long period) { checkPeriod = ((period != -1) ? period * 1000L * 60L : -1); resourceCache = new MultiKeyConcurrentHashMap<>(30); }
/** * Legacy method testing if some key maps into the specified value in this * table. This method is identical in functionality to {@link * #containsValue}, and exists solely to ensure full compatibility with * class {@link java.util.Hashtable}, which supported this method prior to * introduction of the Java Collections framework. * * @param value a value to search for. * * @return <tt>true</tt> if and only if some key maps to the <tt>value</tt> * argument in this table as determined by the <tt>equals</tt> * method; <tt>false</tt> otherwise. * * @throws NullPointerException if the value is <tt>null</tt>. */ public boolean contains(Object value) { return containsValue(value); }