Пример #1
0
 /**
  * Creates a new schedule expression instance from this annotations data.
  *
  * @return \AppserverIo\Psr\EnterpriseBeans\ScheduleExpression The expression initialzed with the data from this annotation
  */
 public function toScheduleExpression()
 {
     // create a new expression instance
     $expression = new ScheduleExpression();
     // copy the data from the annotation
     $expression->hour($this->getHour());
     $expression->minute($this->getMinute());
     $expression->month($this->getMonth());
     $expression->second($this->getSecond());
     $expression->start($this->getStart());
     $expression->end($this->getEnd());
     $expression->timezone($this->getTimezone());
     $expression->year($this->getYear());
     $expression->dayOfMonth($this->getDayOfMonth());
     $expression->dayOfWeek($this->getDayOfWeek());
     // return the expression
     return $expression;
 }
Пример #2
0
 /**
  * Initializes the timer with the necessary data.
  *
  * @param \AppserverIo\Appserver\PersistenceContainer\CalendarTimerBuilder $builder      The builder with the data to create the timer from
  * @param \AppserverIo\Psr\EnterpriseBeans\TimerServiceInterface           $timerService The timer service instance
  */
 public function __construct(CalendarTimerBuilder $builder, TimerServiceInterface $timerService)
 {
     // call parent constructor
     parent::__construct($builder, $timerService);
     // load the auto timer flag
     $this->autoTimer = $builder->isAutoTimer();
     // check if we've an auto timer
     if ($this->autoTimer) {
         // check if the timeout method is available
         if ($builder->getTimeoutMethod() == null) {
             // TODO: Throw an exception here, because we NEED a timeout method
         }
         // if yes, set it
         $this->timeoutMethod = $builder->getTimeoutMethod();
     } else {
         // we don't expect an timeout method here
         if ($builder->getTimeoutMethod() != null) {
             // TODO: Throw an exception here, because we DON'T expect a timeout method
         }
         // reset the timeout method
         $this->timeoutMethod = null;
     }
     // create the schedule for this timer
     $scheduledExpression = new ScheduleExpression();
     $scheduledExpression->second($builder->getScheduleExprSecond());
     $scheduledExpression->minute($builder->getScheduleExprMinute());
     $scheduledExpression->hour($builder->getScheduleExprHour());
     $scheduledExpression->dayOfWeek($builder->getScheduleExprDayOfWeek());
     $scheduledExpression->dayOfMonth($builder->getScheduleExprDayOfMonth());
     $scheduledExpression->month($builder->getScheduleExprMonth());
     $scheduledExpression->year($builder->getScheduleExprYear());
     $scheduledExpression->start($builder->getScheduleExprStartDate());
     $scheduledExpression->end($builder->getScheduleExprEndDate());
     $scheduledExpression->timezone($builder->getScheduleExprTimezone());
     // create the calender timeout from the schedule
     $this->calendarTimeout = CalendarBasedTimeout::factoryFromScheduleExpression($scheduledExpression);
     // if the timer has a next date and is new
     if ($builder->getNextDate() == null && $builder->isNewTimer()) {
         // compute the next timeout (from "now")
         $nextTimeout = $this->calendarTimeout->getNextRunDate();
         if ($nextTimeout != null) {
             $this->nextExpiration = $nextTimeout->format($scheduledExpression::DATE_FORMAT);
         }
     }
 }