io.opentelemetry.javaagent.bootstrap.internal.ClassLoaderMatcherCacheHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opentelemetry-javaagent-extension-api Show documentation
Show all versions of opentelemetry-javaagent-extension-api Show documentation
Instrumentation of Java libraries using OpenTelemetry.
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.javaagent.bootstrap.internal;
import io.opentelemetry.instrumentation.api.internal.GuardedBy;
import io.opentelemetry.instrumentation.api.internal.cache.Cache;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
/**
* A holder of all ClassLoaderMatcher caches. We store them in the bootstrap class loader so that
* instrumentation can invalidate the ClassLoaderMatcher for a particular ClassLoader, e.g. when
* {@link java.net.URLClassLoader#addURL(URL)} is called.
*
* This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class ClassLoaderMatcherCacheHolder {
@GuardedBy("allCaches")
private static final List> allCaches = new ArrayList<>();
private ClassLoaderMatcherCacheHolder() {}
public static void addCache(Cache cache) {
synchronized (allCaches) {
allCaches.add(cache);
}
}
public static void invalidateAllCachesForClassLoader(ClassLoader loader) {
synchronized (allCaches) {
for (Cache cache : allCaches) {
cache.remove(loader);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy