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.
/*
* Copyright 2020 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micrometer.core.instrument.binder.cache;
import io.micrometer.core.lang.Nullable;
import io.micrometer.core.util.internal.logging.InternalLogger;
import io.micrometer.core.util.internal.logging.InternalLoggerFactory;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.ref.WeakReference;
import static java.lang.invoke.MethodType.methodType;
/**
* Adapter for Hazelcast {@code IMap} class created to provide support for both Hazelcast
* 3 and Hazelcast 4 at the same time. Dynamically checks which Hazelcast version is on
* the classpath and resolves the right classes.
*
* @implNote Note that {@link MethodHandle} is used, so the performance does not suffer.
*/
class HazelcastIMapAdapter {
private static final InternalLogger log = InternalLoggerFactory.getInstance(HazelcastIMapAdapter.class);
private static final Class CLASS_I_MAP = resolveOneOf("com.hazelcast.map.IMap", "com.hazelcast.core.IMap");
private static final Class CLASS_LOCAL_MAP = resolveOneOf("com.hazelcast.map.LocalMapStats",
"com.hazelcast.monitor.LocalMapStats");
private static final Class CLASS_NEAR_CACHE_STATS = resolveOneOf("com.hazelcast.nearcache.NearCacheStats",
"com.hazelcast.monitor.NearCacheStats");
private static final MethodHandle GET_NAME;
private static final MethodHandle GET_LOCAL_MAP_STATS;
static {
GET_NAME = resolveIMapMethod("getName", methodType(String.class));
GET_LOCAL_MAP_STATS = resolveIMapMethod("getLocalMapStats", methodType(CLASS_LOCAL_MAP));
}
private final WeakReference