package br.usp.nds.agualastro.satelites; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Timer; import java.util.TimerTask; public class PoolSatelites { private Map satelites = new HashMap(); private Timer timer = new Timer(); private static PoolSatelites instance; public Collection listar() { return satelites.values(); } public void iniciar() { timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { for (String satelite : satelites.keySet()) { satelites.put(satelite, new Informante().consultarSatelite(satelite)); } } }, 0, 60 * 1000); } public void parar() { timer.cancel(); } public synchronized static PoolSatelites getInstance() { if (instance == null) { instance = new PoolSatelites(); } return instance; } private PoolSatelites() { String[] norads = { "38847", "33065", "33064", "33063", "33062", "33061", "33060", "25986", "25985", "25984", "25983", "25982", "25981", "25980", "25482", "25481", "25480", "25479", "25478", "25477", "25476", "25475", "25420", "25419", "25418", "25417", "25416", "25415", "25414", "25413", "25159", "25158", "25119", "25118", "25117", "25116", "25115", "25114", "25113", "25112", "23546", "23545", "21576" }; for (String norad : norads) { satelites.put(norad, new Satelite(norad, 0, 0)); } } }