public class TimerServiceImpl extends Object implements javax.ejb.TimerService, org.jboss.msc.service.Service<javax.ejb.TimerService>
TimerService| Modifier and Type | Field and Description |
|---|---|
static org.jboss.msc.service.ServiceName |
SERVICE_NAME |
| Constructor and Description |
|---|
TimerServiceImpl(Map<Method,List<AutoTimer>> autoTimers,
org.jboss.msc.service.ServiceName serviceName)
Creates a
TimerServiceImpl |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addTimer(TimerImpl timer)
TODO: Rethink about this method.
|
protected void |
cancelTimeout(TimerImpl timer)
Cancels any scheduled
Future corresponding to the passed timer |
javax.ejb.Timer |
createCalendarTimer(javax.ejb.ScheduleExpression schedule) |
javax.ejb.Timer |
createCalendarTimer(javax.ejb.ScheduleExpression schedule,
javax.ejb.TimerConfig timerConfig) |
javax.ejb.Timer |
createIntervalTimer(Date initialExpiration,
long intervalDuration,
javax.ejb.TimerConfig timerConfig) |
javax.ejb.Timer |
createIntervalTimer(long initialDuration,
long intervalDuration,
javax.ejb.TimerConfig timerConfig) |
javax.ejb.Timer |
createSingleActionTimer(Date expiration,
javax.ejb.TimerConfig timerConfig) |
javax.ejb.Timer |
createSingleActionTimer(long duration,
javax.ejb.TimerConfig timerConfig) |
javax.ejb.Timer |
createTimer(Date initialExpiration,
long intervalDuration,
Serializable info) |
javax.ejb.Timer |
createTimer(Date expiration,
Serializable info) |
javax.ejb.Timer |
createTimer(long initialDuration,
long intervalDuration,
Serializable info) |
javax.ejb.Timer |
createTimer(long duration,
Serializable info) |
org.jboss.msc.value.InjectedValue<EJBComponent> |
getEjbComponentInjectedValue() |
org.jboss.msc.value.InjectedValue<ExecutorService> |
getExecutorServiceInjectedValue() |
TimedObjectInvoker |
getInvoker()
Returns the
TimedObjectInvoker to which this timer service belongs |
org.jboss.msc.service.ServiceName |
getServiceName() |
org.jboss.msc.value.InjectedValue<TimedObjectInvoker> |
getTimedObjectInvoker() |
TimerImpl |
getTimer(javax.ejb.TimerHandle handle)
Returns the
Timer corresponding to the passed TimerHandle |
org.jboss.msc.value.InjectedValue<Timer> |
getTimerInjectedValue() |
org.jboss.msc.value.InjectedValue<TimerPersistence> |
getTimerPersistence() |
Collection<javax.ejb.Timer> |
getTimers() |
protected Transaction |
getTransaction() |
javax.ejb.TimerService |
getValue() |
protected boolean |
isLifecycleCallbackInvocation()
Returns true if the
CurrentInvocationContext represents a lifecycle
callback invocation. |
boolean |
isStarted() |
TimerImpl |
loadAutoTimer(javax.ejb.ScheduleExpression schedule,
javax.ejb.TimerConfig timerConfig,
Method timeoutMethod) |
void |
persistTimer(TimerImpl timer,
boolean newTimer)
Persists the passed
timer. |
protected void |
registerTimerWithTx(TimerImpl timer)
Registers the timer with any active transaction so that appropriate action on the timer can be
carried out on transaction lifecycle events, through the use of
Synchronization
callbacks. |
void |
restoreTimers(List<ScheduleTimer> autoTimers)
Restores persisted timers, corresponding to this timerservice, which are eligible for any new timeouts.
|
protected void |
scheduleTimeout(TimerImpl timer,
boolean newTimer)
Creates and schedules a
TimerTask for the next timeout of the passed timer |
void |
start(org.jboss.msc.service.StartContext context) |
protected void |
startTimer(TimerImpl timer)
Registers a timer with a transaction (if any in progress) and then moves
the timer to a active state, so that it becomes eligible for timeouts
|
void |
stop(org.jboss.msc.service.StopContext context) |
void |
suspendTimers()
Suspends any currently scheduled tasks for
Timers |
public TimerServiceImpl(Map<Method,List<AutoTimer>> autoTimers, org.jboss.msc.service.ServiceName serviceName)
TimerServiceImplautoTimers - serviceName - IllegalArgumentException - If either of the passed param is nullpublic void start(org.jboss.msc.service.StartContext context)
throws org.jboss.msc.service.StartException
start in interface org.jboss.msc.service.Service<javax.ejb.TimerService>org.jboss.msc.service.StartExceptionpublic void stop(org.jboss.msc.service.StopContext context)
stop in interface org.jboss.msc.service.Service<javax.ejb.TimerService>public javax.ejb.TimerService getValue()
throws IllegalStateException,
IllegalArgumentException
getValue in interface org.jboss.msc.value.Value<javax.ejb.TimerService>IllegalStateExceptionIllegalArgumentExceptionpublic javax.ejb.Timer createCalendarTimer(javax.ejb.ScheduleExpression schedule)
throws IllegalArgumentException,
IllegalStateException,
javax.ejb.EJBException
createCalendarTimer in interface javax.ejb.TimerServiceIllegalArgumentExceptionIllegalStateExceptionjavax.ejb.EJBExceptionpublic javax.ejb.Timer createCalendarTimer(javax.ejb.ScheduleExpression schedule,
javax.ejb.TimerConfig timerConfig)
throws IllegalArgumentException,
IllegalStateException,
javax.ejb.EJBException
createCalendarTimer in interface javax.ejb.TimerServiceIllegalArgumentExceptionIllegalStateExceptionjavax.ejb.EJBExceptionpublic javax.ejb.Timer createIntervalTimer(Date initialExpiration, long intervalDuration, javax.ejb.TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, javax.ejb.EJBException
createIntervalTimer in interface javax.ejb.TimerServiceIllegalArgumentExceptionIllegalStateExceptionjavax.ejb.EJBExceptionpublic javax.ejb.Timer createIntervalTimer(long initialDuration,
long intervalDuration,
javax.ejb.TimerConfig timerConfig)
throws IllegalArgumentException,
IllegalStateException,
javax.ejb.EJBException
createIntervalTimer in interface javax.ejb.TimerServiceIllegalArgumentExceptionIllegalStateExceptionjavax.ejb.EJBExceptionpublic javax.ejb.Timer createSingleActionTimer(Date expiration, javax.ejb.TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, javax.ejb.EJBException
createSingleActionTimer in interface javax.ejb.TimerServiceIllegalArgumentExceptionIllegalStateExceptionjavax.ejb.EJBExceptionpublic javax.ejb.Timer createSingleActionTimer(long duration,
javax.ejb.TimerConfig timerConfig)
throws IllegalArgumentException,
IllegalStateException,
javax.ejb.EJBException
createSingleActionTimer in interface javax.ejb.TimerServiceIllegalArgumentExceptionIllegalStateExceptionjavax.ejb.EJBExceptionpublic javax.ejb.Timer createTimer(long duration,
Serializable info)
throws IllegalArgumentException,
IllegalStateException,
javax.ejb.EJBException
createTimer in interface javax.ejb.TimerServiceIllegalArgumentExceptionIllegalStateExceptionjavax.ejb.EJBExceptionpublic javax.ejb.Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, javax.ejb.EJBException
createTimer in interface javax.ejb.TimerServiceIllegalArgumentExceptionIllegalStateExceptionjavax.ejb.EJBExceptionpublic javax.ejb.Timer createTimer(long initialDuration,
long intervalDuration,
Serializable info)
throws IllegalArgumentException,
IllegalStateException,
javax.ejb.EJBException
createTimer in interface javax.ejb.TimerServiceIllegalArgumentExceptionIllegalStateExceptionjavax.ejb.EJBExceptionpublic javax.ejb.Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, javax.ejb.EJBException
createTimer in interface javax.ejb.TimerServiceIllegalArgumentExceptionIllegalStateExceptionjavax.ejb.EJBExceptionpublic TimerImpl loadAutoTimer(javax.ejb.ScheduleExpression schedule, javax.ejb.TimerConfig timerConfig, Method timeoutMethod)
public Collection<javax.ejb.Timer> getTimers() throws IllegalStateException, javax.ejb.EJBException
getTimers in interface javax.ejb.TimerServiceIllegalStateExceptionjavax.ejb.EJBExceptionprotected void addTimer(TimerImpl timer)
TimerHandle to TimerImpl map.timer - Timer instancepublic TimedObjectInvoker getInvoker()
TimedObjectInvoker to which this timer service belongspublic TimerImpl getTimer(javax.ejb.TimerHandle handle)
Timer corresponding to the passed TimerHandlehandle - The TimerHandle for which the Timer is being looked forprotected Transaction getTransaction()
javax.ejb.EJBException - If there is any system level exceptionpublic void persistTimer(TimerImpl timer, boolean newTimer)
timer.
If the passed timer is null or is non-persistent (i.e. Timer.isPersistent() returns false),
then this method acts as a no-op
timer - public void suspendTimers()
Timers
Note that, suspend does not cancel the Timer. Instead,
it just cancels the next scheduled timeout. So once the Timer
is restored (whenever that happens), the Timer will continue to
timeout at appropriate times.
public void restoreTimers(List<ScheduleTimer> autoTimers)
This includes timers whose TimerState is neither of the following:
All such restored timers will be schedule for their next timeouts.
autoTimers - protected void startTimer(TimerImpl timer)
protected void registerTimerWithTx(TimerImpl timer)
Synchronization
callbacks.
If there is no transaction in progress, when this method is called, then this method is effectively a no-op.
timer - protected boolean isLifecycleCallbackInvocation()
CurrentInvocationContext represents a lifecycle
callback invocation. Else returns false.
This method internally relies on CurrentInvocationContext.get() to obtain
the current invocation context.
TimerService methods
in the absence of CurrentInvocationContextprotected void scheduleTimeout(TimerImpl timer, boolean newTimer)
TimerTask for the next timeout of the passed timerprotected void cancelTimeout(TimerImpl timer)
Future corresponding to the passed timertimer - public org.jboss.msc.value.InjectedValue<EJBComponent> getEjbComponentInjectedValue()
public org.jboss.msc.value.InjectedValue<ExecutorService> getExecutorServiceInjectedValue()
public org.jboss.msc.value.InjectedValue<Timer> getTimerInjectedValue()
public org.jboss.msc.value.InjectedValue<TimerPersistence> getTimerPersistence()
public org.jboss.msc.service.ServiceName getServiceName()
public boolean isStarted()
public org.jboss.msc.value.InjectedValue<TimedObjectInvoker> getTimedObjectInvoker()
Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.