Class DatabaseTimerPersistence

    • Constructor Detail

      • DatabaseTimerPersistence

        public DatabaseTimerPersistence​(String database,
                                        String partition,
                                        String nodeName,
                                        int refreshInterval,
                                        boolean allowExecution)
    • Method Detail

      • start

        public void start​(org.jboss.msc.service.StartContext context)
                   throws org.jboss.msc.service.StartException
        Specified by:
        start in interface org.jboss.msc.Service
        Specified by:
        start in interface org.jboss.msc.service.Service<DatabaseTimerPersistence>
        Throws:
        org.jboss.msc.service.StartException
      • stop

        public void stop​(org.jboss.msc.service.StopContext context)
        Specified by:
        stop in interface org.jboss.msc.Service
        Specified by:
        stop in interface org.jboss.msc.service.Service<DatabaseTimerPersistence>
      • loadTimer

        public TimerImpl loadTimer​(String timedObjectId,
                                   String timerId,
                                   TimerServiceImpl timerService)
        Loads a timer from database by its id and timed object id.
        Parameters:
        timedObjectId - the timed object id for the timer
        timerId - the timer id
        timerService - the active timer service
        Returns:
        the timer loaded from database; null if nothing can be loaded
      • addTimer

        public void addTimer​(TimerImpl timerEntity)
        Description copied from interface: TimerPersistence
        Called when a timer is being persisted. In a clustered environment, if an auto timer has already been persisted by another concurrent node, it should not be persisted again, and its state should be set to CANCELED.
        Specified by:
        addTimer in interface TimerPersistence
        Parameters:
        timerEntity - The timer
      • shouldRun

        public boolean shouldRun​(TimerImpl timer)
        Description copied from interface: TimerPersistence
        Invoked before running a timer in order to determine if this node should run the timer.
        Specified by:
        shouldRun in interface TimerPersistence
        Parameters:
        timer - The timer
        Returns:
        true if the timer should be run
      • timerUndeployed

        public void timerUndeployed​(String timedObjectId)
        Description copied from interface: TimerPersistence
        Signals that a timer is being undeployed, and all cached data relating to this object should be dropped to prevent a class loader leak
        Specified by:
        timerUndeployed in interface TimerPersistence
      • timerDeployed

        public void timerDeployed​(String timedObjectId)
        Description copied from interface: TimerPersistence
        Signals that the timer is being deployed and any internal structured required should be added.
        Specified by:
        timerDeployed in interface TimerPersistence
      • loadActiveTimers

        public List<TimerImpl> loadActiveTimers​(String timedObjectId,
                                                TimerServiceImpl timerService)
        Description copied from interface: TimerPersistence
        Load all active timers for the given object. If the object is an entity bean timers for all beans will be returned.
        Specified by:
        loadActiveTimers in interface TimerPersistence
        Parameters:
        timedObjectId - The timed object id to load timers for
        Returns:
        A list of all active timers
      • refreshTimers

        public void refreshTimers()
      • getPersistedTimerInfo

        public Serializable getPersistedTimerInfo​(TimerImpl timer)
        Retrieves the timer info from the timer database.
        Parameters:
        timer - the timer whose info to be retrieved
        Returns:
        the timer info from database; null if SQLException
      • getDataSourceInjectedValue

        public org.jboss.msc.value.InjectedValue<org.jboss.as.naming.ManagedReferenceFactory> getDataSourceInjectedValue()
      • getModuleLoader

        public org.jboss.msc.value.InjectedValue<org.jboss.modules.ModuleLoader> getModuleLoader()
      • getTimerInjectedValue

        public org.jboss.msc.value.InjectedValue<Timer> getTimerInjectedValue()