added configs for fetching live hover data to allow users to customize the behaviour

This commit is contained in:
Martin Lippert
2019-11-19 14:41:37 +01:00
parent 560128a0bb
commit f8dd7929fd
10 changed files with 81 additions and 12 deletions

View File

@@ -86,6 +86,9 @@ public class BootJavaPreferencesPage extends FieldEditorPreferencePage implement
addField(new BooleanFieldEditor(Constants.PREF_LIVE_INFORMATION_AUTOMATIC_TRACKING_ENABLED, "Live Information - Automatic Process Tracking Enabled", fieldEditorParent));
addField(new StringFieldEditor(Constants.PREF_LIVE_INFORMATION_AUTOMATIC_TRACKING_DELAY, "Live Information - Automatic Process Tracking Delay in ms", fieldEditorParent));
addField(new BooleanFieldEditor(Constants.PREF_LIVE_INFORMATION_FETCH_DATA_RETRY_MAX_NO, "Live Information - Max number of retries (before giving up)", fieldEditorParent));
addField(new StringFieldEditor(Constants.PREF_LIVE_INFORMATION_FETCH_DATA_RETRY_DELAY_IN_SECONDS, "Live Information - Delay between retries in seconds", fieldEditorParent));
addField(new BooleanFieldEditor(PreferenceConstants.HIGHLIGHT_CODELENS_PREFS, "Highlights CodeLens", fieldEditorParent) {
@Override
public IPreferenceStore getPreferenceStore() {

View File

@@ -20,11 +20,16 @@ public class Constants {
public static final String PREF_LIVE_INFORMATION_AUTOMATIC_TRACKING_ENABLED = "boot-java.live-information.automatic-tracking.on";
public static final String PREF_LIVE_INFORMATION_AUTOMATIC_TRACKING_DELAY = "boot-java.live-information.automatic-tracking.delay";
public static final String PREF_LIVE_INFORMATION_FETCH_DATA_RETRY_MAX_NO = "boot-java.live-information.fetch-data.max-retries";
public static final String PREF_LIVE_INFORMATION_FETCH_DATA_RETRY_DELAY_IN_SECONDS = "boot-java.live-information.fetch-data.retry-delay-in-seconds";
public static final String PREF_SCAN_JAVA_TEST_SOURCES = "boot-java.scan-java-test-sources";
public static final String PREF_SUPPORT_SPRING_XML_CONFIGS = "boot-java.support-spring-xml-config.on";
public static final String PREF_XML_CONFIGS_SCAN_FOLDERS = "boot-java.support-spring-xml-config.scan-folders-globs";
public static final String PREF_SCAN_JAVA_TEST_SOURCES = "boot-java.scan-java-test-sources";
public static final String PREF_XML_CONFIGS_HYPERLINKS = "boot-java.support-spring-xml-config.hyperlinks";
public static final String PREF_XML_CONFIGS_CONTENT_ASSIST = "boot-java.support-spring-xml-config.content-assist";
public static final String PREF_CHANGE_DETECTION = "boot-java.change-detection.on";
}

View File

@@ -231,6 +231,7 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
Map<String, Object> bootJavaObj = new HashMap<>();
Map<String, Object> liveInformation = new HashMap<>();
Map<String, Object> liveInformationAutomaticTracking = new HashMap<>();
Map<String, Object> liveInformationFetchData = new HashMap<>();
Map<String, Object> supportXML = new HashMap<>();
Map<String, Object> bootChangeDetection = new HashMap<>();
Map<String, Object> scanTestJavaSources = new HashMap<>();
@@ -240,7 +241,11 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
liveInformationAutomaticTracking.put("on", preferenceStore.getBoolean(Constants.PREF_LIVE_INFORMATION_AUTOMATIC_TRACKING_ENABLED));
liveInformationAutomaticTracking.put("delay", preferenceStore.getInt(Constants.PREF_LIVE_INFORMATION_AUTOMATIC_TRACKING_DELAY));
liveInformationFetchData.put("max-retries", preferenceStore.getInt(Constants.PREF_LIVE_INFORMATION_FETCH_DATA_RETRY_MAX_NO));
liveInformationFetchData.put("retry-delay-in-seconds", preferenceStore.getInt(Constants.PREF_LIVE_INFORMATION_FETCH_DATA_RETRY_DELAY_IN_SECONDS));
liveInformation.put("automatic-tracking", liveInformationAutomaticTracking);
liveInformation.put("fetch-data", liveInformationFetchData);
supportXML.put("on", preferenceStore.getBoolean(Constants.PREF_SUPPORT_SPRING_XML_CONFIGS));
supportXML.put("scan-folders", preferenceStore.getString(Constants.PREF_XML_CONFIGS_SCAN_FOLDERS));

View File

@@ -27,13 +27,19 @@ public class PrefsInitializer extends AbstractPreferenceInitializer {
@Override
public void initializeDefaultPreferences() {
IPreferenceStore preferenceStore = BootLanguageServerPlugin.getDefault().getPreferenceStore();
preferenceStore.setDefault(Constants.PREF_LIVE_INFORMATION_AUTOMATIC_TRACKING_ENABLED, true);
preferenceStore.setDefault(Constants.PREF_LIVE_INFORMATION_AUTOMATIC_TRACKING_DELAY, 5000);
preferenceStore.setDefault(Constants.PREF_LIVE_INFORMATION_FETCH_DATA_RETRY_MAX_NO, 10);
preferenceStore.setDefault(Constants.PREF_LIVE_INFORMATION_FETCH_DATA_RETRY_DELAY_IN_SECONDS, 3);
preferenceStore.setDefault(Constants.PREF_SUPPORT_SPRING_XML_CONFIGS, false);
preferenceStore.setDefault(Constants.PREF_XML_CONFIGS_HYPERLINKS, true);
preferenceStore.setDefault(Constants.PREF_XML_CONFIGS_CONTENT_ASSIST, true);
preferenceStore.setDefault(Constants.PREF_XML_CONFIGS_SCAN_FOLDERS, "src/main");
preferenceStore.setDefault(Constants.PREF_CHANGE_DETECTION, false);
preferenceStore.setDefault(Constants.PREF_SCAN_JAVA_TEST_SOURCES, false);
}

View File

@@ -32,6 +32,10 @@ public class BootJavaConfig implements InitializingBean {
public static final boolean LIVE_INFORMATION_AUTOMATIC_TRACKING_ENABLED_DEFAULT = true;
public static final int LIVE_INFORMATION_AUTOMATIC_TRACKING_DELAY_DEFAULT = 5000;
public static final int LIVE_INFORMATION_FETCH_DATA_RETRY_MAX_NO_DEFAULT = 10;
public static final int LIVE_INFORMATION_FETCH_DATA_RETRY_DELAY_IN_SECONDS_DEFAULT = 3;
//TODO: Consider changing this to something that raises Spring application events.
// I.e. like described in here: https://www.baeldung.com/spring-events
@@ -54,6 +58,16 @@ public class BootJavaConfig implements InitializingBean {
return delay != null ? delay.intValue() : LIVE_INFORMATION_AUTOMATIC_TRACKING_DELAY_DEFAULT;
}
public int getLiveInformationFetchDataMaxRetryCount() {
Integer delay = settings.getInt("boot-java", "live-information", "fetch-data", "max-retries");
return delay != null ? delay.intValue() : LIVE_INFORMATION_FETCH_DATA_RETRY_MAX_NO_DEFAULT;
}
public int getLiveInformationFetchDataRetryDelayInSeconds() {
Integer delay = settings.getInt("boot-java", "live-information", "fetch-data", "retry-delay-in-seconds");
return delay != null ? delay.intValue() : LIVE_INFORMATION_FETCH_DATA_RETRY_DELAY_IN_SECONDS_DEFAULT;
}
public boolean isSpringXMLSupportEnabled() {
Boolean enabled = settings.getBoolean("boot-java", "support-spring-xml-config", "on");
return enabled != null && enabled.booleanValue();

View File

@@ -199,6 +199,10 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
liveProcessTracker.setDelay(config.getLiveInformationAutomaticTrackingDelay());
liveProcessTracker.setTrackingEnabled(config.isLiveInformationAutomaticTrackingEnabled());
// live information data fetch params
liveDataService.setMaxRetryCount(config.getLiveInformationFetchDataMaxRetryCount());
liveDataService.setRetryDelayInSeconds(config.getLiveInformationFetchDataRetryDelayInSeconds());
// live change detection watchdog
if (config.isChangeDetectionEnabled()) {
liveChangeDetectionWatchdog.enableHighlights();

View File

@@ -39,8 +39,7 @@ public class SpringProcessConnectorOverJMX implements SpringProcessConnector {
private final String jmxURL;
private final String urlScheme;
private final String port;
final private String projectName;
private final String projectName;
// not final, might be updated with data from JMX process, if not initially set
private String processID;

View File

@@ -18,6 +18,7 @@ import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.commons.languageserver.ProgressTask;
import org.springframework.ide.vscode.boot.app.BootJavaConfig;
import org.springframework.ide.vscode.commons.languageserver.ProgressService;
/**
@@ -27,9 +28,6 @@ public class SpringProcessConnectorService {
private static final Logger log = LoggerFactory.getLogger(SpringProcessConnectorService.class);
private static final int RETRY_MAX_NO = 10;
private static final int RETRY_DELAY_IN_SECONDS = 3;
private final SpringProcessLiveDataProvider liveDataProvider;
private final ScheduledThreadPoolExecutor scheduler;
@@ -41,6 +39,8 @@ public class SpringProcessConnectorService {
private final ProgressService progressService;
private int progressIdKey = 0;
private int maxRetryCount;
private int retryDelayInSeconds;
public SpringProcessConnectorService(ProgressService progressService, SpringProcessLiveDataProvider liveDataProvider) {
this.liveDataProvider = liveDataProvider;
@@ -49,6 +49,9 @@ public class SpringProcessConnectorService {
this.connectedSuccess = new ConcurrentHashMap<>();
this.progressService = progressService == null ? ProgressService.NO_PROGRESS : progressService;
this.maxRetryCount = BootJavaConfig.LIVE_INFORMATION_FETCH_DATA_RETRY_MAX_NO_DEFAULT;
this.retryDelayInSeconds = BootJavaConfig.LIVE_INFORMATION_FETCH_DATA_RETRY_DELAY_IN_SECONDS_DEFAULT;
this.connectorListener = new SpringProcessConnectionChangeListener() {
@Override
public void connectionClosed(String processKey) {
@@ -57,6 +60,14 @@ public class SpringProcessConnectorService {
};
}
public void setMaxRetryCount(int maxRetryCount) {
this.maxRetryCount = maxRetryCount;
}
public void setRetryDelayInSeconds(int retryDelayInSeconds) {
this.retryDelayInSeconds = retryDelayInSeconds;
}
public void connectProcess(String processKey, SpringProcessConnector connector) {
log.info("connect to process: " + processKey);
@@ -130,8 +141,8 @@ public class SpringProcessConnectorService {
catch (Exception e) {
log.info("problem occured during process connect", e);
if (retryNo < RETRY_MAX_NO) {
scheduleConnect(connectProgressTask, processKey, connector, RETRY_DELAY_IN_SECONDS, TimeUnit.SECONDS, retryNo + 1);
if (retryNo < maxRetryCount) {
scheduleConnect(connectProgressTask, processKey, connector, retryDelayInSeconds, TimeUnit.SECONDS, retryNo + 1);
} else {
connectProgressTask.progressDone();
}
@@ -149,8 +160,8 @@ public class SpringProcessConnectorService {
catch (Exception e) {
log.info("problem occured during process disconnect", e);
if (retryNo < RETRY_MAX_NO) {
scheduleDisconnect(processKey, connector, RETRY_DELAY_IN_SECONDS, TimeUnit.SECONDS, retryNo + 1);
if (retryNo < maxRetryCount) {
scheduleDisconnect(processKey, connector, retryDelayInSeconds, TimeUnit.SECONDS, retryNo + 1);
}
}
}, delay, unit);
@@ -183,8 +194,8 @@ public class SpringProcessConnectorService {
log.info("problem occured during process live data refresh", e);
if (retryNo < RETRY_MAX_NO) {
scheduleRefresh(refreshProgressTask, processKey, connector, RETRY_DELAY_IN_SECONDS, TimeUnit.SECONDS,
if (retryNo < maxRetryCount) {
scheduleRefresh(refreshProgressTask, processKey, connector, retryDelayInSeconds, TimeUnit.SECONDS,
retryNo + 1);
}
else {

View File

@@ -30,6 +30,16 @@ export const BootConfigSchema: PreferenceSchema = {
description: 'Live Information - Automatic Process Tracking Delay in ms',
default: 5000
},
'boot-java.live-information.fetch-data.max-retries': {
type: 'number',
default: 10,
description: 'Live Information - Max number of retries (before giving up)'
},
'boot-java.live-information.fetch-data.retry-delay-in-seconds': {
type: 'number',
default: 3,
description: 'Live Information - Delay between retries in seconds'
},
'boot-java.scan-java-test-sources.on': {
type: 'boolean',
description: 'Enable/Disable Java test sources files scanning',
@@ -81,6 +91,8 @@ export const BootConfigSchema: PreferenceSchema = {
export interface BootConfiguration {
'boot-java.live-information.automatic-tracking.on': boolean;
'boot-java.live-information.automatic-tracking.delay': number;
'boot-java.live-information.fetch-data.max-retries': number;
'boot-java.live-information.fetch-data.retry-delay-in-seconds': number;
'boot-java.scan-java-test-sources.on': boolean;
'boot-java.support-spring-xml-config.on': boolean;
'boot-java.support-spring-xml-config.hyperlinks': boolean;

View File

@@ -84,6 +84,16 @@
"default": 5000,
"description": "Live Information - Automatic Process Tracking Delay in ms"
},
"boot-java.live-information.fetch-data.max-retries": {
"type": "number",
"default": 10,
"description": "Live Information - Max number of retries (before giving up)"
},
"boot-java.live-information.fetch-data.retry-delay-in-seconds": {
"type": "number",
"default": 3,
"description": "Live Information - Delay between retries in seconds"
},
"boot-java.scan-java-test-sources.on": {
"type": "boolean",
"default": false,