public abstract class EJBTimerService extends Object
Modifier and Type | Class and Description |
---|---|
static class |
EJBTimerService.TimerCache |
Modifier and Type | Field and Description |
---|---|
protected String |
domainName_ |
protected EjbContainerUtil |
ejbContainerUtil |
protected boolean |
isDas |
protected String |
ownerIdOfThisServer_ |
static int |
STATE_ACTIVE |
static int |
STATE_CANCELLED |
protected EJBTimerService.TimerCache |
timerCache_ |
protected long |
totalTimedObjectsInitialized_ |
Modifier | Constructor and Description |
---|---|
protected |
EJBTimerService() |
Modifier and Type | Method and Description |
---|---|
protected void |
_createTimer(TimerPrimaryKey timerId,
long containerId,
long applicationId,
Object timedObjectPrimaryKey,
String server_name,
Date initialExpiration,
long intervalDuration,
EJBTimerSchedule schedule,
javax.ejb.TimerConfig timerConfig) |
protected void |
_destroyTimers(long id,
boolean all) |
protected Date |
_getNextTimeout(RuntimeTimerState rt)
Non-persistent part of the implementation of the getNextTimeout() call
|
void |
addTimerSynchronization(EJBContextImpl context_,
String timerId,
Date initialExpiration,
long containerId,
String ownerId) |
void |
addTimerSynchronization(EJBContextImpl context_,
String timerId,
Date initialExpiration,
long containerId,
String ownerId,
boolean persistent) |
protected void |
addToSchedules(long containerId,
TimerPrimaryKey timerId,
EJBTimerSchedule ts) |
protected Date |
calcNextFixedRateExpiration(Date initialExpiration,
long intervalDuration) |
protected Date |
calcNextFixedRateExpiration(RuntimeTimerState timerState) |
protected abstract void |
cancelTimer(TimerPrimaryKey timerId) |
protected abstract void |
cancelTimersByKey(long containerId,
Object primaryKey)
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.
|
void |
cancelTimerSynchronization(EJBContextImpl context_,
TimerPrimaryKey timerId,
long containerId,
String ownerId) |
protected void |
cancelTimerSynchronization(EJBContextImpl context_,
TimerPrimaryKey timerId,
long containerId,
String ownerId,
boolean persistent) |
protected javax.ejb.EJBException |
createEJBException(Exception ex)
Create EJBException using the exception that is passed in
|
protected void |
createSchedules(long containerId,
long applicationId,
Map<?,List<ScheduledTimerDescriptor>> schedules,
Map<TimerPrimaryKey,Method> result,
String server_name,
boolean startTimers,
boolean deploy)
Create automatic timers defined by the @Schedule annotation on the EJB bean.
|
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.
|
void |
createSchedulesOnServer(EjbDescriptor ejbDescriptor,
String server_name)
Called in a clustered environment to eagerly create automatic persistent timers
on the specific server instance.
|
void |
destroyAllTimers(long applicationId)
Destroy all timers associated with a particular application.
|
void |
destroyTimers(long containerId)
Destroy all timers associated with a particular ejb container
This is typically called when an ejb is undeployed.
|
protected void |
expungeTimer(TimerPrimaryKey timerId,
boolean removeTimerBean)
Remove all traces of a timer.
|
protected BaseContainer |
getContainer(long containerId) |
static EJBTimerService |
getEJBTimerService(boolean persistent) |
static EJBTimerService |
getEJBTimerService(String target) |
static EJBTimerService |
getEJBTimerService(String target,
boolean force) |
static EJBTimerService |
getEJBTimerService(String target,
boolean force,
boolean persistent) |
static EJBTimerServiceWrapper |
getEJBTimerServiceWrapper(EJBContextImpl ejbContext) |
protected abstract Serializable |
getInfo(TimerPrimaryKey timerId) |
protected long |
getMaxRedeliveries() |
protected Date |
getNextScheduledTimeout(EJBTimerSchedule ts)
Returns next schedule-based timeout or null if such schedule will
not expire again.
|
protected abstract Date |
getNextTimeout(TimerPrimaryKey timerId)
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.
|
abstract Set<TimerPrimaryKey> |
getNonPersistentActiveTimerIdsByThisServer() |
static EJBTimerService |
getNonPersistentTimerService() |
String |
getOwnerIdOfThisServer()
Return the ownerId of the server instance in
which we are running.
|
static EJBTimerService |
getPersistentTimerService() |
ClassLoader |
getTimerClassLoader(long containerId)
Get the application class loader for the timed object
that created a given timer.
|
protected abstract Collection<TimerPrimaryKey> |
getTimerIds(Collection<Long> containerIds) |
protected abstract Collection<TimerPrimaryKey> |
getTimerIds(long containerId,
Object timedObjectPrimaryKey)
Called by EJBTimerServiceWrapper when caller calls getTimers.
|
protected abstract EJBTimerSchedule |
getTimerSchedule(TimerPrimaryKey timerId)
Called by #getScheduleExpression and #isCalendarTimer
|
protected RuntimeTimerState |
getTimerState(TimerPrimaryKey timerId) |
protected boolean |
isCancelledByAnotherInstance(RuntimeTimerState timerState)
For a non-persistent timer, it's not possible to be cancelled by another
server instance
|
static boolean |
isNonPersistentTimerServiceLoaded() |
abstract boolean |
isPersistent() |
protected abstract boolean |
isPersistent(TimerPrimaryKey timerId) |
static boolean |
isPersistentTimerServiceLoaded() |
protected abstract boolean |
isValidTimerForThisServer(TimerPrimaryKey timerId,
RuntimeTimerState timerState)
Non-persistent timers are always valid because to be executed on this
server instance.
|
String[] |
listTimers(String[] serverIds)
Provide a count of timers owned by each server.
|
abstract int |
migrateTimers(String fromOwnerId)
Called by CLI.Take ownership of another server's timers.
|
static void |
onShutdown()
Called from TimerBean PreDestroy
|
protected Map<TimerPrimaryKey,Method> |
recoverAndCreateSchedules(long containerId,
long applicationId,
Map<Method,List<ScheduledTimerDescriptor>> schedules,
boolean deploy)
Create automatic non-persistent timers defined by the @Schedule
annotation on the EJB bean.
|
protected boolean |
redeliverTimeout(RuntimeTimerState timerState) |
protected abstract void |
resetEJBTimers(String target)
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
|
protected abstract void |
resetLastExpiration(TimerPrimaryKey timerId,
RuntimeTimerState timerState)
Nothing special to do for non-persistent timers
|
protected void |
scheduleTask(TimerPrimaryKey timerId,
Date expiration) |
protected static void |
setNonPersistentTimerService(EJBTimerService timerService) |
protected static void |
setPersistentTimerService(EJBTimerService timerService) |
protected boolean |
stopOnFailure() |
protected abstract void |
stopTimers(long containerId)
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.
|
protected void |
stopTimers(Set<TimerPrimaryKey> timerIds) |
protected abstract boolean |
timerExists(TimerPrimaryKey timerId) |
static String |
timerStateToString(int state) |
protected EjbContainerUtil ejbContainerUtil
protected String domainName_
protected boolean isDas
protected String ownerIdOfThisServer_
protected EJBTimerService.TimerCache timerCache_
protected long totalTimedObjectsInitialized_
public static final int STATE_ACTIVE
public static final int STATE_CANCELLED
public static EJBTimerServiceWrapper getEJBTimerServiceWrapper(EJBContextImpl ejbContext)
protected static void setPersistentTimerService(EJBTimerService timerService)
protected static void setNonPersistentTimerService(EJBTimerService timerService)
public static EJBTimerService getPersistentTimerService()
public static EJBTimerService getNonPersistentTimerService()
public static boolean isPersistentTimerServiceLoaded()
public static boolean isNonPersistentTimerServiceLoaded()
public static EJBTimerService getEJBTimerService(boolean persistent)
public static EJBTimerService getEJBTimerService(String target)
public static EJBTimerService getEJBTimerService(String target, boolean force)
public static EJBTimerService getEJBTimerService(String target, boolean force, boolean persistent)
public abstract boolean isPersistent()
public abstract int migrateTimers(String fromOwnerId)
fromOwnerId
- protected abstract void resetEJBTimers(String target)
target
- protected abstract void stopTimers(long containerId)
containerId
- protected abstract Collection<TimerPrimaryKey> getTimerIds(long containerId, Object timedObjectPrimaryKey)
containerId
- the id of the EJB which owns the timerstimedObjectPrimaryKey
- can be null if not entity beanprotected abstract Collection<TimerPrimaryKey> getTimerIds(Collection<Long> containerIds)
containerIds
- the EJBs which own the timersprotected abstract void cancelTimersByKey(long containerId, Object primaryKey)
containerId
- primaryKey
- protected abstract void cancelTimer(TimerPrimaryKey timerId) throws javax.ejb.FinderException, Exception
javax.ejb.FinderException
Exception
protected abstract Date getNextTimeout(TimerPrimaryKey timerId) throws javax.ejb.FinderException
timerId
- javax.ejb.FinderException
protected abstract Serializable getInfo(TimerPrimaryKey timerId) throws javax.ejb.FinderException
javax.ejb.FinderException
protected abstract boolean isPersistent(TimerPrimaryKey timerId) throws javax.ejb.FinderException
javax.ejb.FinderException
protected abstract boolean timerExists(TimerPrimaryKey timerId)
protected abstract EJBTimerSchedule getTimerSchedule(TimerPrimaryKey timerId) throws javax.ejb.FinderException
timerId
- javax.ejb.FinderException
protected abstract boolean isValidTimerForThisServer(TimerPrimaryKey timerId, RuntimeTimerState timerState)
timerId
- timerState
- protected abstract void resetLastExpiration(TimerPrimaryKey timerId, RuntimeTimerState timerState)
timerId
- timerState
- public abstract Set<TimerPrimaryKey> getNonPersistentActiveTimerIdsByThisServer()
public String getOwnerIdOfThisServer()
public String[] listTimers(String[] serverIds)
protected javax.ejb.EJBException createEJBException(Exception ex)
protected void addToSchedules(long containerId, TimerPrimaryKey timerId, EJBTimerSchedule ts)
public void destroyTimers(long containerId)
public void destroyAllTimers(long applicationId)
protected void _destroyTimers(long id, boolean all)
protected void stopTimers(Set<TimerPrimaryKey> timerIds)
protected void scheduleTask(TimerPrimaryKey timerId, Date expiration)
protected Date calcNextFixedRateExpiration(RuntimeTimerState timerState)
protected Date calcNextFixedRateExpiration(Date initialExpiration, long intervalDuration)
protected void expungeTimer(TimerPrimaryKey timerId, boolean removeTimerBean)
protected void _createTimer(TimerPrimaryKey timerId, long containerId, long applicationId, Object timedObjectPrimaryKey, String server_name, Date initialExpiration, long intervalDuration, EJBTimerSchedule schedule, javax.ejb.TimerConfig timerConfig) throws Exception
timedObjectPrimaryKey
- can be null if timed object is not an entity bean.Exception
protected Map<TimerPrimaryKey,Method> recoverAndCreateSchedules(long containerId, long applicationId, Map<Method,List<ScheduledTimerDescriptor>> schedules, boolean deploy)
public void createSchedulesOnServer(EjbDescriptor ejbDescriptor, String server_name)
public void createSchedules(long containerId, long applicationId, Map<MethodDescriptor,List<ScheduledTimerDescriptor>> methodDescriptorSchedules, String server_name)
protected void createSchedules(long containerId, long applicationId, Map<?,List<ScheduledTimerDescriptor>> schedules, Map<TimerPrimaryKey,Method> result, String server_name, boolean startTimers, boolean deploy) throws Exception
Exception
public ClassLoader getTimerClassLoader(long containerId)
protected RuntimeTimerState getTimerState(TimerPrimaryKey timerId)
protected Date _getNextTimeout(RuntimeTimerState rt)
protected BaseContainer getContainer(long containerId)
protected boolean isCancelledByAnotherInstance(RuntimeTimerState timerState)
protected boolean redeliverTimeout(RuntimeTimerState timerState)
protected boolean stopOnFailure()
protected long getMaxRedeliveries()
public void addTimerSynchronization(EJBContextImpl context_, String timerId, Date initialExpiration, long containerId, String ownerId) throws Exception
Exception
public void addTimerSynchronization(EJBContextImpl context_, String timerId, Date initialExpiration, long containerId, String ownerId, boolean persistent) throws Exception
Exception
public void cancelTimerSynchronization(EJBContextImpl context_, TimerPrimaryKey timerId, long containerId, String ownerId) throws Exception
Exception
protected void cancelTimerSynchronization(EJBContextImpl context_, TimerPrimaryKey timerId, long containerId, String ownerId, boolean persistent) throws Exception
Exception
protected Date getNextScheduledTimeout(EJBTimerSchedule ts)
public static void onShutdown()
public static String timerStateToString(int state)
Copyright © 2019. All rights reserved.