Categories:
Audio (13)
Biotech (29)
Bytecode (35)
Database (77)
Framework (7)
Game (7)
General (512)
Graphics (53)
I/O (32)
IDE (2)
JAR Tools (86)
JavaBeans (16)
JDBC (89)
JDK (337)
JSP (20)
Logging (103)
Mail (54)
Messaging (8)
Network (71)
PDF (94)
Report (7)
Scripting (83)
Security (32)
Server (119)
Servlet (17)
SOAP (24)
Testing (50)
Web (19)
XML (301)
Other Resources:
Jackson Annotations Source Code
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java".
Jackson Annotations Source Code files are provided in the source packge (jackson-annotations-2.12.4-sources.jar). You can download it at Jackson Maven Website.
You can also browse Jackson Annotations Source Code below:
✍: FYIcenter.com
⏎ com/fasterxml/jackson/databind/util/LRUMap.java
package com.fasterxml.jackson.databind.util; import java.io.*; import java.util.concurrent.ConcurrentHashMap; /** * Helper for simple bounded maps used for reusing lookup values. *<p> * Note that serialization behavior is such that contents are NOT serialized, * on assumption that all use cases are for caching where persistence * does not make sense. The only thing serialized is the cache size of Map. *<p> * NOTE: since version 2.4.2, this is <b>NOT</b> an LRU-based at all; reason * being that it is not possible to use JDK components that do LRU _AND_ perform * well wrt synchronization on multi-core systems. So we choose efficient synchronization * over potentially more efficient handling of entries. *<p> * And yes, there are efficient LRU implementations such as * <a href="https://code.google.com/p/concurrentlinkedhashmap/">concurrentlinkedhashmap</a>; * but at this point we really try to keep external deps to minimum. * Plan from Jackson 2.12 is to focus more on pluggability as {@link LookupCache} and * let users, frameworks, provide their own cache implementations. */ public class LRUMap<K,V> implements LookupCache<K,V>, // since 2.12 java.io.Serializable { private static final long serialVersionUID = 1L; protected final transient int _maxEntries; protected final transient ConcurrentHashMap<K,V> _map; public LRUMap(int initialEntries, int maxEntries) { // We'll use concurrency level of 4, seems reasonable _map = new ConcurrentHashMap<K,V>(initialEntries, 0.8f, 4); _maxEntries = maxEntries; } @Override public V put(K key, V value) { if (_map.size() >= _maxEntries) { // double-locking, yes, but safe here; trying to avoid "clear storms" synchronized (this) { if (_map.size() >= _maxEntries) { clear(); } } } return _map.put(key, value); } /** * @since 2.5 */ @Override public V putIfAbsent(K key, V value) { // not 100% optimal semantically, but better from correctness (never exceeds // defined maximum) and close enough all in all: if (_map.size() >= _maxEntries) { synchronized (this) { if (_map.size() >= _maxEntries) { clear(); } } } return _map.putIfAbsent(key, value); } // NOTE: key is of type Object only to retain binary backwards-compatibility @Override public V get(Object key) { return _map.get(key); } @Override public void clear() { _map.clear(); } @Override public int size() { return _map.size(); } /* /********************************************************** /* Serializable overrides /********************************************************** */ /** * Ugly hack, to work through the requirement that _value is indeed final, * and that JDK serialization won't call ctor(s) if Serializable is implemented. * * @since 2.1 */ protected transient int _jdkSerializeMaxEntries; private void readObject(ObjectInputStream in) throws IOException { _jdkSerializeMaxEntries = in.readInt(); } private void writeObject(ObjectOutputStream out) throws IOException { out.writeInt(_jdkSerializeMaxEntries); } protected Object readResolve() { return new LRUMap<Object,Object>(_jdkSerializeMaxEntries, _jdkSerializeMaxEntries); } }
⏎ com/fasterxml/jackson/databind/util/LRUMap.java
Â
⇒ Jackson Dataformat Extensions
⇠Jackson Data Binding Source Code
⇑ Downloading and Reviewing jackson-*.jar
⇑⇑ Jackson - Java JSON library
2022-02-19, 36203👍, 0💬
Popular Posts:
How to download and install ojdbc7.jar for Oracle 12c R1? ojdbc8.jar for Oracle 12c R1 is a Java 7 a...
What Is mail.jar of JavaMail 1.4.2? I got the JAR file from javamail-1.4.2.zip. mail.jar in javamail...
How to display types defined in an XML Schema file with the xs\QueryXS.java provided in the Apache X...
JDK 11 jdk.internal.le.jmod is the JMOD file for JDK 11 Internal Line Editing module. JDK 11 Interna...
What Is commons-fileupload-1.3.3 .jar?commons-fileupload-1.3.3 .jaris the JAR file for Apache Common...