Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.fitbur.fasterxml.jackson.databind.ser;
import java.util.*;
import com.fitbur.fasterxml.jackson.databind.*;
import com.fitbur.fasterxml.jackson.databind.ser.impl.ReadOnlyClassToSerializerMap;
/**
* Simple cache object that allows for doing 2-level lookups: first level is
* by "local" read-only lookup Map (used without locking)
* and second backup level is by a shared modifiable HashMap.
* The idea is that after a while, most serializers are found from the
* local Map (to optimize performance, reduce lock contention),
* but that during buildup we can use a shared map to reduce both
* number of distinct read-only maps constructed, and number of
* serializers constructed.
*
* Since version 1.5 cache will actually contain three kinds of entries,
* based on com.fitburbination of class pair key. First class in key is for the
* type to serialize, and second one is type used for com.fitburtermining how
* to resolve value type. One (but not both) of entries can be null.
*/
public final class SerializerCache
{
/**
* Shared, modifiable map; all access needs to be through synchronized blocks.
*
* NOTE: keys are of various types (see below for key types), in addition to
* basic {@link JavaType} used for "untyped" serializers.
*/
private HashMap> _sharedMap = new HashMap>(64);
/**
* Most recent read-only instance, created from _sharedMap, if any.
*/
private ReadOnlyClassToSerializerMap _readOnlyMap = null;
public SerializerCache() { }
/**
* Method that can be called to get a read-only instance populated from the
* most recent version of the shared lookup Map.
*/
public ReadOnlyClassToSerializerMap getReadOnlyLookupMap()
{
ReadOnlyClassToSerializerMap m;
synchronized (this) {
m = _readOnlyMap;
if (m == null) {
_readOnlyMap = m = ReadOnlyClassToSerializerMap.from(_sharedMap);
}
}
return m.instance();
}
/*
/**********************************************************
/* Lookup methods for accessing shared (slow) cache
/**********************************************************
*/
public synchronized int size() {
return _sharedMap.size();
}
/**
* Method that checks if the shared (and hence, synchronized) lookup Map might have
* untyped serializer for given type.
*/
public JsonSerializer