Class PersistentEJBTimerService


  • public class PersistentEJBTimerService
    extends NonPersistentEJBTimerService
    Persistent support part of the EJBTimerService
    Author:
    Marina Vatkina
    • Method Detail

      • cancelTimersByKey

        protected void cancelTimersByKey​(long containerId,
                                         Object primaryKey)
        Description copied from class: EJBTimerService
        Cancel all timers associated with a particular entity bean identity.This is typically called when an entity bean is removed.Note that this action falls under the normal EJB Timer removal semantics, which means it can be rolled back if the transaction rolls back.
        Overrides:
        cancelTimersByKey in class NonPersistentEJBTimerService
      • stopTimers

        protected void stopTimers​(long containerId)
        Description copied from class: EJBTimerService
        Remove from the cache and stop all timers associated with a particular ejb container and known to this server instance.This is typically called when an ejb is disabled or on a server shutdown to avoid accidentally removing a valid timer. This is also called when an ejb is disabled as part of an undeploy. Removal of the associated timer from the database is done as the last step of undeployment.
        Overrides:
        stopTimers in class NonPersistentEJBTimerService
      • _createTimer

        protected void _createTimer​(TimerPrimaryKey timerId,
                                    long containerId,
                                    long applicationId,
                                    Object timedObjectPrimaryKey,
                                    String server_name,
                                    Date initialExpiration,
                                    long intervalDuration,
                                    EJBTimerSchedule schedule,
                                    jakarta.ejb.TimerConfig timerConfig)
                             throws Exception
        Create persistent timer.
        Overrides:
        _createTimer in class EJBTimerService
        timedObjectPrimaryKey - can be null if timed object is not an entity bean.
        Throws:
        Exception
      • recoverAndCreateSchedules

        protected Map<TimerPrimaryKey,​Method> recoverAndCreateSchedules​(long containerId,
                                                                              long applicationId,
                                                                              Map<Method,​List<ScheduledTimerDescriptor>> schedules,
                                                                              boolean deploy)
        Recover pre-existing timers associated with the Container identified by the containerId, and create automatic timers defined by the @Schedule annotation on the EJB bean. If it is called from deploy on a non-clustered instance, both persistent and non-persistent timers will be created. Otherwise only non-persistent timers are created by this method.
        Overrides:
        recoverAndCreateSchedules in class EJBTimerService
        Returns:
        a Map of both, restored and created timers, where the key is TimerPrimaryKey and the value is the Method to be executed by the container when the timer with this PK times out.
      • createSchedulesOnServer

        public void createSchedulesOnServer​(EjbDescriptor ejbDescriptor,
                                            String server_name)
        Called in a clustered environment to eagerly create automatic persistent timers on the specific server instance.
        Overrides:
        createSchedulesOnServer in class EJBTimerService
      • createSchedules

        public void createSchedules​(long containerId,
                                    long applicationId,
                                    Map<MethodDescriptor,​List<ScheduledTimerDescriptor>> methodDescriptorSchedules,
                                    String server_name)
        Create automatic timers defined by the @Schedule annotation on the EJB bean during deployment to a cluster or the first create-application-ref call after deployment to DAS only. Only persistent schedule based timers for the containerId that has no timers associated with it, will be created. And no timers will be scheduled.
        Overrides:
        createSchedules in class EJBTimerService
      • getTimerIds

        protected Collection<TimerPrimaryKey> getTimerIds​(long containerId,
                                                          Object timedObjectPrimaryKey)
        Use database query to retrieve persistrent timer ids of all active timers. Results must be transactionally consistent. E.g., a client calling getTimerIds within a transaction where a timer has been created but not committed "sees" the timer but a client in a different transaction doesn't. Called by EJBTimerServiceWrapper when caller calls getTimers.
        Overrides:
        getTimerIds in class NonPersistentEJBTimerService
        Parameters:
        timedObjectPrimaryKey - can be null if not entity bean
        containerId - the id of the EJB which owns the timers
        Returns:
        Collection of Timer Ids.
      • getNextTimeout

        protected Date getNextTimeout​(TimerPrimaryKey timerId)
                               throws jakarta.ejb.FinderException
        Description copied from class: EJBTimerService
        Return next planned timeout for this timer.We have a fair amount of leeway regarding the consistency of this information.We should strive to detect the case where the timer no longer exists.However, since the current timer instance may not even own this timer, it's difficult to know the exact time of delivery in another server instance. In the case of single-action timers, we return the expiration time that was provided upon timer creation. For periodic timers, we can derive the next scheduled fixed rate expiration based on the initial expiration and the interval.
        Overrides:
        getNextTimeout in class NonPersistentEJBTimerService
        Returns:
        Throws:
        jakarta.ejb.FinderException
      • expungeTimer

        protected void expungeTimer​(TimerPrimaryKey timerId,
                                    boolean removeTimerBean)
        Description copied from class: EJBTimerService
        Remove all traces of a timer. This should be written defensively so that if expunge is called multiple times for the same timer id, the second, third, fourth, etc. calls will not cause exceptions.
        Overrides:
        expungeTimer in class EJBTimerService
      • resetEJBTimers

        protected void resetEJBTimers​(String target)
        Description copied from class: EJBTimerService
        Called at server startup *after* user apps have been re-activated to restart any active EJB timers or cleanup old timers.No-op for non-persistent timers
        Overrides:
        resetEJBTimers in class NonPersistentEJBTimerService