/**
  * Invokes the timeout on the passed timer.
  *
  * @param \AppserverIo\Psr\EnterpriseBeans\TimerInterface $timer The timer we want to invoke the timeout for
  *
  * @return void
  */
 protected function callTimeout(TimerInterface $timer)
 {
     // if we have any more schedules remaining, then schedule a new task
     if ($timer->getNextExpiration() != null && !$timer->isInRetry()) {
         $timer->scheduleTimeout(false);
     }
     // finally invoke the timeout method through the invoker
     if ($timer->isAutoTimer()) {
         $timer->getTimerService()->getTimedObjectInvoker()->callTimeout($timer, $timer->getTimeoutMethod());
     } else {
         $timer->getTimerService()->getTimedObjectInvoker()->callTimeout($timer);
     }
 }
Example #2
0
 /**
  * Calculates and returns the next timeout for the passed timer.
  *
  * @param \AppserverIo\Psr\EnterpriseBeans\TimerInterface $timer The timer we want to calculate the next timeout for
  *
  * @return \DateTime|null The next expiration timeout
  */
 protected function calculateNextTimeout(TimerInterface $timer)
 {
     // try to load the interval
     $intervalDuration = $timer->getIntervalDuration();
     // check if we've a interval
     if ($intervalDuration > 0) {
         // load the next expiration date
         $nextExpiration = $timer->getNextExpiration();
         // compute and return the next expiration date
         return $nextExpiration->add(new \DateInterval(sprintf('PT%sS', $intervalDuration / 1000000)));
     }
     // return nothing
     return null;
 }
Example #3
0
 /**
  * Creates and schedules a timer task for the next timeout of the passed timer.
  *
  * @param \AppserverIo\Psr\EnterpriseBeans\TimerInterface $timer    The timer we want to schedule a task for
  * @param boolean                                         $newTimer TRUE if this is a new timer being scheduled, and not a re-schedule due to a timeout
  *
  * @return void
  */
 public function scheduleTimeout(TimerInterface $timer, $newTimer)
 {
     // check if this timer has been cancelled by another thread
     if ($newTimer === false && $this->getTimers()->has($timer->getId()) === false) {
         return;
         // if yes, we just return
     }
     // if next expiration is NULL, no more tasks will be scheduled for this timer
     if ($timer->getNextExpiration() == null) {
         return;
         // we just return
     }
     // create the timer task and schedule it
     $this->getTimerServiceExecutor()->schedule($timer);
 }