I have a simple application that uses Spring 3 for dependency injection. I have a JFrame for the user to look at and some background tasks for synchronizing with a back-end server and local database maintenance.
This is the relevant part of my application context:
<task:scheduler id="scheduler" pool-size="1"/>
<task:scheduled-tasks scheduler="scheduler">
<task:scheduled ref="synchronizer" method="incrementalSync" fixed-delay="600000"/>
... more tasks ...
</task:scheduled-tasks>
<bean id="mainFrame" class="nl.gdries.myapp.client.ui.MainFrame">
... properties and such ...
</bean>
When I start this applicationContext the scheduler immediately starts executing the background tasks even while my UI is loading. Because the first task is a rather heavy one at the start I want it to wait for the UI to fully load and display before it starts execution.
Does anyone know how to tell Spring to delay executing the scheduled tasks until a moment of my choosing?
-
This seems to have been left out of the
<task:scheduled>
bean definition, something I only just noticed last week.Remember, though, that the
<task:...>
definitions are just shortcuts, you can always use the explicit approach, by defining aScheduledExecutorFactoryBean
, with nestedScheduledExecutorTask
beans. This gives you much finer control, includinginitialDelay
.
0 comments:
Post a Comment