mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-09 01:56:03 +00:00
[JENKINS-51205] Improve performance of /pluginManager/available service.
(cherry picked from commit 3b61b96119)
This commit is contained in:
1 parent
5ff1c08c7b
commit
7bd6d1e80c
3 files changed
+48
-23
No files matched your search
@@ -144,6 +144,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.net.JarURLConnection;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.jar.JarEntry;
|
||||
|
||||
import static java.util.logging.Level.FINE;
|
||||
@@ -1816,6 +1817,19 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
return requestedPlugins;
|
||||
}
|
||||
|
||||
@Restricted(DoNotUse.class) // table.jelly
|
||||
public MetadataCache createCache() {
|
||||
return new MetadataCache();
|
||||
}
|
||||
|
||||
@Restricted(NoExternalUse.class) // table.jelly
|
||||
public static final class MetadataCache {
|
||||
private final Map<String, Object> data = new HashMap<>();
|
||||
public <T> T of(String key, Class<T> type, Supplier<T> func) {
|
||||
return type.cast(data.computeIfAbsent(key, _ignored -> func.get()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ClassLoader} that can see all plugins.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user