public ServletTimer createTimer(SipApplicationSession appSession, long delay, boolean isPersistent, Serializable info) { MobicentsSipApplicationSession sipApplicationSessionImpl =(MobicentsSipApplicationSession)appSession; if (sipApplicationSessionImpl.isValid() == false) { throw new IllegalStateException("Sip application session has been invalidated!!!"); } if (!sipApplicationSessionImpl.hasTimerListener()) { throw new IllegalStateException("No Timer listeners have been configured for this application "); } TimerListener listener = sipApplicationSessionImpl.getSipContext().getListeners().getTimerListener(); ServletTimerImpl servletTimer = createTimerLocaly(listener, delay, isPersistent, info, sipApplicationSessionImpl); return servletTimer; }
/** * * @param listener * @param delay * @param isPersistent * @param info * @param sipApplicationSession * @return */ private ServletTimerImpl createTimerLocaly(TimerListener listener, long delay, boolean isPersistent, Serializable info, MobicentsSipApplicationSession sipApplicationSession) { ServletTimerImpl servletTimer = new ServletTimerImpl(info, delay, listener, sipApplicationSession); if(logger.isDebugEnabled()) { logger.debug("Scheduling Timer "+ servletTimer.getId() +" to expire in " + delay + " ms"); } ScheduledFuture<?> future = scheduledExecutor.schedule(servletTimer, delay, TimeUnit.MILLISECONDS); servletTimer.setFuture(future); // sipApplicationSession.timerScheduled(st); sipApplicationSession.addServletTimer(servletTimer); if (isPersistent) { persist(servletTimer); } return servletTimer; } /**
timerService = new TimerServiceImpl();
timerService = new TimerServiceImpl(sipApplicationDispatcher.getSipService());
timerService = new TimerServiceImpl(sipApplicationDispatcher.getSipService());
public ServletTimer createTimer(SipApplicationSession appSession, long delay, long period, boolean fixedDelay, boolean isPersistent, Serializable info) { if (period < 1) { throw new IllegalArgumentException( "Period should be greater than 0"); } MobicentsSipApplicationSession sipApplicationSessionImpl = (MobicentsSipApplicationSession) appSession; if (sipApplicationSessionImpl.isValid() == false) { throw new IllegalStateException("Sip application session has been invalidated!!!"); } if (!sipApplicationSessionImpl.hasTimerListener()) { throw new IllegalStateException("No Timer listeners have been configured for this application "); } TimerListener timerListener = sipApplicationSessionImpl.getSipContext().getListeners().getTimerListener(); ServletTimerImpl servletTimer = createTimerLocaly(timerListener , delay, period, fixedDelay,isPersistent, info,sipApplicationSessionImpl); return servletTimer; }
persist(servletTimer);
timerService = new TimerServiceImpl(sipApplicationDispatcher.getSipService(), getApplicationName());
timerService = new TimerServiceImpl(sipApplicationDispatcher.getSipService(), getApplicationName());