private Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info, boolean persistent) {
        if (this.isLifecycleCallbackInvocation() && !this.isSingletonBeanInvocation()) {
            throw EJB3_TIMER_LOGGER.failToCreateTimerDoLifecycle();
        }
        if (initialExpiration == null) {
            throw EJB3_TIMER_LOGGER.initialExpirationIsNull();
        }
        if (intervalDuration < 0) {
            throw EJB3_TIMER_LOGGER.invalidIntervalDuration();
        }

        // create an id for the new timer instance
        UUID uuid = UUID.randomUUID();
        // create the timer

        TimerImpl timer = TimerImpl.builder()
                .setNewTimer(true)
                .setId(uuid.toString())
                .setInitialDate(initialExpiration)
                .setRepeatInterval(intervalDuration)
                .setInfo(info)
                .setPersistent(persistent)
                .setPrimaryKey(currentPrimaryKey())
                .setTimerState(TimerState.CREATED)
                .setTimedObjectId(getInvoker().getTimedObjectId())
                .build(this);

        // now "start" the timer. This involves, moving the timer to an ACTIVE state
        // and scheduling the timer task

        this.persistTimer(timer, true);
        this.startTimer(timer);
        // return the newly created timer
        return timer;
    }
private Timer createTimer ( Date initialExpiration , long intervalDuration , Serializable info , boolean persistent ) { if ( this . isLifecycleCallbackInvocation ( ) && ! this . isSingletonBeanInvocation ( ) ) { throw EJB3_TIMER_LOGGER . failToCreateTimerDoLifecycle ( ) ; } if ( initialExpiration == null ) { throw EJB3_TIMER_LOGGER . initialExpirationIsNull ( ) ; } if ( intervalDuration < 0 ) { throw EJB3_TIMER_LOGGER . invalidIntervalDuration ( ) ; } UUID uuid = UUID . randomUUID ( ) ; TimerImpl timer = TimerImpl . builder ( ) . setNewTimer ( true ) . setId ( uuid . toString ( ) ) . setInitialDate ( initialExpiration ) . setRepeatInterval ( intervalDuration ) . setInfo ( info ) . setPersistent ( persistent ) . setPrimaryKey ( currentPrimaryKey ( ) ) . setTimerState ( TimerState . CREATED ) . setTimedObjectId ( getInvoker ( ) . getTimedObjectId ( ) ) . build ( this ) ; this . persistTimer ( timer , true ) ; this . startTimer ( timer ) ; return timer ; }
Create a {@link javax.ejb.Timer}

@param initialExpiration The {@link java.util.Date} at which the first timeout should occur.
<p>If the date is in the past, then the timeout is triggered immediately
when the timer moves to {@link TimerState#ACTIVE}</p>
@param intervalDuration  The interval (in milliseconds) between consecutive timeouts for the newly created timer.
<p>Cannot be a negative value. A value of 0 indicates a single timeout action</p>
@param info              {@link java.io.Serializable} info that will be made available through the newly created timer's {@link javax.ejb.Timer#getInfo()} method
@param persistent        True if the newly created timer has to be persistent
@return Returns the newly created timer
@throws IllegalArgumentException If <code>initialExpiration</code> is null or <code>intervalDuration</code> is negative
@throws IllegalStateException    If this method was invoked during a lifecycle callback on the EJB