public Map<String, Object> getAccountSync(String user) { Map<String, Object> properties = new HashMap<>(); try { properties.put("balance", moneyServiceClient.getBalance(user)); properties.put("photos", photoCacheClient.getPhotos(user)); properties.put("friends", friendsServiceClient.getFriends(user)); } catch (IOException e) { properties.put("error", e); } return properties; }
public Map<String, Object> getAccount(String user) { Map<String, Object> properties = new HashMap<>(); try { Future<BalanceStatement> balanceStatementFuture = moneyServiceClient.getBalanceAsync(user, executorService); Future<List<Photo>> photoListFuture = photoCacheClient.getPhotosAsync(user, executorService); Future<List<Friend>> friendListFuture = friendsServiceClient.getFriendsAsync(user, executorService); properties.put("balance", balanceStatementFuture.get()); properties.put("photos", photoListFuture.get()); properties.put("friends", friendListFuture.get()); } catch (InterruptedException | ExecutionException | IOException e) { properties.put("error", e); } return properties; }