@Inject
public APIStatusTableModel(IGW2StatsService gw2statsService) {
this.gw2statsService = checkNotNull(gw2statsService);
// TODO refactor this to an event based system -> wrap it
final AbstractScheduledService service = new AbstractScheduledService() {
@Override
protected Scheduler scheduler() {
return AbstractScheduledService.Scheduler.newFixedDelaySchedule(0, 5000, TimeUnit.MILLISECONDS);
}
@Override
protected void runOneIteration() throws Exception {
APIStatusTableModel.this.states = APIStatusTableModel.this.gw2statsService.retrieveAPIStates();
APIStatusTableModel.this.fireTableDataChanged();
}
};
service.start();
}