我有以下方法可以在不同的 PaaS 中创建和部署应用程序:
private void deployModulesInPaaS() {
ExecutorService executor = Executors.newFixedThreadPool(listModules
.size());
ModuleParsed mod;
for (Iterator<ModuleParsed> iterator = listModules.iterator(); iterator
.hasNext();) {
mod = (ModuleParsed) iterator.next();
try {
switch (mod.getId_paas()) {
case 1:
GAEDeployer gaeDeployer = new GAEDeployer(mod.getId_paas(),
mod.getId_component(), "//whatever/path");
FutureTask<URI> gaeFuture = new FutureTask<URI>(gaeDeployer);
executor.execute(gaeFuture);
mod.setDeployedURI(gaeFuture.get());
break;
case 2:
AzureDeployer azureDeployer = new AzureDeployer(
"subscription", "path_certificate", "password",
"storageAccountName", "storageAccountKey");
FutureTask<URI> azureFuture = new FutureTask<URI>(
azureDeployer);
executor.execute(azureFuture);
mod.setDeployedURI(azureFuture.get());
break;
default:
System.out.println("The PaaS identifier of module "
+ mod.getId_component() + " is unknown.");
break;
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}
FutureTask
一旦所有人都完成了计算,我该如何调用另一个方法?我已经阅读了关于Command
模式和关于Listener
但我不确定这些是否是正确的,也不确定在这种情况下如何实现它们。