Java Reference
In-Depth Information
More complex scheduling, such as fixed interval execution, requires that you set the TimerTask
explicitly. Here, it does little good to actually submit jobs manually. For more advanced functionality,
you'll want to use something like Quartz, which can support cron expressions.
<bean
id="timerTaskExecutorWithScheduledTimerTasks"
class="org.springframework.scheduling.timer.TimerTaskExecutor">
<property
name="timer">
<bean
class="org.springframework.scheduling.timer.TimerFactoryBean">
<property
name="scheduledTimerTasks">
<list>
<bean
class="org.springframework.scheduling.timer.ScheduledTimerTask"
p:delay="10"
p:ixedRate="true"
p:period="10000"
p:runnable-ref="task" />
</list>
</property>
</bean>
</property>
</bean>
The last example is ThreadPoolTaskExecutor , which is a full on thread pool implementation building
on java.util.concurrent.ThreadPoolExecutor .
If you want to build applications using the CommonJ WorkManager/TimerManager
support available in IBM WebSphere 6.0 and BEA WebLogic 9.0, you can use
org.springframework.scheduling.commonj.WorkManagerTaskExecutor . This class delegates
to a reference to the CommonJ Work Manager available inside of WebSphere or WebLogic.
Usually, you'll provide it with a JNDI reference to the appropriate resource. This works
well enough (such as with Geronimo), but extra effort is required with JBoss or GlassFish.
Spring provides classes that delegate to the JCA support provided on those servers: for GlassFish,
use org.springframework.jca.work.glassfish.GlassFishWorkManagerTaskExecutor ; for JBoss, use
org.springframework.jca.work.jboss.JBossWorkManagerTaskExecutor .
The TaskExecutor support provides a powerful way to access scheduling services on your
application server via a unified interface. If you're looking for more robust (albeit much heavier)
support that can be deployed on any server (even Tomcat and Jetty!), you might consider Spring's
Quartz support.
Search WWH ::




Custom Search