Class EjbScheduler
- All Implemented Interfaces:
io.smint.clapi.consumer.integration.core.services.IPlatformScheduler
TimerService
to be used with Enterprise Java Beans.
This scheduler relies on creation upon startup of the servlet/container. As soon as the instance is created by the
container, startup()
is called, which stores a reference to this
bean to a static variable. Its
value can be retrieved with #getSchedulerBean()
to acquire access to the scheduler as created by the J2EE
container.
-
Field Summary
Fields inherited from class io.smint.clapi.consumer.integration.core.services.impl.AbstractScheduler
MINIMAL_PERIOD_MILLISECONDS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.smint.clapi.consumer.integration.core.services.IPlatformScheduler
cancel()
static EjbScheduler
Returns the singleton scheduler bean as created by the J2EE container and stored withstartup()
.scheduleAtFixedRate
(Runnable job, long period) io.smint.clapi.consumer.integration.core.services.IPlatformScheduler
void
shutdown()
Cancels all timers.void
startup()
Stores a reference tothis
, which can be retrieved withgetSchedulerBean()
.io.smint.clapi.consumer.integration.core.services.IPlatformScheduler
stopSchedule
(String jobKey) void
timerFired
(Timer timer) Methods inherited from class io.smint.clapi.consumer.integration.core.services.impl.AbstractScheduler
createRandomKey, createUniqueRandomKey, getAllJobKey, getJob, getKey, hasJob, putJob, removeJob
-
Constructor Details
-
EjbScheduler
public EjbScheduler()
-
-
Method Details
-
getSchedulerBean
Returns the singleton scheduler bean as created by the J2EE container and stored withstartup()
.- Returns:
- the scheduler bean as saved after creation by the J2EE container or
null
if the bean has not been created yet.
-
startup
Stores a reference tothis
, which can be retrieved withgetSchedulerBean()
.In case a second instance of this class is created, the reference to these additional instances are not stored. Only a singleton is supported.
-
shutdown
Cancels all timers.With EJB timers are persistent and resurrect in case the application is stopped and started again. This would not work with this class, as the actual code to execute with the timer is stored as
Runnable
inside a bigMap
. This data will get lost in application unload from memory. Hence it will not be available upon next start of the application. Therefore there is no use in persistent timers and so all timers are cancelled prior to shutting down the application. -
timerFired
-
scheduleAtFixedRate
- Specified by:
scheduleAtFixedRate
in interfaceio.smint.clapi.consumer.integration.core.services.IPlatformScheduler
-
stopSchedule
public io.smint.clapi.consumer.integration.core.services.IPlatformScheduler stopSchedule(String jobKey) - Specified by:
stopSchedule
in interfaceio.smint.clapi.consumer.integration.core.services.IPlatformScheduler
-
cancel
public io.smint.clapi.consumer.integration.core.services.IPlatformScheduler cancel()- Specified by:
cancel
in interfaceio.smint.clapi.consumer.integration.core.services.IPlatformScheduler
-
scheduleForImmediateExecution
public io.smint.clapi.consumer.integration.core.services.IPlatformScheduler scheduleForImmediateExecution(Runnable job) - Specified by:
scheduleForImmediateExecution
in interfaceio.smint.clapi.consumer.integration.core.services.IPlatformScheduler
-