List of utility methods to do ConcurrentMap
void | fileReaderDecrement(ConcurrentMap file Reader Decrement readers.compute(fileNum, (key, value) -> { if (value == null) throw new IllegalMonitorStateException("file not locked: " + fileNum); if (value.longValue() == 1L) { return null; } else { return value - 1L; }); |
void | fileReaderIncrement(ConcurrentMap file Reader Increment readers.compute(fileNum, (key, value) -> value == null ? 1L : value + 1L); |
Logger | get(Class> clazz) get if (clazz == null) { return null; Logger logger = loggers.get(clazz); if (logger == null) { logger = LoggerFactory.getLogger(clazz); loggers.put(clazz, logger); return logger; |
ConcurrentMap,?> | getCache(String cacheName) get Cache return MAP_OF_MAP.get(cacheName);
|
ConcurrentHashMap | getConcurrentMap(int... size) get Concurrent Map if (size.length == 0) { return new ConcurrentHashMap<K, V>(); } else { return new ConcurrentHashMap<K, V>(size[0]); |
String | getContextPath() get Context Path return (String) dataMap.get("__contextPath__"); |
Map | getFilesystem(String id) get Filesystem Map<String, String> fs = mounts.get(id); if (fs == null) { fs = new ConcurrentHashMap<String, String>(); Map<String, String> prev = mounts.putIfAbsent(id, fs); if (prev != null) { fs = prev; return fs; |
Set | getNestedSet(K1 key, ConcurrentMap Get and/or allocate as needed a nested concurrent set inside a concurrent map in a threadsafe way. Set<K2> inner = set.get(key); if (inner == null) { inner = Collections.newSetFromMap(new ConcurrentHashMap<K2, Boolean>()); Set<K2> old = set.putIfAbsent(key, inner); if (old != null) inner = old; return inner; ... |
int | getNewLogFactor(String factorName) get New Log Factor Integer newFactor = null; if (logFactorMap.containsKey(factorName)) { Integer oldFactor = logFactorMap.get(factorName); newFactor = oldFactor + 1; logFactorMap.put(factorName, newFactor); } else { logFactorMap.put(factorName, 0); newFactor = 0; ... |
T | getSingleInstance(Class get Single Instance T instance = null; if (instanceMap.containsKey(classType)) { instance = (T) instanceMap.get(classType); } else { instance = classType.newInstance(); instanceMap.put(classType, instance); return instance; ... |