Achal1607 commented on code in PR #8514: URL: https://github.com/apache/netbeans/pull/8514#discussion_r2149340004
########## java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/ClientConfigurationManager.java: ########## @@ -0,0 +1,204 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * http://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 org.netbeans.modules.java.lsp.server.protocol; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.List; +import java.util.WeakHashMap; +import java.util.concurrent.CompletableFuture; +import java.util.function.BiConsumer; +import org.eclipse.lsp4j.ConfigurationItem; +import org.eclipse.lsp4j.ConfigurationParams; +import org.eclipse.lsp4j.services.LanguageClient; +import org.netbeans.api.project.FileOwnerQuery; +import org.netbeans.api.project.Project; +import org.netbeans.modules.java.lsp.server.Utils; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.Lookup; + +/** + * Manages configuration settings for LSP clients + * + * @author atalati + */ +public class ClientConfigurationManager { + + final WeakHashMap<LanguageClient, ConfigValueCache> clientCaches = new WeakHashMap<>(); + + private ClientConfigurationManager() { + } + + public static ClientConfigurationManager getInstance() { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder { + + private static final ClientConfigurationManager INSTANCE = new ClientConfigurationManager(); + } + + public void registerClient(LanguageClient client) { + clientCaches.put(client, new ConfigValueCache()); + } + + public void registerConfigChangeListener(NbCodeLanguageClient client, String section, BiConsumer<String, JsonElement> consumer) { + ConfigValueCache cache = clientCaches.get(client); + if (cache != null) { + cache.registerListener(section, consumer); + } + } + + public void registerConfigCache(NbCodeLanguageClient client, String section) { Review Comment: Okay, so thinking on this lines, would this approach be fine: When the caller requests for the config we will cache it by default and also expose a method which accepts `boolean` if the caller doesn't want to cache the value (whatever be the reason be it large object size or something else). So, then it would be the responsibility of the caller to state explicitly if they don't want to cache the value. Would this approach work? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For additional commands, e-mail: notifications-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists