public static final ConnectorTimerProxy getProxy() { if (connectorTimer == null) { connectorTimer = new ConnectorTimerProxy(true); } return connectorTimer; }
public Timer getTimer() { return ConnectorTimerProxy.getProxy(); }
/** * Proxy method to schedule a timer task for repeated fixed-delay execution, * beginning after the specified delay. * The unchecked exceptions are caught here and in such cases, the timer * is recreated and task is rescheduled. * @param task * @param delay * @param period */ @Override public void schedule(TimerTask task, long delay, long period) { timer = getTimer(); try { timer.schedule(task, delay, period); } catch(Exception ex) { handleTimerException(ex); timer.schedule(task, delay, period); } }
@Override public void cancel() { timer = getTimer(); try { timer.cancel(); } catch(Exception ex) { _logger.log(Level.WARNING, "exception_cancelling_timer", ex.getMessage()); } }
/** * Proxy method to schedule a timer task at the specified time. * The unchecked exceptions are caught here and in such cases, the timer * is recreated and task is rescheduled. * @param task * @param delay * @param period */ @Override public void schedule(TimerTask task, Date time) { timer = getTimer(); try { timer.schedule(task, time); } catch(Exception ex) { handleTimerException(ex); timer.schedule(task, time); } }
@Override public int purge() { int status = 0; timer = getTimer(); try { status = timer.purge(); } catch(Exception ex) { _logger.log(Level.WARNING, "exception_purging_timer", ex.getMessage()); } return status; }
/** * Proxy method to schedule a timer task for repeated fixed-delay execution, * beginning after the specified delay. * The unchecked exceptions are caught here and in such cases, the timer * is recreated and task is rescheduled. * @param task * @param delay * @param period */ @Override public void schedule(TimerTask task, Date firstTime, long period) { timer = getTimer(); try { timer.schedule(task, firstTime, period); } catch(Exception ex) { handleTimerException(ex); timer.schedule(task, firstTime, period); } }
/** * Handle any exception occured during scheduling timer. * * In case of unchecked exceptions, the timer is recreated to be used * by the subsequent requests for scheduling. * @param ex exception that was caught */ private void handleTimerException(Exception ex) { _logger.log(Level.WARNING, "exception_scheduling_timer", ex.getMessage()); //In case of unchecked exceptions, timer needs to recreated. _logger.info("Recreating Timer and scheduling at fixed rate"); timer = null; timer = getTimer(); } }
/** * Proxy method to schedule a timer task at fixed rate. * The unchecked exceptions are caught here and in such cases, the timer * is recreated and task is rescheduled. * @param task * @param delay * @param period */ @Override public void scheduleAtFixedRate(TimerTask task, long delay, long period) { timer = getTimer(); try { timer.scheduleAtFixedRate(task, delay, period); } catch(Exception ex) { handleTimerException(ex); timer.scheduleAtFixedRate(task, delay, period); } }
/** * Proxy method to schedule a timer task after a specified delay. * The unchecked exceptions are caught here and in such cases, the timer * is recreated and task is rescheduled. * @param task * @param delay * @param period */ @Override public void schedule(TimerTask task, long delay) { timer = getTimer(); try { timer.schedule(task, delay); } catch(Exception ex) { handleTimerException(ex); timer.schedule(task, delay); } }
/** * Proxy method to schedule a timer task for repeated fixed-rate execution, * beginning after the specified delay. * The unchecked exceptions are caught here and in such cases, the timer * is recreated and task is rescheduled. * @param task * @param delay * @param period */ @Override public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period) { timer = getTimer(); try { timer.scheduleAtFixedRate(task, firstTime, period); } catch(Exception ex) { handleTimerException(ex); timer.scheduleAtFixedRate(task, firstTime, period); } }