Adopt new MemoizingProxy in SpringLiveHoverWatchdog
This commit is contained in:
@@ -27,6 +27,7 @@ public class LocalSpringBootAppCache {
|
||||
|
||||
private static final Duration EXPIRE_AFTER = Duration.ofMillis(500); //Limits rate at which we refresh list of apps
|
||||
private long nextRefreshAfter = Long.MIN_VALUE;
|
||||
private final MemoizingProxy.Builder<LocalSpringBootApp> memoizingProxyBuilder = MemoizingProxy.builder(LocalSpringBootApp.class, Duration.ofMillis(4500), VirtualMachineDescriptor.class);
|
||||
|
||||
private ImmutableMap<VirtualMachineDescriptor, SpringBootApp> apps = ImmutableMap.of();
|
||||
|
||||
@@ -46,7 +47,7 @@ public class LocalSpringBootAppCache {
|
||||
newAppsBuilder.put(vm, existingApp);
|
||||
} else {
|
||||
try {
|
||||
LocalSpringBootApp localApp = MemoizingProxy.create(LocalSpringBootApp.class, Duration.ofMillis(4500), new Class[] {VirtualMachineDescriptor.class}, vm);
|
||||
LocalSpringBootApp localApp = memoizingProxyBuilder.newInstance(vm);
|
||||
newAppsBuilder.put(vm, localApp);
|
||||
} catch (Exception e) {
|
||||
//Ignore problems attaching to a VM. We will try again on next polling loop, if vm still exists.
|
||||
@@ -63,4 +64,5 @@ public class LocalSpringBootAppCache {
|
||||
apps = newApps;
|
||||
nextRefreshAfter = System.currentTimeMillis() + EXPIRE_AFTER.toMillis();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@ import java.util.Properties;
|
||||
import org.springframework.ide.vscode.commons.util.MemoizingProxy;
|
||||
|
||||
public class RemoteSpringBootApp extends AbstractSpringBootApp {
|
||||
|
||||
private static MemoizingProxy.Builder<RemoteSpringBootApp> memoizingProxyBuilder = MemoizingProxy.builder(RemoteSpringBootApp.class, Duration.ofMillis(4900),
|
||||
String.class, String.class, String.class, String.class, boolean.class
|
||||
);
|
||||
|
||||
private final String jmxUrl;
|
||||
private final String host;
|
||||
@@ -27,8 +31,7 @@ public class RemoteSpringBootApp extends AbstractSpringBootApp {
|
||||
private boolean keepChecking;
|
||||
|
||||
public static SpringBootApp create(String jmxUrl, String host, String port, String urlScheme, boolean keepChecking) {
|
||||
return MemoizingProxy.create(RemoteSpringBootApp.class, Duration.ofMillis(4900), new Class[] {String.class, String.class, String.class, String.class, boolean.class},
|
||||
jmxUrl, host, port, urlScheme, keepChecking);
|
||||
return memoizingProxyBuilder.newInstance(jmxUrl, host, port, urlScheme, keepChecking);
|
||||
}
|
||||
|
||||
protected RemoteSpringBootApp(String jmxUrl, String host, String port, String urlScheme, boolean keepChecking) {
|
||||
|
||||
Reference in New Issue
Block a user