moved language server system property set call to main method to have that happening as early as possible in the JVM lifetime

This commit is contained in:
Martin Lippert
2019-05-03 17:43:54 +02:00
parent db780c0479
commit 28c0637395
6 changed files with 18 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,6 +17,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.ide.vscode.bosh.models.BoshCommandCloudConfigProvider;
import org.springframework.ide.vscode.bosh.models.BoshCommandReleasesProvider;
import org.springframework.ide.vscode.bosh.models.BoshCommandStemcellsProvider;
import org.springframework.ide.vscode.commons.languageserver.LanguageServerRunner;
import org.springframework.ide.vscode.commons.util.LogRedirect;
import org.springframework.ide.vscode.commons.yaml.reconcile.ASTTypeCache;
@@ -26,6 +27,8 @@ public class BoshLanguageServerBootApp {
private static final String SERVER_NAME = "bosh-language-server";
public static void main(String[] args) throws Exception {
System.setProperty(LanguageServerRunner.SYSPROP_LANGUAGESERVER_NAME, SERVER_NAME); //makes it easy to recognize language server processes - and set this as early as possible
LogRedirect.bootRedirectToFile(SERVER_NAME); //TODO: use boot (or logback realy) to configure logging instead.
SpringApplication.run(BoshLanguageServerBootApp.class, args);
}
@@ -34,10 +37,6 @@ public class BoshLanguageServerBootApp {
return new ASTTypeCache();
}
@Bean public String serverName() {
return SERVER_NAME;
}
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
@Bean BoshCommandCloudConfigProvider cloudConfg(BoshCliConfig cliConfig) {
return new BoshCommandCloudConfigProvider(cliConfig);

View File

@@ -75,18 +75,15 @@ public class LanguageServerRunner implements CommandLineRunner {
public static final String SYSPROP_LANGUAGESERVER_NAME = "sts4.languageserver.name";
private LanguageServerProperties properties;
private final String name;
private final SimpleLanguageServer languageServer;
public LanguageServerRunner(String name, LanguageServerProperties properties, SimpleLanguageServer languageServer) {
public LanguageServerRunner(LanguageServerProperties properties, SimpleLanguageServer languageServer) {
super();
this.name = name;
this.properties = properties;
this.languageServer = languageServer;
}
public void start() throws Exception {
System.setProperty(SYSPROP_LANGUAGESERVER_NAME, name); //makes it easy to recognize language server processes.
LanguageServerRunner app = this;
log.info("Server ready to start after {} ms", ManagementFactory.getRuntimeMXBean().getUptime());
if (properties.isStandalone()) {

View File

@@ -10,7 +10,6 @@
*******************************************************************************/
package org.springframework.ide.vscode.languageserver.starter;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.ide.vscode.commons.languageserver.LanguageServerRunner;
@@ -21,11 +20,10 @@ import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguage
public class LanguageServerRunnerAutoConf {
@Bean public LanguageServerRunner serverApp(
@Qualifier("serverName") String serverName,
LanguageServerProperties properties,
SimpleLanguageServer languageServerFactory
) {
return new LanguageServerRunner(serverName, properties, languageServerFactory);
return new LanguageServerRunner(properties, languageServerFactory);
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@ package org.springframework.ide.vscode.concourse;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.ide.vscode.commons.languageserver.LanguageServerRunner;
import org.springframework.ide.vscode.commons.languageserver.util.HierarchicalDocumentSymbolHandler;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
@@ -29,14 +30,12 @@ public class ConcourseLanguageServerBootApp {
private static final String SERVER_NAME = "concourse-language-server";
public static void main(String[] args) throws Exception {
System.setProperty(LanguageServerRunner.SYSPROP_LANGUAGESERVER_NAME, SERVER_NAME); //makes it easy to recognize language server processes - and set this as early as possible
LogRedirect.bootRedirectToFile(SERVER_NAME); //TODO: use boot (or logback realy) to configure logging instead.
SpringApplication.run(ConcourseLanguageServerBootApp.class, args);
}
@Bean public String serverName() {
return SERVER_NAME;
}
@Bean GithubInfoProvider github() {
return new DefaultGithubInfoProvider();
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@ package org.springframework.ide.vscode.manifest.yaml;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.ide.vscode.commons.languageserver.LanguageServerRunner;
import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter.CompletionFilter;
import org.springframework.ide.vscode.commons.util.LogRedirect;
import org.springframework.ide.vscode.commons.util.Unicodes;
@@ -24,14 +25,12 @@ public class ManifestYamlLanguageServerBootApp {
private static final String SERVER_NAME = "manifest-yaml-language-server";
public static void main(String[] args) throws Exception {
System.setProperty(LanguageServerRunner.SYSPROP_LANGUAGESERVER_NAME, SERVER_NAME); //makes it easy to recognize language server processes - and set this as early as possible
LogRedirect.bootRedirectToFile(SERVER_NAME); //TODO: use boot (or logback realy) to configure logging instead.
SpringApplication.run(ManifestYamlLanguageServerBootApp.class, args);
}
@Bean public String serverName() {
return SERVER_NAME;
}
@Bean
public CompletionFilter completionFilter() {
return (proposal) -> {

View File

@@ -38,6 +38,7 @@ import org.springframework.ide.vscode.boot.metadata.ProjectBasedPropertyIndexPro
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
import org.springframework.ide.vscode.boot.yaml.completions.ApplicationYamlAssistContext;
import org.springframework.ide.vscode.commons.languageserver.LanguageServerRunner;
import org.springframework.ide.vscode.commons.languageserver.util.DocumentEventListenerManager;
import org.springframework.ide.vscode.commons.languageserver.util.LspClient;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
@@ -56,17 +57,16 @@ import org.yaml.snakeyaml.Yaml;
@SpringBootApplication(proxyBeanMethods = false)
public class BootLanguagServerBootApp {
private static final String SERVER_NAME = "boot-language-server";
public static void main(String[] args) throws Exception {
System.setProperty(LanguageServerRunner.SYSPROP_LANGUAGESERVER_NAME, SERVER_NAME); //makes it easy to recognize language server processes - and set this as early as possible
LogRedirect.bootRedirectToFile(SERVER_NAME); //TODO: use boot (or logback realy) to configure logging instead.
SpringApplication.run(BootLanguagServerBootApp.class, args);
}
@Bean public String serverName() {
return SERVER_NAME;
}
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
@Bean
SymbolCache symbolCache(BootLsConfigProperties props) {