日期:2014-05-20 浏览次数:20647 次
Timer timer = new Timer("Timer-reconnect provider Timer"); TimerTask task = new TimerTask() { @Override public void run() { log.info("it is time to check jtapi Provider."); try { checkProvider(); } catch (Exception e) { log.info("the Network may be disconnected,please check!"); e.printStackTrace(); } } }
@Override public void providerInService(ProviderEvent event) { log.info("provider is InService."); timer.cancel(); } @Override public void providerOutOfService(ProviderEvent event) { log.info("provider is OutOfService,please wait for InService."); timer.schedule(task, 3000, 10000); } @Override public void providerShutdown(ProviderEvent event) { log.info("provider is Shutdown,please wait for restart."); timer.schedule(task, 3000, 10000); }