Removed CF target caching
Clients should be cached and reused when possible, but not the targets as the external targets configuration (e.g. CLI config) can change while the language server is running.
This commit is contained in:
@@ -21,16 +21,21 @@ import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.DefaultClou
|
||||
* Creates targets given a client parameters factory and a client factory.
|
||||
*
|
||||
*/
|
||||
public class CFTargets {
|
||||
public class CFTargetsFactory {
|
||||
|
||||
private final CFClientParamsFactory paramsFactory;
|
||||
private final CloudFoundryClientFactory clientFactory;
|
||||
private final CFClientParamsFactory paramsFactory;
|
||||
|
||||
public CFTargets(CFClientParamsFactory paramsFactory, CloudFoundryClientFactory clientFactory) {
|
||||
this.paramsFactory = paramsFactory;
|
||||
public CFTargetsFactory(CFClientParamsFactory paramsFactory, CloudFoundryClientFactory clientFactory) {
|
||||
this.clientFactory = clientFactory;
|
||||
this.paramsFactory = paramsFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return up-to-date list of CF targets.
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<CFTarget> getTargets() throws Exception {
|
||||
List<CFClientParams> allParams = paramsFactory.getParams();
|
||||
List<CFTarget> targets = new ArrayList<>();
|
||||
@@ -59,10 +64,11 @@ public class CFTargets {
|
||||
}
|
||||
}
|
||||
|
||||
public static CFTargets createDefaultV2Targets() {
|
||||
CFClientParamsFactory paramsFactory = CFClientParamsFactory.INSTANCE;
|
||||
public static CFTargetsFactory createDefaultV2TargetsFactory() {
|
||||
CloudFoundryClientFactory clientFactory = DefaultCloudFoundryClientFactoryV2.INSTANCE;
|
||||
return new CFTargets(paramsFactory, clientFactory);
|
||||
CFClientParamsFactory paramsFactory = CFClientParamsFactory.INSTANCE;
|
||||
|
||||
return new CFTargetsFactory(paramsFactory, clientFactory);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFClientParamsFactory;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargets;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargetsFactory;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.CloudFoundryClientFactory;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.DefaultCloudFoundryClientFactoryV2;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class CFClientTest {
|
||||
CFClientParamsFactory paramsFactory = CFClientParamsFactory.INSTANCE;
|
||||
CloudFoundryClientFactory clientFactory = DefaultCloudFoundryClientFactoryV2.INSTANCE;
|
||||
|
||||
CFTargets targets = new CFTargets(paramsFactory, clientFactory);
|
||||
CFTargetsFactory targets = new CFTargetsFactory(paramsFactory, clientFactory);
|
||||
CFTarget target = targets.getTargets().get(0);
|
||||
|
||||
List<CFBuildpack> buildPacks = target.getBuildpacks();
|
||||
|
||||
Reference in New Issue
Block a user