From 51d55899951f5df79bf6fd2268c4eec2195951c3 Mon Sep 17 00:00:00 2001 From: DaScheid <75588422+dascheid@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:08:15 +0200 Subject: [PATCH] Reduce inits of MetroConfigLoader Creating a MetroConfigLoader requires frequent class- and resource-loading, so re-use factories when applicable --- .../assembler/TubelineAssemblyController.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/jaxws-ri/runtime/rt/src/main/java/com/sun/xml/ws/assembler/TubelineAssemblyController.java b/jaxws-ri/runtime/rt/src/main/java/com/sun/xml/ws/assembler/TubelineAssemblyController.java index dbc707b12..01a05d002 100644 --- a/jaxws-ri/runtime/rt/src/main/java/com/sun/xml/ws/assembler/TubelineAssemblyController.java +++ b/jaxws-ri/runtime/rt/src/main/java/com/sun/xml/ws/assembler/TubelineAssemblyController.java @@ -10,8 +10,11 @@ package com.sun.xml.ws.assembler; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import com.sun.istack.NotNull; import com.sun.istack.logging.Logger; +import com.sun.xml.ws.api.server.Container; import com.sun.xml.ws.assembler.dev.ClientTubelineAssemblyContext; import com.sun.xml.ws.assembler.dev.ServerTubelineAssemblyContext; import com.sun.xml.ws.resources.TubelineassemblyMessages; @@ -23,6 +26,7 @@ import java.net.URISyntaxException; import java.util.Collection; import java.util.LinkedList; +import java.util.concurrent.TimeUnit; /** * @@ -32,6 +36,11 @@ final class TubelineAssemblyController { private final MetroConfigName metroConfigName; + private static final Cache tubeFactoryListCache = CacheBuilder.newBuilder() + .maximumSize(100) + .expireAfterWrite(5, TimeUnit.MINUTES) + .build(); + TubelineAssemblyController(MetroConfigName metroConfigName) { this.metroConfigName = metroConfigName; } @@ -59,8 +68,13 @@ Collection getTubeCreators(ClientTubelineAssemblyContext context) { endpointUri = null; } - MetroConfigLoader configLoader = new MetroConfigLoader(context.getContainer(), metroConfigName); - return initializeTubeCreators(configLoader.getClientSideTubeFactories(endpointUri)); + TubeFactoryList tubeFactoryList = tubeFactoryListCache.getIfPresent(context.getContainer()); + if (tubeFactoryList == null) { + MetroConfigLoader configLoader = new MetroConfigLoader(context.getContainer(), metroConfigName); + tubeFactoryList = configLoader.getClientSideTubeFactories(endpointUri); + tubeFactoryListCache.put(context.getContainer(), tubeFactoryList); + } + return initializeTubeCreators(tubeFactoryList); } /**